---
title: "Large-scale Near-deduplication Behind BigCode"
description: "BigCode deduplicates massive code and text corpora for LLM training with MinHash plus locality-sensitive hashing: word n-gram shingles, permuted-hash fingerprints, banding into LSH buckets, then clustering candidate pairs into connected components."
url: "https://swe.quest/articles/large-scale-near-deduplication-behind-bigcode-db7192844c316bd2"
canonical: "https://huggingface.co/blog/dedup"
source: "Hugging Face"
published: "2023-05-16"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 18
tags: ["data-pipelines","model-training","algorithms","llms"]
---

# Large-scale Near-deduplication Behind BigCode

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2023-05-16, 18 min read, Deep dive. Original: [https://huggingface.co/blog/dedup](https://huggingface.co/blog/dedup)

## Summary

BigCode deduplicates massive code and text corpora for LLM training with MinHash plus locality-sensitive hashing: word n-gram shingles, permuted-hash fingerprints, banding into LSH buckets, then clustering candidate pairs into connected components. Experiments on The Stack showed that treating all LSH candidate pairs as duplicates, without verifying exact Jaccard similarity, gave the best downstream model performance and saved time. For clustering, a union-find structure works for medium datasets. At larger scale the pipeline moves to Spark, using distributed groupBy and a connected-components algorithm, while keeping a Datasketch-compatible hashing implementation. Parameter tables compare deduplication setups across datasets such as C4, ROOTS, CodeParrot and The Stack.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)
- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- hashing basics
- Jaccard similarity
- graph connected components
- LLM training data ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))

## Keywords

MinHash, Locality Sensitive Hashing, BigCode, The Stack, Datasketch, Apache Spark, BigScience, union-find

## Related posts

- [Training CodeParrot 🦜 from Scratch](https://swe.quest/articles/training-codeparrot-from-scratch-20fa62d39adc1089.md): Hugging Face · 2021-12-08 · Medium · 11 min read · Model training, LLMs, AI for coding, Python
  CodeParrot is a GPT-2 model (110M and 1.5B parameters) trained from scratch for Python code completion, using a 180 GB GitHub Python dump from BigQuery.
- [tokenizers v1: encode, decode and scaling, measured](https://swe.quest/articles/tokenizers-v1-encode-decode-and-scaling-measured-49d0c7f94c7739e1.md): Hugging Face · 2026-09-21 · Medium · 10 min read · Performance engineering, Rust, LLMs, Algorithms
  tokenizers v1 encodes text 3 to 30 times faster than v0.23 single-threaded on an Apple M4 Max and scales at 76% of linear across eight cores, while producing identical token IDs and keeping the same API.
- [StarCoder: A State-of-the-Art LLM for Code](https://swe.quest/articles/starcoder-a-state-of-the-art-llm-for-code-ae224d2374e67db4.md): Hugging Face · 2023-05-04 · Easy · 5 min read · LLMs, AI for coding, Evaluation, Open source
  StarCoder and StarCoderBase are ~15B-parameter code LLMs trained on 1 trillion tokens of permissively licensed GitHub data from The Stack 1.2, covering 80+ languages, commits, issues and notebooks, with StarCoder further fine-tuned on 35B Python tokens.
- [Huggy Lingo: Using Machine Learning to Improve Language Metadata on the Hugging Face Hub](https://swe.quest/articles/huggy-lingo-using-machine-learning-to-improve-language-metadata-on-the-hugging-c4b326d3f2e50ea0.md): Hugging Face · 2023-08-02 · Medium · 8 min read · Machine learning, Data pipelines, Search
  Roughly 87% of the ~50K public datasets on the Hugging Face Hub lack language metadata, so Hugging Face samples 20 rows from likely text columns via the dataset viewer API and runs Meta's fastText language-identification model (217 languages) on each row.
- [Building LLMs for Code Repair](https://swe.quest/articles/building-llms-for-code-repair-56ef089519b9fe77.md): Replit · 2024-04-02 · Hard · 14 min read · Model training, AI for coding, LLMs, Evaluation, Data pipelines
  Replit finetuned a 7B code model (DeepSeek-Coder-Instruct-v1.5) to repair Python errors flagged by LSP diagnostics.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
