Rounds paused
← Leaderboard

tidy v1

by stet entered 22 Nov 2026 entered by the organisers

sentence-line count + dedup + crude quality rank, whole pages, shuffled

Pages that read as writing, in any language: exact duplicates dropped, ranked by how much of each page is sentences, the best kept whole, shuffled. No model, no GPU.

Rank
12of 17 on the leaderboard
Rating
+0.040its gain a round, on average, held nearer everyone's while its rounds are few (±0.007)

Against the record holder, fineweb2: behind by −0.023 a round over 4 shared rounds. Tested at 5, 1 to go. the race →

Inside one of its rounds round 1
pages kept
9.3%of the documents drawn
read
1.0×over what it kept
on the exam
1.101bits per byte, against 1.137 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.

bits per byte better than unedited−0.050.000.050.10reference+0.054news+0.091technical+0.001conversation+0.070agents−0.032reading−0.045logic+0.012grammar+0.012numbers−0.047programs−0.007knowledge−0.004

The model, learning from it

Training loss on its pages. Low here is not the goal; the exam is.

246810training loss, bits per tokenstep 48step 9,696

who ran and graded it in round 1 →

Its code 2 files · 2.8 kB

Public from its first round. Start from it:

$ stet fork 126c85671411
"""An afternoon of heuristics: the baseline a serious entry should beat.

  1. Keep pages that read as writing, in whatever language they are written.
  2. Drop exact duplicates.
  3. Count how much of each page is writing: the lines long enough to be a sentence, with
     the end of one in them.
  4. Rank the pages by that.
  5. Keep the best pages, whole, until their writing fills the training budget once, and
     shuffle them.

No model, no GPU, a few seconds per shard, on every core it is given (task.map).

It copies its pages whole. It used to keep only the lines it counted as writing, and the two
were trained side by side on the same pages in four orders: whole pages did better each time,
by 0.03 bits per byte on the exam's writing, nearly all of it on technical writing and code,
whose lines are not sentences (docs/EXPERIMENTS.md). The lines still say which pages to keep.

The exam is written in every language of the crawl, each counting by its share of it. So
nothing here asks what language a page is in: a rule that only English can pass throws away
more than half of what the student is examined on.
"""

import hashlib
import random
import re
import unicodedata

from stet.curator import Task

# How a sentence ends: in scripts written with spaces, a mark and then a space; in Chinese and
# Japanese, the mark alone.
SENTENCE_END = re.compile(r"[.!?…؟۔।][\"')\]”’»]?\s|[。!?。]")
SPACELESS = re.compile("[぀-ヿ一-鿿฀-๿]")  # kana, Chinese characters, Thai
# The vowel signs of Hindi, Thai and Arabic are marks and not letters: they count as part of
# the letters they sit on. (Asking each character in turn is a hundred times slower, and a
# round's pages are gigabytes.)
MARKS = "".join(c for c in map(chr, range(0x300, 0x10000)) if unicodedata.category(c)[0] == "M")
WRITING = re.compile(rf"(?:[^\W\d_]|\s|[{re.escape(MARKS)}])+")  # letters of any script, spaces and marks
# Rough, under the season's tokenizer, and on the generous side: a stream that runs over the
# budget is cut off, one that falls short repeats from the top.
BYTES_PER_TOKEN = 3.7


def looks_written(text: str) -> bool:
    """Mostly letters, of any script, and enough of them to say something."""
    sample = text[:3000]
    if len(sample) < 200:
        return False
    return len(WRITING.sub("", sample)) <= 0.25 * len(sample)


def spaceless(text: str) -> bool:
    """Written without spaces between words, so that a line's length is counted in characters."""
    sample = text[:2000]
    return len(SPACELESS.findall(sample)) > 0.3 * len(sample)


def prose_ranges(raw: bytes, dense: bool) -> tuple[list[list[int]], int]:
    """Byte ranges of the lines that read as writing, each a whole line with its line break,
    and how many bytes they hold. A line counts when it is long enough to be a sentence and
    has the end of one in it. tidy ranks pages by the count; the ranges are for a curator that
    wants the lines themselves ({"d": page, "k": ranges} keeps them and nothing else)."""
    ranges: list[list[int]] = []
    pos = 0
    least = 25 if dense else 60
    for line in raw.split(b"\n"):
        n = len(line) + 1  # + the line break
        if n <= least:  # too few bytes to be that many characters: most of a page's furniture
            pos += n
            continue
        body = line.decode("utf-8", "replace").strip()
        long_enough = len(body) >= least and (dense or body.count(" ") >= 9)
        if long_enough and SENTENCE_END.search(body + " "):
            if ranges and ranges[-1][1] == pos:
                ranges[-1][1] = pos + n
            else:
                ranges.append([pos, pos + n])
        pos += n
    if ranges and ranges[-1][1] > len(raw):  # the last line may have no line break
        ranges[-1][1] = len(raw)
    return ranges, sum(b - a for a, b in ranges)


def score(size: int, kept: int) -> float:
    """Higher is better: a page that is mostly writing, and long enough to say something."""
    return kept / max(1, size) + min(1.0, kept / 3000)


def edit(task: Task):
    corpus = task.corpus

    def judge(i, text):
        """In a worker: how many bytes of this page are writing, and a key that is the same
        for every copy of it. None for a page that is not writing, or too little of it."""
        if not looks_written(text):
            return None
        _, kept = prose_ranges(corpus.raw(i), spaceless(text))
        if kept < 400:
            return None
        return kept, hashlib.blake2b(text[:2000].encode("utf-8", "replace"), digest_size=8).digest()

    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[1] in seen:
            continue
        kept, key = found
        seen.add(key)
        scored.append((score(corpus.size(i), kept), i, kept))

    scored.sort(key=lambda t: (-t[0], t[1]))
    budget_bytes = task.train_tokens * BYTES_PER_TOKEN
    chosen = []
    used = 0
    for _, i, kept in scored:
        if used >= budget_bytes:
            break
        chosen.append(i)
        used += kept
    # The budget was counted in bytes of writing and the pages are copied whole, so these are
    # more pages than the student reads once: the stream is cut off at the budget, and what
    # is trained on is a shuffled part of the best pages. (Only as many of the top-ranked
    # pages as fill the budget did worse, both times it was tried.)
    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 126c8567141193cde3c7d44e656877b34bf11d5806b8af74782656b59327e222