🌐 [translation-sync] Revise JAX intro lecture and add autodiff lecture#16
🌐 [translation-sync] Revise JAX intro lecture and add autodiff lecture#16
Conversation
✅ Translation Quality ReviewVerdict: PASS | Model: claude-sonnet-4-6 | Date: 2026-04-08 📝 Translation Quality
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:
🔍 Diff Quality
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. |
There was a problem hiding this comment.
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.mdand its translation-sync state file. - Updated
lectures/jax_intro.mdwith expanded sections (random keys, JIT pipeline explanation,vmap, autodiff preview) and new diagrams. - Updated
lectures/numpy_vs_numba_vs_jax.mdwith 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 |
There was a problem hiding this comment.
lectures/ 下的讲座文件通常在 frontmatter 中包含 translation: { title, headings } 映射(用于标题/目录同步与后续翻译更新)。autodiff.md 目前缺少该段,可能会导致目录标题或后续 translation-sync 工具无法正确对齐章节。建议补充 translation.title 以及主要小节的 translation.headings 映射。
| name: python3 | |
| name: python3 | |
| translation: | |
| title: Adventures in Autodiff | |
| headings: | |
| - - Overview | |
| - 概述 |
| 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)) |
There was a problem hiding this comment.
grad_descent 的 Barzilai–Borwein 步长更新中分母 (Δdf @ Δdf) 可能为 0(例如梯度在相邻迭代间不变或接近收敛时数值下溢),从而产生 inf/NaN 并使后续迭代失效。建议在更新步长前对分母做零值/极小值保护(如保持旧 λ、回退到默认 λ 或提前停止)。
| 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 + β + σ * ϵ |
There was a problem hiding this comment.
这里的注释把 α/β 的含义写反了:在 y = α * x + β + ... 中,α 是斜率、β 是截距。建议更正注释以避免读者混淆。
| ## 使用 `vmap` 进行向量化 | ||
|
|
||
| ## 梯度 | ||
| JAX 的另一个强大变换是 `jax.vmap`,它能自动将为单个输入编写的函数 向量化,使其可以在批量数据上运行。 |
There was a problem hiding this comment.
这句里 “函数 向量化” 中间多了一个空格,影响排版与可读性。建议去掉多余空格。
| JAX 的另一个强大变换是 `jax.vmap`,它能自动将为单个输入编写的函数 向量化,使其可以在批量数据上运行。 | |
| JAX 的另一个强大变换是 `jax.vmap`,它能自动将为单个输入编写的函数向量化,使其可以在批量数据上运行。 |
| # Root key | ||
| ax.text(3, 3, "key₀", ha='center', va='center', fontsize=11, | ||
| bbox=box_style) | ||
|
|
||
| # Level 1 |
There was a problem hiding this comment.
图中标签使用了 Unicode 下标字符(如 key₀、key₁ 等)。在当前 i18n 字体设置下这些字符可能缺字导致渲染为方块,并且对屏幕阅读器也不友好。建议改为纯 ASCII(如 key0 / key_0)或使用 Matplotlib mathtext(如 $key_0$)以保证跨平台渲染一致。
|
|
||
| ax.text(3, -0.5, "⋮", ha='center', va='center', fontsize=14) | ||
|
|
||
| ax.set_title("PRNG Key Splitting Tree", fontsize=13, pad=10) |
There was a problem hiding this comment.
该图标题仍为英文("PRNG Key Splitting Tree"),与整篇中文讲义的语言不一致,可能影响读者理解与检索。建议翻译为中文或在标题中同时提供中英文。
| ax.set_title("PRNG Key Splitting Tree", fontsize=13, pad=10) | |
| ax.set_title("PRNG 密钥拆分树(PRNG Key Splitting Tree)", fontsize=13, pad=10) |
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.ymlFiles Updated
lectures/jax_intro.md.translate/state/jax_intro.md.ymllectures/numpy_vs_numba_vs_jax.md.translate/state/numpy_vs_numba_vs_jax.md.ymllectures/_toc.ymlDetails
This PR was created automatically by the translation action.