early-phrase-coverage v1
Cross-site phrase counts and equal-token curriculum swaps within language and writing form
Moves passages with reusable phrases earlier in training while preserving every selected page.
- Rank
- not yet1 of the 3 rounds it needs to be ranked
- Rating
- +0.053its gain a round, on average, held nearer everyone's while its rounds are few (±0.014)
Against the record holder, fineweb2: ahead by +0.010 a round over 1 shared round. Tested at 5, 4 to go. the race →
Round by round
1 round
Where it came in each round, and its gain.
Inside its latest round round 11
- pages kept
- 14.6%of the documents drawn
- read
- 1.0×over what it kept
- on the exam
- 1.085bits per byte, against 1.149 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 10 files · 16.3 kB
Public from its first round. Start from it:
$ stet fork dff6832d6a78
- continuity.py3.8 kB
- curator.py17.6 kB
- early_order.py6.4 kB
- lengths.py1.5 kB
- packing_blocks.py4.0 kB
- phrase_order.py6.3 kB
- prose_selection.py3.9 kB
- stet.toml1.3 kB
- teacher_rank.py3.0 kB
- technical_rehearsal.py7.4 kB
"""Select a second exposure to native technical examples at exact-width positions."""
import heapq
import math
import re
from collections import Counter, defaultdict
from itertools import batched
from types import SimpleNamespace
from stet.script import build_doc
from stet.spec import load_season
from stet.tok import encode_batch, load_encoding
from curator import COMMAND, NUMERIC, PROGRAM, find_genre, host_of, language_of
from lengths import CountedPages
FORMS = {"code": PROGRAM, "shell": COMMAND, "quantitative": NUMERIC}
SUPPORTED = {*FORMS, "technical"}
BUCKET = 64
EXPLANATION = re.compile(rb"[.!?](?:[ \t]|$)")
INLINE_EXAMPLE = re.compile(rb"`[^`\n]{3,72}`|^\s{0,6}(?:\$ |>>> )\S")
def example_quality(raw, genre):
pattern = FORMS.get(genre, INLINE_EXAMPLE)
lines = [line.strip() for line in raw.splitlines() if line.strip()]
structured = [(index, line) for index, line in enumerate(lines) if pattern.search(line)]
if not structured:
return 0.0
prose = [len(line) >= 70 and bool(EXPLANATION.search(line)) for line in lines]
explained = sum(
any(prose[neighbor] for neighbor in range(max(0, index - 2), min(len(lines), index + 3))
if neighbor != index)
for index, _ in structured
)
distinct = len({line for _, line in structured})
return math.log1p(distinct) + 1.1 * math.log1p(explained) - 0.4 * math.log1p(len(structured) - distinct)
def describe(corpus, season, rows, encoding, detector, widths=None, time_left=None):
pages, measured = [], []
limits = season.raw["script"]
bounds = season.min_copy_bytes, int(limits["max_segments"]), int(limits["max_out_doc_bytes"])
for batch in batched(enumerate(rows, start=1), 128):
if time_left and time_left() < 18:
return None, None
bodies = []
for index, row in batch:
body = build_doc(corpus, index, row, *bounds).data
text = body.decode("utf-8", errors="replace")
bodies.append(text)
if "d" not in row or "k" not in row or not 650 <= len(body) <= 19_000:
pages.append(None)
continue
url = corpus.urls[row["d"]].lower()
middle = len(body) // 2
sample = body[:4_000] + (b"\n" + body[middle:middle + 2_500] if len(body) > 7_500 else b"")
genre, _ = find_genre(sample, url, body.count(b"\n"))
if genre not in SUPPORTED:
pages.append(None)
continue
language = language_of(text, detector)
pages.append((language, genre, host_of(url), example_quality(body, genre)))
if widths is None:
measured.extend(1 + len(tokens) for tokens in encode_batch(encoding, bodies))
return pages, measured if widths is None else widths
def pack_positions(widths, lane_count, lane_len):
ends = [(0, lane) for lane in range(lane_count)]
positions = []
for index, width in enumerate(widths):
offset, lane = heapq.heappop(ends)
positions.append((index, offset))
heapq.heappush(ends, (offset + width, lane))
if ends[0][0] >= lane_len:
return positions
return None
def rehearse(corpus, scale, rows, pages, widths, encoding, time_left=None):
lane_len = scale.steps * scale.ctx + 1
positions = pack_positions(widths, scale.batch_size, lane_len)
if positions is None:
return rows, 0, Counter(), 0, 0
earliest, latest = round(0.04 * scale.steps) * scale.ctx, round(0.48 * scale.steps) * scale.ctx
after = round(0.55 * scale.steps) * scale.ctx
early_docs, late = defaultdict(list), []
for index, offset in positions:
page, width = pages[index], widths[index]
if page is None or not 220 <= width <= 4_200:
continue
language, genre, _, quality = page
if earliest <= offset and offset + width <= latest and quality >= 1.65:
early_docs[language, genre, width // BUCKET].append(index)
elif offset >= after and offset + width < lane_len:
late.append(index)
for group in early_docs.values():
group.sort(key=lambda index: (-pages[index][3], index))
measured = CountedPages(corpus, encoding)
result, donors = list(rows), set()
per_host, volume = Counter(), Counter()
max_tokens = int(scale.train_tokens * 0.018)
swaps = 0
for target in sorted(late, key=lambda index: (pages[index][1] == "quantitative", pages[index][3], index)):
if time_left and time_left() < 12:
break
language, genre, host, quality = pages[target]
width = widths[target]
used_tokens = sum(volume.values())
if used_tokens + width - 1 > max_tokens:
continue
quantitative = genre == "quantitative"
if quantitative and volume[genre] + width - 1 > 1.25 * (used_tokens - volume[genre]):
continue
margin = 0.70 if quantitative else 0.55
upper = int(width * (1.08 if quantitative else 1.18))
candidates = [index for bucket in range(width // BUCKET, upper // BUCKET + 1)
for index in early_docs.get((language, genre, bucket), ())
if index not in donors and width <= widths[index] <= upper
and pages[index][2] != host and per_host[pages[index][2]] < 12
and pages[index][3] >= quality + margin]
candidates.sort(key=lambda index: (-pages[index][3], widths[index] - width, index))
for index in candidates[:16]:
row = rows[index]
page = SimpleNamespace(doc=row["d"], ranges=row["k"])
ranges = row["k"] if widths[index] == width else measured.fit(page, width - 1)
if not ranges:
continue
copied = {"d": row["d"], "k": [list(span) for span in ranges]}
if widths[index] != width:
raw = corpus.raw(row["d"])
kept = b"".join(raw[left:right] for left, right in ranges)
if example_quality(kept, genre) < quality + margin:
continue
result[target] = copied
donors.add(index)
per_host[pages[index][2]] += 1
volume[genre] += width - 1
swaps += 1
break
return result, swaps, volume, len(late), sum(map(len, early_docs.values()))
def apply(task, selected, sizes, detector, prose):
if task.time_left() < 55:
return
student = task.info["student"]
steps = task.train_tokens // (student["batch_size"] * student["ctx"])
scale = SimpleNamespace(steps=steps, batch_size=student["batch_size"], ctx=student["ctx"],
train_tokens=task.train_tokens)
season = load_season(task.info["season"])
encoding = load_encoding(season)
rows = [{"d": page.doc, "k": [list(span) for span in page.ranges]} for page in selected]
pages, widths = describe(task.corpus, season, rows, encoding, detector, sizes, task.time_left)
if pages is None:
return
repeated, _, _, _, _ = rehearse(task.corpus, scale, rows, pages, widths, encoding, task.time_left)
combined = [prose.get(index, row) for index, row in enumerate(repeated)]
intact_replays = sum(left != right and index not in prose
for index, (left, right) in enumerate(zip(rows, repeated, strict=True)))
if intact_replays:
print(f"Added {intact_replays:,} earlier technical examples to late training slots", flush=True)
task.write(combined)
download bundle (.tar.zst) id dff6832d6a789152c78bb445ba86645da8f2c3625af464c49261ba43894b4e6f
Files it fetches 112.9 MB in 4 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 |
|---|---|---|---|
| language/lid.176.ftz | 916.0 kB | 8f3472cfe873 | https://huggingface.co/julien-c/fasttext-language-id/resolve/9f2e94d2fd6b2615d26f5ec5b34cf7e2f38cb86e/lid.176.ftz |
| difficulty/early.safetensors | 56.0 MB | f828164714bf | https://huggingface.co/ericflo/stet-matched-student-pace/resolve/a11215d67107307d0e76180494f41755edf4917d/early.safetensors |
| difficulty/mature.safetensors | 56.0 MB | 64c2afc22042 | https://huggingface.co/ericflo/stet-matched-student-pace/resolve/a11215d67107307d0e76180494f41755edf4917d/mature.safetensors |
| difficulty/calibration.json | 170 B | 3be8effd9fd9 | https://huggingface.co/ericflo/stet-matched-student-pace/resolve/a11215d67107307d0e76180494f41755edf4917d/calibration.json |
| total | 112.9 MB |