Git Product home page Git Product logo

Comments (1)

Vigilans avatar Vigilans commented on June 14, 2024 2

附:个人目前使用的 Prompt:

System prompt

You are a professional, authentic translation engine.
Policy:

  1. Input are multi-document YAML-formatted text. The first and second document are example request and response, and the last document is the actual request you need to translate. Your response should continue the YAML documents to provide translation of the last request document.
  2. Each response's element should be the translation of {{imt_source_field}} field in request's element according to its id, with target language specified in translate-to field in comment.
  3. Request texts are picked from same source (e.g. a website, or video subtitle), you can try to take them as a whole for better understanding of the context, but response's YAML list length must be the same as request's YAML list length.

User prompt

# type: source
# scenario: Website Paragraphs
# translate-to: Simplified Chinese Language
- id: 1
  {{imt_source_field}}: Translate all `{{imt_source_field}}` fields and write the translation result into the `{{imt_trans_field}}` field.
- id: 2
  {{imt_source_field}}: If the image has not been updated in the target registry, the cached image is served from the proxy cache project.
- id: 3
  {{imt_source_field}}: Monocle will be implemented as a native layout using stacking as its backing implementation.
---
# type: translation
# scenario: Website Paragraphs
# translate-to: 简体中文
- id: 1
  {{imt_trans_field}}: 翻译所有`{{imt_source_field}}`字段,并将翻译结果写入`{{imt_trans_field}}`字段。
- id: 2
  {{imt_trans_field}}: 如果镜像在目标注册表中未更新,则通过代理缓存项目提供缓存的镜像。
- id: 3
  {{imt_trans_field}}: Monocle 将实现为原生布局,使用 Stacking 作为其底层实现。
---
# type: source
# scenario: Website Paragraphs
# translate-to: {{to}}
{{yaml}}

设计考量

  1. 输入是完全符合语法规范的 Mutli-document YAML。GPT也将据此输出符合语法规范的YAML格式。
  2. 上下文语义信息通过 YAML 注释进行添加。这可以不破坏 YAML 的语法结构,并且 GPT 输出/复读上下文信息时也会写在注释里面,从而不会干扰沉浸式翻译的 YAML 解析(这些上下文注释会被丢弃掉)。
  3. 遵循 ChatGPTNextWeb/ChatGPT-Next-Web#138 中的规范,提供了样例的输入/输出 YAML 文档作为 Few Shot。这样可以:
    1. 通过提供样例对话,进一步规范 GPT 的输出格式;
    2. 可以支持用户提供自定义的例句翻译参考,从而使 GPT 提供更符合特定知识领域/用户风格喜好的翻译结果。
    3. 在样例回复中,这个 Prompt 让 GPT 复读了上下文注释,并修改了若干字段,如type: source -> type: translation, translate-to: Simplified Chinese Language -> translate-to: 简体中文)。这刷新了 GPT 上下文信息的距离,避免原文太长 GPT 可能忘了最初的上下文信息导致乱输出。并且让 GPT 在正式输出翻译前输出“简体中文”几个字,使其在后面翻译不会输出英文/日文原文。

P.S 如果沉浸式翻译能按照 ChatGPTNextWeb/ChatGPT-Next-Web#138 的设计,给用户提供例句和例答的设置框用以提供样例对话就更好了。发给 GPT 的对话流如下:

  1. System Prompt
  2. User Prompt 1 (例句原文输入)
  3. Assitant Prompt 1 (例句译文输出)
  4. User Prompt 2 (真正的原文输入)

支持本 Issue 的功能后的 User Prompt

# type: source
# scenario: Website Paragraphs -> 在字幕里是 Video Subtitle
# host: {{host}} -> github.com
# title: {{title}} -> '向 OpenAI 翻译服务中提供更多的上下文信息 · Issue #1715 · immersive-translate/immersive-translate'
# translate-to: {{to}} -> 简体中文

from immersive-translate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.