Repository navigation
fix(embedding): preserve zero filename embedding weight - #19397
yuzhichang merged 2 commits into
Conversation
Signed-off-by: FeiHaihao <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change preserves explicit zero values for filename and title embedding weights. Default values apply only when weights are ChangesEmbedding weight handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to Explicit zero embedding weights now preserve the intended content-only embedding behavior, while omitted or None values retain the default. The updated tests cover the changed semantics, with no active merge-readiness risk identified. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. A rabbit checks the weights with care Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19397 +/- ##
==========================================
- Coverage 37.89% 37.82% -0.08%
==========================================
Files 54 54
Lines 15312 15343 +31
Branches 118 118
==========================================
Hits 5803 5803
- Misses 9483 9514 +31
Partials 26 26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
LGTM |
Summary
Fix the Python document-ingestion paths so that an explicit
filename_embd_weight=0.0is preserved instead of being replaced with the default0.1.The parameter is documented and validated as a value in
[0.0, 1.0], so zero means that the document filename/title should contribute nothing to the chunk embedding. After this change, omitted/Nonevalues still use the default0.1, while0.0,0.5, and1.0retain their numeric meanings.Problem
The normal Python document task path defaults to
TE_RUN_MODE=0and reachesTaskManager.run_refactored_task()→TaskHandler→EmbeddingService.embed_chunks().The active embedding helper currently does this:
Because
0.0is falsy, a user-configured zero is converted to0.1. With a title vector[10, 20]and content vector[1, 2], the configured value0.0currently produces[1.9, 3.8]instead of the expected content-only vector[1.0, 2.0].The original Python executor uses the same falsy fallback and has the same behavior when selected through
TE_RUN_MODE.Change
rag/svr/task_executor_refactor/embedding_utils.pywith an explicitNonecheck.Nonecheck inrag/svr/task_executor.pyfor the original executor path.EmbeddingService.embed_chunks()regression test with distinct title and content vectors, so it verifies the actual output rather than only the vector size.Go implementation
The corresponding Go Tokenizer path was reviewed but does not need a change.
internal/ingestion/component/tokenizer.gopassesFilenameEmbdWeightdirectly tomergeEmbeddingVectors, whose formula naturally makes0.0a content-only embedding. This PR is therefore limited to correcting the Python truthiness bug.