This documentation page is also available as an interactive notebook. You can launch the notebook in
Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the
above links.
Automatically translate content into multiple languages using LLMs.
Problem
You have content that needs to be available in multiple
languages—product descriptions, documentation, user-generated content.
Manual translation is slow and expensive.
Solution
What’s in this recipe:
- Translate text using OpenAI models
- Create multiple language columns from one source
- Handle batch translation efficiently
You add computed columns for each target language. Translations are
generated automatically when you insert new content and cached for
future queries.
Setup
Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘translate_demo’.
<pixeltable.catalog.dir.Dir at 0x31f62aa90>
Create translation pipeline
Created table ‘content’.
Added 0 column values with 0 errors.
Added 0 column values with 0 errors.
No rows affected.
Added 0 column values with 0 errors.
Added 0 column values with 0 errors.
No rows affected.
Translate content
Inserting rows into `content`: 3 rows [00:00, 198.43 rows/s]
Inserted 3 rows with 0 errors.
3 rows inserted, 18 values computed.
Explanation
How it works:
Each target language is a computed column with a translation prompt.
When you insert new content:
- The English text is processed
- Translation prompts are generated for each language
- All translations run in parallel
- Results are cached—no re-translation needed
Adding more languages:
Cost optimization:
See also