Skip to content

fix(rerank): accept sparse indexed results - #3121

Merged
MaojiaSheng merged 2 commits into
volcengine:mainfrom
huangruiteng:codex/fix-sparse-rerank-3090
Jul 11, 2026
Merged

fix(rerank): accept sparse indexed results#3121
MaojiaSheng merged 2 commits into
volcengine:mainfrom
huangruiteng:codex/fix-sparse-rerank-3090

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

Motivation

OpenAI-compatible rerank providers may return sparse or top-N results with valid input indexes. The client rejected any result-count mismatch before reading those indexes, so the hierarchical retriever discarded valid rerank output and fell back to vector scores.

Fixes #3090.

Implementation

  • Accept sparse result lists from the OpenAI-compatible rerank endpoint.
  • Map each returned score back to its original input index while leaving missing documents at the existing zero default.
  • Preserve validation for missing or out-of-range indexes.
  • Downgrade sparse-result length reporting from warning to debug.
  • Convert the previous mismatch-rejection test into an out-of-order sparse regression test.

Validation

  • 22 focused OpenAI rerank tests passed; 2 unrelated historical RerankConfig assertions were deselected after both reproduced on the pinned base revision.
  • 14 adjacent rerank unit tests passed.
  • Ruff check passed.
  • Ruff format check passed.
  • Python compile check passed.
  • Diff hygiene passed.

The two pre-existing base failures are:

  • TestRerankConfig.test_default_provider_is_vikingdb
  • TestRerankConfig.test_unknown_provider_raises_value_error

Risk and gaps

The behavior change is limited to the OpenAI-compatible rerank client. Full-length responses and other rerank providers are unchanged. Missing sparse entries receive 0.0, so existing threshold and sorting logic can naturally exclude them. Validation uses a mocked provider response matching the reported shape; no live provider credentials were used.

@huangruiteng

huangruiteng commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

@MaojiaSheng could you please review this focused fix for #3090? It corrects sparse OpenAI rerank result mapping and adds regression coverage; all current CI checks are passing. Thank you!

Comment thread openviking/models/rerank/openai_rerank.py Outdated
@MaojiaSheng
MaojiaSheng merged commit 2f5b2e2 into volcengine:main Jul 11, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

OpenAIRerankClient rejects sparse rerank results and falls back to vector scores

2 participants