Implement generate_until for LMEvalORTGenAIEvaluator#2448
Open
justinchuby wants to merge 1 commit intomainfrom
Open
Implement generate_until for LMEvalORTGenAIEvaluator#2448justinchuby wants to merge 1 commit intomainfrom
justinchuby wants to merge 1 commit intomainfrom
Conversation
Add generate_until method to the ortgenai evaluator, enabling chain-of-thought (CoT) benchmarks like MMLU Pro that generate text and extract answers via regex filters. Previously, generate_until raised NotImplementedError, limiting the evaluator to log-likelihood-only benchmarks. This blocked CoT-scored benchmarks which are the standard methodology for instruction-tuned models like Gemma4. The implementation: - Tokenizes the prompt and generates token-by-token using og.Generator - Supports multiple EOS token IDs (common in modern models) - Checks stop sequences periodically during generation for early exit - Handles temperature/sampling and max_gen_toks from gen_kwargs - Truncates output at the first matching stop sequence Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <justinchu@microsoft.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds generate_until support to the ortgenai (ONNX Runtime GenAI) lm-eval-harness evaluator so CoT-style benchmarks can run via text generation rather than log-likelihood only.
Changes:
- Implement
generate_untilinLMEvalORTGenAIEvaluator, including stop-sequence handling and early-exit checks. - Add config handling for
eos_token_idthat may be a list (but currently only retains the first element). - Support basic sampling vs greedy decoding based on
temperature, and enforcemax_gen_tokswithin the model’smax_length.
Comment on lines
+514
to
+515
| # Use the first element for loglikelihood evaluation. | ||
| self._eot_token_id = eot[0] if isinstance(eot, list) else eot |
Comment on lines
+621
to
+631
| eos_ids = self._eot_token_id if isinstance(self._eot_token_id, (list, tuple)) else [self._eot_token_id] | ||
|
|
||
| generated_ids = [] | ||
| # Decode periodically to check for stop sequences | ||
| decode_interval = 16 | ||
| while not generator.is_done(): | ||
| generator.generate_next_token() | ||
| token_id = generator.get_next_tokens()[0] | ||
| generated_ids.append(token_id) | ||
| if token_id in eos_ids: | ||
| break |
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
Implements
generate_untilfor theortgenai(ORT GenAI) evaluator in lm-eval-harness integration, enabling chain-of-thought (CoT) benchmarks.Motivation
The
LMEvalORTGenAIEvaluatorpreviously raisedNotImplementedErrorforgenerate_until, which blocked CoT-scored benchmarks like MMLU Pro (v3). These benchmarks are the standard methodology for evaluating instruction-tuned models — Google's published Gemma4 scores use CoT generation + regex answer extraction, not log-likelihood scoring.Changes
generate_untilmethod toLMEvalORTGenAIEvaluator[1, 106])Testing
Validated with Gemma4 E4B-IT ONNX models on MMLU Pro:
leaderboard_mmlu_pro): 33.0% F16mmlu_pro): running, results pendingThe log-likelihood vs CoT methodology difference explains the gap vs Google's published 69.4% (which uses CoT).