fineweb-edu v1
educational-value classifier (FineWeb-Edu), top of the ranking
FineWeb-Edu's recipe, rebuilt: English pages, exact duplicates dropped, ranked by the published educational-value classifier, the most educational kept. A reference: data made this way gave large models their best knowledge and reasoning scores.
- Rank
- 16of 17 on the leaderboard
- Rating
- −0.322its gain a round, on average, held nearer everyone's while its rounds are few (±0.007)
Against the record holder, fineweb2: behind by −0.383 a round over 4 shared rounds. Tested at 5, 1 to go. the race →
Round by round
4 rounds
Where it came in each round, and its gain.
Inside its latest round round 4
- pages kept
- 19.1%of the documents drawn
- read
- 1.0×over what it kept
- on the exam
- 1.449bits per byte, against 1.155 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.9 kB
Public from its first round. Start from it:
$ stet fork 284b4c55162a
"""FineWeb-Edu's filter, rebuilt as a reference curator.
FineWeb-Edu (Penedo et al., 2024) kept web pages that a classifier, trained on Llama-3-70B's
ratings of educational value (0 to 5), scored 3 or more. Models trained on it gained most on
knowledge and reasoning benchmarks. This curator uses that classifier, as published
(HuggingFaceFW/fineweb-edu-classifier):
1. English pages, exact duplicates dropped.
2. Each page's opening (512 tokens, as the classifier was trained) scored for educational
value, in a fixed random order until time is nearly up; a page not reached is not kept.
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. 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
BATCH = 64
RESERVE_SECONDS = 30
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):
corpus = task.corpus
lid(task) # loaded before task.map starts its workers, so that they share it
def english(i, text):
"""In a worker: an English page's key (the same for every copy of it) and its size."""
if not looks_english(task, text):
return None
raw = text.encode("utf-8", "replace")
return hashlib.blake2b(raw, digest_size=8).digest(), len(raw)
# Which pages are English is the part of this that a GPU cannot do, and every second of
# it is a second the classifier does not get: so on every core, and before PyTorch is
# loaded, by workers that have no use for it.
seen: set[bytes] = set()
cands = []
for i, found in task.map(english): # in page order: of two copies, the first is the one kept
if found is None or found[0] in seen:
continue
seen.add(found[0])
cands.append((i, found[1]))
random.Random(1).shuffle(cands)
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
device = task.device()
where = task.asset("fineweb-edu-classifier")
tok = AutoTokenizer.from_pretrained(where)
model = AutoModelForSequenceClassification.from_pretrained(where, dtype=torch.float16 if device == "cuda" else torch.float32).to(device).eval()
print(f"{len(cands):,} English pages; classifier on {device}, {task.time_left():.0f}s left", file=sys.stderr)
scored = []
with torch.inference_mode():
for b in range(0, len(cands), BATCH):
if task.time_left() < RESERVE_SECONDS:
break
part = cands[b : b + BATCH]
# A page's opening is read again here, a batch at a time: kept from the first pass,
# the openings of a round's English pages are gigabytes.
enc = tok([corpus.text(i)[:6000] for i, _ in part], truncation=True, max_length=512, padding=True, return_tensors="pt").to(device)
out = model(**enc).logits.squeeze(-1).float().tolist()
scored += [(round(s, 2), i, size) for s, (i, size) in zip(out, part, strict=True)] # two places: the same on any GPU
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):,} 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 284b4c55162a82ab7cd7b612be8f3531f27c1d78f6de5b3cb430f582fdcfc399
Files it fetches 1.5 GB in 7 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.