Repository navigation
Add SmolLM2-135M-Instruct model (smollm2_infer) - #8
Merged
Merged
Conversation
Pure refactor in preparation for a second Hugging Face model; GPT-2 output is unchanged (verified identical for fixed seeds). - models/hf_lm.py: cached local-dir-or-download loading, sampling, param clamping and error result, previously private to gpt2_infer - Load weights explicitly in float32 rather than relying on the transformers default - Rename scripts/download_gpt2.py to download_hf_model.py, taking the target dir and model id explicitly Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds SmolLM2-135M-Instruct alongside GPT-2 for side-by-side comparison in the course: similar parameter count, but newer data, architecture and instruction tuning. GPT-2 is unchanged. - smollm2_infer wraps the student's response in the chat template and returns only the model's reply (GPT-2 returns prompt + continuation); the difference is documented for teachers in docs/user.md - Same params as gpt2_infer; word_count defaults to 64 (max 256) for chat replies and top_k is clamped to the 49152-token vocabulary - Bake the weights into the image under SMOLLM2_MODEL_DIR, in their own layer, with the same safetensors permission fix as GPT-2 - Tests cover both models; generation tests now run under RUN_HF_MODEL_TESTS (was RUN_GPT2_TESTS) Verified in the built image (offline, non-root): both models load from the baked directories, with peak memory about 1.5GB once both are loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds SmolLM2-135M-Instruct next to GPT-2 so the course can compare them side by side: a similar parameter count, but newer training data, a newer architecture and instruction tuning. GPT-2's behaviour is unchanged.
Two commits, best reviewed separately:
gpt2_infer(refactor only). Moves loading, sampling, parameter clamping and the error result intomodels/hf_lm.py, and renamesscripts/download_gpt2.pytodownload_hf_model.py, which now takes the target directory and--model-idexplicitly. For fixed seeds, GPT-2's output was identical before and after, including clamped and invalid parameters and an empty prompt.smollm2_infer.add_generation_prompt=True), and only the reply is returned. GPT-2 returns the prompt followed by its continuation. The difference is documented for teachers indocs/user.md.word_countdefaults to 64 (max 256) for chat replies, andtop_kis clamped to the 49152-token vocabulary. Temperature andtop_kdefaults match GPT-2's, so the comparison is fair.SMOLLM2_MODEL_DIR, with the same safetensorschmodfix as GPT-2.RUN_HF_MODEL_TESTS=1is set (previouslyRUN_GPT2_TESTS).Testing
pytest: the CI-safe tests pass. WithRUN_HF_MODEL_TESTS=1, the generation tests also pass for both models, loading both from baked directories and from the Hugging Face download fallback.--network noneas a non-root user. Both load from their baked directories and generate. Peak memory with both loaded was about 1.5GB, against the Lambda's 2GB.scripts/stress_test.py --model smollm2_inferafter the model has been added to a question set.🤖 Generated with Claude Code