Translation
1. Translation
Welcome back! Now, we'll explore how to use Snowflake Cortex to solve various business tasks. In this lesson, we'll translate guest reviews using the `translate()` function - a powerful way to support multilingual operations at scale.2. Why translate?
As we've been familiarizing ourselves with Executive Resorts' database, we've noticed something important: many reviews are written in other languages, including French and Spanish. To understand and act on this feedback, we need a way to consistently translate reviews into English.3. Translating with Cortex
Snowflake Cortex to the rescue! We can use the `translate` function to convert text from one language to another. `translate()` is also part of the `snowflake.cortex` module. It takes three arguments: `text`: The content we want to translate; `from_language`: The language of the text; `to_language`: The language that we want to translate the text into.4. Translated review
Here's the output, check it out! Also see the languages currently supported, along with corresponding codes. Check out the documentation for the complete list. Cortex translate is an incredibly powerful tool for companies providing global services!5. Translations from the database
Let's put this into a workflow. Here, we query the most recent Spanish-language review from our hotels database. We extract the description, pass it to `translate()`, and print the result. This allows us to convert multilingual guest feedback into a single, unified format.6. Translation
Check out the results! The model provides a natural and accurate translation. This means guest insights are no longer lost in translation.7. A word of caution
As with any powerful tool, we must be careful about blindly accepting the outputs of translation, particularly if we don't know the original language ourselves! Take this example. The AI translation is grammatically correct, but "Like royalty" is more neutral and natural in a hospitality tone. Or this output, which doesn't make sense in English. Idioms, which are phrases whose meanings cannot be understood from the literal meanings of the individual words, must be interpreted rather than directly translated. So what should we do to minimize the risk of these issues?8. Quality assurance
We need quality assurance! An example of this approach would be to require human reviews based on specific criteria, such as when a rating is below a certain threshold or certain keywords are produced in the output.9. Let's practice!
Your turn to translate reviews!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.