Translation Agent: Agentic Translation with LLM Reflection Workflow

Translation Agent: Agentic Translation with LLM Reflection Workflow

Summary

Translation Agent is a Python demonstration of an agentic workflow for machine translation, leveraging large language models (LLMs) and a reflection process. This innovative approach aims to improve translation quality by having the LLM translate, reflect on its output, and then refine the translation based on its own suggestions. It offers significant customizability for style, idioms, and regional language variations, making it a promising direction for future translation technologies.

Repository Info

Updated on March 24, 2026
View on GitHub

Introduction

Translation Agent is a Python demonstration of an innovative agentic workflow for machine translation, developed by Andrew Ng and collaborators. This project leverages large language models (LLMs) to perform translations through a unique reflection process. The core idea involves an LLM first translating a text, then reflecting on its own output to identify areas for improvement, and finally using these self-generated suggestions to refine the translation.

This approach offers significant customizability, allowing users to easily modify the output's style (e.g., formal/informal), specify how to handle idioms and special terms, and even target specific regional language uses or dialects. While not yet mature software, Translation Agent is presented as a promising starting point for agentic translations, encouraging further discussion, experimentation, and open-source contributions in the field.

Installation

To get started with translation-agent, follow these steps. The Poetry package manager is required for installation.

  1. Install Poetry:

    pip install poetry
    

    For more detailed instructions, refer to the Poetry Installation Guide.

  2. Clone the repository and set up:

    A .env file with an OPENAI_API_KEY is required to run the workflow. See the .env.sample file in the repository for an example.

    git clone https://github.com/andrewyng/translation-agent.git
    cd translation-agent
    poetry install
    poetry shell # activates virtual environment
    

Examples

Once installed, you can use translation-agent in your Python projects:

import translation_agent as ta
source_lang, target_lang, country = "English", "Spanish", "Mexico"
source_text = "Hello, how are you?" # Example text
translation = ta.translate(source_lang, target_lang, source_text, country)
print(translation)

For a complete example script, refer to examples/example_script.py within the cloned repository.

Why Use It

Translation Agent presents a compelling alternative to traditional machine translation systems, primarily due to its high steerability and potential for superior translation quality in specific contexts. By integrating LLMs into a reflection workflow, it allows for granular control over translation nuances, such as stylistic choices, consistent handling of specialized terminology via glossaries, and adaptation to regional language variations.

Although its performance can vary, the project has shown instances of producing "fantastic results" that surpass commercial offerings. Furthermore, this agentic approach could serve as a valuable mechanism for automatically generating high-quality parallel text corpora, which can then be used to train and improve traditional, faster machine translation algorithms. The project actively invites the open-source community to explore extensions, including experimenting with different LLMs, developing glossary creation and usage strategies, and conducting more robust evaluations.

Links