Feat/semantica triplet dedup v2 336#340
Merged
KaifAhmad1 merged 4 commits intoHawksight-AI:mainfrom Feb 25, 2026
Merged
Conversation
ca88cc3 to
91ba521
Compare
- Add name check to prevent function from calling itself recursively - Fixes crash when using semantic deduplication mode - Maintains all existing functionality while preventing stack overflow
KaifAhmad1
approved these changes
Feb 25, 2026
Contributor
KaifAhmad1
left a comment
There was a problem hiding this comment.
PR Review: Feat/Semantica Triplet Dedup v2 (#340)
Status: ✅ APPROVED
Performance
- 6.98x speedup: Semantic V2 (~83ms) vs Legacy (~579ms)
- O(1) hash matching: Fast-path optimization
- All benchmarks passed: 13/13 tests
Key Features
- ✅ Semantic deduplication: Predicate synonyms + literal normalization
- ✅ Weighted scoring: 60% predicate + 40% object composition
- ✅ Explainable AI:
semantic_match_scoremetadata - ✅ API:
dedup_triplets()function - ✅ Backward compatible: Opt-in
semantic_v2mode
Critical Fix
- Infinite recursion: Fixed self-calling in
dedup_triplets() - Solution: Added name check in registry lookup
- Status: ✅ Fixed and verified
Testing
- ✅ Functionality: Semantic dedup working (3/3 duplicates)
- ✅ Compatibility: Legacy mode preserved
- ✅ No recursion: Function completes successfully
- ✅ Integration: Merge strategy working
Files Modified
duplicate_detector.py: +203 linesmethods.py: +35 lines (includes fix)merge_strategy.py: +35 linestest_deduplication.py: +57 lines
Impact: 7x performance improvement, semantic intelligence, full backward compatibility.
…n v2 features - Added comprehensive changelog entry for Semantic Relationship Deduplication v2 - Documented 6.98x performance improvement and key features - Included contributor credits (@ZohaibHassan16) and fix credits (@KaifAhmad1) - Listed all technical implementations and benchmarks - Noted critical infinite recursion bug fix
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR completes the Deduplication v2 Epic by introducing an opt-in semantic relationship deduplication mode (
semantica_v2). This moves triplet matching away from naive string comparisons toward canonicalization and weighted semantic scoring, all backed by a highly optimized fast-path hash check.Type of Change
Related Issues
Changes Made
1. Canonicalization Engine
Implemented
predicate_synonym_mapandliteral_normalization_enabledsupport to align semantic equivalents (e.g., works_for == employed_by).2. Fast Path Hash Matching
Updated$O(1)$ time. This allows the system to skip heavy string math when exact canonical matches exist.
detect_relationship_duplicatesto pre-compute and compare canonical signatures in3. Weighted Semantic Path
Developed a weighted confidence composition (60% predicate / 40% object) in
_relationships_are_duplicatesas a fallback for fuzzy matches, including explainablesemantic_match_scoremetadata.4. Merge Alignment & API
_merge_relationshipsto group by canonical keys rather than raw strings.dedup_tripletsinmethods.pyas a first-class entry point.Benchmark Results
The canonical hash path yields massive performance gains alongside accuracy improvements:
Testing & Quality Assurance
test_relationship_dedup_speedto track synonym resolution and hash-path speed.python -m buildsuccessful.legacymode to preserve existing SPO matching behavior.Additional Notes
This is the third PR in the Deduplication v2 sequence. Please note:
feat/semantic-triplet-dedup-v2-336) is sub-branched fromfeat/prefilter-logic-v2-335.mainhistory clean!