fix: stabilize Jina v5 and Qwen3 reranker deployment - #5232
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to keep the inherited sentence-transformers scientific stack ABI-compatible in virtual environments by pinning packages like numpy, scipy, scikit-learn, and pandas to their parent environment versions. It also updates the sentence-transformers dependency to version 5.2.0 or higher for Jina v5 embedding models and adds corresponding tests. The review feedback suggests improving the robustness of the newly added test by dynamically identifying model families that require specific transformers versions instead of hardcoding model names.
OliverBryant
left a comment
There was a problem hiding this comment.
Review
Reviewed the full diff, ran the new tests locally (3 ABI-pin + 1 Jina-v5 + rerank param tests all pass), and verified the replacement GGUF repos against the live HF/ModelScope APIs. Overall this is a solid, well-tested fix. Notes below.
Verified correct
pin_sentence_transformers_numpy_abi— engine name is exactly"sentence_transformers"(rerank/core.py:246,embedding/core.py:442), and the function lowercases before comparing, so casing is safe. Call ordering in_prepare_virtual_envisexpand_placeholders → filter_by_markers → ensure_system_torch_pin → pin_sentence_transformers_numpy_abi, so by the time it runs the#sentence_transformers_dependencies#marker is fully expanded; any explicitnumpy/scipy/sklearn/pandasis caught byexplicitly_requestedand won't be double-pinned.canonicalize_namecorrectly handles underscore/hyphen spellings. Pinning to parent versions under--system-site-packagesis the right ABI-alignment behavior.- Q8 filename split — the two-spec-entry approach maps to real files: HF repo has
Qwen3-Reranker-0.6B-Q4_K_M.gguf(dash) for most quants andQwen3-Reranker-0.6B.Q8_0.gguf(dot) for Q8_0.match_rerankflattens per-quant, so requestingQ8_0resolves to the dot-template spec and everything else to the dash-template spec. Confirmed against the live HF tree. sentence_transformers>=5.2.0correctly matches thetransformers==5.7.0runtime (ST 5.1.x requirestransformers<5, which was the root-cause conflict).
Worth noting (non-blocking)
-
ModelScope coverage dropped for Qwen3 rerankers. The change removes the
modelscopesrc entirely for all three GGUF reranker families. I confirmedVoodisss/Qwen3-Reranker-*-GGUF-llama_cppreturns 404 on the ModelScope API and 200 on HF — so there is no ModelScope mirror to point at, making this unavoidable with these repos. But CN users (a large part of the audience) who relied on the ModelScope GGUF path will now be forced onto HuggingFace, which is frequently slow/blocked there. Consider (a) mirroring these GGUFs to a ModelScope org, or (b) at minimum calling this out in the PR description / release notes so CN users aren't surprised. The non-GGUF (pytorch) reranker specs still have ModelScope, so this only affects the GGUF path. -
Minor: the HF repos also ship an
F16GGUF that isn't exposed as a quantization option. Not required, just noting it's available if you want full coverage.
Nothing here blocks merge. Item 1 is the only thing I'd want a conscious decision on.
Summary
sentence-transformers>=5.2.0for the Jina embeddings v5 family, matching its pinned Transformers 5 runtime--system-site-packagesvirtual environmentRoot cause
The Jina v5 virtualenv spec pinned
transformers==5.7.0but leftsentence_transformersunconstrained. Package mirrors could therefore resolvesentence-transformers 5.1.x, which requires
transformers<5, and fail duringthe uv dry-run.
Even when dependency resolution succeeded, uv could upgrade only part of the
scientific Python stack inside the child virtualenv while inheriting compiled
packages from the parent environment. Mixing NumPy, SciPy, scikit-learn, and
pandas across incompatible ABIs caused import-time failures.
The Qwen3-Reranker GGUF specs referenced community conversions that omitted the
reranker classifier tensor and metadata required by llama.cpp. Those files
could load and return HTTP 200 while producing near-zero, incorrectly ordered
scores. The replacement conversions include the classifier tensor, rank
pooling metadata, output labels, and rerank chat template.
Validation
pre-commit run --filespassed for all modified filesjina-embeddings-v5-text-smallthrough a real Xinference RESTserver on an RTX 3090 Ti, using ModelScope and virtualenv mode
/v1/embeddingsreturned HTTP 200 for three inputs with 1024-dimensionalnormalized embeddings; terminate/relaunch against the reused virtualenv also passed
Qwen3-Reranker-0.6Bwith the sentence-transformers engine on theRTX 3090 Ti; English and Chinese
/v1/rerankrequests returned HTTP 200 andcorrect ordering before and after relaunch
deployed the replacement Q4_K_M GGUF with xllamacpp on the same GPU
the relevant English document scored
0.999512versus0.000395for theirrelevant document
Deployment note
On the GPU test host, the xllamacpp CUDA package index was reachable but its
GitHub Release asset timed out. Supplying the identical official wheel locally
allowed the GGUF runtime test to complete; this is a host egress limitation,
not a package-resolution or model-loading failure.