Skip to content

fix: ask for a justification instead of step-by-step reasoning in the CoT prompt - #282

Open
Leandro (Leandr0Duar7e) wants to merge 1 commit into
braintrustdata:mainfrom
Leandr0Duar7e:fix/llm-classifier-cot-wording
Open

Leandro (Leandr0Duar7e) wants to merge 1 commit into
braintrustdata:mainfrom
Leandr0Duar7e:fix/llm-classifier-cot-wording

Conversation

@Leandr0Duar7e

Copy link
Copy Markdown

Fixes #280

The default CoT prompt asks the judge to write out its reasoning step by step. Claude Haiku 5.5 refuses that under Anthropic's reasoning_extraction safeguard: 80 of 100 cases on the repo's own eval data failed. This PR asks for a justification that cites the evidence instead, and keeps the rest of the sentence as it was.

Change

Two strings, the same in Python and JS:

  • COT_SUFFIX: "with your reasoning in a step-by-step manner" becomes "with a justification that cites the evidence,". The rest ("to be sure that your conclusion is correct. Avoid simply stating the correct answer at the outset. …") is unchanged.
  • The reasons field description in COT_RESPONSE_SCHEMA: "Write out in a step by step manner your reasoning to be sure that your conclusion is correct." becomes "A justification for your conclusion that cites the evidence, to be sure that it is correct." The "Avoid simply stating…" sentence stays.

The field name reasons, its title and the parsing are unchanged, so metadata["rationale"] works as before.

This rewrites the Python line that has the "step-by-step matter" typo, so the Python and JS prompts become identical, which is what #265 sets out to do. Happy to rebase if #265 merges first.

Results

The repo's CoQA cases from evals/ (60 Factuality and 40 ClosedQA, the sets autoevals.eval.ts uses), each scored with NumericDiff against the gold label, through the Braintrust gateway. "Exact" is the number of the 100 verdicts that match the gold label.

Model Wording Errors Exact NumericDiff
gpt-6-luna current, run 1 0 88 0.880
gpt-6-luna current, run 2 0 86 0.875
gpt-6-luna this PR, run 1 0 88 0.887
gpt-6-luna this PR, run 2 0 88 0.887
claude-haiku-5-5 current 80 19 0.190
claude-haiku-5-5 this PR 0 87 0.877
  • gpt-6-luna is unchanged. The two runs of the current prompt disagree on 6 of 100 verdicts. Current vs this PR disagree on 6 or 7 depending on the pair of runs, so the change moves about as many verdicts as a rerun does.
  • claude-haiku-5-5 goes from 80 errors to none, and its accuracy matches gpt-6-luna's.
  • "Step by step" is the trigger. A wording that kept the original sentence but said "Explain step by step why your conclusion is correct" was still refused in 26 of 30 cases on Haiku 5.5. The wording in this PR was refused in none.
  • A shorter wording ("A short justification for the choice, citing the evidence.") also avoided the refusals (0 of 100 on Haiku, 87 exact on gpt-6-luna). I went with the one closer to the current text.

Not covered

  • Other built-in templates (Battle, Humor, Security, Sql, Summary, Translation) use the same suffix but weren't evaluated, and neither were the AnswerCorrectness and ContextRelevancy parts of autoevals.eval.ts.
  • ragas scorers (ContextRelevancy and others) have their own "step by step" wording, which may hit the same refusal. Not tested and not changed here.
  • Data: CoQA cases only, no production traces. Each configuration ran once or twice.
  • Languages: the runs for this PR's wording used the Python package; the JS strings are identical. The "current" Haiku run and the shorter wording ran through the JS package with braintrust eval --no-send-logs.
  • Other models: only gpt-6-luna and claude-haiku-5-5 were run.
  • fix: report model refusals instead of KeyError in LLM classifiers #281 (raise a clear error on content_filter) is separate; neither PR depends on the other.

Validation

  • pnpm exec vitest run js/llm.test.ts: 11 passed.
  • uv run --extra dev --extra scipy pytest py/autoevals/test_llm.py: 16 passed; the 5 failures need a real OpenAI or Braintrust key (Missing credentials) and fail the same way on main.
  • pre-commit run on the changed files (black, ruff, codespell) and prettier@3.3.2 --check.
  • pnpm run build.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default CoT prompt (use_cot=True) is refused by Claude Haiku 5.5, and the refusal surfaces as KeyError: 'choice'

1 participant