← Leaderboard
tidy v1
prose-line ranges + dedup + crude quality rank, shuffled
English prose only, exact duplicates dropped, navigation and boilerplate lines cut out of each page, the best budget's worth kept, shuffled. No model, no GPU.
- Rank
- 13of 14 on the leaderboard
- Rating
- −0.146its gain a round, on average (±0.006)
Against the record holder, ericflo-sol-6-2: behind by −0.191 a round over 13 shared rounds. Tested at 20, 7 to go. the race →
Round by round
14 rounds
Where it came in each round, and its gain.
- Round 14 11th of 11 one grader −0.185
- Round 13 11th of 11 one grader −0.116
- Round 12 11th of 11 one grader −0.125
- Round 11 8th of 8 one grader −0.123
- Round 10 8th of 8 one grader −0.126
- Round 9 8th of 8 one grader −0.169
- Round 8 9th of 9 one grader −0.172
- Round 7 10th of 11 one grader −0.114
- Round 6 10th of 11 one grader −0.163
- Round 5 9th of 10 one grader −0.139
- Round 4 7th of 8 one grader −0.142
- Round 3 7th of 8 one grader −0.146
- Round 2 5th of 6 one grader −0.148
- Round 1 3rd of 3 one grader −0.173
Inside its latest round round 14
- pages kept
- 28.6%of the documents drawn
- read
- 1.2×over what it kept
- its own words
- 0%of tokens not copied
- on the exam
- 3.015bits 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.0 kB
Public from its first round. Start from it:
"""An afternoon of heuristics: the baseline a serious entry should beat.
1. Keep English prose.
2. Drop exact duplicates.
3. Inside each document, cut lines that look like navigation or boilerplate.
4. Rank what is left by a crude "is this explanatory prose" score.
5. Keep the best documents until the training budget is filled once, and shuffle them.
No model, no GPU, a few seconds per shard. Everything here is a cut of at least
min_copy_bytes, so it spends no ink.
"""
import hashlib
import random
import re
from stet.curator import Task
SENTENCE_END = re.compile(r"[.!?][\"')\]]?\s")
STOPWORDS = (" the ", " of ", " and ", " to ", " in ", " is ", " that ", " for ")
# Rough, for English prose under the season 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_english(text: str) -> bool:
sample = text[:3000]
if len(sample) < 200:
return False
letters = sum(c.isascii() and (c.isalpha() or c == " ") for c in sample)
if letters / len(sample) < 0.75:
return False
low = sample.lower()
return sum(low.count(w) for w in STOPWORDS) >= max(4, len(sample) // 300)
def prose_ranges(text: str, min_copy: int = 64) -> tuple[list[list[int]], int]:
"""Byte ranges of the lines worth keeping, and how many bytes they hold."""
ranges: list[list[int]] = []
pos = 0
for line in text.split("\n"):
n = len(line.encode("utf-8")) + 1 # + the newline
body = line.strip()
words = body.count(" ") + 1
is_prose = len(body) >= 60 and words >= 10 and (SENTENCE_END.search(body + " ") is not None)
if is_prose:
if ranges and ranges[-1][1] == pos:
ranges[-1][1] = pos + n
else:
ranges.append([pos, pos + n])
pos += n
# A kept run shorter than min_copy bytes would be charged as ink. Drop those.
ranges = [r for r in ranges if r[1] - r[0] >= min_copy + 4]
return ranges, sum(b - a for a, b in ranges)
def score(text: str, kept: int) -> float:
"""Higher is better. Rewards documents that are mostly prose and long enough to say something."""
total = max(1, len(text.encode("utf-8")))
density = kept / total
length = min(1.0, kept / 3000)
low = text[:4000].lower()
explains = sum(low.count(w) for w in (" because ", " therefore ", " however ", " for example ", " which ", " whereas "))
sells = sum(low.count(w) for w in (" buy ", " price", " shipping", " cart", " sale", " click ", " subscribe", " cookies"))
return density * 1.0 + length * 1.0 + min(explains, 8) * 0.08 - min(sells, 8) * 0.1
def edit(task: Task):
corpus = task.corpus
min_copy = int(task.info.get("min_copy_bytes", 64))
seen: set[bytes] = set()
scored = []
for i, text in corpus:
if not looks_english(text):
continue
ranges, kept = prose_ranges(text, min_copy)
if kept < 400:
continue
key = hashlib.blake2b(text[:2000].encode("utf-8", "replace"), digest_size=8).digest()
if key in seen:
continue
seen.add(key)
size = corpus.size(i)
# Clamp to the document: the last line may not end in a newline.
ranges = [[a, min(b, size)] for a, b in ranges if a < size and min(b, size) - a >= min_copy]
scored.append((score(text, kept), i, ranges, kept))
scored.sort(key=lambda t: -t[0])
budget_bytes = task.train_tokens * BYTES_PER_TOKEN
chosen = []
used = 0
for _, i, ranges, kept in scored:
if used >= budget_bytes:
break
chosen.append({"d": i, "k": ranges})
used += kept
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 b82597376e3b604cd7daef4b0e0cd66e1c74934fa81db51407988e8d1e7b9c03