feat: preserve provenance for local datasets - #433
Open
aim9sour wants to merge 8 commits into
Open
Conversation
Owner
|
Hey, thanks for the PR, but this would grow Heretic's entire codebase by about 20%. Which I'm afraid is absolutely not going to happen for a minor feature like this. Not sure what else to say here, this is too much code by a factor of 10 at least 😢 |
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.
Summary
This adds verifiable native reproducibility for local Hugging Face
datasets.save_to_disk()inputs when they are exact materializations of pinned public datasets.heretic --reproducereproduce.json,config.toml, and the generated READMEThis does not change the one-prompt-per-line TXT contract and does not upload any dataset.
Investigation
I reproduced this on current
masteratbedb94ef117a271532ac2058447fbc165d5051bd.The minimal case uses:
fka/awesome-chatgpt-promptsca0bf873b687e093f27beaddce8421f92d8ea7b4train[3, 104]promptBoth selected prompts contain embedded newlines. Saving the selected rows with
save_to_disk()preserves those records and Heretic loads them successfully throughload_from_disk(). However, the local path fails the native reproduction eligibility gate. If reproduction metadata is generated directly, it contains only the machine-local path and cannot rebuild the dataset elsewhere.I also searched the open and closed issues, PRs, and commit history for local datasets,
save_to_disk,load_from_disk, reproducibility,reproduce.json, provenance, materialization, hashes, and pinned datasets. Existing work such as #33 adds local loading but does not preserve reconstructable provenance. The historical local-dataset exclusion was deliberately conservative because incomplete metadata would make a reproduction package misleading; this change preserves that policy for unverified local paths and adds the missing verification.Provenance and verification
Example:
The content hash is domain-separated SHA-256 over the ordered prompt sequence. Each exact UTF-8 prompt is prefixed with its unsigned 64-bit big-endian byte length, preserving order, record boundaries, empty values, and multiline content without normalization.
A local dataset is eligible only when:
A mismatch aborts verified loading or disables the reproducibility offer with an actionable reason. Unsupported arbitrary transformation fields are rejected rather than ignored.
Privacy and compatibility
heretic --reproduceaccepts both v3 and v4Tests
ruff format --check .ruff check --extend-select I .ty check --error-on-warning .python -m unittest discover -s tests -p 'test_*.py'— 33 passed, 1 opt-in network test skippedHERETIC_RUN_NETWORK_TESTS=1 python -m unittest tests.test_public_dataset_provenance -v— passeduv build— sdist and wheel built successfullyThe network integration test performs the full data path: fetch exact public revision → select exact multiline rows →
save_to_disk()→ verified local load → schema-v4 path sanitization → settings reconstruction → public rematerialization → identical prompt list and SHA-256.