Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughWhen normalization is enabled, Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue is identified; this change appears mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @ktz03 Thanks for the detailed report and the repro.
Per-token output That said, nothing documents or enforces this today, so your setup passed through silently. We'll make it explicit separately, so per-token output with |
When a custom ONNX model returns token embeddings with
pooling=PoolingType.DISABLEDandnormalization=True, normalization runs across the token axis. A single token vector[3, 4]becomes[1, 1]instead of[0.6, 0.8]; repeating the token also changes its normalized vector. This affects custom token-level embedding exports used for multi-vector retrieval.Normalize along the final embedding axis. This preserves the existing behavior for two-dimensional sentence outputs. Add regressions for token and sentence outputs, enabled/disabled normalization, zero vectors, repeated tokens, output dtypes, and input preservation.
The issue was found through code inspection and reproduced through
TextEmbedding.add_custom_model, construction, andembed, using an actual local CPU ONNX lookup graph and tokenizer. The fixture emits known vectors and checks independent per-vector mathematical expectations; it requires no pretrained model download. Before the fix,"hello"produces[1, 1]and"hello hello"produces approximately[0.7071, 0.7071]for each token. After the fix, both inputs produce[0.6, 0.8]for each hello token.Validation on Windows, Python 3.14.3, FastEmbed 0.9.0, NumPy 2.5.3, and ONNX Runtime 1.31.0 CPU:
pytest tests/test_custom_models.py -k 'mock_add or lookup or existing or disabled_pooling' -q: 16 passed, including 12 new postprocessing cases. The unmodified baseline fails the three new normalized token-output cases and passes the other nine.pytest tests/test_common.py tests/test_image_transform.py tests/test_parallel_processor.py tests/test_postprocess.py -k 'not single_input' -q: 24 passed; one model-loading case deselected.pyright tests/type_stub.py: zero errors or warnings.No full pretrained-model suite, GPU execution, retrieval-quality benchmark, or full CI matrix was run locally.
All Submissions: