aligned-native-restoration v1
Exact-width passage restoration and context refill with constrained neighboring-passage swaps
Restores continuous source text, refills repeated contexts, and gives long passage openings more room.
- 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.7%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 14 files · 21.8 kB
Public from its first round. Start from it:
$ stet fork e91f5246372e
- context_refill.py9.6 kB
- continuity.py3.8 kB
- curator.py17.8 kB
- early_order.py6.4 kB
- lengths.py1.5 kB
- native_restore.py7.1 kB
- packing_blocks.py4.0 kB
- passage_order.py6.0 kB
- prose_selection.py3.9 kB
- repetition_detection.py4.9 kB
- restore_and_refill.py1.7 kB
- stet.toml1.3 kB
- teacher_rank.py3.0 kB
- technical_rehearsal.py7.4 kB
"""Detect cross-document repetition in fixed training contexts."""
from bisect import bisect_right
from collections import Counter, defaultdict
from functools import lru_cache
from urllib.parse import urlsplit
import numpy as np
SHINGLE = 5
BANDS = 4
ROWS_PER_BAND = 3
SIGNATURE_WIDTH = BANDS * ROWS_PER_BAND
def shingles(contexts):
contexts = np.asarray(contexts, dtype=np.uint64)
count = contexts.shape[-1] - SHINGLE + 1
values = contexts[..., :count].copy()
for offset in range(1, SHINGLE):
values *= np.uint64(0x9E3779B185EBCA87)
values += contexts[..., offset:offset + count]
return values
def summarize(tokens, context, steps):
rng = np.random.default_rng(42_713)
salts = rng.integers(0, np.iinfo(np.uint64).max, SIGNATURE_WIDTH, dtype=np.uint64)
signatures = np.empty((len(tokens), steps, SIGNATURE_WIDTH), dtype=np.uint64)
for begin in range(0, steps, 48):
end = min(steps, begin + 48)
block = tokens[:, begin * context:end * context].reshape(len(tokens), end - begin, context)
values = shingles(block)
for index, salt in enumerate(salts):
mixed = values ^ salt
mixed ^= mixed >> np.uint64(30)
mixed *= np.uint64(0xBF58476D1CE4E5B9)
mixed ^= mixed >> np.uint64(27)
mixed *= np.uint64(0x94D049BB133111EB)
mixed ^= mixed >> np.uint64(31)
signatures[:, begin:end, index] = mixed.min(axis=-1)
return signatures
def bands(vector):
for start in range(0, SIGNATURE_WIDTH, ROWS_PER_BAND):
yield start, vector[start:start + ROWS_PER_BAND].tobytes()
def matches(tokens, scale, signatures):
early_end = round(0.53 * scale.steps)
late_begin = round(0.54 * scale.steps)
early = defaultdict(list)
for lane in range(scale.batch_size):
for step in range(early_end):
for key in bands(signatures[lane, step]):
listed = early[key]
if len(listed) < 8:
listed.append((lane, step))
@lru_cache(maxsize=300)
def actual(lane, step):
return set(shingles(tokens[lane, step * scale.ctx:(step + 1) * scale.ctx]).tolist())
report = []
for lane in range(scale.batch_size):
for step in range(late_begin, scale.steps):
vector = signatures[lane, step]
options = {loc for key in bands(vector) for loc in early.get(key, ())}
best = None
for earlier in sorted(options):
if np.count_nonzero(vector == signatures[earlier]) < 5:
continue
first, second = actual(*earlier), actual(lane, step)
overlap = len(first & second) / len(first | second)
if overlap >= 0.40 and (best is None or overlap > best[0]):
best = overlap, earlier
if best:
overlap, (previous_lane, previous_step) = best
report.append([lane, step, previous_lane, previous_step, round(overlap, 6)])
return report, scale.batch_size * (scale.steps - late_begin)
def source_at(context_start, context, offsets, lane, widths):
middle = context_start + context // 2
slot = lane[bisect_right(offsets, middle) - 1]
overlap = min(slot.offset + widths[slot.row], context_start + context) - max(slot.offset, context_start)
return slot if overlap >= 0.70 * context else None
def identify(corpus, scale, rows, lanes, widths, findings):
by_type, targets, windows = Counter(), Counter(), defaultdict(list)
offsets = [[slot.offset for slot in lane] for lane in lanes]
hosts = {}
def source(lane, step):
return source_at(step * scale.ctx, scale.ctx, offsets[lane], lanes[lane], widths)
def host(doc):
if doc not in hosts:
hosts[doc] = (urlsplit(corpus.urls[doc]).hostname or "").lower().removeprefix("www.")
return hosts[doc]
for late_lane, late_step, early_lane, early_step, overlap in findings:
early, late = source(early_lane, early_step), source(late_lane, late_step)
if early is None or late is None or not all(isinstance(rows[slot.row], dict) and "d" in rows[slot.row]
for slot in (early, late)):
by_type["mixed_context"] += 1
continue
left, right = rows[early.row]["d"], rows[late.row]["d"]
if left == right:
by_type["same_document"] += 1
continue
relation = "same_site" if host(left) == host(right) else "different_sites"
by_type[relation] += 1
if overlap >= 0.65:
targets[late.row] += 1
context_start = late_step * scale.ctx
# Positions include the delimiter at the start of each document.
if late.offset < context_start and context_start + scale.ctx <= late.offset + widths[late.row]:
windows[late.row].append(context_start - late.offset - 1)
return by_type, targets, windows
download bundle (.tar.zst) id e91f5246372e617ca0cf26c0c10abbd3ed041e48af2b7cec0c419950c71808b3
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 |