张添翼
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 学Rust,学编译原理,英文原版看不懂?让Higress和通义千问帮你! 计算机相关英文教材的中译本质量堪忧,对于计算机专业的学生来说,应该深有体会。因为大部分教材的译者本人可能未必完全吃透书中技术内容,又或者是领域技术大拿,但并不擅长英文翻译。 本文将介绍基于 AI 大语言模型进行英文技术内容翻译,并基于又免费又好用的翻译软件进行内容呈现,帮助大家轻松学习计算机英文原版教材。 ## 先介绍两个Chrome插件 1. 沉浸式翻译:https://immersivetranslate.com 2. openai translator:https://github.com/openai-translator/openai-translator 这两个工具支持对接 OpenAI ChatGPT 来进行内容翻译,其中沉浸式翻译还支持 PDF、EPUB,以及视频字幕的实时翻译。其翻译效果远超 Google 翻译,甚至人工翻译。其原因是推理模型本身基于内容的理解之后的翻译,而即使是英语专八水平,如果缺少特定领域知识(如:计算机、医学、物理学),也很难翻译出信达雅的水平。 虽然国内用户无法使用 OpenAI ChatGPT 的功能,但我们有自己的通义千问,结合 Higress 的多模型协议转换能力(在这篇[《通义千问 2.5 “客串” ChatGPT4,你分的清吗?》](https://higress.io/zh-cn/blog/qwen-or-chatgpt)中有介绍),就可以用极低的 API 调用成本用上这两个插件了。 通义千问前不久刚进行了一轮大降价:[《击穿全网底价,通义千问GPT-4级大模型直降97%!1块钱能买200万tokens》](https://wallstreetcn.com/articles/3715367) 本文下面演示的效果就是基于**1 块钱 200 万 tokens 额度**(相当于5本新华字典的文字量)的 qwen-long 模型。 在演示之前,先要感谢沉浸式翻译的作者 Owen 和 openai translator 的作者 Yetone 设计并开发出如此优秀的工具,帮助知识的传递跨域语言的边界,让跨语言学习变得更容易,用母语去沉浸式学习,👩再也不用担心我的学习了~ ## Higress x 通义千问效果演示 ### Part.1 沉浸式学习 Rust (使用沉浸式翻译) 这里选取了 Rust 官方的 [《The Rust Programming Language》](https://doc.rust-lang.org/book/) 的 Understanding Ownership 一节的部分内容进行演示。因为是浏览器在线阅读,直接开启沉浸式翻译就可以看到双语显示: #### 通义千问翻译 ![](https://img.alicdn.com/imgextra/i2/O1CN01PNjxmd1RqheLoogYF_!!6000000002163-0-tps-1562-1302.jpg) ![](https://img.alicdn.com/imgextra/i3/O1CN017KCUaq1zLHPYHezOB_!!6000000006697-0-tps-1474-1492.jpg) #### 人工翻译 我在 GitHub 上找到一个项目 star 数有 4.3k 的中文版:[《Rust 程序设计语言》](https://github.com/KaiserY/trpl-zh-cn),对比上面截取内容的翻译如下: ![](https://img.alicdn.com/imgextra/i1/O1CN01E2TYyT1vEdCO2jM09_!!6000000006141-0-tps-1608-588.jpg) ![](https://img.alicdn.com/imgextra/i2/O1CN01foPM7Z1gYaDUPSap9_!!6000000004154-0-tps-1458-574.jpg) 对比上面通义千问的翻译,阅读这个人工翻译内容,我的阅读速度明显下降了;推测人工翻译作者应该是在机器翻译的基础上,做了一些简单调整,所以有一些翻译并不是中文语境下的常见句式,例如: > 英文原文:Think of being seated at a restaurant. When you enter, you state the number of people in your group, and the host finds an empty table that fits everyone and leads you there. > > 中文版翻译:想象一下去餐馆就座吃饭。当进入时,你说明有几个人,餐馆员工会找到一个够大的空桌子并领你们过去。 而这一段通义千问的翻译是: > 想象一下在餐厅就座的情景。进入时,你告诉服务员你们一行的人数,然后服务员会找到一张足以容纳所有人的空桌子并带你们过去。 通义千问在翻译时,举例来说,做了这样的改进: 1. 语句格式更完整(想象一下去餐馆就座吃饭->想象一下在餐厅就座的情景) 2. 去掉了中文语境下冗余的介词“When”(~~当~~进入时) 3. 补充了英文原文中省略的宾语(你告诉**服务员**) 通义千问的翻译显然更容易阅读和理解。另外值得一题的是 《The Rust Programming Language》一书还在跟随 Rust 语言自身的演进不断迭代。但中文版《Rust 程序设计语言》仍停留在 2021 年的版本。 ### Part.2 沉浸式学习编译原理(使用沉浸式翻译) 这里选取了 Bob Nystrom 编写的 [《Crafting Interpreters》](https://craftinginterpreters.com/) 的 Garbage Collection 一节的部分内容进行演示。用的作者免费发布的开源 PDF,用沉浸式翻译工具打开 PDF 即可。 ![](https://img.alicdn.com/imgextra/i2/O1CN01W8Pg7x1RYqCiOVqTH_!!6000000002124-0-tps-3020-1848.jpg) 效果炸裂! ### Part.3 主动和英文世界交流 (使用 openai transaltor) “学而不思则罔”。在学习的过程中,我们难免会有疑问需要交流,对于这些英文技术内容,国内的讨论地方不多,我们可以去 Reddit 上和外国友人进行交流。例如这里就有对于 [Crafting Interpreters](https://www.reddit.com/r/ProgrammingLanguages/comments/uiyhae/crafting_interpreters/) 的一些讨论。 如果你的英文能力不佳,可以考虑使用 openai translator 来翻译你的问题,然后发布到 Reddit 上: ![](https://img.alicdn.com/imgextra/i2/O1CN01hjbfED1Euk8bMW8vf_!!6000000000412-0-tps-1428-1228.jpg) 我这里手滑把“误”识别打成了“勿”识别,不过通义千问显然结合语境知道了我真正的意图,翻译成了“misidentification”。 Bravo! 对了,我们还可以来跟通义千问对话一下,看看他的回答: > 这里使用了 Higress+NextChat,把 gpt-4 模型映射为通义千问的 qwen-max 模型,所以截图显示为 gpt-4,具体方式可以参考这里:https://github.com/alibaba/higress/issues/938 ![](https://img.alicdn.com/imgextra/i2/O1CN017B7V6p1FNb5YqgKjm_!!6000000000475-2-tps-1710-1804.png) ## 手把手教你如何配置 ### Step.0 创建通义千问 API Key 1. 使用支付宝[注册](https://account.aliyun.com/register/qr_register.htm)一个阿里云账号 2. 进入[灵积平台](https://dashscope.console.aliyun.com/apiKey),创建一个 API Key ### Step.1 启动 Higress Higress 支持用 Docker 启动: ```bash= # 创建一个工作目录 mkdir higress; cd higress # 启动 higress,配置文件会写到工作目录下 docker run -d --rm --name higress-ai -v ${PWD}:/data \ -p 8001:8001 -p 8080:8080 -e CONFIG_TEMPLATE=ai-proxy \ -e DEFAULT_AI_SERVICE=qwen -e DASHSCOPE_API_KEY="这里填APIKey" \ higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/all-in-one:1.4.0-rc.1 ``` 默认模型映射方式: - gpt-4 映射到 qwen-max - 其他都映射到 qwen-long 如有需求,你也可以在浏览器输入: [http://localhost:8001](http://localhost:8001), 登陆 Higress 控制台,在 qwen 这个路由的策略里找到 AI 代理插件,修改映射到其他模型: ![](https://img.alicdn.com/imgextra/i2/O1CN01BWeOkV24luWMqwt0E_!!6000000007432-0-tps-3582-1350.jpg) ### Step.2.1 配置沉浸式翻译 找到沉浸式翻译的设置页,在翻译服务处选择 OpenAI,点开设置。 沉浸式翻译比较消耗 token,这里我们用最便宜的 qwen-long 模型。因为除了 gpt-4 都被 Higress 映射到了 qwen-long,这里可以直接选 "gpt-3.5-turbo"。 然后再填入自定义接口地址:http://127.0.0.1:8080/api/openai/v1/chat/completions ![](https://img.alicdn.com/imgextra/i1/O1CN01Yx2Ins1pMWKN53baM_!!6000000005346-0-tps-2666-1858.jpg) > 这里不再需要填写 API Key,因为 Higress 代理后没有配置 API Key,当然你也可以设置一个自定义的 API Key,然后将 Higress 地址暴露到外部给其他人使用,并通过 API Key 来进行认证. > Higress 侧最简单的配置方式,就是为路由直接配置一个 Authorization Header 匹配,如下图配置后,API Key 就是 "my-custom-token": > ![](https://img.alicdn.com/imgextra/i1/O1CN01hJQyvw1IYznIzCann_!!6000000000906-0-tps-3192-1602.jpg) ### Step.2.2 配置 openai translator 找到 openai translator 的设置页,服务提供商选择 OpenAI,进行如下类似的配置,不过这里我们把模型改为 gpt-4,即 Higress 映射后的 qwen-max。因为使用 openai translator 的场景一般不会输入太多 token,我们使用 qwen-max 会比 qwen-long 有更好的翻译效果: ![](https://img.alicdn.com/imgextra/i4/O1CN01fyNFPq1J53WJ9JauU_!!6000000000976-0-tps-1428-1228.jpg) ## 解锁 Higress AI 代理插件的更多玩法 ### 更精确的翻译修订 Higress 支持使用 qwen-long 模型的文件上传对话能力,可以用如下命令上传一份自定义的词典用于翻译上下文: ```bash= curl --location --request POST 'https://dashscope.aliyuncs.com/compatible-mode/v1/files' \ --header 'Authorization: Bearer 这里填APIKey' \ --form 'file=@"./dict.txt"' \ --form 'purpose="file-extract"' # 返回内容: {"id":"file-fe-xxxxxxx","object":"file","bytes":596687,"created_at":1716635947,"filename":"doc.md","purpose":"file-extract","status":"processed"} ``` 将返回 json 的 id 字段配置到 Higress AI 代理插件的配置中: ```yaml= provider: apiTokens: - "sk-0e6c387446ff45d0924111475a82462e" modelMapping: '*': "qwen-long" gpt-4: "qwen-max" gpt-4-turbo: "qwen-max" gpt-4o: "qwen-max" qwenFileIds: - "file-fe-xxxxxxx" type: "qwen" ``` 后续用 qwen-long 翻译就可以用上这些上下文信息了。当然这个玩法不仅局限于翻译,还可以用在基于文档的 FAQ 机器人搭建等场景。 ### 对接更多的大模型 Higress AI 代理插件目前支持的模型列表如下 - 通义千问 - OpenAI - Azure OpenAI - 月之暗面 - 百川智能 - 零一万物 - DeepSeek - Groq - Anthropic Claude 相应的详细配置方式可以查看: https://github.com/alibaba/higress/tree/main/plugins/wasm-go/extensions/ai-proxy 也欢迎有兴趣的同学参与 Higress 开源建设,帮助 Higress 对接更多大模型,并不断探索新的玩法。有兴趣的同学可以到这个 issue 下认领任务: https://github.com/alibaba/higress/issues/940 有任何使用问题,欢迎到社区提 issue,也可以进微信或钉钉群交流: ![](https://img.alicdn.com/imgextra/i1/O1CN01LWh6QW1TxEWflxKVg_!!6000000002448-0-tps-720-405.jpg)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully