Winnowing: local algorithms for document fingerprinting

S. SchleimerD. WilkersonA. Aiken

article2003SIGMOD1,391 citations

Introduces the winnowing algorithm, a local document fingerprinting technique behind the widely used MOSS system that provides formal guarantees for detecting shared substrings while minimizing the number of stored hash values.

Listen

Digital documents are easily replicated, modified, and reused across platforms, driving a strong operational need for reliable detection of both exact and partial text duplication. Conventional copy-detection strategies frequently rely on document fingerprinting, which hashes short overlapping character sequences known as k-grams and selects a sample of those hashes. However, standard sampling approaches—such as keeping only hashes matching a fixed modulo value—lack mathematical guarantees, leaving unpredictable gaps where extensive duplicated passages can completely escape detection.

The article introduces and evaluates "winnowing," a local document-fingerprinting algorithm designed to guarantee the detection of any shared substring meeting a user-defined length threshold. It establishes a theoretical performance baseline for local fingerprinting algorithms and demonstrates winnowing's efficiency in both controlled benchmarks and production systems.

The authors evaluated the framework through theoretical proofs and empirical tests. To ensure credibility across different environments, they tested the method on 8 megabytes of randomized text, a production-scale dataset of 500,000 web pages encompassing nearly 2 billion computed hashes, and operational longitudinal data from MOSS, a widely used software similarity and plagiarism detection service. The algorithm maintains guarantees by evaluating sliding windows of hashes and systematically choosing the minimum hash within each window, ensuring that document matches depend solely on local text content rather than global position.

The article yields four core findings. First, winnowing provides a strict detection guarantee, identifying at least one shared marker in any matching passage of length w + k − 1, where w is the window size and k is the substring length. Second, winnowing achieves an expected fingerprint density of 2 / (w + 1), performing within 33% of the theoretical lower bound of 1.5 / (w + 1) proven for all local algorithms. Third, while standard modulo-based sampling fails to select fingerprints over long non-random stretches—evidenced by a run of nearly 30,000 characters without a single selected hash in web data—winnowing reliably captures samples across all segments. Fourth, repetitive, low-entropy content creates redundant minimums that degrade efficiency; the authors resolved this by introducing "robust winnowing," an enhancement that breaks ties by preserving previously selected hashes to keep sampling density bounded at 1 / w.

These findings indicate that document similarity systems can guarantee copy detection while maintaining highly compact indexes and low computational overhead. Decoupling document-specific normalization front-ends from the core hashing engine minimizes software complexity and engineering costs when supporting diverse file types. Furthermore, querying databases with variable window sizes enables flexible trade-offs between rapid resemblance checks and thorough containment audits.

Organizations implementing copy or plagiarism detection should adopt robust winnowing to avoid index bloat on repetitive data and use 64-bit rolling hash functions to prevent accidental collisions. Systems should separate format-specific preprocessing—such as removing whitespace or normalizing variable names—from the language-agnostic fingerprinting pipeline. Operations should also filter out known boilerplate, like standard license text, by pre-indexing template materials to suppress non-actionable matches.

The theoretical model relies on the assumption of uniformly distributed hash values; although real-world data deviates from this assumption due to repetitive text patterns, robust winnowing effectively neutralizes this limitation. Because k-gram matching provides coarse initial boundaries, users requiring exact substring borders may need a secondary refinement step, such as suffix trees, on detected pairs. Overall, multi-year production evidence from MOSS confirms high confidence in the algorithm's reliability, reporting no false positives and robust deterrence against illicit copying.

  • Paper: Similarity Search in High Dimensions via Hashing, Aristides Gionis et al. (1999). Introduces locality-sensitive hashing to map high-dimensional data points to hash buckets with collision guarantees, establishing the broader randomized hashing paradigm that underpins local document fingerprinting algorithms.
  • Paper: Fast subsequence matching in time-series databases, Christos Faloutsos et al. (1994). Establishes sliding-window indexing mechanisms for robust subsequence matching, providing foundational sliding-window principles applied in local fingerprint selection.
Cover for Winnowing: local algorithms for document fingerprinting

Abstract

Digital content is for copying: quotation, revision, plagiarism, and file sharing all create copies. Document fingerprinting is concerned with accurately identifying copying, including small partial copies, within large sets of documents.

We introduce the class of local document fingerprinting algorithms, which seems to capture an essential property of any fingerprinting technique guaranteed to detect copies. We prove a novel lower bound on the performance of any local algorithm. We also develop winnowing, an efficient local fingerprinting algorithm, and show that winnowing’s performance is within 33% of the lower bound. Finally, we also give experimental results on Web data, and report experience with MOSS, a widely-used plagiarism detection service.

Table of Contents

  • 1. INTRODUCTION
  • 2. BACKGROUND AND RELATED WORK
  • 2.1 Desirable properties
  • 2.2 Karp-Rabin String Matching
  • 2.3 All-to-all matching
  • 2.4 Other techniques
  • 3. WINNOWING
  • 3.1 Expected Density
  • 3.1.1 Comparison to 0 mod p at same density
  • 3.1.2 Comparison to 0 mod p with guarantee
  • 3.2 Queries
  • 4. LOCAL ALGORITHMS
  • 5. EXPERIMENTS
  • 5.1 Experiments with Web Data
  • 5.2 Plagiarism Detection
  • 6. CONCLUSIONS
  • 7. ACKNOWLEDGMENTS
  • 8. REFERENCES

Knowls

  1. Knowl 1 — The Winnowing Algorithm for Document Fingerprinting

    model/method

    Winnowing is a local document fingerprinting algorithm designed to detect shared substrings between documents while bounding the number of retained fingerprints. Given text preprocessed to discard formatting or semantic noise, the document is decomposed into contiguous substrings of length kk (kk-grams), and a hash value hih_i is computed for each kk-gram at index ii, yielding a sequence h1,h2,…,hnh_1, h_2, \dots, h_n.

    Let kk be the noise threshold (minimum match length of interest) and tt be the guarantee threshold (the shortest substring match guaranteed to be detected), where t≥kt \ge k. The window size is set to: w=t−k+1w = t - k + 1

    For every window of ww consecutive hashes Wi=(hi,hi+1,…,hi+w−1)W_i = (h_i, h_{i+1}, \dots, h_{i+w-1}) for 1≤i≤n−w+11 \le i \le n - w + 1, the algorithm selects the minimum hash value. If multiple positions within the window share the minimum value, the rightmost occurrence is selected. The set of all uniquely selected hashes across all windows, stored alongside their document positions, constitutes the document fingerprints.

    Because every substring of length at least tt contains at least ww consecutive kk-grams (and therefore spans at least one complete window of length ww), winnowing guarantees that at least one identical fingerprint is selected from both copies of any shared substring of length ≥t\ge t.

  2. Knowl 2 — Expected Fingerprint Density of Winnowing

    theoretical result

    Under the assumption that kk-gram hash values are independent and uniformly distributed random variables over a sufficiently large domain where ties within small windows have negligible probability, the expected density dd (the expected proportion of computed kk-gram hashes selected as fingerprints) of the winnowing algorithm with window size ww is: d=2w+1d = \frac{2}{w + 1}

    This density is derived by charging each selected fingerprint to the leftmost window that selects it. For any two adjacent overlapping windows Wi−1W_{i-1} and WiW_i, which together span a union interval of w+1w + 1 hashes, window WiW_i is charged for selecting a new fingerprint if and only if the minimum hash in the union interval is located at the leftmost position (index i−1i-1) or at the rightmost position (index i+w−1i+w-1). Each of these two disjoint events occurs with probability 1w+1\frac{1}{w+1}, giving an expected charge of 2w+1\frac{2}{w+1} per window.

  3. Knowl 3 — Local Document Fingerprinting Algorithms and Substring Match Guarantee

    definition

    A document fingerprinting algorithm is defined as local if its selection of a fingerprint from any window of ww consecutive hashes hi,…,hi+w−1h_i, \dots, h_{i+w-1} is determined strictly by a selection function: S:Hw→{0,1,…,w−1}S: H^w \to \{0, 1, \dots, w-1\} where HH is the set of possible hash values. For every window hi,…,hi+w−1h_i, \dots, h_{i+w-1}, the algorithm selects the hash at position i+S(hi,…,hi+w−1)i + S(h_i, \dots, h_{i+w-1}) as a fingerprint without relying on global position or document-level coordinates.

    Any local algorithm with window size w=t−k+1w = t - k + 1 is guaranteed to detect all matching pairs of substrings of length at least tt across documents (where kk is the kk-gram noise threshold). Because a shared substring of length ≥t\ge t contains at least ww consecutive kk-gram hashes, it contains at least one identical full window WW, and the locality of SS ensures the identical fingerprint is chosen in both documents.

  4. Knowl 4 — Theoretical Lower Bound on the Density of Local Fingerprinting Algorithms

    theoretical result

    For any local fingerprinting algorithm operating on independent and uniformly distributed random hash inputs with noise threshold kk and guarantee threshold t=w+k−1t = w + k - 1 (window size ww), the fingerprint density dd satisfies the lower bound: d≥1.5w+1d \ge \frac{1.5}{w + 1}

    By applying the Cauchy-Schwarz inequality to the collision probability across overlapping windows, this bound can be strengthened to: d≥1.5+12ww+1d \ge \frac{1.5 + \frac{1}{2w}}{w + 1}

    Because the winnowing algorithm achieves an expected density of d=2w+1d = \frac{2}{w+1}, its density is within 33%33\% of the theoretical lower bound for any local fingerprinting algorithm.

  5. Knowl 5 — Robust Winnowing for Low-Entropy Sequences

    algorithm

    Standard winnowing selects a new fingerprint in almost every window on low-entropy strings (e.g., long sequences of repeating characters where every kk-gram hash is identical) because the rightmost minimum advances with each step, causing the density to approach 11. Robust winnowing modifies the tie-breaking rule to favor previously selected hashes:

    Input: A sequence of hashes h1,h2,…,hnh_1, h_2, \dots, h_n and window size ww
    Output: A set of selected fingerprints with global positions
    for each window Wi=(hi,hi+1,…,hi+w−1)W_i = (h_i, h_{i+1}, \dots, h_{i+w-1}) from i=1i = 1 to n−w+1n - w + 1:
        Find the minimum hash value in WiW_i
        if the minimum hash value equals the hash selected in Wi−1W_{i-1} and that hash index is still in WiW_i:
            Select the same hash instance as in Wi−1W_{i-1}
        else:
            Select the rightmost occurrence of the minimum hash in WiW_i
        Record the selected hash and its document position if not previously recorded

    On repetitive strings of identical hashes, robust winnowing reduces fingerprint density from asymptotically 11 to 1w\frac{1}{w} (one fingerprint per window length). For any matching substring of length ≥t=w+k−1\ge t = w + k - 1, robust winnowing guarantees selecting the same hash value in both occurrences within a distance of at most w−1w - 1 positions.

  6. Knowl 6 — Circular Buffer Implementation of the Winnowing Algorithm

    algorithm

    Winnowing can be implemented in O(1)O(1) amortized time per hash using a circular buffer of size ww. A full scan of the window is required only when the previous minimum leaves the window:

    Input: Stream of hashes from next_hash() and window size ww
    Output: Document fingerprints emitted via record(hash, position)
    Initialize circular array hh of size ww with all elements set to ∞\infty
    r←0r \leftarrow 0
    min←0\text{min} \leftarrow 0
    while more hashes are available:
        r←(r+1) mod wr \leftarrow (r + 1) \bmod w
        h[r]←next_hash()h[r] \leftarrow \text{next\_hash}()
        if min=r\text{min} = r:
            for i←(r−1) mod wi \leftarrow (r - 1) \bmod w down to rr (circular leftward scan):
                if h[i]<h[min]:h[i] < h[\text{min}]:
                    min←i\text{min} \leftarrow i
            record(h[min]h[\text{min}], global_pos(min,r,w\text{min}, r, w))
        else:
            if h[r]≤h[min]:h[r] \le h[\text{min}]:
                min←r\text{min} \leftarrow r
                record(h[min]h[\text{min}], global_pos(min,r,w\text{min}, r, w))

    In the common case where the previous minimum remains in the current window, only a single comparison against the new hash h[r]h[r] is performed. Replacing h[r]≤h[min]h[r] \le h[\text{min}] with h[r]<h[min]h[r] < h[\text{min}] converts this procedure into robust winnowing.

  7. Knowl 7 — Density Analysis of Safe 0 mod p Fingerprinting

    theoretical result

    The Safe 0 mod p0 \bmod p algorithm modifies modular hash sampling to guarantee detection of matches of length ≥t=w+k−1\ge t = w + k - 1 by classifying hashes as:

    • Good: if the hash is 0 mod p0 \bmod p
    • Bad: if the hash and the w−1w-1 hashes to its left are not Good
    • Ugly: otherwise

    All non-Ugly (Good or Bad) hashes are selected as fingerprints. For independent uniformly distributed hashes with P=1/pP = 1/p, the probability of a position being non-Ugly is f(P)≈P+e−wPf(P) \approx P + e^{-wP}. Minimizing f(P)f(P) yields the optimal probability parameter: P0=ln⁡wwP_0 = \frac{\ln w}{w}

    At this optimal setting, the minimum expected density of Safe 0 mod p0 \bmod p is: f(P0)=1+ln⁡wwf(P_0) = \frac{1 + \ln w}{w}

    This density is strictly higher than winnowing's expected density of 2w+1\frac{2}{w+1} for all practical window sizes ww.

  8. Knowl 8 — Match Detection Failure Rate of 0 mod p Sampling at Equivalent Density

    theoretical result

    When selecting fingerprints by choosing hashes satisfying h≡0(modp)h \equiv 0 \pmod p with parameter p=1/d=(w+1)/2p = 1/d = (w + 1)/2 (matching the expected density d=2w+1d = \frac{2}{w+1} of winnowing with window size ww), the algorithm provides no guarantee of detecting matches.

    For a specific shared substring of guarantee length t=w+k−1t = w + k - 1 containing ww consecutive kk-gram hashes, assuming independent uniformly distributed hash values and large ww, the probability that 0 mod p0 \bmod p sampling fails to select any fingerprint within the sequence is: (1−d)w=(1−2w+1)w≈e−2ww+1≈e−2≈13.5%(1 - d)^w = \left(1 - \frac{2}{w + 1}\right)^w \approx e^{-\frac{2w}{w+1}} \approx e^{-2} \approx 13.5\%

    Thus, at identical expected density, 0 mod p0 \bmod p sampling misses approximately 13.5%13.5\% of threshold-length matches that winnowing is guaranteed to detect.

  9. Knowl 9 — Empirical Density and Gap Comparison on Web Data

    data/table

    An evaluation on 500,000 HTML pages (Stanford WebBase) compared winnowing against 0 mod 500 \bmod 50 sampling using noise threshold k=50k = 50 and window size w=100w = 100:

    Metric Winnowing 0 mod 500 \bmod 50
    Total bytes 7,182,692,852 7,182,692,852
    Text bytes 1,940,576,448 1,940,576,448
    Hashes computed 1,940,576,399 1,940,576,399
    Fingerprints selected 38,530,846 38,761,128
    Measured density 0.019855 0.019974
    Expected density 0.019802 0.020000
    Longest run with no fingerprint - 29,983

    While both methods matched their expected average densities across the entire corpus ( ≈0.0198\,\approx 0.0198 for winnowing and  ≈0.0200\,\approx 0.0200 for 0 mod 500 \bmod 50), 0 mod 500 \bmod 50 exhibited a maximum gap of 29,983 non-whitespace, non-tag characters without a single fingerprint due to low-entropy repetitive strings. Winnowing strictly bounded the gap to at most one fingerprint per window of 100 hashes.

  10. Knowl 10 — Power-Law Distribution of k-Gram Hash Frequencies in Web Documents

    empirical result

    In an analysis of kk-gram hashes (k=50k=50) across 20,000 Web pages, the relationship between the rank rr of a hash (sorted in descending order of occurrence frequency) and its frequency ff follows a power law: f∝r−0.7f \propto r^{-0.7}

    Log-log linear regression on the plateau endpoints of the frequency-rank data yields a power-law slope of approximately −0.70-0.70 for all computed kk-gram hashes and −0.68-0.68 for fingerprints selected by winnowing. In both distributions, 82%82\% of distinct hashes occur exactly once, 14%14\% occur twice, and 2%2\% occur three times, while repetitive boilerplate text (such as menus, legal disclaimers, and repeated script strings) constitutes the high-frequency tail.

Coverage note — Omitted general background discussions of Karp-Rabin hashing, related copy-detection systems (SCAM, p-matches, DRM), and MOSS operational anecdotes (e.g., UI merging heuristics and front-end tokenization) as they do not form the paper's core technical contributions.

References

  1. 1.Arvind Arasu, Junghoo Cho, Hector Garcia-Molina, Andreas Paepcke, and Sriram Raghavan. Searching the web. ACM Transactions on Internet Technology (TOIT), 1(1):2–43, 2001.
  2. 2.Brenda S. Baker. On finding duplication and near-duplication in large software systems. In L. Wills, P. Newcomb, and E. Chikofsky, editors, Second Working Conference on Reverse Engineering, pages 86–95, Los Alamitos, California, 1995. IEEE Computer Society Press.
  3. 3.Brenda S. Baker and Udi Manber. Deducing similarities in java sources from bytecodes. In Proc. of Usenix Annual Technical Conf., pages 179–190, 1998.
  4. 4.Sergey Brin, James Davis, and Héctor García-Molina. Copy detection mechanisms for digital documents. In Proceedings of the ACM SIGMOD Conference, pages 398–409, 1995.
  5. 5.Andrei Broder. On the resemblance and containment of documents. In SEQS: Sequences ’91, 1998.
  6. 6.Andrei Broder, Steve Glassman, Mark Manasse, and Geoffrey Zweig. Syntactic clustering of the web. In Proceedings of the Sixth International World Wide Web Conference, pages 391–404, April 1997.
  7. 7.The Crystals. Da do run run, 1963.
  8. 8.Nevin Heintze. Scalable document fingerprinting. In 1996 USENIX Workshop on Electronic Commerce, November 1996.
  9. 9.James Joyce. Finnegans wake [1st trade ed.]. Faber and Faber (London), 1939.
  10. 10.Richard M. Karp and Michael O. Rabin. Pattern-matching algorithms. IBM Journal of Research and Development, 31(2):249–260, 1987.
  11. 11.Sergio Leone, Clint Eastwood, Eli Wallach, and Lee Van Cleef. The Good, the Bad and the Ugly / Il Buono, Il Brutto, Il Cattivo (The Man with No Name). Produzioni Europee Associate (Italy) Production, Distributed by United Artists (USA), 1966.
  12. 12.Udi Manber. Finding similar files in a large file system. In Proceedings of the USENIX Winter 1994 Technical Conference, pages 1–10, San Fransisco, CA, USA, 17–21 1994.
  13. 13.Peter Mork, Beitao Li, Edward Chang, Junghoo Cho, Chen Li, and James Wang. Indexing tamper resistant features for image copy detection, 1999. URL: citeseer.nj.nec.com/mork99indexing.html.
  14. 14.Narayanan Shivakumar and Héctor García-Molina. SCAM: A copy detection mechanism for digital documents. In Proceedings of the Second Annual Conference on the Theory and Practice of Digital Libraries, 1995.
  15. 15.Esko Ukkonen. On-line construction of suffix trees. Algorithmica, 14:249–260, 1995.
  16. 16.George K. Zipf. The Psychobiology of Language. Houghton Mifltm Co., 1935.

Citation

MLA
Schleimer, S., et al. “Winnowing”. Proceedings of the 2003 ACM SIGMOD International Conference on Management of Data, 2003, pp. 76–85, https://doi.org/10.1145/872757.872770.
APA
Schleimer, S., Wilkerson, D. S., & Aiken, A. (2003). Winnowing. Proceedings of the 2003 ACM SIGMOD International Conference on Management of Data, 76–85. https://doi.org/10.1145/872757.872770
Chicago
Schleimer, S., D. S. Wilkerson, and A. Aiken. 2003. “Winnowing”. Proceedings of the 2003 ACM SIGMOD International Conference on Management of Data, 76–85. https://doi.org/10.1145/872757.872770.
Harvard
Schleimer, S., Wilkerson, D.S. and Aiken, A. (2003) “Winnowing”, Proceedings of the 2003 ACM SIGMOD international conference on Management of data. ACM, pp. 76–85. Available at: https://doi.org/10.1145/872757.872770.
Vancouver
1. Schleimer S, Wilkerson DS, Aiken A (2003) Winnowing. In: Proceedings of the 2003 ACM SIGMOD international conference on Management of data. ACM, pp 76–85

BibTeX

@inproceedings{Schleimer_2003, series={SIGMOD/PODS03}, title={Winnowing: local algorithms for document fingerprinting}, url={http://dx.doi.org/10.1145/872757.872770}, DOI={10.1145/872757.872770}, booktitle={Proceedings of the 2003 ACM SIGMOD international conference on Management of data}, publisher={ACM}, author={Schleimer, Saul and Wilkerson, Daniel S. and Aiken, Alex}, year={2003}, month=June, pages={76–85}, collection={SIGMOD/PODS03} }
Metadata:Crossref

Access the Paper

This paper is available from its original source. Click below to access the PDF.

Open PDF