Repository navigation
Add GPT-2 model (gpt2_infer) - #6
Merged
Merged
Conversation
Adds gpt2_infer, which uses the student's response as a prompt and returns GPT-2's sampled continuation. Weights are baked into the Docker image at build time so no network is needed at runtime; locally they download on first use into HF_HOME. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/download_gpt2.py takes the target dir (default $GPT2_MODEL_DIR) and an optional --model-id, so it can also be run locally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
peterbjohnson
approved these changes
Nov 3, 2026
peterbjohnson
left a comment
Member
There was a problem hiding this comment.
Looks great thanks. Minor comments.
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.
Summary
Adds
gpt2_infer, the next model afterbengio_infer: pre-trained GPT-2 (124M) loaded with Hugging Facetransformers. The student's response is used as the prompt, and GPT-2's sampled continuation is returned asgeneralfeedback.word_count(new tokens, default 20, max 100),temperature(default 1.0),top_k(default 50),seed(optional).scripts/download_gpt2.pydownloads them into/app/hf_models/gpt2(GPT2_MODEL_DIR) at Docker build time, so nothing is fetched at runtime. Locally, they download on first use intoHF_HOME(default/tmp/hf).bengio_infer. A load or inference error returns an errorResultrather than crashing the RPC worker. The loaded model is cached, so a warm worker loads it once.transformers ^4.57(lock file updated).In the built image, with
--memory 1024m, peak memory for one GPT-2 request was 989MB in the Python process alone. That's too close for a 1024MB Lambda once shimmy is counted. Recommend at least 2048MB before this model is used in production.docs/dev.mdhas been updated to say so.Image size: 3.43 GB.
Testing
pytest evaluation_function/evaluation_test.py: 3 passed (withRUN_GPT2_TESTS=1, including a real download and generation).RUN_GPT2_TESTS=1is set, so CI doesn't download about 500MB.--network none --memory 1024m. Weights loaded from/app/hf_models/gpt2and generation worked.python -m evaluation_function.dev --config dev.json --case gpt2_inferworks when pointed at a local copy of the downloaded weights.Note (not changed here)
evaluation_function/dev.pycallsevaluation_function(answer, response, ...), swapping the two arguments. This affects every dev case. Forgpt2_inferit means the dev case'sanswer(0) is the prompt, so it falls back to the default prompt.🤖 Generated with Claude Code