Repository navigation
fix(rerank): honor rank_by in VoyageAIReranker - #864
Merged
vishal-bala merged 2 commits intoNov 25, 2026
Merged
Conversation
rank_by was accepted but never read, so dict docs without a 'content' key were stringified wholesale. Build the rerank text from the rank_by fields (per-call override supported) and raise if a field is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vishal-bala
requested changes
Nov 23, 2026
Contributor
Author
|
Thanks @vishal-bala, restored the per-document This comment was drafted with Claude Code. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #864 +/- ##
==========================================
+ Coverage 80.15% 80.82% +0.66%
==========================================
Files 121 121
Lines 14867 15708 +841
Branches 2602 2813 +211
==========================================
+ Hits 11917 12696 +779
- Misses 2228 2267 +39
- Partials 722 745 +23
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
vishal-bala
approved these changes
Nov 25, 2026
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.
Motivation
VoyageAIRerankertakesrank_by(documented in its constructor and inherited fromBaseReranker), but_preprocessnever reads it. Dict documents without acontentkey, such as Redis search results with adescriptionfield, are sent to Voyage asstr(doc): every key, the braces and fields likevector_distanceall go into the rerank text, whateverrank_bysays.CohereRerankerdoes userank_by.Changes
VoyageAIReranker._preprocessreadsrank_byWhen
rank_byis set (in the constructor or as a per-call kwarg, as inCohereReranker) and every doc is a dict, the text sent to Voyage is therank_byfields joined by a space. A doc that lacks one of the fields raisesValueErrornaming the missing fields. Withoutrank_by, behavior is unchanged: thecontentkey if every doc has one, otherwisestr(doc).rankandarankshare_preprocess, so both are covered.tests/unit/test_voyageai_reranker_rank_by.py, with thevoyageaimodule mocked (no network): single field, several fields plus per-call override, missing field, defaultcontentpath.Release Notes
VoyageAIRerankernow ranks dict documents by the fields given inrank_byinstead of the whole stringified document. A document missing one of therank_byfields now raisesValueError.AI Assistance
Claude Code (claude-sonnet-5-5): implementation, tests and description; reviewed by Claude Code (claude-opus-5-5).
Reviewer Brief
Start here:
redisvl/utils/rerank/voyageai.py,_preprocess.Where it could fail: callers that set
rank_bybut pass dicts missing those fields used to get the wholestr(doc)reranked silently; they now get aValueError. Lists that mix dicts and strings skiprank_byand keep the oldstr(doc)path.Not verified: a live Voyage
/rerankcall; the tests mock the client.Beyond CI: with
voyageai.pyrestored tomain, 3 of the 4 new tests fail (thecontentdefault test passes on both); with the fix all 4 pass.Reviewed commit: 8b675e0 (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
Note
Medium Risk
Callers that set rank_by but pass incomplete dicts will now get ValueError instead of silently reranking stringified documents; this fixes ranking quality for Redis-style search hits.
Overview
VoyageAIReranker._preprocessnow appliesrank_by(constructor or per-call) when all documents are dicts: rerank text is the selected fields space-joined, matchingCohereRerankersemantics instead of sendingstr(doc)with metadata noise.Dicts missing any
rank_byfield raiseValueErrorwith the missing keys. With norank_by, behavior is unchanged: usecontentwhen every dict has it, otherwisestr(doc).Unit tests mock the
voyageaiclient and cover single/multi-field selection, override, validation, and the defaultcontentpath.Reviewed by Cursor Bugbot for commit 8d81adc. Bugbot is set up for automated code reviews on this repo. Configure here.