You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 59c0c126-bd86-46c6-b33d-e7ecbf12f259
📥 Commits
Reviewing files that changed from the base of the PR and between b1dd097 and 45b85f6.
📒 Files selected for processing: 1
tests/test_static_embeddings.py
🚧 Files skipped from review as they are similar to previous changes: 1
tests/test_static_embeddings.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
The single-document weighted-vector path now selects an explicit result dtype for multiplication. A regression test checks output dtype, finiteness, batch-size agreement, and normalized values across tensor types, mmap settings, and scale combinations.
The precision fix is mergeable after normal checks; no actionable regression was identified.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
标题简洁、具体,并准确概括了修复 float16 静态向量加权池化精度问题这一主要变更。
Description check
描述与代码变更直接相关,说明了 float16 下溢和溢出问题、修复方案、回归测试范围及验证结果。
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
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
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.
提交检查
问题与修复
载入 float16 静态向量和权重时,同一文本的嵌入结果会随 batch_size 改变。单条路径先用 float16 相乘,小数值会下溢成零,大数值会溢出并在归一化后产生 NaN;批量路径则使用 float32 计数矩阵,得到正常的单位向量。
本次用
np.multiply显式选择至少为 float32 的乘法精度,并保留更高精度输入的类型提升行为。没有新增依赖。回归测试通过公开的
TextEmbedding接口载入本地生成的 safetensors 和 tokenizer,覆盖 float16/float32、小数值/大数值、普通读取/内存映射。测试同时比较单条与批量结果,并检查有限性和预期方向。修复前 4 个 float16 用例失败,4 个 float32 对照通过;修复后全部通过。验证
Python 3.12.9,NumPy 2.5.4。
Ruff 使用项目 pre-commit 固定的 0.3.4 版本。相关 #826 修改 ColBERT/LateOn 的归一化,不涉及本次静态模型加权池化路径。
本次问题调查、代码修改和回归验证使用了 Codex AI 辅助。
2026-10-19 验证补充
Iterator的标准库导入,满足当前 Ruff 规则。pytest tests/test_static_embeddings.py -q -k "weighted_pooling_matches_across_batch_sizes or load_safetensors":13 项通过,20 项未选中;Ruff 与差异空白检查通过。