Repository navigation
Conversation
This branch has not been deployed
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.
Problem
Multi-field exact deduplication can silently remove different records before any hash collision occurs. With
input_keys=["question", "answer"], these two rows produce exactly the same delimiter-joined string:{"question": "x\nanswer:\ny", "answer": "z"} {"question": "x", "answer": "y\nanswer:\nz"}Consequently
HashDeduplicateFilterkeeps only the first row with MD5, SHA-256, and xxh3 alike. Text such as field labels and newlines can legitimately occur in question/answer datasets.Change
Encode the ordered string representations of the selected values as a JSON array. JSON escaping preserves field boundaries even when values contain delimiters, quotes, backslashes, NULs, or Unicode.
The single-field paths (
input_keyand a one-elementinput_keys) stay unchanged. Multi-field values retain their existing string-conversion semantics, and genuine duplicates still keep the first row in its original order. Hashes are local to each run; no persisted fingerprint format is changed.Validation
Added 33 CPU cases covering all three hash algorithms, embedded field markers (including unusual column labels), exact duplicates, row indices/order, empty and escaped text, Unicode, non-string values, and both single-field entry points.
git diff --checkpasses.python -m pytest test/cpu_only/test_hash_dedup_field_boundaries.py test/cpu_only/test_dedup_single_input_keys.py test/cpu_only/test_minhash_short_texts.py -qValidated on Windows with Python 3.12.14 and the normal repository conftest. The full model/API test suite was not run.