Fix litellm judge backend: send max_tokens as an int, not a 1-tuple#1302
Open
oraziooztas wants to merge 1 commit into
Open
Fix litellm judge backend: send max_tokens as an int, not a 1-tuple#1302oraziooztas wants to merge 1 commit into
oraziooztas wants to merge 1 commit into
Conversation
A trailing comma turned max_tokens into a 1-tuple, which serializes to a JSON array and gets rejected by OpenAI-compatible servers with a 400; after the retries the judge scored the error string as a real response. Adds regression tests with a stubbed litellm module (no network needed). Fixes huggingface#1296 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0158ZooCCJEy6xtme9c8iksT
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1296.
What does this PR do?
JudgeLM.__call_litellmbuilds the completion kwargs with a trailing comma:The value serializes to a JSON array (
"max_tokens": [512]), which OpenAI-compatible servers reject with a 400. After the retries, the judge returns the error string"ERROR: Failed to get response from the API."as if it were a judge response, so corrupted scores are produced without any crash or warning. This affects the litellm backend whenevermax_tokensis set.The fix sends the parameter as the integer it is:
Tests
Added
tests/unit/metrics/test_llm_as_judge.pywith a stubbedlitellmmodule (no network, no litellm install needed) that captures the kwargs passed tolitellm.completion:test_litellm_max_tokens_is_sent_as_integer: fails on currentmain(captures(512,)), passes with the fix;test_litellm_omits_max_tokens_when_unset:max_tokens=Nonekeeps the key out of the request.Verification
tests/unit/metrics/: 288 passed; the singleextractiveness.jsonfailure is unrelated and reproduces identically on pristinemainin the same environmentruff checkandruff format --checkpass on both touched files🤖 Generated with Claude Code
https://claude.ai/code/session_0158ZooCCJEy6xtme9c8iksT