Skip to content

fix(llm): make LLMReranker work with Claude Opus 5.5 on Bedrock via call_kwargs - #278

Merged
zxqfd555 merged 2 commits into
pathwaycom:mainfrom
kimnamu:fix/bedrock-opus-5-5
Sep 23, 2026
Merged

zxqfd555 merged 2 commits into
pathwaycom:mainfrom
kimnamu:fix/bedrock-opus-5-5

Conversation

@kimnamu

@kimnamu kimnamu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for taking a look, and for the Bedrock wrappers this builds on (#170, #248).

LLMReranker now takes call_kwargs. The default stays {"temperature": 0}; call_kwargs={} lets the reranker run on Claude Opus 5.5 on Bedrock, which accepts only the default temperature of 1 and rejects the reranker's temperature=0.

This is a small, self-contained bug fix and non-breaking: existing callers get the same kwargs as before. CHANGELOG.md has an entry under [Unreleased].

Related issue(s) / prior discussion

Fixes #277

Context

LLMReranker(llm, ...), live us-east-1 Before (argument did not exist) After
BedrockChat("us.anthropic.claude-opus-5-5"), call_kwargs={} ❌ ValidationException: temperature is deprecated, no way to drop it ✅ [{'score': 5.0}]
BedrockChat("global.anthropic.claude-opus-5-5"), call_kwargs={} ❌ same ✅ [{'score': 5.0}]
LiteLLMChat("bedrock/us.anthropic.claude-opus-5-5"), call_kwargs={} ❌ UnsupportedParamsError: ... does not support temperature=0 ✅ [{'score': 5.0}]
BedrockChat("us.anthropic.claude-opus-5"), call_kwargs={} ❌ same ValidationException ✅ [{'score': 5.0}]
any llm, no call_kwargs sends temperature=0 ✅ unchanged, still sends temperature=0
Sonnet 4.5 / Opus 4.5 with the default ✅ [{'score': 5.0}] ✅ unchanged
other LLMReranker arguments, return type ✅ ✅ unchanged

The hardcoded dict(temperature=0) in __call__ (rerankers.py:119-127) becomes self.call_kwargs, named after HFPipelineChat(call_kwargs=...). Plus one test and the CHANGELOG line. The default is kept rather than picked per model, since that would need a model list in the chat wrappers.

How has this been tested?

Run on the pathway 0.33.0 wheel with the changed files copied over it (the llm xpack files are byte-identical to main):

$ pytest -q xpacks/llm/tests/test_rerankers.py xpacks/llm/tests/test_llms.py xpacks/llm/tests/test_rag.py
77 passed, 6 xfailed, 10 xpassed, 1 warning      # main: 75 passed, 6 xfailed, 10 xpassed

black 24, isort and flake8 pass on the changed files; mypy reports nothing in rerankers.py.

New test against the old source, and the live runs

With only rerankers.py reverted:

E       TypeError: LLMReranker.__init__() got an unexpected keyword argument 'call_kwargs'
FAILED .../test_rerankers.py::test_llm_reranker_call_kwargs[None-expected_kwargs0]
FAILED .../test_rerankers.py::test_llm_reranker_call_kwargs[call_kwargs1-expected_kwargs1]
2 failed, 2 passed, 1 warning

With the change: 4 passed, 1 warning.

Live, same wheel with this change applied:

us.anthropic.claude-opus-5-5 default -> ERR ValidationException: ... `temperature` is deprecated for this model
us.anthropic.claude-opus-5-5 call_kwargs={} -> [{'score': 5.0}]
global.anthropic.claude-opus-5-5 default -> ERR ValidationException: ... `temperature` is deprecated for this model
global.anthropic.claude-opus-5-5 call_kwargs={} -> [{'score': 5.0}]
bedrock/us.anthropic.claude-opus-5-5 default -> ERR UnsupportedParamsError: ... does not support temperature=0. Only temperature=1 is supported.
bedrock/us.anthropic.claude-opus-5-5 call_kwargs={} -> [{'score': 5.0}]
us.anthropic.claude-opus-5 default -> ERR ValidationException: ... `temperature` is deprecated for this model
us.anthropic.claude-opus-5 call_kwargs={} -> [{'score': 5.0}]
us.anthropic.claude-sonnet-4-5-20250929-v1:0 default -> [{'score': 5.0}]
us.anthropic.claude-opus-4-5-20251101-v1:0 default -> [{'score': 5.0}]

Eight documents through Opus 5.5 with call_kwargs={}, both profiles: rows: 8 scores: [5.0, 4.0, 4.0, 2.0, 1.0, 1.0, 1.0, 1.0].

Why the default stays {"temperature": 0}: in one of two runs, Sonnet 4.5 with call_kwargs={} wrapped its answer in a json code fence and the parse failed (ValueError: Expected a json response, got followed by the fence); with temperature=0 it scored in both runs.

Where the docstring's "accept only the default temperature, such as Claude Opus 4.7 and newer" comes from, Bedrock Converse with inferenceConfig.temperature:

model                              0      0.5    1      1.0
us.anthropic.claude-opus-4-6-v1    OK     OK     OK     OK
us.anthropic.claude-opus-4-7       ERR    ERR    OK     OK
us.anthropic.claude-opus-4-8       ERR    ERR    OK     OK
us.anthropic.claude-opus-5         ERR    ERR    OK     OK
us.anthropic.claude-opus-5-5       ERR    ERR    OK     OK
global.anthropic.claude-opus-5-5   ERR    ERR    OK     OK
ERR = ValidationException: `temperature` is deprecated for this model.

References: Claude Opus 5.5 announcement, migration guide, models overview

…all_kwargs

LLMReranker hardcoded temperature=0 on every LLM call. Claude Opus 4.7
and newer (including Opus 5.5) accept only the default temperature of 1,
so the reranker failed on Bedrock with a ValidationException and on
LiteLLM with UnsupportedParamsError. Add a call_kwargs argument,
defaulting to {"temperature": 0}, so callers can pass {} for those models.
@CLAassistant

CLAassistant commented Sep 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@zxqfd555

Copy link
Copy Markdown
Collaborator

Hi @kimnamu,
Thank you for your contribution! It solves a problem, and I agree that we should apply the fix. In order to proceed, could you please sign the CLA?

@kimnamu

kimnamu commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Hi @zxqfd555 , I've done. Thank you for supporting great open source :)

@zxqfd555
zxqfd555 merged commit e0f6318 into pathwaycom:main Sep 23, 2026
1 check passed
@zxqfd555

Copy link
Copy Markdown
Collaborator

Thank you, merged!

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.

[Bug]: LLMReranker fails with Claude Opus 5.5 on Bedrock: hardcoded temperature=0 is rejected with ValidationException

3 participants