fix(phase-10/10): perplexity was different on every run - #358
Open
thejesh23 wants to merge 1 commit into
Open
Conversation
The simulated log-probs are seeded from the text so the same text scores the same way, and STEP 3 compares Strong/Medium/Weak on that basis. hash() of a str is salted per interpreter process, so the seed changed every run - three consecutive runs gave Strong-model perplexity 1.20, 1.16, 1.13. Seed from hashlib.sha256 instead. Three runs now produce byte-identical output, and the Strong < Medium < Weak ordering the lesson relies on is preserved (1.13 / 1.44 / 2.52).
📝 WalkthroughWalkthroughThe evaluation helpers now derive NumPy seeds from SHA-256 digests of their text or prompt inputs instead of Python’s ChangesDeterministic evaluation seeding
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/10-llms-from-scratch/10-evaluation/code/main.py`:
- Line 1: Add the required 4–6 line educational comment header at the top of
main.py before import hashlib, citing the lesson’s docs/en.md path and the
applicable canonical sources. Keep the existing import and implementation
unchanged.
🪄 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 Plus
Run ID: a29a3ed3-4113-40df-a0a8-d82938a18e52
📒 Files selected for processing (1)
phases/10-llms-from-scratch/10-evaluation/code/main.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
The evaluation lesson's perplexity numbers changed on every run, despite being explicitly seeded.
Kind of change
Checklist
docs/en.mdclaimsPhase / lesson
Phase 10 · 10-evaluation
Detail
token_log_probs_simulatedseeds from the text precisely so the same text yields the same simulated log-probs, and STEP 3 compares Strong / Medium / Weak on that basis. Buthash()of astris salted per interpreter process, so seeding from the content — whose only purpose is stability — produced different numbers each run.Three consecutive runs of the unmodified file:
Seeded from
hashlib.sha256instead. Two call sites use the same pattern and both are updated.After — three runs, byte-identical output:
The Strong < Medium < Weak ordering the lesson relies on is preserved:
1.13 / 1.44 / 2.52.