- Categories:
String & binary functions (AI Functions)
TRANSLATE (SNOWFLAKE.CORTEX)¶
Note
AI_TRANSLATE is the latest version of this function. Use AI_TRANSLATE for the latest functionality. You can continue to use TRANSLATE (SNOWFLAKE.CORTEX).
Translates the given input text from one supported language to another.
Attention
This function does not transform a string given a search string and a replacement string. See the TRANSLATE function if that functionality is what you’re looking for.
Syntax¶
Arguments¶
textA string containing the text to be translated.
source_languageA string specifying the language code for the language the text is currently in. See Usage notes for a list of supported language codes. If the source language code is an empty string,
'', the source language is automatically detected.target_languageA string specifying the language code into which the text should be translated. See Usage notes for a list of supported language codes.
Returns¶
A string containing a translation of the original text into the target language.
Usage notes¶
The following languages are supported by the TRANSLATE function. Use the corresponding language code for the source and target language.
The TRANSLATE model also supports a mix of two different languages in the text being translated (for example,
“Spanglish”). In this case, specify an empty string ('') as the source language to auto-detect the languages
used in the source text.
Language |
Code |
|---|---|
Chinese |
|
Dutch |
|
English |
|
French: |
|
German |
|
Hindi |
|
Italian |
|
Japanese |
|
Korean |
|
Polish |
|
Portuguese |
|
Russian |
|
Spanish |
|
Swedish |
|
The TRANSLATE function produces its best results when either the source or target language is English (for example, English to Spanish or German to English). Results for other language pairs, such as German to Spanish, might be less accurate.
Access control requirements¶
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.
Examples¶
The following example translates each row of a table from English to German (in this example, review_content is
a column from the reviews table):
The following example translates a fictitious product review from English to Spanish:
The result of this query is:
The following example translates a call transcript from German to English:
The result is:
Finally, the following example illustrates translating text from two different languages (in this case English and Spanish, or “Spanglish”) to English. Note that the specification of the source language is the empty string.
This query results in:
Legal notices¶
Refer to Snowflake AI and ML.
Limitations¶
Snowflake Cortex functions do not support dynamic tables.