Data poisoning and integrity
Quick answer
Training data integrity means that approved data remains complete, unchanged and traceable. Data poisoning is intentional corruption of training inputs or the training process. Treat unexpected changes as evidence to investigate, not proof of an attack. Examples use small inert synthetic inputs and standard-library Python. No real endpoints. ByteMind execution is unverified.
Compare approved snapshot bytes
import hashlibapproved = b"id,label\n1,0\n"received = b"id,label\n1,0\n"print(hashlib.sha256(approved).digest() == hashlib.sha256(received).digest())Expected output (locally tested): True. Identical bytes match the trusted snapshot digest.
How it works
Begin with a threat model: identify assets (labels, datasets, weights), trusted identities, write paths and consequences. Pin a digest of the approved bytes in a separately trusted record. SHA-256 changes when bytes change but cannot identify who changed them. Schema and range checks detect some quality failures; plausible but wrong labels need independent review. Restrict ingestion identities to required writes, training identities to approved reads, and log dataset versions. Quarantine suspect versions and compare to independent validation data. A clean checksum proves identity with the approved snapshot, not label truth or consent.
Quarantine invalid records
rows = [(1, 0), (2, 1), (3, 5)]print([i for i, label in rows if label not in (0, 1)])Expected output (locally tested): [3]. A label outside the binary schema requires review; the check cannot detect all wrong labels.
Common mistakes
Do not treat distribution shift as proof of poisoning or accept a digest supplied only by the untrusted uploader. Do not discard suspicious rows without preserving evidence; this may hide ordinary upstream defects.
Practice and next steps
List a label source, its owner, permitted writers and a validation control. Calculate the digest of an approved toy snapshot and explain why approval is separate from hashing. Next: loading artifacts safely.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Data poisoning and integrity — knowledge check
Apply data poisoning and integrity to small examples and debugging scenarios.
What does a matching trusted digest establish?
What should happen to suspicious rows?
Who should write approved data?
Can valid-looking labels be wrong?
What does unexpected drift prove?