|
| 1 | +# LLM-as-a-Judge Evaluation Prompt |
| 2 | + |
| 3 | +Use the prompt below to instruct Claude to adjudicate search results between Code2Code and BM25. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +```markdown |
| 8 | +You are an expert software engineer and information retrieval scientist acting as an **LLM-as-a-judge**. |
| 9 | + |
| 10 | +Your task is to adjudicate the search results of two code search engines: **Code2Code Semantic Search** and **BM25 Keyword Search**, and output a single JSON file called `judge_annotations.json` containing your graded relevance annotations. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +### Input Data |
| 15 | +You will be provided with two JSON files containing the search results: |
| 16 | +1. `evaluation_results_code2codesearch_toolforge_org_search_7runs.json` (Code2Code results) |
| 17 | +2. `bm25_results_code2codesearch_toolforge_org_search_7runs.json` (BM25 results) |
| 18 | + |
| 19 | +Each file contains a list of benchmark queries (identified by IDs like `A1`, `A2`, ... `D4`). For each query, you are given: |
| 20 | +- The input code snippet (`code` of the query) |
| 21 | +- Up to 10 retrieved code snippets in the `results` list (ranked 1 to 10) |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +### Relevance Grading Scale |
| 26 | +For each retrieved code snippet (both in the BM25 and Code2Code results), assign a relevance score from the following scale: |
| 27 | +- **`1.0` (Relevant)**: Implements the exact same computational task or correct specific solution for the query intent. Differences in variable names or language do not affect relevance if the task is identical. |
| 28 | +- **`0.5` (Partially Relevant)**: Topically related; represents a partial realization of the query intent, a non-idiomatic implementation, or uses the target logic merely as a helper step in a larger function. |
| 29 | +- **`0.0` (Irrelevant)**: Does not solve the problem or is completely unrelated (e.g., matched on random variables/keywords like `mid` or `min` but does a completely different task). |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +### Metrics to Compute per Query |
| 34 | +For each query, calculate: |
| 35 | +1. **`bm25_p10`**: Fraction of the top-10 BM25 results with a score >= 0.5 (e.g., `0.7`). |
| 36 | +2. **`c2c_p10`**: Fraction of the top-10 Code2Code results with a score >= 0.5. |
| 37 | +3. **`bm25_p10_strict`**: Fraction of the top-10 BM25 results with a score equal to 1.0. |
| 38 | +4. **`c2c_p10_strict`**: Fraction of the top-10 Code2Code results with a score equal to 1.0. |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +### Output Format Requirement |
| 43 | +Your response must be **strictly a raw JSON block** matching this exact schema. Do not output any markdown text or conversational preamble outside of the JSON block. |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "metric": "P@10 = fraction of top-10 with graded relevance >= 0.5 (primary); strict = fraction == 1.0", |
| 48 | + "judge": "Claude 3.5 Sonnet (LLM-as-a-judge, pooled BM25+Code2Code top-10)", |
| 49 | + "per_query": { |
| 50 | + "QUERY_ID": { |
| 51 | + "bm25_scores": [ |
| 52 | + SCORE_RANK_1, SCORE_RANK_2, SCORE_RANK_3, SCORE_RANK_4, SCORE_RANK_5, |
| 53 | + SCORE_RANK_6, SCORE_RANK_7, SCORE_RANK_8, SCORE_RANK_9, SCORE_RANK_10 |
| 54 | + ], |
| 55 | + "c2c_scores": [ |
| 56 | + SCORE_RANK_1, SCORE_RANK_2, SCORE_RANK_3, SCORE_RANK_4, SCORE_RANK_5, |
| 57 | + SCORE_RANK_6, SCORE_RANK_7, SCORE_RANK_8, SCORE_RANK_9, SCORE_RANK_10 |
| 58 | + ], |
| 59 | + "bm25_p10": 0.0, |
| 60 | + "c2c_p10": 0.0, |
| 61 | + "bm25_p10_strict": 0.0, |
| 62 | + "c2c_p10_strict": 0.0, |
| 63 | + "comment": "Brief comment summarizing why the systems behaved the way they did. Mention specific ranks and tasks (e.g. 'BM25: r2 exact recursive gcd; r1 uses gcd as step. C2C: r1-7 real GCD impls')." |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | +``` |
| 68 | +``` |
0 commit comments