dclm v1
fastText quality classifier (OH-2.5 + ELI5 vs web), top of the ranking
DCLM-Baseline's recipe, rebuilt: English pages, exact duplicates dropped, ranked by the published fastText classifier (OpenHermes 2.5 and ELI5 against random web), the top kept. A reference: the best published filter for 1B to 7B models.
- Rank
- 15of 17 on the leaderboard
- Rating
- −0.299its gain a round, on average, held nearer everyone's while its rounds are few (±0.004)
Against the record holder, fineweb2: behind by −0.356 a round over 11 shared rounds. Tested at 20, 9 to go. the race →
Round by round
11 rounds
Where it came in each round, and its gain.
- Round 11 7th of 7 one grader −0.262
- Round 10 6th of 6 one grader −0.258
- Round 9 6th of 6 one grader −0.275
- Round 8 7th of 7 one grader −0.282
- Round 7 7th of 7 one grader −0.296
- Round 6 7th of 7 one grader −0.319
- Round 5 6th of 7 one grader −0.343
- Round 4 6th of 6 one grader −0.310
- Round 3 9th of 11 one grader −0.319
- Round 2 10th of 11 one grader −0.326
- Round 1 6th of 8 one grader −0.302
Inside one of its rounds round 9
- pages kept
- 19.7%of the documents drawn
- read
- 1.0×over what it kept
- on the exam
- 1.434bits per byte, against 1.159 unedited
Where the gain comes from
Its gain on each part of the exam, in bits per byte better than unedited. The kinds of writing are three quarters of the score, the skills one quarter. Right is better.
The model, learning from it
Training loss on its pages. Low here is not the goal; the exam is.
Its code 2 files · 2.2 kB
Public from its first round. Start from it:
$ stet fork 8b5d3d8b655a
"""DCLM-Baseline's filter, rebuilt as a reference curator.
DataComp-LM (Li et al., 2024) found that the best filter for its 1B to 7B models was a
fastText classifier telling instruction-style text (OpenHermes 2.5, and highly rated ELI5
answers) from random web pages, keeping the top tenth. This curator uses that classifier, as
published (mlfoundations/fasttext-oh-eli5):
1. English pages, exact duplicates dropped.
2. Each page scored by the classifier's probability that it is the instruction-style kind.
3. The best pages kept until the training budget is filled once, in a fixed random order.
It is a reference, not an entry to beat. An exam is checked by whether it puts this, and
FineWeb-Edu's filter, above heuristic filtering, and that above raw crawl text, as the
published results did. Whole pages only: every line of its script is a page as it is.
"""
import hashlib
import random
import sys
from stet.curator import Task
BYTES_PER_TOKEN = 3.7
LID_MIN = 0.65 # RefinedWeb's and FineWeb's threshold for English
_lid = None
def lid(task):
"""Meta's language identification model (facebook/fasttext-language-identification), loaded
the first time it is asked for. Ask before task.map starts its workers and they share the
one copy; left to load it themselves, each would hold a gigabyte of its own."""
global _lid
if _lid is None:
import fasttext
_lid = fasttext.load_model(str(task.asset("lid/model.bin")))
return _lid
def looks_english(task, text: str) -> bool:
"""English, as the published recipes decide it: fastText language identification, the
English score at least 0.65."""
if len(text) < 200:
return False
labels, probs = lid(task).predict(" ".join(text[:2000].split()))
return labels[0] == "__label__eng_Latn" and float(probs[0]) >= LID_MIN
def edit(task: Task):
import fasttext
# Both models are loaded here, before task.map starts its workers: 3.6 GB that every
# worker reads and none of them copies.
model = fasttext.load_model(str(task.asset("dclm-fasttext/openhermes_reddit_eli5_vs_rw_v2_bigram_200k_train.bin")))
lid(task)
print(f"classifier loaded, {task.time_left():.0f}s left", file=sys.stderr)
def judge(i, text):
"""In a worker: an English page's key (the same for every copy of it), score and size."""
if not looks_english(task, text):
return None
raw = text.encode("utf-8", "replace")
labels, probs = model.predict(" ".join(text.split())[:100_000])
p = float(probs[0]) if labels[0] == "__label__hq" else 1.0 - float(probs[0])
return hashlib.blake2b(raw, digest_size=8).digest(), round(p, 4), len(raw)
seen: set[bytes] = set()
scored = []
for i, found in task.map(judge): # in page order: of two copies, the first is the one kept
if found is None or found[0] in seen:
continue
key, p, size = found
seen.add(key)
scored.append((p, i, size))
scored.sort(key=lambda t: (-t[0], t[1]))
budget, used, chosen = task.train_tokens * BYTES_PER_TOKEN, 0, []
for _, i, size in scored:
if used >= budget:
break
chosen.append(i)
used += size
print(f"{len(scored):,} English pages scored, {len(chosen):,} kept", file=sys.stderr)
random.Random(0).shuffle(chosen)
return chosen
def main():
task = Task.from_env()
task.write(edit(task))
if __name__ == "__main__":
main()
download bundle (.tar.zst) id 8b5d3d8b655a98a19d79d9a954c13264245732af10b31faf6e6bd2f3cd33799b
Files it fetches 3.3 GB in 2 files
Too large for the bundle, so named in it by address and hash. Every machine that runs it downloads each one and checks its sha256 before the curator starts, and the curator still has no network.
| Path | Size | sha256 | From |
|---|---|---|---|
| dclm-fasttext/openhermes_reddit_eli5_vs_rw_v2_bigram_200k_train.bin | 2.2 GB | f8da53846636 | https://huggingface.co/mlfoundations/fasttext-oh-eli5/resolve/cd8b714a90f2dbcd3b02cf5fc972e5d7c7f4f107/openhermes_reddit_eli5_vs_rw_v2_bigram_200k_train.bin |
| lid/model.bin | 1.1 GB | 8ded5749a2ad | https://huggingface.co/facebook/fasttext-language-identification/resolve/3af127d4124fc58b75666f3594bb5143b9757e78/model.bin |
| total | 3.3 GB |