Repository navigation
fix(sparse): preserve small positive SPLADE weights with log1p - #773
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~2 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to This change preserves very small positive SPLADE weights that were previously rounded away. It carries little risk and is ready to merge after the normal CI checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
Thanks for the PR! I ran it on ~9.5k texts (SciFact, Quora, AG News) and saw no measurable difference: no tokens gained or lost, and SciFact nDCG@10 was identical. Since sentence-transformers also uses log1p, I'm ok with merging it, but I dropped the new test file and the docstring to keep the change to the one-liner. |
For float32 logits
[[[1e-8, 0.0, -1.0, 1.0]]]with attention mask[[1]], the currentlog(1+x)postprocessing drops dimension 0 because adding the small value to 1 rounds to 1. The resulting sparse indices are[3]instead of[0, 3].This uses
np.log1pto evaluate the same mathematical log-ReLU formula accurately for small positives. Masking, maximum pooling, and nonzero filtering are unchanged. The tests compare tiny values against an independent scalar reference and cover negatives/zeros, padding exclusion, batch order, pooling, empty output, input preservation, and missing-mask behavior. This is a numerical-accuracy fix; retrieval-quality improvement is not claimed.Validation on Windows 11, Python 3.13.5, NumPy 2.3.5, FastEmbed 0.8.1:
python -m pytest -q tests/test_splade_log1p.py.600ce23fd7611e71694fcf724f46778f1ad24c1c. Canonical expectations were unchanged. The single-embedding test used its existing model-selection hook to select SPLADE.The full model/OS/Python CI matrix was not run locally.
Split from #766 following the maintainer's request for one PR per problem. This branch is based directly on current main and contains only this problem's production change and regression module.