Fix duplicate detection: lower default threshold and log near-misses#16
Conversation
The pipeline similarity_threshold default of 0.82 was too high for real OpenAI text-embedding-3-small vectors on cross-source rewrites of the same story (which land ~0.60-0.80), so Clusterer::match() almost never merged and every article became a new cluster. The below-threshold branch also returned null with no log, hiding the miscalibration. - Lower default similarity_threshold 0.82 -> 0.72 - Log the nearest-story score when it falls below the threshold - Add help text to the Duplicate sensitivity setting Existing installs must lower their stored setting; the default only affects new installs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe default similarity threshold fallback value was lowered from 0.82 to 0.72 in both Settings and Admin classes. The settings view markup was reformatted. Clusterer now logs an info-level event when a candidate's similarity score falls below the threshold, treating the item as a new story. ChangesSimilarity Threshold Update
Estimated code review effort: 1 (Trivial) | ~5 minutes Related issues: None identified from the provided information. Related PRs: None identified from the provided information. Suggested labels: enhancement, settings, logging Suggested reviewers: None identified from the provided information. 🌱 PoemA whisker tighter, threshold shrinks, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) 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 |
Problem
Dedup was silently failing on the live site: multiple near-identical posts (e.g. four "Entain exits Poland/Croatia" articles) published as separate stories.
Root cause
On OpenAI (
text-embedding-3-small), the pipelinesimilarity_thresholddefault of 0.82 is too high. Real cross-source rewrites of the same story score ~0.60-0.80, soClusterer::match()almost never cleared the threshold and every article started a new cluster.Worse, the
score < thresholdbranch returnednullwith no log, so the Activity log showed nothing (the existing "Close call" line only fires when score ≥ threshold but facts don't overlap). The failure was invisible.Changes
similarity_threshold0.82 → 0.72 (Settings.php,Admin.php)Clusterer.php)The shared-salient-fact guard (signal 3) still blocks false merges, so a lower embedding threshold is safe.
Note for existing installs
Lowering the code default does not change a stored option. Existing sites must set Duplicate sensitivity → 0.72 in Settings for the fix to take effect.
Testing
86 tests pass, lint clean.
Summary by CodeRabbit