feat(site): render LaTeX math via KaTeX + convert plain-text formulas#293
feat(site): render LaTeX math via KaTeX + convert plain-text formulas#293Jayantkhandebharad wants to merge 65 commits into
Conversation
Lesson docs had no way to show real math: formulas were ASCII art in untagged code fences or plain-text inline, which reads poorly. Add pinned KaTeX 0.17.0 (CDN + SRI) and teach the client-side markdown renderer two math forms: - inline $...$ via the Pandoc rule (opener not followed by space, closer not preceded by space nor followed by a digit) so prose dollar amounts like $50,000 and $0.25/$2.50 are never mistaken for math - block $$...$$ (single- or multi-line) rendered as a display equation Inline code and math are stashed behind sentinels before the escape / emphasis pass so a $ inside `code` and a * inside a formula stay verbatim. Bad or unloaded TeX degrades to the raw source, never a blank. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Render formulas via KaTeX ($...$ / $$...$$) instead of ASCII art and plain-text notation. Math is unchanged; only notation is converted. Part of rohitg00#158. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds KaTeX math rendering to ChangesLaTeX Math Rendering
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (8)
site/lesson.html (1)
2202-2204:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle required docs frontmatter before markdown parsing.
At Line 2202,
parseMdparses raw markdown directly; there’s no YAML frontmatter strip step. If docs adopt requireddocs/en.mdfrontmatter, the opening---will be treated as markdown content (<hr>+ visible metadata lines), breaking lesson rendering.Suggested fix
+ function stripFrontmatter(md) { + // Supports: + // --- + // key: value + // --- + if (!md || md.slice(0, 4) !== '---\n') return md; + var end = md.indexOf('\n---', 4); + if (end === -1) return md; + return md.slice(end + 4).replace(/^\r?\n/, ''); + } + function parseMd(md) { + md = stripFrontmatter(md); var lines = md.split(/\r?\n/);As per coding guidelines, "
**/docs/en.md: Include frontmatter in docs/en.md with fields: Title, one-line hook, Type (Learn|Build|Reference), Languages, Prerequisites, Time estimate, and Learning Objectives."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@site/lesson.html` around lines 2202 - 2204, The parseMd function currently processes markdown content without stripping YAML frontmatter, which means if markdown files include frontmatter blocks delimited by `---` at the beginning, these will be rendered as markdown content (producing `<hr>` tags and visible metadata lines) instead of being extracted and removed. Before processing the markdown lines, add logic to detect and strip YAML frontmatter: check if the markdown starts with `---`, find the closing `---` delimiter, and remove everything between them (including the delimiters themselves) before continuing with the rest of the markdown parsing logic.Source: Coding guidelines
phases/01-math-foundations/01-linear-algebra-intuition/docs/en.md (1)
1-16:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftAdd required YAML frontmatter for
docs/en.mdand migrate metadata fields.At Lines 1-16, the file still uses inline metadata (
**Type:**,**Languages:**, etc.) instead of required frontmatter. This should be converted in this file and consistently across the other updated phase-01 lesson docs in this PR to keep docs schema-compliant.Suggested frontmatter shape
--- Title: Linear Algebra Intuition Hook: Every AI model is just matrix math wearing a fancy hat. Type: Learn Languages: [Python, Julia] Prerequisites: Phase 0 Time estimate: 60 minutes Learning Objectives: - Implement vector and matrix operations (addition, dot product, matrix multiply) from scratch in Python - Explain geometrically what the dot product, projection, and Gram-Schmidt process do - Determine linear independence, rank, and basis of a set of vectors using row reduction - Connect linear algebra concepts to AI applications: embeddings, attention scores, and LoRA ---As per coding guidelines, "
**/docs/en.md: Include frontmatter in docs/en.md with fields: Title, one-line hook, Type (Learn|Build|Reference), Languages, Prerequisites, Time estimate, and 4-6 Learning Objectives bullet pointsandThe Languages: field ... must match the languages with a main.* file in the code/ directory`."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/01-math-foundations/01-linear-algebra-intuition/docs/en.md` around lines 1 - 16, Convert the inline metadata in the markdown file from markdown bold formatting to YAML frontmatter at the top. Remove the existing inline metadata fields (Type, Languages, Prerequisites, Time) and the blockquote hook, then add a YAML block delimited by --- at the very beginning of the file containing: Title (set to "Linear Algebra Intuition"), Hook (the blockquote text), Type (Learn), Languages (as a list: [Python, Julia]), Prerequisites (Phase 0), Time estimate (60 minutes), and Learning Objectives (as a list of the four bullet points currently in the body). After the closing ---, start with the main heading "# Linear Algebra Intuition" and the remaining content.Source: Coding guidelines
phases/01-math-foundations/11-singular-value-decomposition/docs/en.md (1)
446-448:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winDon't assign the seed call to
image.
np.random.seed()returnsNone, so this line is misleading and briefly setsimageto a non-array value. Make the seed call standalone.💡 Suggested fix
- image = np.random.seed(42) + np.random.seed(42)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/01-math-foundations/11-singular-value-decomposition/docs/en.md` around lines 446 - 448, The np.random.seed() function returns None, so assigning its result to the image variable makes image None instead of an array, which is misleading. Remove the assignment operator from the line np.random.seed(42) and make it a standalone statement that just sets the random seed without assigning to image. Keep the subsequent lines that define rows and cols, and then create the image array with np.random.randn(rows, cols).phases/01-math-foundations/16-sampling-methods/docs/en.md (3)
615-618:⚠️ Potential issue | 🟠 Major | ⚡ Quick winStop taking
log()of logits.These inputs are named
logits, butmath.log(p)treats them like probabilities and will fail on valid negative logits. Add Gumbel noise directly to the logits, or rename the parameter if you really mean probabilities.🛠 Suggested fix
def gumbel_softmax(logits, temperature): - gumbels = [math.log(p) + gumbel_sample() for p in logits] + gumbels = [z + gumbel_sample() for z in logits] return softmax([g / temperature for g in gumbels])🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/01-math-foundations/16-sampling-methods/docs/en.md` around lines 615 - 618, The gumbel_softmax function incorrectly applies math.log() to its inputs despite naming the parameter logits. Logits are unnormalized scores that can be negative, and taking their logarithm will fail or produce invalid results. Remove the math.log(p) call and instead add the gumbel_sample() output directly to each logit value in the list comprehension, since the Gumbel-Softmax technique adds Gumbel noise directly to logits before temperature scaling and softmax.
557-560:⚠️ Potential issue | 🟠 Major | ⚡ Quick winHandle
temperature = 0explicitly.The prose says
T = 0.0means greedy decoding, but this function divides bytemperatureand will raise on that input. Special-case zero before scaling.🧩 Suggested fix
def temperature_sample(logits, temperature): + if temperature == 0: + return max(range(len(logits)), key=lambda i: logits[i]) scaled = [z / temperature for z in logits] probs = softmax(scaled) return sample_from_probs(probs)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/01-math-foundations/16-sampling-methods/docs/en.md` around lines 557 - 560, The temperature_sample function performs division by temperature without handling the case when temperature equals zero, which causes a division error and contradicts the documented behavior that T = 0.0 should perform greedy decoding. Add an explicit check at the beginning of the temperature_sample function: if temperature is 0, return the index of the maximum logit value (greedy selection) directly. Otherwise, proceed with the existing scaling and sampling logic.
468-470:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAvoid
log(0)in the exponential sampler.
random.random()can return0.0, so-math.log(u)can fail.log1p(-u)keeps the inverse-CDF transform well-defined on[0, 1).🔧 Suggested fix
def sample_exponential_inverse_cdf(lam): u = random.random() - return -math.log(u) / lam + return -math.log1p(-u) / lam🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/01-math-foundations/16-sampling-methods/docs/en.md` around lines 468 - 470, The sample_exponential_inverse_cdf function uses -math.log(u) which fails when u equals 0.0 (since random.random() can return 0.0). Replace -math.log(u) with -math.log1p(-u) to compute log(1-u) in a numerically stable way that remains well-defined across the entire [0, 1) range that random.random() produces.phases/01-math-foundations/17-linear-systems/docs/en.md (1)
245-249:⚠️ Potential issue | 🟠 Major | ⚡ Quick winCorrect the least-squares example solution.
The normal-equations system here solves to
[1.5, 1.6], not[1.5, 1.7]. The current value disagrees with the derivation above it.📌 Suggested fix
- Solve: x = [1.5, 1.7] + Solve: x = [1.5, 1.6]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/01-math-foundations/17-linear-systems/docs/en.md` around lines 245 - 249, The least-squares solution vector in the normal equations example is incorrect. Change the solution from x = [1.5, 1.7] to x = [1.5, 1.6] to match the correct result that solves the normal-equations system A^T A x = A^T b shown in the diff.phases/11-llm-engineering/13-production-app/docs/en.md (1)
206-209:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winTwo critical KaTeX rendering failures in production-app doc.
Both issues stem from the markdown-to-KaTeX pipeline in site/lesson.html and will break rendering:
Issue 1 — Line 231: The expression
$50{,}000 \times (1 - 0.35)$uses LaTeX's{,}command for spacing, which KaTeX does not support. KaTeX has no built-in support for{,}; use\,(thin space) or plain50,000instead.Issue 2 — Lines 206–209: The Scaling table's currency amounts (
$50/month,$500/month,$5K/month,$50K+/month) will be matched by the Pandoc inline-math regex/\$(?=\S)([^$\n]+?)\$(?!\d)/(opening$not after space, closing$not before space/digit, followed by/orKnot a digit). These will be incorrectly interpreted as LaTeX inline math and render as broken expressions instead of plain currency text. Escape or wrap in code.Fixes:
- Line 231: Change
$50{,}000 \times (1 - 0.35)$→$50,000 \times (1 - 0.35)$- Lines 206–209: Wrap currency in backticks (
`$50/month`) or escape dollar signs (\$50/month)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/11-llm-engineering/13-production-app/docs/en.md` around lines 206 - 209, Fix two KaTeX rendering failures in the production-app documentation. At lines 206-209 in the Scaling table, wrap all currency amounts (`$50/month`, `$500/month`, `$5K/month`, `$50K+/month`) in backticks (e.g., `` `$50/month` ``) or escape the dollar signs (e.g., `\$50/month`) to prevent Pandoc's markdown-to-KaTeX pipeline from misinterpreting them as LaTeX inline math expressions. At line 231, change the cost expression from `$50{,}000 \times (1 - 0.35)$` to `$50,000 \times (1 - 0.35)$` by removing the unsupported `{,}` LaTeX command and replacing it with a plain comma.
🧹 Nitpick comments (1)
phases/01-math-foundations/22-stochastic-processes/docs/en.md (1)
168-170: 💤 Low valueConsider rewording to avoid successive sentences starting with "At."
Lines 170–171 have three consecutive sentences opening with "At," which breaks sentence-variety conventions.
✏️ Optional rewrite
-At temperature $T = 0$, this is pure gradient descent. At high temperature, it is nearly a random walk. At the right temperature, the particle explores the energy landscape and spends more time in low-energy regions. +At temperature $T = 0$, this is pure gradient descent. Higher temperatures produce nearly random-walk behavior. The sweet spot allows the particle to explore the energy landscape and spend more time in low-energy regions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@phases/01-math-foundations/22-stochastic-processes/docs/en.md` around lines 168 - 170, The three consecutive sentences in the temperature description paragraph all begin with "At," creating poor sentence variety. Reword at least one or two of these sentences to vary the sentence structure while maintaining the same information about how the particle behaves at temperature T=0, at high temperature, and at the right temperature. Consider using alternative phrasings such as describing conditions differently or restructuring the sentences to lead with different elements.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@phases/01-math-foundations/07-bayes-theorem/docs/en.md`:
- Around line 423-427: The fenced code block starting at line 423 in the
pseudocode section is missing a required language tag. Add the "text" language
identifier to the opening fence by changing the bare triple backticks to ```text
to comply with markdown documentation guidelines and eliminate lint violations.
In `@phases/01-math-foundations/13-numerical-stability/docs/en.md`:
- Around line 573-575: The "Precision hunt" exercise incorrectly defines machine
epsilon by asking for the smallest positive float32 value where `1.0 + x ==
1.0`. Machine epsilon should be the smallest positive value where the addition
actually produces a change, not values that get completely rounded away. Modify
the condition in the "Precision hunt" exercise from `1.0 + x == 1.0` to `1.0 + x
> 1.0` to correctly ask students to find the smallest positive value that makes
the sum strictly greater than 1.0.
In `@phases/01-math-foundations/14-norms-and-distances/docs/en.md`:
- Line 31: The sentence makes an overly broad claim that every distance function
can be written as the norm of their difference, but not all distances covered in
the lesson follow this form. Replace "Every distance function between two
vectors" with more accurate language such as "many vector distances" or
"norm-induced distances" to properly qualify the claim and reflect that only
certain types of distances can be expressed as ||a - b||.
In `@phases/01-math-foundations/15-statistics-for-ml/docs/en.md`:
- Around line 179-186: The confidence interval formula is incorrectly using the
z-distribution with sample standard deviation s. When the population standard
deviation is unknown and you use the sample standard deviation s, you must use
the t-distribution instead of the z-distribution. Replace the reference to z =
1.96 with the appropriate t-critical value from the t-distribution with degrees
of freedom n-1, and update the explanation to clarify that this is the
t-interval formula. Note that t ≈ 1.96 for large samples but is larger for
smaller samples, which is an important distinction for proper statistical
inference.
In `@phases/01-math-foundations/16-sampling-methods/docs/en.md`:
- Around line 111-123: The acceptance rate formula stated at the end of the
rejection sampling algorithm section does not account for the possibility of
unnormalized target densities, which was explicitly mentioned earlier in the
section. Modify the "Acceptance rate = 1/M" statement to add a qualification
clarifying that this formula applies only when p(x) is normalized. If p(x) is
unnormalized with normalization constant Z, the actual acceptance rate would be
1/(M*Z), which is unknown without knowing Z. Ensure the revised statement makes
this distinction clear so readers understand the acceptance rate depends on
whether the target density is normalized or not.
In `@phases/01-math-foundations/17-linear-systems/docs/en.md`:
- Around line 324-329: The condition number formula for regularized matrices in
the regularization explanation is incorrect. When λI is added to the normal
equations (A^T A), the eigenvalues of the modified matrix become σ^2 + λ (using
squared singular values), not σ + λ. Update the condition number formula to
correctly reflect that the improved condition number should be written as
(σ_max^2 + λ) / (σ_min^2 + λ) in terms of squared singular values, not (σ_max +
λ) / (σ_min + λ).
In `@phases/01-math-foundations/20-fourier-transform/docs/en.md`:
- Around line 45-52: Add language tags to three text blocks in the markdown file
to comply with documentation guidelines. At lines 45-52, wrap the step-by-step
walk positions content with ```text opening and closing fence markers. At lines
247-256, wrap the STFT procedure content with ```text tags. At lines 264-273,
wrap the aliasing example content with ```text tags. Each fenced code block must
include an explicit language identifier per the coding standards.
---
Outside diff comments:
In `@phases/01-math-foundations/01-linear-algebra-intuition/docs/en.md`:
- Around line 1-16: Convert the inline metadata in the markdown file from
markdown bold formatting to YAML frontmatter at the top. Remove the existing
inline metadata fields (Type, Languages, Prerequisites, Time) and the blockquote
hook, then add a YAML block delimited by --- at the very beginning of the file
containing: Title (set to "Linear Algebra Intuition"), Hook (the blockquote
text), Type (Learn), Languages (as a list: [Python, Julia]), Prerequisites
(Phase 0), Time estimate (60 minutes), and Learning Objectives (as a list of the
four bullet points currently in the body). After the closing ---, start with the
main heading "# Linear Algebra Intuition" and the remaining content.
In `@phases/01-math-foundations/11-singular-value-decomposition/docs/en.md`:
- Around line 446-448: The np.random.seed() function returns None, so assigning
its result to the image variable makes image None instead of an array, which is
misleading. Remove the assignment operator from the line np.random.seed(42) and
make it a standalone statement that just sets the random seed without assigning
to image. Keep the subsequent lines that define rows and cols, and then create
the image array with np.random.randn(rows, cols).
In `@phases/01-math-foundations/16-sampling-methods/docs/en.md`:
- Around line 615-618: The gumbel_softmax function incorrectly applies
math.log() to its inputs despite naming the parameter logits. Logits are
unnormalized scores that can be negative, and taking their logarithm will fail
or produce invalid results. Remove the math.log(p) call and instead add the
gumbel_sample() output directly to each logit value in the list comprehension,
since the Gumbel-Softmax technique adds Gumbel noise directly to logits before
temperature scaling and softmax.
- Around line 557-560: The temperature_sample function performs division by
temperature without handling the case when temperature equals zero, which causes
a division error and contradicts the documented behavior that T = 0.0 should
perform greedy decoding. Add an explicit check at the beginning of the
temperature_sample function: if temperature is 0, return the index of the
maximum logit value (greedy selection) directly. Otherwise, proceed with the
existing scaling and sampling logic.
- Around line 468-470: The sample_exponential_inverse_cdf function uses
-math.log(u) which fails when u equals 0.0 (since random.random() can return
0.0). Replace -math.log(u) with -math.log1p(-u) to compute log(1-u) in a
numerically stable way that remains well-defined across the entire [0, 1) range
that random.random() produces.
In `@phases/01-math-foundations/17-linear-systems/docs/en.md`:
- Around line 245-249: The least-squares solution vector in the normal equations
example is incorrect. Change the solution from x = [1.5, 1.7] to x = [1.5, 1.6]
to match the correct result that solves the normal-equations system A^T A x =
A^T b shown in the diff.
In `@phases/11-llm-engineering/13-production-app/docs/en.md`:
- Around line 206-209: Fix two KaTeX rendering failures in the production-app
documentation. At lines 206-209 in the Scaling table, wrap all currency amounts
(`$50/month`, `$500/month`, `$5K/month`, `$50K+/month`) in backticks (e.g., ``
`$50/month` ``) or escape the dollar signs (e.g., `\$50/month`) to prevent
Pandoc's markdown-to-KaTeX pipeline from misinterpreting them as LaTeX inline
math expressions. At line 231, change the cost expression from `$50{,}000 \times
(1 - 0.35)$` to `$50,000 \times (1 - 0.35)$` by removing the unsupported `{,}`
LaTeX command and replacing it with a plain comma.
In `@site/lesson.html`:
- Around line 2202-2204: The parseMd function currently processes markdown
content without stripping YAML frontmatter, which means if markdown files
include frontmatter blocks delimited by `---` at the beginning, these will be
rendered as markdown content (producing `<hr>` tags and visible metadata lines)
instead of being extracted and removed. Before processing the markdown lines,
add logic to detect and strip YAML frontmatter: check if the markdown starts
with `---`, find the closing `---` delimiter, and remove everything between them
(including the delimiters themselves) before continuing with the rest of the
markdown parsing logic.
---
Nitpick comments:
In `@phases/01-math-foundations/22-stochastic-processes/docs/en.md`:
- Around line 168-170: The three consecutive sentences in the temperature
description paragraph all begin with "At," creating poor sentence variety.
Reword at least one or two of these sentences to vary the sentence structure
while maintaining the same information about how the particle behaves at
temperature T=0, at high temperature, and at the right temperature. Consider
using alternative phrasings such as describing conditions differently or
restructuring the sentences to lead with different elements.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 092d54c9-f364-434b-ad73-79f7a5620b52
📒 Files selected for processing (55)
phases/01-math-foundations/01-linear-algebra-intuition/docs/en.mdphases/01-math-foundations/04-calculus-for-ml/docs/en.mdphases/01-math-foundations/05-chain-rule-and-autodiff/docs/en.mdphases/01-math-foundations/06-probability-and-distributions/docs/en.mdphases/01-math-foundations/07-bayes-theorem/docs/en.mdphases/01-math-foundations/08-optimization/docs/en.mdphases/01-math-foundations/09-information-theory/docs/en.mdphases/01-math-foundations/11-singular-value-decomposition/docs/en.mdphases/01-math-foundations/13-numerical-stability/docs/en.mdphases/01-math-foundations/14-norms-and-distances/docs/en.mdphases/01-math-foundations/15-statistics-for-ml/docs/en.mdphases/01-math-foundations/16-sampling-methods/docs/en.mdphases/01-math-foundations/17-linear-systems/docs/en.mdphases/01-math-foundations/18-convex-optimization/docs/en.mdphases/01-math-foundations/19-complex-numbers/docs/en.mdphases/01-math-foundations/20-fourier-transform/docs/en.mdphases/01-math-foundations/22-stochastic-processes/docs/en.mdphases/02-ml-fundamentals/04-decision-trees/docs/en.mdphases/02-ml-fundamentals/06-knn-and-distances/docs/en.mdphases/02-ml-fundamentals/10-bias-variance/docs/en.mdphases/02-ml-fundamentals/18-feature-selection/docs/en.mdphases/03-deep-learning-core/01-the-perceptron/docs/en.mdphases/03-deep-learning-core/06-optimizers/docs/en.mdphases/03-deep-learning-core/07-regularization/docs/en.mdphases/04-computer-vision/01-image-fundamentals/docs/en.mdphases/04-computer-vision/02-convolutions-from-scratch/docs/en.mdphases/04-computer-vision/03-cnns-lenet-to-resnet/docs/en.mdphases/04-computer-vision/08-instance-segmentation-mask-rcnn/docs/en.mdphases/04-computer-vision/10-image-generation-diffusion/docs/en.mdphases/04-computer-vision/13-3d-vision-nerf/docs/en.mdphases/04-computer-vision/14-vision-transformers/docs/en.mdphases/04-computer-vision/17-self-supervised-vision/docs/en.mdphases/04-computer-vision/20-image-retrieval-metric/docs/en.mdphases/04-computer-vision/21-keypoint-pose/docs/en.mdphases/04-computer-vision/23-diffusion-transformers-rectified-flow/docs/en.mdphases/07-transformers-deep-dive/02-self-attention-from-scratch/docs/en.mdphases/07-transformers-deep-dive/04-positional-encoding/docs/en.mdphases/07-transformers-deep-dive/13-scaling-laws/docs/en.mdphases/07-transformers-deep-dive/15-attention-variants/docs/en.mdphases/08-generative-ai/01-generative-models-taxonomy-history/docs/en.mdphases/08-generative-ai/02-autoencoders-vae/docs/en.mdphases/08-generative-ai/06-diffusion-ddpm-from-scratch/docs/en.mdphases/08-generative-ai/13-flow-matching-rectified-flows/docs/en.mdphases/08-generative-ai/19-visual-autoregressive-var/docs/en.mdphases/10-llms-from-scratch/01-tokenizers/docs/en.mdphases/10-llms-from-scratch/16-differential-attention-v2/docs/en.mdphases/11-llm-engineering/04-embeddings/docs/en.mdphases/11-llm-engineering/06-rag/docs/en.mdphases/11-llm-engineering/13-production-app/docs/en.mdphases/12-multimodal-ai/01-vision-transformer-patch-tokens/docs/en.mdphases/13-tools-and-protocols/03-parallel-and-streaming-tool-calls/docs/en.mdphases/16-multi-agent-and-swarms/19-swarm-optimization-pso-aco/docs/en.mdphases/18-ethics-safety-alignment/02-reward-hacking-goodhart/docs/en.mdphases/19-capstone-projects/10-multi-agent-software-team/docs/en.mdsite/lesson.html
Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ate caveat Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ition number Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review feedback addressedThanks for the thorough pass. I verified each finding against the actual code and KaTeX before acting. Summary below; all changed math re-validated (KaTeX FixedIn-diff (replied inline): norm-induced distance claim, machine-epsilon exercise, t-interval caveat, rejection-sampling acceptance rate, regularized condition number (squared spectrum), and the untyped fences in bayes/fourier. Outside-diff:
Not changed (verified non-issues)
|
gumbel_softmax took math.log() of values named logits, which crashes on negative logits and is mathematically wrong. The Gumbel-Softmax trick adds Gumbel noise directly to logits, matching code/sampling.py. Addresses CodeRabbit review feedback on rohitg00#293. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@rohitg00 can you take a look at this one! |
Closes #158.
Math formulas across the curriculum were written as ASCII art in untagged code fences or as plain text inline, which reads poorly. The blocker was that the site had no math renderer at all — so simply writing
$...$would have shown literal dollar signs. This PR adds the renderer and converts the formulas.1. Render LaTeX with KaTeX (
site/lesson.html)$...$and block$$...$$(single- and multi-line, including\begin{aligned}andbmatrix).$not followed by a space; closing$not preceded by a space nor followed by a digit) so prose dollar amounts that are common in this curriculum —$50,000,$0.25/$2.50— are never mistaken for math. Verified 0 false positives across all 503 docs.$inside`code`and a*inside a formula stay verbatim. Invalid or unloaded TeX degrades to the raw source rather than blanking the lesson.2. Convert plain-text formulas (54 lessons, one commit each)
Genuine formulas were converted to
$...$/$$...$$; the math is unchanged, only the notation. Architecture diagrams, terminal sessions, code, mermaid blocks, and shape-annotation sketches were deliberately left as monospace.The three examples from the issue now render, e.g.:
$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$\nabla f = \left[ \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z} \right]$Verification
throwOnError→ 0 failures; 0 literal pipes inside table-cell math.$-in-code,*-in-math, edge cases).bmatrix, inline-in-prose, table-cell math).python3 scripts/audit_lessons.py→ 0 issues across 503 lessons. No new broken links introduced.site/data.jsis left for CI to regenerate on merge, perAGENTS.md.🤖 Generated with Claude Code