Skip to content

🌐 [translation-sync] Revise JAX intro lecture and add autodiff lecture#16

Open
mmcky wants to merge 7 commits intomainfrom
translation-sync-2026-04-08T00-26-49-pr-513
Open

🌐 [translation-sync] Revise JAX intro lecture and add autodiff lecture#16
mmcky wants to merge 7 commits intomainfrom
translation-sync-2026-04-08T00-26-49-pr-513

Conversation

@mmcky
Copy link
Copy Markdown
Contributor

@mmcky mmcky commented Apr 8, 2026

Automated Translation Sync

This PR contains automated translations from QuantEcon/lecture-python-programming.

Source PR

#513 - Revise JAX intro lecture and add autodiff lecture

Files Added

  • lectures/autodiff.md
  • .translate/state/autodiff.md.yml

Files Updated

  • ✏️ lectures/jax_intro.md
  • ✏️ .translate/state/jax_intro.md.yml
  • ✏️ lectures/numpy_vs_numba_vs_jax.md
  • ✏️ .translate/state/numpy_vs_numba_vs_jax.md.yml
  • ✏️ lectures/_toc.yml

Details

  • Source Language: en
  • Target Language: zh-cn
  • Model: claude-sonnet-4-6

This PR was created automatically by the translation action.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-4-6 | Date: 2026-04-08


📝 Translation Quality

Criterion Score
Accuracy 9/10
Fluency 9/10
Terminology 9/10
Formatting 9/10
Overall 9/10

Summary: The translation is of high quality across all changed sections. It accurately conveys the technical content of the autodiff, JAX introduction, and NumPy/Numba/JAX comparison lectures. Terminology is consistent and follows established conventions. There is one minor spacing error in the vmap section, and a minor inconsistency between '操作' and '运算' in the Overall recommendations section versus the section headings. The mathematical content, code blocks, and MyST formatting are all correctly preserved. Technical terminology is consistently and correctly translated throughout all changed sections, including autodiff concepts, gradient descent, JIT compilation, and vmap. Mathematical expressions and LaTeX are fully preserved without any modifications. The translation of the 'How JIT compilation works' section accurately captures the technical pipeline description (trace → computational graph → XLA → optimized kernel). Code block structure, MyST directives, exercise/solution markup, and all formatting elements are correctly preserved across all added and modified sections. The 'Overall recommendations' section is translated fluently with appropriate academic register, accurately conveying the nuanced trade-offs between JAX, NumPy, and Numba.

Suggestions:

  • Vectorization with vmap section, paragraph 1: '它能自动将为单个输入编写的函数 向量化' contains an extra space before '向量化'. Should be '它能自动将为单个输入编写的函数向量化'.

  • What is automatic differentiation? > ### Autodiff section: '导数通过链式法则将计算分解为各组成部分来构建' is slightly ambiguous. The English 'Derivatives are constructed by breaking calculations into component parts via the chain rule' could be more clearly rendered as '通过链式法则将计算分解为各个组成部分来构建导数' to preserve the subject-verb order more naturally.

  • Gradient Descent > ### A function for gradient descent: The docstring comments inside the code cell are left in English ('Function to be minimized', 'Extra arguments to the function', etc.). While code comments are often left untranslated, the surrounding prose is fully translated. This is acceptable but worth noting for consistency with the project's translation approach.

  • Overall recommendations section: '对于向量化操作' and '对于顺序操作' use '操作' while earlier sections consistently use '运算' (e.g., '向量化运算', '顺序运算' in headings). Should use '运算' for consistency: '对于向量化运算' and '对于顺序运算'.


🔍 Diff Quality

Check Status
Scope Correct
Position Correct
Structure Preserved
Heading-map Correct
Overall 10/10

Summary: All three files are correctly modified with proper scope, position, structure, and heading-map updates reflecting the source changes.


This review was generated automatically by action-translation review mode.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This translation-sync PR updates the zh-cn JAX-related lectures to match upstream changes: it expands the JAX introduction (JIT internals, vmap, autodiff preview), adds a new autodiff lecture, and wires the new lecture into the book ToC.

Changes:

  • Added new lecture lectures/autodiff.md and its translation-sync state file.
  • Updated lectures/jax_intro.md with expanded sections (random keys, JIT pipeline explanation, vmap, autodiff preview) and new diagrams.
  • Updated lectures/numpy_vs_numba_vs_jax.md with minor code fixes/edits and a new “Overall recommendations” section; updated ToC/state files accordingly.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
