Add MMLU benchmark evaluation to evals#1183
Open
CarlG0123 wants to merge 3 commits intoTransformerLensOrg:devfrom
Open
Add MMLU benchmark evaluation to evals#1183CarlG0123 wants to merge 3 commits intoTransformerLensOrg:devfrom
CarlG0123 wants to merge 3 commits intoTransformerLensOrg:devfrom
Conversation
Skip MMLU docstring examples in doctest runs since they require network access (HuggingFace dataset download) and may require GPU. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
@jlarson4 @bryce13950 Hi, could one of you take a look at this PR to add MMLU benchmark evaluation? Thanks! |
jlarson4
reviewed
Mar 6, 2026
transformer_lens/evals.py
Outdated
| subjects: Optional[Union[str, List[str]]] = None, | ||
| split: str = "test", | ||
| num_samples: Optional[int] = None, | ||
| device: str = "cuda", |
Collaborator
There was a problem hiding this comment.
if a user loads a model on CPU but forgets to pass device="cpu" here (or vice versa), they'll get a device mismatch error. Since model already knows its device, you can just use model.cfg.device internally and drop this parameter. That's also consistent with how ioi_eval works (it doesn't take a device arg).
Collaborator
There was a problem hiding this comment.
Outside of this, looks good to my eyes! Make that tweak and I'll plan on including it in the next 2.x release
Author
There was a problem hiding this comment.
Thanks for the speedy review; it should be updated now!
Author
Address PR review feedback: use model.cfg.device internally instead of accepting a device parameter, consistent with ioi_eval. This prevents device mismatch errors when users forget to pass the correct device.
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
mmlu_eval()function for evaluating models on the MMLU (Massive Multitask Language Understanding) benchmarkmake_mmlu_data_loader()for loading MMLU data from HuggingFace (cais/mmludataset)MMLU_SUBJECTS(all 57 subjects) andMMLU_ANSWER_LETTERSmodule-level constantsChanges
transformer_lens/evals.py: AddedMMLU_SUBJECTS,MMLU_ANSWER_LETTERS,make_mmlu_data_loader(), andmmlu_eval()tests/acceptance/test_evals.py: Added 5 tests covering data loading (single/multiple/invalid subjects) and evaluationTesting
Test plan
pytest tests/acceptance/test_evals.py -v🤖 Generated with Claude Code