# Judge prompt, parsing, and Table 5 provenance This document describes the released implementation in [`code/VLM_inference/llm_as_a_judge.py`](../code/VLM_inference/llm_as_a_judge.py) and the deterministic option parser in [`code/VLM_inference/run_ft_eval_ablation.py`](../code/VLM_inference/run_ft_eval_ablation.py). ## Full prompt template For the released A-E questions, `create_judge_prompt()` selects its non-coordinate branch. The judge receives one plain-text string (not separate chat-role messages) with this exact structure. The system lines below are joined with spaces in the implementation. ```text SYSTEM: Model: {model_name} You are an expert judge evaluating circuit analysis predictions. Decide whether the predicted answer is semantically correct compared to the ground truth. Respond with ONLY ONE WORD: either correct or incorrect. Do not add any other text. For multiple-choice questions: identify which choice the ground-truth letter refers to and compare the predicted text against that choice's semantic meaning. If they differ, mark incorrect. USER: Task: {task} Circuit: {circuit} Question context: {prompt} Ground Truth Answer: {ground_truth} Predicted Answer: {prediction_text} Is the prediction semantically correct compared to the ground truth? ASSISTANT: ``` `model_name` is the judge-model string passed to `create_judge_prompt()` by the runner. The prompt also has a coordinate-question branch, but none of Tasks A-E are intended as coordinate tasks. The branch condition is a keyword check on the question text. The exact logic is in the linked function. ## Input and output schemas The implementation reads one JSON object per line from an evaluation result file. The consumed fields are: | Input key | Expected content | Missing-key behavior | |---|---|---| | `task` | Task label | Empty string | | `circuit` | Circuit/layout label | Empty string | | `prompt` | Full question with answer options | Empty string | | `ground_truth` | Ground-truth option letter | Empty string | | `prediction` | Raw VLM output | Empty string | | `scoring` | Prior deterministic scoring object | Empty object | | `vlm_model` | VLM provenance | Empty string unless inferred from containing folder | Each written judgment object has `file`, `task`, `circuit`, `prompt`, `ground_truth`, `prediction`, `prediction_text`, `judge_response`, `judge_correct`, `original_scoring`, and `vlm_model`. `judge_correct` is a JSON boolean, while `judge_response` is the raw text. `file` is the input JSONL path. The [machine-readable schema](judge_record.schema.json) describes this output shape. The code may preserve additional fields in the source input, but it does not copy them to this output object. ## Normalization and parsing 1. `extract_text_from_prediction()` removes a leading `text=` wrapper and truncates at the first newline marker among `input_token_len`, `generate_token_len`, `finish_reason`, `token_ids`, and `logprobs`. Otherwise it trims outer whitespace. The resulting `prediction_text` is sent to the judge. 2. The judge is sampled with temperature `0`, top-p `1`, and maximum `6` generated tokens. `parse_judge_response()` lowercases and trims the reply. Any reply containing `incorrect` maps to `false`. A reply containing `correct` but not `incorrect` maps to `true`. Replies beginning `yes` or `no` are fallbacks. Unrecognized replies map to `false`, **not** to a separate invalid-response status. 3. For the deterministic reference, `parse_choice_letter()` looks for an explicit `answer`/`choice` label, then a bare A-F answer line, then a final strict letter token while trying to avoid echoed option lists. It uppercases the selected letter. The reference verdict is true only when this letter equals the uppercase ground-truth letter. Absent or unparsable choices are incorrect. The judge's semantic instruction and the deterministic reference are conceptually different. Exact agreement on these structured outputs does not show that a semantic judge is necessary for this benchmark format. ## Worked verdict examples These are **illustrative** applications of the documented protocol. For the Task B question `What circuit is shown? A. ldo B. hpf C. miller ota`, with ground truth `A`: | VLM prediction | Deterministic verdict | Expected judge reply | Interpretation | |---|---|---|---| | `A` | Correct | `correct` | The selected option is the ground truth. | | `B` | Incorrect | `incorrect` | The selected option is not the ground truth. | Here, “incorrect verdict” means a correct *verdict that the VLM answer is wrong*.