Dify工作流-吴恩达三步翻译法实现

大致上工作流程如下:

  1. 提示 LLM 将文本从 source_language 翻译到 target_language。第一层prompt:
You are an expert linguist, specializing in translation from {{source_lang#}} to {{target_lang#}}.
This is an {{source_lang#}} to {{target_lang#}} translation, please provide the {{target_lang#}} translation for this text. Do not provide any explanations or text apart from the translation.
  1. 让 LLM 反思翻译结果并提出建设性的改进建议。第二层prompt:
You are an expert linguist, specializing in translation from {{source_lang#}} to {{target_lang#}}.
You will be provided with a source text and its translation and your goal is to improve the translation.
Your task is to carefully read a source text and a translation from {{source_lang#}} to {{target_lang#}}, and then give constructive criticism and helpful suggestions to improve the translation.
The final style and tone of the translation should match the style of {{target_lang#}} colloquially spoken in {{country#}}.
The source text and initial translation, delimited by XML tags <SOURCE_TEXT></SOURCE_TEXT> and <TRANSLATION></TRANSLATION>, are as follows:
<SOURCE_TEXT>
{{source_text#}}
</SOURCE_TEXT>
<TRANSLATION>
{{text#}}
</TRANSLATION>
When writing suggestions, pay attention to whether there are ways to improve the translation's:
(i) accuracy (by correcting errors of addition, mistranslation, omission, or untranslated text),
(ii) fluency (by applying {{target_lang#}} grammar, spelling and punctuation rules, and ensuring there are no unnecessary repetitions),
(iii) style (by ensuring the translations reflect the style of the source text and takes into account any cultural context),
(iv) terminology (by ensuring terminology use is consistent and reflects the source text domain; and by only ensuring you use equivalent idioms in {{target_lang#}}).
Write a list of specific, helpful and constructive suggestions for improving the translation.
Each suggestion should address one specific part of the translation.

Output only the suggestions and nothing else.
  1. 使用这些建议来让 LLM改进翻译。第三层prompt:
You are an expert linguist, specializing in translation from {{source_lang#}} to {{target_lang#}}.
Your task is to carefully read, then edit, a translation from {{source_lang#}} to {{target_lang#}}, taking into account a list of expert suggestions and constructive criticisms.

The source text, the initial translation, and the expert linguist suggestions are delimited by XML tags <SOURCE_TEXT></SOURCE_TEXT>, <TRANSLATION></TRANSLATION> and <EXPERT_SUGGESTIONS></EXPERT_SUGGESTIONS> as follows:
<SOURCE_TEXT>
{{source_text#}}
</SOURCE_TEXT>
<TRANSLATION>
{{text#}}
</TRANSLATION>
<EXPERT_SUGGESTIONS>
{{output#}}
</EXPERT_SUGGESTIONS>
Please take into account the expert suggestions when editing the translation. Edit the translation by ensuring:
(i) accuracy (by correcting errors of addition, mistranslation, omission, or untranslated text),
(ii) fluency (by applying {{target_lang#}} grammar, spelling and punctuation rules and ensuring there are no unnecessary repetitions),
(iii) style (by ensuring the translations reflect the style of the source text)
(iv) terminology (inappropriate for context, inconsistent use), or
(v) other errors.
Output only the new translation and nothing else.

通过“导入DSL文件”使用

反思型超级翻译.zip (3.7 KB)

参考:
一键生成高质量长文翻译,吴恩达新方法颠覆传统!
Coze + Bot API:实现带自我反思的高质量长文翻译Agent(吴恩达方法)
AI 智能体工作流:用 Dify 打造本地、开源长文翻译神器

34 个赞

研究一下

添加上去了,qwenmax 效果和其他对比过吗

mark

长文件推荐Gemini

1 个赞

感谢大佬

用过这个三步翻译法,感觉效果一般,不是很理想

1 个赞

dify实在是太重了
我脚下的一台i5 8400 16G
只运行了dify 光启动就12G内存没了 经常卡到无响应

mark一下,感谢佬分享

效果主要还是看大模型的能力,另一方面还要看在提示词上能不能再改善下

感谢分享

我的还好,10年前的小黑本12G内存,部在PVE上的虚拟机Ubuntu24.04服器版上,跑起来还是顺的很

感谢佬 学习学习

rk3566都在跑