feat(reranker): add Jina v3 reranker support#331
Merged
jundot merged 3 commits intojundot:mainfrom Mar 21, 2026
Merged
Conversation
added 3 commits
March 21, 2026 08:48
- Add JinaForRanking to CAUSAL_LM_RERANKER_ARCHITECTURES in model_discovery - Add MLXRerankerModel._load_jina_reranker() for loading jinaai/jina-reranker-v3-mlx via mlx-lm with <|score_token|> and <|rerank_token|> token resolution - Add MLXRerankerModel._rerank_jina() for reranking using score token logits - Dispatch to _rerank_jina() when model is JinaForRanking architecture Closes: jundot#326
…en logic for Jina reranker
- Fix token ID lookup in added_tokens_decoder (handle both str and Token objects) - Add fallback to convert_tokens_to_ids and get_added_vocab - Test passes with real jina-reranker-v3-mlx model
f6faf2f to
c2beead
Compare
jundot
approved these changes
Mar 21, 2026
Owner
jundot
left a comment
There was a problem hiding this comment.
Reviewed the code. Clean scope, follows the existing _rerank_causal_lm pattern well.
Two bare except: in _load_jina_reranker() should be except Exception: to avoid catching KeyboardInterrupt/SystemExit. I'll fix those in a follow-up commit after merge.
LGTM otherwise.
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.
What
Add support for Jina v3 reranker models (
jinaai/jina-reranker-v3-mlx) to omlx's reranker module.Why
Issue #326 requested Jina reranker support. The Jina v3 reranker uses
<|score_token|>logits for scoring instead of the yes/no token approach used by Qwen3-Reranker, and requires a separate implementation path.Changes
JinaForRankingtoCAUSAL_LM_RERANKER_ARCHITECTURESinmodel_discovery.pyMLXRerankerModel._load_jina_reranker()for loading Jina models viamlx-lmMLXRerankerModel._rerank_jina()for reranking using<|score_token|>logitsJinaForRankingadded_tokens_decoder)Implementation Notes
<|score_token|>and<|rerank_token|>special tokens<|score_token|>position at the last token_rerank_causal_lm()but with Jina-specific token handlingValidation (Local testing PASSED ✅)
This implementation has been validated with a real
jinaai/jina-reranker-v3-mlxmodel:<|score_token|>= 151669,<|rerank_token|>= 151671)reranker.pyTesting Results
The implementation was tested locally with:
jinaai/jina-reranker-v3-mlxNotes
added_tokens_decoder→convert_tokens_to_ids→get_added_vocabCloses: #326