- 类别:
:doc:`/sql-reference/functions-string`(AI 函数)
AI_TRANSLATE¶
备注
AI_TRANSLATE 是 TRANSLATE (SNOWFLAKE.CORTEX) 的更新版本。要获得最新功能,请使用 AI_TRANSLATE。
将给定的输入文本从一种受支持的语言翻译为另一种受支持的语言。
语法¶
AI_TRANSLATE(
<text>, <source_language>, <target_language>)
实参¶
返回¶
一个字符串,包含原始文本到目标语言的翻译。
使用说明¶
AI_TRANSLATE 函数支持以下语言。使用源语言和目标语言对应的语言代码。
AI_TRANSLATE 模型还支持在被翻译的文本中混合使用不同的语言(例如,“Spanglish”)。在这种情况下,指定空字符串 ('') 作为源语言,以自动检测源文本中使用的语言。
语言 |
代码 |
|---|---|
阿拉伯语 |
|
中文 |
|
克罗地亚语 |
|
捷克语 |
|
荷兰语 |
|
英语 |
|
芬兰语 |
|
法语 |
|
德语 |
|
希腊语 |
|
希伯来语 |
|
印地语 |
|
意大利语 |
|
日语 |
|
韩语 |
|
挪威语 |
|
波兰语 |
|
葡萄牙语 |
|
罗马尼亚语 |
|
俄语 |
|
西班牙语 |
|
瑞典语 |
|
土耳其语 |
|
访问控制要求¶
Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role. See Cortex LLM privileges for more information on this privilege.
示例¶
以下示例将表格的每一行从英语翻译成德语(在本示例中,review_content 是 reviews 表中的一列):
SELECT AI_TRANSLATE(review_content, 'en', 'de') FROM reviews LIMIT 10;
以下示例将虚构的产品评论从英语翻译为西班牙语:
SELECT AI_TRANSLATE(
'Hit the slopes with Snowflake\'s latest innovation - "Skii Headphones" designed to keep your ears warm and your soul ablaze. Engineered specifically for snow weather, these rugged headphones combine crystal-clear sound with thermally-insulated ear cups to keep the chill out and the beats in. Whether you\'re carving through powder or cruising down groomers, Skii Headphones will fuel your mountain adventures with vibrant sound and unrelenting passion. Stay warm, stay fired up, and shred the mountain with Snowflake Skii Headphones',
'en','es');
此查询的结果是:
Sube a las pistas con la última innovación de Snowflake: "Skii Headphones", diseñados para mantener tus oídos calientes y tu alma encendida. Diseñados específicamente para el clima de nieve, estos audífonos resistentes combinan un sonido cristalino con copas de oído aisladas térmicamente para mantener el frío fuera y los ritmos dentro. Ya sea que estés esculpiendo en polvo o deslizándote por pistas preparadas, los Skii Headphones alimentarán tus aventuras en la montaña con un sonido vibrante y una pasión incesante. Mantente caliente, mantente encendido y arrasa la montaña con los Skii Headphones de Snowflake.
以下示例将调用记录从德语翻译为英语:
SELECT AI_TRANSLATE(
('Kunde: Hallo
Agent: Hallo, ich hoffe, es geht Ihnen gut. Um Ihnen am besten helfen zu können, teilen Sie bitte Ihren Vor- und Nachnamen und den Namen der Firma, von der aus Sie anrufen.
Kunde: Ja, hier ist Thomas Müller von SkiPisteExpress.
Agent: Danke Thomas, womit kann ich Ihnen heute helfen?
Kunde: Also wir haben die XtremeX Helme in Größe M bestellt, die wir speziell für die kommende Wintersaison benötigen. Jedoch sind alle Schnallen der Helme defekt, und keiner schließt richtig.
Agent: Ich verstehe, dass das ein Problem für Ihr Geschäft sein kann. Lassen Sie mich überprüfen, was mit Ihrer Bestellung passiert ist. Um zu bestätigen: Ihre Bestellung endet mit der Nummer 56682?
Kunde: Ja, das ist meine Bestellung.
Agent: Ich sehe das Problem. Entschuldigen Sie die Unannehmlichkeiten. Ich werde sofort eine neue Lieferung mit reparierten Schnallen für Sie vorbereiten, die in drei Tagen bei Ihnen eintreffen sollte. Ist das in Ordnung für Sie?
Kunde: Drei Tage sind ziemlich lang, ich hatte gehofft, diese Helme früher zu erhalten. Gibt es irgendeine Möglichkeit, die Lieferung zu beschleunigen?
Agent: Ich verstehe Ihre Dringlichkeit. Ich werde mein Bestes tun, um die Lieferung auf zwei Tage zu beschleunigen. Wie kommst du damit zurecht?
Kunde: Das wäre großartig, ich wäre Ihnen sehr dankbar.
Agent: Kein Problem, Thomas. Ich kümmere mich um die eilige Lieferung. Danke für Ihr Verständnis und Ihre Geduld.
Kunde: Vielen Dank für Ihre Hilfe. Auf Wiedersehen!
Agent: Bitte, gerne geschehen. Auf Wiedersehen und einen schönen Tag noch!'
,'de','en');
结果是:
Customer: Hello
Agent: Hello, I hope you are well. To best assist you, please share your first and last name and the name of the company you are calling from.
Customer: Yes, this is Thomas Müller from SkiPisteExpress.
Agent: Thank you, Thomas, what can I help you with today?
Customer: So, we ordered the XtremeX helmets in size M, which we specifically need for the upcoming winter season. However, all the buckles on the helmets are defective and none of them close properly.
Agent: I understand that this can be a problem for your business. Let me check what happened with your order. To confirm: your order ends with the number 56682?
Customer: Yes, that's my order.
Agent: I see the issue. I apologize for the inconvenience. I will prepare a new delivery with repaired buckles for you immediately, which should arrive in three days. Is that okay for you?
Customer: Three days is quite a long time; I was hoping to receive these helmets sooner. Is there any way to expedite the delivery?
Agent: I understand your urgency. I will do my best to expedite the delivery to two days. How does that sound?
Customer: That would be great, I would be very grateful.
Agent: No problem, Thomas. I will take care of the urgent delivery. Thank you for your understanding and patience.
Customer: Thank you very much for your help. Goodbye!
Agent: You're welcome. Goodbye and have a nice day!
最后,以下示例演示了将两种不同语言(在本例中为英语和西班牙语,或“Spanglish”)的文本翻译为英语。请注意,源语言的指定为空字符串,这会告诉 AI_TRANSLATE 自动检测语言。
SELECT AI_TRANSLATE('Voy a likear tus fotos en Insta.', '', 'en')
此查询导致:
I'm going to like your photos on Insta.
法律声明¶
请参阅 Snowflake AI 和 ML。
限制¶
Snowflake Cortex 函数不支持动态表。