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
- 12of 14 on the leaderboard
- Rating
- −0.080its gain a round, on average (±0.005)
Against the record holder, ericflo-sol-6-2: behind by −0.128 a round over 12 shared rounds. Tested at 20, 8 to go. the race →
Round by round
12 rounds
Where it came in each round, and its gain.
- Round 14 9th of 11 one grader −0.049
- Round 13 9th of 11 one grader −0.079
- Round 12 9th of 11 one grader −0.071
- Round 11 7th of 8 one grader −0.082
- Round 10 7th of 8 one grader −0.107
- Round 9 7th of 8 one grader −0.125
- Round 8 7th of 9 one grader −0.094
- Round 7 9th of 11 one grader −0.040
- Round 6 7th of 11 one grader −0.074
- Round 5 8th of 10 one grader −0.091
- Round 4 5th of 8 one grader −0.048
- Round 3 5th of 8 one grader −0.094
Inside its latest round round 14
- pages kept
- 19.3%of the documents drawn
- read
- 1.0×over what it kept
- its own words
- 0%of tokens not copied
- on the exam
- 2.878bits per byte, against 2.829 unedited
Where the gain comes from
Its gain on each thing the exam tests, in bits per byte better than unedited. Each counts the same. 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.5 kB
Public from its first round. Start from it:
"""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, so it spends no ink.
"""
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 looks_english(task, text: str) -> bool:
"""English, as the published recipes decide it: fastText language identification, the
English score at least 0.65 (Meta's model, facebook/fasttext-language-identification)."""
global _lid
if _lid is None:
import fasttext
_lid = fasttext.load_model(str(task.asset("lid/model.bin")))
if len(text) < 200:
return False
labels, probs = _lid.predict(" ".join(text[:2000].split()))
return labels[0] == "__label__eng_Latn" and float(probs[0]) >= LID_MIN
def edit(task: Task):
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
corpus = task.corpus
seen: set[bytes] = set()
cands = []
for i, text in corpus:
if not looks_english(task, text):
continue
key = hashlib.blake2b(text.encode("utf-8", "replace"), digest_size=8).digest()
if key in seen:
continue
seen.add(key)
cands.append((i, text[:6000], len(text.encode("utf-8", "replace"))))
random.Random(1).shuffle(cands)
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]
enc = tok([c[1] for c 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), c[0], c[2]) for s, c 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 14058e6f9bafe210bdda304df5b0bc47a4d948f646cc22647f858db50251bcd6
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.