Add robust HumanEval postprocess for chat outputs#2515
Open
Ding-god wants to merge 1 commit into
Open
Conversation
Author
|
Hi maintainers, this PR improves HumanEval post-processing for chat-style model outputs. It handles cases such as unclosed markdown fences and reasoning text before code blocks. Could you please review when available? Thanks! |
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.
Motivation
The current HumanEval postprocess mainly extracts closed Markdown code blocks from model outputs. This works for models that return clean fenced code, but it is less robust for chat/API models that may include reasoning before the final code or produce an opening code fence that is not closed because the generation is truncated.
In these cases, the evaluator may receive natural-language text instead of the intended Python solution, which can cause
SyntaxErrorfailures due to output formatting rather than the generated solution itself.This PR aims to make HumanEval postprocessing more robust for chat-style model outputs while keeping the existing postprocess behavior unchanged.
Modification
This PR adds a new
humaneval_chat_postprocessfunction.The new postprocessor:
from,import,def,class, or a decorator;humaneval_postprocess_v2orhumaneval_postprocess_v3behavior.Unit tests are added for:
BC-breaking (Optional)
No backward compatibility breaking change is introduced.
The existing
humaneval_postprocess_v2andhumaneval_postprocess_v3functions are unchanged. The newhumaneval_chat_postprocessfunction is opt-in and only affects users who explicitly configure it.Use cases (Optional)
This postprocessor can be used when evaluating chat/API models on HumanEval, especially when the model output may contain reasoning text before the final Python code or an unclosed Markdown code fence.
Example use case:
The postprocessor only recovers code already produced by the model. It does not repair invalid code, synthesize missing function bodies, or modify model logic.
Checklist
Before PR:
After PR: