-
Notifications
You must be signed in to change notification settings - Fork 483
support code generation tasks. #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ASCE-D
wants to merge
4
commits into
eval_qa
Choose a base branch
from
codegen-pipeline
base: eval_qa
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,18 +144,30 @@ def add_worktree_for_commit( | |
|
|
||
| def group_rows_by_repo( | ||
| rows: Iterable[dict[str, str]], | ||
| task: str = "qa", | ||
| ) -> dict[str, list[Tuple[str, str]]]: | ||
| """ | ||
| Group rows by repo_url. | ||
| Input row should have keys: 'repo_url', 'commit_id', 'problem_id' | ||
| Group rows by repo URL. | ||
|
|
||
| Args: | ||
| rows: Iterable of row dictionaries | ||
| task: "qa" for legacy format, "codegen" for SWE-bench format | ||
|
|
||
| Returns mapping: repo_url -> list of (commit_id, problem_id) | ||
| """ | ||
| mapping: dict[str, list[Tuple[str, str]]] = {} | ||
| for r in rows: | ||
| repo = r["repo_url"] | ||
| commit = r["commit_id"] | ||
| prob = r["problem_id"] | ||
| mapping.setdefault(repo, []).append((commit, prob)) | ||
| if task == "codegen": | ||
| # SWE-bench format: "django/django" -> "https://github.com/django/django" | ||
| repo_url = f"https://github.com/{r['repo']}" | ||
| commit = r["base_commit"] | ||
| prob = r["instance_id"] | ||
| else: | ||
| repo_url = r["repo_url"] | ||
| commit = r["commit_id"] | ||
| prob = r["problem_id"] | ||
|
|
||
| mapping.setdefault(repo_url, []).append((commit, prob)) | ||
| return mapping | ||
|
|
||
|
|
||
|
|
@@ -273,14 +285,16 @@ def prepare_worktrees( | |
| batch_no: int, | ||
| max_workers: int = 8, | ||
| skip_if_exists: bool = True, | ||
| task: str = "qa", | ||
| ) -> tuple[dict[tuple[str, str], dict[tuple[str, int], Path]], list[dict[str, Any]]]: | ||
| """ | ||
| rows: iterable of dicts with keys 'repo_url','commit_id','problem_id' | ||
| rows: iterable of dicts with keys 'repo_url','commit_id','problem_id' (QA) or 'repo','base_commit','instance_id' (codegen) | ||
| base_dir: root directory where we will create: | ||
| - base_dir/bare/<repo_name>.git | ||
| - base_dir/worktrees/<repo_name>/<worktree_name> | ||
| batch_no: number of batch copies to create per (commit,problem) | ||
| max_workers: number of threads for parallel repo processing | ||
| task: "qa" for legacy format, "codegen" for SWE-bench format | ||
|
||
| Returns a list of per-repo summaries. | ||
| """ | ||
| logger.bind(base_dir=base_dir, batch_no=batch_no, max_worker=max_workers).info( | ||
|
|
@@ -289,7 +303,7 @@ def prepare_worktrees( | |
| base = Path(base_dir).resolve() | ||
| base.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| grouped = group_rows_by_repo(rows) | ||
| grouped = group_rows_by_repo(rows, task=task) | ||
| summaries = [] | ||
| repo_map: dict[tuple[str, str], dict[tuple[str, int], Path]] = {} | ||
|
|
||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,37 @@ | |
| Do NOT include any text outside the JSON object. | ||
| """ | ||
|
|
||
| CODE_EVAL_CRITERIA = """ | ||
| You are a senior software engineer evaluating a code fix or implementation. | ||
| Your task is to assess the quality and correctness of the GENERATED CODE compared to the EXPECTED SOLUTION (or based on the PROBLEM DESCRIPTION). | ||
| Evaluate using the following criteria: | ||
| 1. Functional Correctness (50%): Does the code solve the stated problem? | ||
| 2. Code Quality & Best Practices (30%): Is the code idiomatic, safe, and maintainable? | ||
| 3. Logic Similarity (20%): Does it follow a similar (or better) valid approach to the reference solution? | ||
| Output ONLY a JSON object with: | ||
| { | ||
| "score": <number_between_0_and_1>, | ||
| "reason": "<brief explanation>" | ||
| } | ||
| Where: | ||
| - 0.0 = The generated code fails to address the problem or is fundamentally incorrect. | ||
| - 1.0 = The generated code completely solves the problem with high quality and matches the reference approach or improves upon it. | ||
| Scoring Rules: | ||
| - Functional Correctness is paramount. If the code doesn't solve the problem, the score should be low (<0.5). | ||
| - Code Quality matters. Correct but messy code should be penalized slightly. | ||
| - Logic Similarity allows for different valid approaches, but they must solve the same root cause. | ||
| Your final output must contain: | ||
| - A numeric "score" between 0 and 1. | ||
| - A short "reason" describing the main factors affecting the score. | ||
| Do NOT include any text outside the JSON object. | ||
| """ | ||
|
|
||
| correctness = GEval( | ||
|
||
| name="Correctness", | ||
| criteria=EVAL_CRITERIA, | ||
|
|
@@ -54,3 +85,14 @@ | |
| ], | ||
| strict_mode=True, | ||
| ) | ||
|
|
||
| code_correctness = GEval( | ||
| name="CodeCorrectness", | ||
| criteria=CODE_EVAL_CRITERIA, | ||
| evaluation_params=[ | ||
| LLMTestCaseParams.INPUT, | ||
| LLMTestCaseParams.ACTUAL_OUTPUT, | ||
| LLMTestCaseParams.EXPECTED_OUTPUT, | ||
| ], | ||
| strict_mode=True, | ||
| ) | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using task, can you just check if it's URL or repo slug?