lectures/autodiff.md New autodiff lecture content (examples, gradient descent) added to the curriculum
lectures/jax_intro.md Expanded JAX intro content (random keys, JIT internals, vmap, autodiff preview) + diagrams
lectures/numpy_vs_numba_vs_jax.md Small code/wording fixes and new overall recommendations section referencing autodiff
lectures/_toc.yml Adds autodiff to the book table of contents
.translate/state/autodiff.md.yml Records translation sync state for the new lecture
.translate/state/jax_intro.md.yml Updates translation sync state metadata
.translate/state/numpy_vs_numba_vs_jax.md.yml Updates translation sync state metadata

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lectures/ 下的讲座文件通常在 frontmatter 中包含 translation: { title, headings } 映射(用于标题/目录同步与后续翻译更新)。autodiff.md 目前缺少该段,可能会导致目录标题或后续 translation-sync 工具无法正确对齐章节。建议补充 translation.title 以及主要小节的 translation.headings 映射。

Suggested change
name: python3
name: python3
translation:
title: Adventures in Autodiff
headings:
- - Overview
- 概述

Copilot uses AI. Check for mistakes.
Comment on lines +316 to +322
while ϵ > tol and i < max_iter:
new_x = x - λ * df
new_df = f_grad(new_x, args)
Δx = new_x - x
Δdf = new_df - df
λ = jnp.abs(Δx @ Δdf) / (Δdf @ Δdf)
ϵ = jnp.max(jnp.abs(Δx))
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grad_descent 的 Barzilai–Borwein 步长更新中分母 (Δdf @ Δdf) 可能为 0(例如梯度在相邻迭代间不变或接近收敛时数值下溢),从而产生 inf/NaN 并使后续迭代失效。建议在更新步长前对分母做零值/极小值保护(如保持旧 λ、回退到默认 λ 或提前停止)。

Copilot uses AI. Check for mistakes.
Comment on lines +339 to +345
x = jax.random.uniform(key, (n,))

α, β, σ = 0.5, 1.0, 0.1 # Set the true intercept and slope.
key, subkey = jax.random.split(key)
ϵ = jax.random.normal(subkey, (n,))

y = α * x + β + σ * ϵ
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的注释把 α/β 的含义写反了:在 y = α * x + β + ... 中,α 是斜率、β 是截距。建议更正注释以避免读者混淆。

Copilot uses AI. Check for mistakes.
## 使用 `vmap` 进行向量化

## 梯度
JAX 的另一个强大变换是 `jax.vmap`,它能自动将为单个输入编写的函数 向量化,使其可以在批量数据上运行。
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这句里 “函数 向量化” 中间多了一个空格,影响排版与可读性。建议去掉多余空格。

Suggested change
JAX 的另一个强大变换是 `jax.vmap`它能自动将为单个输入编写的函数 向量化,使其可以在批量数据上运行。
JAX 的另一个强大变换是 `jax.vmap`它能自动将为单个输入编写的函数向量化,使其可以在批量数据上运行。

Copilot uses AI. Check for mistakes.
Comment on lines +381 to +385
# Root key
ax.text(3, 3, "key₀", ha='center', va='center', fontsize=11,
bbox=box_style)

# Level 1
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图中标签使用了 Unicode 下标字符(如 key₀key₁ 等)。在当前 i18n 字体设置下这些字符可能缺字导致渲染为方块,并且对屏幕阅读器也不友好。建议改为纯 ASCII(如 key0 / key_0)或使用 Matplotlib mathtext(如 $key_0$)以保证跨平台渲染一致。

Copilot uses AI. Check for mistakes.

ax.text(3, -0.5, "⋮", ha='center', va='center', fontsize=14)

ax.set_title("PRNG Key Splitting Tree", fontsize=13, pad=10)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

该图标题仍为英文("PRNG Key Splitting Tree"),与整篇中文讲义的语言不一致,可能影响读者理解与检索。建议翻译为中文或在标题中同时提供中英文。

Suggested change
ax.set_title("PRNG Key Splitting Tree", fontsize=13, pad=10)
ax.set_title("PRNG 密钥拆分树(PRNG Key Splitting Tree", fontsize=13, pad=10)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants