A hash function takes any input, a sentence, a PDF, a 34 GB model checkpoint, and squashes it into a fixed-length string of hex digits. The same input always produces the same string. Change one bit anywhere in the input and you get, with near certainty, a completely different string. That is the whole product: a fingerprint for data.
Fingerprints sound trivial. They are not. The property that tiny edits scramble the fingerprint is what lets a package manager verify a download, what broke SHA-1, and what, in its opposite form, quietly deduplicates the training data behind frontier language models.
What the definition actually requires
A cryptographic hash function maps arbitrary-length bitstrings to fixed-length digests, and it needs three properties beyond speed:
- Preimage resistance. Given a digest, you cannot work backward to an input that produces it. Finding some input for a target hash should take brute force across the digest space.
- Second-preimage resistance. Given a file and its hash, you cannot find a different file with that same hash.
- Collision resistance. You cannot find any two inputs that share a hash. This is the hardest property to keep, because of the math below.
NIST's Secure Hash Standard (FIPS 180-4) defines the SHA family the industry runs on: SHA-256 and SHA-512 produce 256- and 512-bit digests respectively. The output is always the same size no matter how big the input is. That fixed size is why hashing scales. Comparing two 5-terabyte copies of a dataset means comparing two 32-byte digests, and a content-addressed store can name every object by its digest so identical files automatically merge into one entry. Git does exactly this: every object it stores, every commit, every file blob, is looked up by its hash.
Why 128 bits was not enough: the birthday bound
Collision resistance is weaker than the digest length suggests, because an attacker does not need to hit a specific hash, just any pair that matches. After k random inputs, the number of pairs grows roughly as k squared over two, so collisions show up around 2^(n/2) trials for an n-bit digest, not 2^n. This is the birthday attack, the same combinatorics behind the parlor puzzle about matching birthdays in a room of 23 people.
The numbers are brutal for old designs. MD5 has a 128-bit digest, so a brute-force collision should take about 2^64 tries. SHA-1's 160-bit digest should resist up to 2^80. Those bounds are worst cases anyway; structural weaknesses let attackers do far better, and for both algorithms, far better arrived.
A short history of broken fingerprints
MD5 was designed by Ron Rivest in 1992 and published as RFC 1321. In August 2004, Xiaoyun Wang and coauthors announced full MD5 collisions at the rump session of CRYPTO, with the analytical attack reportedly taking about an hour on an IBM p690 cluster. MD5 was finished for anything adversarial, and the practical demonstrations followed fast: in 2005, researchers built two X.509 certificates with different public keys and the same MD5 hash.
Wang, Yiqun Lisa Yin, and Hongbo Yu then attacked SHA-1 itself, with collisions findable in fewer than 2^69 operations, orders of magnitude below the ideal 2^80. NIST commented on the attack in 2006 and accepted it as a practical collision threat for signature use. The final nail came in February 2017, when CWI Amsterdam and Google published SHAttered: two different PDFs with the identical SHA-1 hash, built with about 2^63.1 SHA-1 evaluations, roughly 9.2 quintillion. That was over 100,000 times faster than the birthday brute-force bound and consumed the equivalent of 6,500 years of single-CPU computation or 110 years of single-GPU work before finishing. Web browsers dropped SHA-1 TLS certificates the same year. In 2020, Gaetan Leurent's SHA-1 is a Shambles attack pushed it further: a first practical chosen-prefix collision, costing about $11,000 for a plain collision and $45,000 for chosen-prefix on rented gaming GPUs, 900 GTX 1060s for two months, and used to forge a PGP identity. Chosen-prefix means the attacker controls what both colliding documents say up to the injected difference, which is the variant that breaks signature schemes.
The lesson generalizes: digest length sets a ceiling, algebra decides the actual height. SHA-256 has no public full attack, but the community assumes designs age. One changed bit flipping half the output is the avalanche property, the very feature collision hunters spend decades exploiting.

The opposite trick: hashes that preserve similarity
Cryptographic hashes have the avalanche property on purpose. One changed bit should flip about half the output bits, so near-identical files get totally unrelated digests. That is great for integrity and useless for the problem every web crawler and every pre-training pipeline runs into: these two pages are not identical, but they are 96% the same, and we cannot afford to compare them character by character.
Locality-sensitive hashing (LSH) solves it by making the hash depend on similarity instead of destroying it.
MinHash, introduced by Andrei Broder in 1997 and first deployed in AltaVista to collapse duplicate web pages, works like this. Shingle each document into a set of overlapping word sequences. Apply a family of random hash functions (or permutations) to the shingles and keep only the minimum value from each one. The result is a short signature, say 100 or 200 integers, that summarizes thousands of shingles. Broder's key observation: the probability that two documents share a minimum under a random permutation equals their Jaccard similarity, the size of the shingle intersection divided by the union. So the fraction of matching signature positions estimates document similarity directly, at a comparison cost that is constant per document pair.
Charikar's SimHash (STOC 2002) is the geometric cousin: project the input vector onto a set of random hyperplanes and record the sign of each projection. Documents with high cosine similarity land on signatures that differ in few bits, so a Hamming-distance check on 64-bit fingerprints substitutes for high-dimensional search.

