Skip to content

Answer unsupported reranker models with a clear error, not a server error - #399

Merged
jjang-ai merged 2 commits into
jjang-ai:mainfrom
tobocop2:rerank-encoder-load
Nov 23, 2026
Merged

jjang-ai merged 2 commits into
jjang-ai:mainfrom
tobocop2:rerank-encoder-load

Conversation

@tobocop2

@tobocop2 tobocop2 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #398

Problem

/v1/rerank returns HTTP 500 for BGE and XLM-RoBERTa rerankers and dumps all 393 checkpoint weight names. These checkpoints declare a sequence-classification architecture, but mlx-embeddings loads them without a classification head, so the strict weight load rejects every key and the generic handler maps it to 500.

Solution

One gate in the load path: read config.json, and if architectures names a *ForSequenceClassification model other than ModernBERT, raise UnsupportedRerankerError before any weight loads. The endpoint maps it to HTTP 400 naming the architecture and two working rerankers. No weight renaming, no widened fallback. Scoring these models needs a classification head added upstream in mlx-embeddings.

Test

10 tests were added; 6 fail on main. macos-15 acceptance: 8/8 at the head, the same 4 cells red with the fix reverted, 20 stability repeats clean. ModernBERT and jina scores unchanged.

@tobocop2
tobocop2 marked this pull request as ready for review November 21, 2026 21:22
@jjang-ai
jjang-ai merged commit 2d4ebcb into jjang-ai:main Nov 23, 2026
1 check passed
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.

/v1/rerank answers HTTP 500 for BGE and XLM-RoBERTa cross-encoder rerankers

2 participants