mirror of
https://github.com/deepseek-ai/DeepSeek-Coder.git
synced 2026-11-05 00:57:19 +00:00
[PR #724] fix(eval): robust code block extraction across evaluation scripts #295
Labels
No labels
documentation
ENV
pull-request
research question
WIP
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-Coder#295
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepSeek-Coder/pull/724
Author: @reginaldalfret
Created: 10/25/2026
Status: 🔄 Open
Base:
main← Head:fix/evaluation-code-extraction📝 Commits (1)
f5c8e58fix(eval): robust code block extraction across evaluation scripts📊 Changes
4 files changed (+149 additions, -17 deletions)
View changed files
📝
Evaluation/HumanEval/utils/utils.py(+27 -11)📝
Evaluation/LeetCode/evaluate_leetcode.py(+8 -4)📝
Evaluation/MBPP/eval_instruct.py(+5 -2)➕
tests/test_code_extraction.py(+109 -0)📄 Description
Problem
Evaluation/HumanEval/utils/utils.py,Evaluation/MBPP/eval_instruct.py, andEvaluation/LeetCode/evaluate_leetcode.py, regex patterns for markdown code blocks used strict\nwithout supporting\r?\nor trailing whitespace after the language identifier (e.g.,```python). On Windows environments or when responses contain CRLF, all extracted code blocks failed to match and fell back to raw/unparsed output.max_new_tokens, the terminating```fence is often not generated. The previous regex patterns strictly required closing fences, discarding otherwise valid completions.Evaluation/HumanEval/utils/utils.py, the loopwhile start - indent >= 0 and code_block[start - indent - 1] == ' ':evaluatedcode_block[-1]whenstart == indent. If the generated code block ended with trailing whitespace,code_block[-1] == ' 'wasTrue, causingindentto erroneously increment to1and corrupting the closing brace search.get_function_namerequiredfunc_lines[i].startswith("def "), failing when function definitions had leading whitespace (e.g. methods in class templates).Solution
\r?\n), optional horizontal whitespace after language tags ([^\S\r\n]*), and unclosed code blocks ((?:```|$)).start - indent > 0to prevent Python negative index wrap-around.defdeclarations inget_function_name().tests/test_code_extraction.pycovering all extraction edge cases (CRLF, trailing space, unclosed fence, negative index safety, and LeetCode fallbacks).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.