Where this shows up in LLM work
Pre-training corpora are where these 1990s hashing tricks earn their keep at 2020s scale.
DeepMind's Gopher paper (arXiv 2112.11446) describes a data pipeline that removes exact duplicates and then runs fuzzy deduplication with MinHash: 13-gram Jaccard similarities computed over shingled documents to identify near-copies across Common Crawl, citing Katherine Lee and colleagues' finding that deduplication makes language models measurably better (arXiv 2107.06499). TII's RefinedWeb paper (arXiv 2306.01116), the web-only dataset that powered Falcon, runs a comparable ladder, exact URL removal, exact substring deduplication, then MinHash-style fuzzy deduplication, and its ablations state that deduplication brings a steady performance boost across datasets. The broader point these papers make is that duplication is not cosmetic: Lee et al. tie repeated training text to verbatim memorization, and repeated web copies are one of the quietest contamination vectors there is.
On the serving side, vLLM's automatic prefix caching identifies reusable KV-cache blocks by hashing each block's tokens plus parent-block metadata; hit the same hash and the server skips recomputing that stretch of prompt. The docs are explicit that production uses a 128-bit non-cryptographic hash (xxHash) for speed, and they document the residual risk, including a per-request cache salt to blunt cache-probing attacks. It is a neat illustration of the two hash worlds in one system: speed-optimized non-crypto hashes for cache keys, cryptographic hashes for integrity.
And when you download weights from a model hub, the file you fetch is checked against a published digest. Every safetensors blob, every tarball, arrives validated by exactly the SHA-family machinery NIST standardized: mismatch, refuse the file, download again.
How to think about it, briefly
When you need "same only if identical": use SHA-256 or better, and never build a security decision on MD5 or SHA-1.
When you need "same-ish, cheaply": use the LSH family, MinHash for set/Jaccard similarity, SimHash for cosine.
When you need "fast buckets, no adversary": Murmur or xxHash are fine, and that is why serving engines reach for them, but they carry no collision-resistance guarantee.
A hash function is the rare 40-year-old idea that underwrites everything from your git history to the deduplication pass on a trillion-token corpus. It is also the clearest example in infrastructure of a security claim with an expiry date: an algorithm can be the industry standard for two decades and a liability in one CRYPTO rump session.
Sources
- NIST FIPS 180-4, Secure Hash Standard: https://csrc.nist.gov/pubs/fips/180-4/upd1/final
- Rivest, The MD5 Message-Digest Algorithm (RFC 1321): https://datatracker.ietf.org/doc/html/rfc1321
- Wikipedia, MD5 (2004 Wang et al. collision announcement; 2005 X.509 collision): https://en.wikipedia.org/wiki/MD5
- Wang, Yin, Yu, Finding Collisions in the Full SHA-1 (CRYPTO 2005): https://people.csail.mit.edu/yiqun/SHA1AttackProceedingVersion.pdf
- NIST comments on cryptanalytic attacks on SHA-1 (2006): https://csrc.nist.gov/news/2006/nist-comments-on-cryptanalytic-attacks-on-sha-1
- CWI news, CWI and Google announce first collision for SHA-1 (2017): https://www.cwi.nl/en/news/cwi-and-google-announce-first-collision-for-industry-security-standard-sha-1
- Google Security Blog, Announcing the first SHA-1 collision: https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html
- Leurent, SHA-1 is a Shambles (USENIX Security 2020): https://www.usenix.org/conference/usenixsecurity20/presentation/leurent
- Wikipedia, Birthday attack (collision bound): https://en.wikipedia.org/wiki/Birthday_attack
- Broder, On the Resemblance and Containment of Documents (1997): https://doi.org/10.1109/SEQUEN.1997.666900
- Charikar, Similarity Estimation Techniques from Rounding Algorithms (STOC 2002): https://dl.acm.org/doi/10.1145/509907.509965
- Rae et al., Scaling Language Models: Methods, Analysis and Insights from Training Gopher (arXiv 2112.11446): https://arxiv.org/abs/2112.11446
- Lee et al., Deduplicating Training Data Makes Language Models Better (arXiv 2107.06499): https://arxiv.org/abs/2107.06499
- Penedo et al., The RefinedWeb Dataset for Falcon LLM (arXiv 2306.01116): https://arxiv.org/abs/2306.01116
- vLLM docs, Automatic Prefix Caching: https://docs.vllm.ai/en/latest/design/prefix_caching/
- Pro Git, Git Internals - Git Objects: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects
