Skip to content

Latest commit

 

History

History
51 lines (42 loc) · 5.2 KB

7_1_1_Translation_Case.md

File metadata and controls

51 lines (42 loc) · 5.2 KB

Translation Case Study

Recently, Professor Andrew Ng of Stanford University open-sourced an AI agent for machine translation—an agent that employs a reflective workflow for translation. This project showcases an example of machine translation utilizing the reflective agent workflow. The primary steps of the agent include:

  1. Initial translation, utilizing a large model (LLM) to translate text from the source language to the target language;
  2. Reflection, wherein the large model identifies deficiencies in the translation and offers constructive improvement suggestions;
  3. Revision of the translation, where the large model retranslates based on the suggestions derived from the reflection; The reflective workflow employed in the project enables the model to identify its own deficiencies and implement targeted revisions, constituting a typical multi-agent collaborative working mechanism. This is also a domain in which agentUniverse has been actively engaged, prompting me to contemplate the migration of Andrew Ng's translation agent to agentUniverse. This case is based on the Qianwen large model, and prior to use, you need to configure the DASHSCOPE_API_KEY in the environment variables.

Collaborative Working Process of Multi-Agents

During the translation process, the priority is to ascertain whether the model's length surpasses the maximum number of tokens it can accommodate. For instances where the length exceeds the limit, the text is initially segmented, followed by the translation of each segment. Nonetheless, the entire translation process adheres to the initial translation -> reflection -> revision workflow. Multi-Agent Collaborative Working Process

Implementing this translation in aU involves the following steps:

  1. Define prompts related to translation, with three for short text and three for long text. Relevant files include:

  2. Define three agents

  3. Define the collaborative work process of the three agents
    The collaborative process is illustrated in the earlier-mentioned flowchart of multi-agent collaboration.
    Collaborative Work
    For a deeper dive into the processes, refer to the detailed code file.
    The configuration file for the collaborative agents.

Demonstration Code

Code Link

Long Text
Short Text

Translation Of Long Text
Translation Of Short Text

演示结果

We can see that using aU maintains consistency with the original translation_agent project results, successfully replicated. aU Results:
aU Long Text Result
translation_agent Results:
translation Long Text Result

Others

In reference to Professor Andrew Ng's code, when managing segmented translations, to ensure the coherence of the translation, each segment is translated with the corresponding context. However, incorporating all translation content into the context within his code can undermine the original intent of segmentation, and in certain cases, it can result in an excess of tokens beyond the model's capacity. I have raised a related issue on the corresponding repository address: Issue Link## Implementation in aU