CorrectnessJudge scores 0 for any reply that is not bare JSON (`_find_first_json_object` has no `self`)

Open Beginner friendly
#61 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
94/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing-qa

Research direction

Read evaluator/judge.py around _parse_response and _find_first_json_object. Run the issue's reproduction from evaluator/ to confirm bare JSON parses and a sentence followed by JSON raises TypeError. Add the indicated decorator, then rerun both cases and confirm the wrapped JSON returns the expected explanation and score.

Written by the indexing model from the issue text.

Description

CorrectnessJudge._find_first_json_object is defined without self or @staticmethod (judge.py#L283). _parse_response calls it as self._find_first_json_object(text) (judge.py#L231). The call raises TypeError whenever the judge's reply isn't a bare JSON object, for example JSON after a sentence or inside a ```json fence. judge() catches the error and returns score 0 (judge.py#L336), so a correct prediction fails. The fenced-JSON fallback right after the call is never reached.

Repro, with no LLM call (run from evaluator/):

from judge import CorrectnessJudge
j = CorrectnessJudge.__new__(CorrectnessJudge)
j._parse_response('{"explanation": "ok", "score": 1}')
# {'explanation': 'ok', 'score': 1}
j._parse_response('Here is my grading: {"explanation": "ok", "score": 1}')
# TypeError: CorrectnessJudge._find_first_json_object() takes 1 positional argument but 2 were given

In our CUGA train runs with gpt-oss-120b as the judge, this never fired: the correctness judge raised no errors at all. A judge model that wraps its JSON would score 0 on every such reply. The cause would also be hidden, because the error message at L336 lacks its f prefix. #55 fixes the prefix but not this bug.

Fix: add @staticmethod above the definition.

Dominant language
Python
Stars
79
Forks
23
Avg merge
2d 7h
Merged PRs (30d)
3

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IBM/vakra

All issues in IBM/vakra

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.