claude-opus-4-8
nano-gpt-data-curation — graded by the task's verifier against a measured baseline.
- backend
- modal
- variant
- claude claude-opus-4-8
- metric
- held-out multi-domain perplexity
- actions
- 87
- duration
- 1h 21m
- recorded
- 2026-08-04
run iddclm-nano-curation__7umcSHc
Everything claude-opus-4-8 did on this task, in order.
download JSON ↗I'll start by understanding the environment, time budget, and available resources.
args
{
"command": "cat /workspace/.timer/remaining_secs 2>/dev/null; echo \"---TIMER---\"; ls -la /workspace/; echo \"---DATA---\"; ls -la /workspace/data/; echo \"---SUBMISSION---\"; ls -la /workspace/submission/ 2>/dev/null; echo \"---GPU---\"; nvidia-smi --query-gpu=name,memory.total,memory.used --format=csv 2>/dev/null",
"description": "Check timer, list files, check GPU"
}Bash result
5390
---TIMER---
total 14
drwxr-xr-x 1 root root 100 Aug 4 04:31 .
drwxr-xr-x 1 root root 160 Aug 4 04:31 ..
drwxr-xr-x 1 root root 60 Aug 4 04:31 .live
drwxr-xr-x 1 root root 100 Aug 4 04:31 .metrics
drwxr-xr-x 1 root root 140 Aug 4 04:31 .timer
drwxr-xr-x 1 root root 57 Aug 3 22:37 data
-rwxrwxr-x 1 root root 714 Aug 3 22:34 dev_eval.sh
-rw-rw-r-- 1 root root 5706 Aug 3 22:34 model.py
-rw-rw-r-- 1 root root 869 Aug 3 22:34 pack_selection.py
drwxr-xr-x 1 root root 10 Aug 3 22:37 submission
-rwxrwxr-x 1 root root 1509 Aug 3 22:34 timer.sh
-rw-rw-r-- 1 root root 2962 Aug 3 22:34 train_nano.py
---DATA---
total 792657
drwxr-xr-x 1 root root 57 Aug 3 22:37 .
drwxr-xr-x 1 root root 100 Aug 4 04:31 ..
-r--r--r-- 1 root root 2000128 Aug 3 22:34 multi_dev.npy
-r--r--r-- 1 root root 809679384 Aug 3 22:35 pool.jsonl
---SUBMISSION---
total 1
drwxr-xr-x 1 root root 10 Aug 3 22:37 .
drwxr-xr-x 1 root root 100 Aug 4 04:31 ..
---GPU---
name, memory.total [MiB], memory.used [MiB]
NVIDIA H100 80GB HBM3, 81559 MiB, 4 MiB
[stdout]
5390
---TIMER---
total 14
drwxr-xr-x 1 root root 100 Aug 4 04:31 .
drwxr-xr-x 1 root root 160 Aug 4 04:31 ..
drwxr-xr-x 1 root root 60 Aug 4 04:31 .live
drwxr-xr-x 1 root root 100 Aug 4 04:31 .metrics
drwxr-xr-x 1 root root 140 Aug 4 04:31 .timer
drwxr-xr-x 1 root root 57 Aug 3 22:37 data
-rwxrwxr-x 1 root root 714 Aug 3 22:34 dev_eval.sh
-rw-rw-r-- 1 root root 5706 Aug 3 22:34 model.py
-rw-rw-r-- 1 root root 869 Aug 3 22:34 pack_selection.py
drwxr-xr-x 1 root root 10 Aug 3 22:37 submission
-rwxrwxr-x 1 root root 1509 Aug 3 22:34 timer.sh
-rw-rw-r-- 1 root root 2962 Aug 3 22:34 train_nano.py
---DATA---
total 792657
drwxr-xr-x 1 root root 57 Aug 3 22:37 .
drwxr-xr-x 1 root root 100 Aug 4 04:31 ..
-r--r--r-- 1 root root 2000128 Aug 3 22:34 multi_dev.npy
-r--r--r-- 1 root root 809679384 Aug 3 22:35 pool.jsonl
---SUBMISSION---
total 1
drwxr-xr-x 1 root root 10 Aug 3 22:37 .
drwxr-xr-x 1 root root 100 Aug 4 04:31 ..
---GPU---
name, memory.total [MiB], memory.used [MiB]
NVIDIA H100 80GB HBM3, 81559 MiB, 4 MiB
[metadata] {"noOutputExpected": false}I have ~90 minutes (5390s). Each training run is ~60s. Let me examine the training pipeline and helper scripts carefully.
args
{
"command": "cd /workspace; echo \"===== train_nano.py =====\"; cat train_nano.py; echo; echo \"===== pack_selection.py =====\"; cat pack_selection.py; echo; echo \"===== dev_eval.sh =====\"; cat dev_eval.sh; echo; echo \"===== timer.sh =====\"; cat timer.sh",
"description": "Read training and helper scripts"
}Bash result
===== train_nano.py =====
"""From-scratch nano-GPT (30M) LM training on a 1D token .npy; report held-out perplexity.
Frozen recipe — the ONLY thing that varies between runs is the training token set."""
import argparse, math, time, numpy as np, torch
from model import GPT, GPTConfig
ap = argparse.ArgumentParser()
ap.add_argument("--train_npy", required=True)
ap.add_argument("--heldout_npy", required=True)
ap.add_argument("--out_json", required=True)
ap.add_argument("--max_iters", type=int, default=3000)
ap.add_argument("--warmup", type=int, default=150)
ap.add_argument("--batch", type=int, default=32)
ap.add_argument("--block", type=int, default=256)
ap.add_argument("--lr", type=float, default=6e-4)
ap.add_argument("--seed", type=int, default=1337)
a = ap.parse_args()
torch.manual_seed(a.seed); np.random.seed(a.seed)
dev = "cuda"
tr = np.load(a.train_npy); ho = np.load(a.heldout_npy)
tr = torch.from_numpy(tr.astype(np.int64)); ho = torch.from_numpy(ho.astype(np.int64))
rng = np.random.default_rng(a.seed)
model = GPT(GPTConfig(block_size=a.block, vocab_size=50257, n_layer=6, n_head=6,
n_embd=384, dropout=0.0, bias=False)).to(dev)
opt = model.configure_optimizers(0.1, a.lr, (0.9, 0.95), "cuda")
def lr_at(it):
if it < a.warmup: return a.lr * (it + 1) / (a.warmup + 1)
r = (it - a.warmup) / max(1, a.max_iters - a.warmup)
return 0.1 * a.lr + 0.5 * (1 + math.cos(math.pi * r)) * (a.lr - 0.1 * a.lr)
def get_batch(src):
ix = rng.integers(0, len(src) - a.block - 1, size=a.batch)
x = torch.stack([src[i:i+a.block] for i in ix]).to(dev)
y = torch.stack([src[i+1:i+1+a.block] for i in ix]).to(dev)
return x, y
t0 = time.time()
model.train()
for it in range(a.max_iters):
for g in opt.param_groups: g["lr"] = lr_at(it)
x, y = get_batch(tr)
with torch.autocast("cuda", dtype=torch.bfloat16):
_, loss = model(x, y)
opt.zero_grad(set_to_none=True); loss.backward()
torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0); opt.step()
train_s = time.time() - t0
# held-out perplexity: mean next-token CE over non-overlapping windows (window-weighted)
import json
model.eval()
nwin = (len(ho) - 1) // a.block
starts = [j * a.block for j in range(nwin)]
sum_loss, nseen = 0.0, 0
with torch.no_grad():
for i in range(0, nwin, a.batch):
bs = starts[i:i+a.batch]
x = torch.stack([ho[s:s+a.block] for s in bs]).to(dev)
y = torch.stack([ho[s+1:s+1+a.block] for s in bs]).to(dev)
with torch.autocast("cuda", dtype=torch.bfloat16):
_, l = model(x, y)
sum_loss += l.item() * len(bs); nseen += len(bs)
mean_loss = sum_loss / max(1, nseen)
ppl = math.exp(mean_loss)
out = {"train_npy": a.train_npy, "heldout_ppl": ppl, "mean_loss": mean_loss,
"max_iters": a.max_iters, "seed": a.seed, "train_s": round(train_s, 1)}
json.dump(out, open(a.out_json, "w"))
print(f"HELDOUT_PPL {ppl:.3f} loss {mean_loss:.4f} train_s {train_s:.0f} {a.train_npy}")
===== pack_selection.py =====
"""Solver-side: pack a selection.json (ordered ids) into a 12M-token train array from pool.jsonl."""
import json, sys, numpy as np
from transformers import AutoTokenizer
POOL = "/workspace/data/pool.jsonl"
SEL = sys.argv[1] if len(sys.argv) > 1 else "/workspace/submission/selection.json"
OUT = sys.argv[2] if len(sys.argv) > 2 else "/tmp/dev_train.npy"
BUDGET = 12_000_000
tok = AutoTokenizer.from_pretrained("gpt2"); EOS = tok.eos_token_id
text = {}
for line in open(POOL):
r = json.loads(line); text[r["id"]] = r["text"]
sel = json.load(open(SEL))
parts, tot = [], 0
for i in sel:
ids = tok(text[i], add_special_tokens=False).input_ids
parts.extend(ids); parts.append(EOS); tot += len(ids) + 1
if tot >= BUDGET: break
arr = np.array(parts[:BUDGET], dtype=np.uint16)
np.save(OUT, arr)
print(f"packed {len(arr)} tokens from {len(sel)} ids -> {OUT}")
===== dev_eval.sh =====
#!/bin/bash
# Diagnostic: train the frozen 30M GPT on your selection and report DEV perplexity.
# Usage: bash dev_eval.sh [selection.json] (default /workspace/submission/selection.json)
# NOTE: the official target is a DIFFERENT (hidden) sample from the same HQ domain.
set -euo pipefail
export TOKENIZERS_PARALLELISM=false
SEL="${1:-/workspace/submission/selection.json}"
cd /workspace
python3 pack_selection.py "$SEL" /tmp/dev_train.npy
python3 train_nano.py --train_npy /tmp/dev_train.npy --heldout_npy /workspace/data/multi_dev.npy \
--out_json /tmp/dev.json --max_iters 3000 --seed 1337 2>&1 | grep HELDOUT_PPL
echo "(dev PPL on multi_dev; official uses a hidden disjoint sample of the same HQ domain)"
===== timer.sh =====
#!/usr/bin/env bash
# Budget timer daemon — writes /workspace/.timer/remaining_secs every 10s so the
# solver can poll time left instead of doing wall-clock arithmetic.
#
# Budget (seconds) comes from $TASK_BUDGET_SECS (set by the runner to the agent
# timeout). Idempotent via a PID file. On ScaleTrain the trial runner starts its
# own timer; this file is the fallback for the Modal/local harbor backends, which
# bootstrap /workspace/timer.sh on environment start. The fallback default below
# (7200 = 2 h) matches this task's [agent] timeout_sec and is only used if
# $TASK_BUDGET_SECS is unset.
set -u
TIMER_DIR="/workspace/.timer"
PID_FILE="$TIMER_DIR/timer.pid"
mkdir -p "$TIMER_DIR"
if [ -s "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE" 2>/dev/null)" 2>/dev/null; then
exit 0 # already running
fi
echo $$ > "$PID_FILE"
trap 'rm -f "$PID_FILE"' EXIT INT TERM
START=$(date +%s)
BUDGET="${TASK_BUDGET_SECS:-7200}"
echo "$START" > "$TIMER_DIR/start_epoch"
echo "$BUDGET" > "$TIMER_DIR/budget_secs"
while true; do
NOW=$(date +%s)
ELAPSED=$((NOW - START))
REMAINING=$((BUDGET - ELAPSED))
[ "$REMAINING" -lt 0 ] && REMAINING=0
echo "$REMAINING" > "$TIMER_DIR/remaining_secs"
echo "$ELAPSED" > "$TIMER_DIR/elapsed_secs"
[ "$REMAINING" -le 1800 ] && [ ! -f "$TIMER_DIR/alert_30min" ] && touch "$TIMER_DIR/alert_30min"
[ "$REMAINING" -le 600 ] && [ ! -f "$TIMER_DIR/alert_10min" ] && touch "$TIMER_DIR/alert_10min"
[ "$REMAINING" -le 0 ] && break
sleep 10
done
[stdout]
===== train_nano.py =====
"""From-scratch nano-GPT (30M) LM training on a 1D token .npy; report held-out perplexity.
Frozen recipe — the ONLY thing that varies between runs is the training token set."""
import argparse, math, time, numpy as np, torch
from model import GPT, GPTConfig
ap = argparse.ArgumentParser()
ap.add_argument("--train_npy", required=True)
ap.add_argument("--heldout_npy", required=True)
ap.add_argument("--out_json", required=True)
ap.add_argument("--max_iters", type=int, default=3000)
ap.add_argument("--warmup", type=int, default=150)
ap.add_argument("--batch", type=int, default=32)
ap.add_argument("--block", type=int, default=256)
ap.add_argument("--lr", type=float, default=6e-4)
ap.add_argument("--seed", type=int, default=1337)
a = ap.parse_args()
torch.manual_seed(a.seed); np.random.seed(a.seed)
dev = "cuda"
tr = np.load(a.train_npy); ho = np.load(a.heldout_npy)
tr = torch.from_numpy(tr.astype(np.int64)); ho = torch.from_numpy(ho.astype(np.int64))
rng = np.random.default_rng(a.seed)
model = GPT(GPTConfig(block_size=a.block, vocab_size=50257, n_layer=6, n_head=6,
n_embd=384, dropout=0.0, bias=False)).to(dev)
opt = model.configure_optimizers(0.1, a.lr, (0.9, 0.95), "cuda")
def lr_at(it):
if it < a.warmup: return a.lr * (it + 1) / (a.warmup + 1)
r = (it - a.warmup) / max(1, a.max_iters - a.warmup)
return 0.1 * a.lr + 0.5 * (1 + math.cos(math.pi * r)) * (a.lr - 0.1 * a.lr)
def get_batch(src):
ix = rng.integers(0, len(src) - a.block - 1, size=a.batch)
x = torch.stack([src[i:i+a.block] for i in ix]).to(dev)
y = torch.stack([src[i+1:i+1+a.block] for i in ix]).to(dev)
return x, y
t0 = time.time()
model.train()
for it in range(a.max_iters):
for g in opt.param_groups: g["lr"] = lr_at(it)
x, y = get_batch(tr)
with torch.autocast("cuda", dtype=torch.bfloat16):
_, loss = model(x, y)
opt.zero_grad(set_to_none=True); loss.backward()
torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0); opt.step()
train_s = time.time() - t0
# held-out perplexity: mean next-token CE over non-overlapping windows (window-weighted)
import json
model.eval()
nwin = (len(ho) - 1) // a.block
starts = [j * a.block for j in range(nwin)]
sum_loss, nseen = 0.0, 0
with torch.no_grad():
for i in range(0, nwin, a.batch):
bs = starts[i:i+a.batch]
x = torch.stack([ho[s:s+a.block] for s in bs]).to(dev)
y = torch.stack([ho[s+1:s+1+a.block] for s in bs]).to(dev)
with torch.autocast("cuda", dtype=torch.bfloat16):
_, l = model(x, y)
sum_loss += l.item() * len(bs); nseen += len(bs)
mean_loss = sum_loss / max(1, nseen)
ppl = math.exp(mean_loss)
out = {"train_npy": a.train_npy, "heldout_ppl": ppl, "mean_loss": mean_loss,
"max_iters": a.max_iters, "seed": a.seed, "train_s": round(train_s, 1)}
json.dump(out, open(a.out_json, "w"))
print(f"HELDOUT_PPL {ppl:.3f} loss {mean_loss:.4f} train_s {train_s:.0f} {a.train_npy}")
===== pack_selection.py =====
"""Solver-side: pack a selection.json (ordered ids) into a 12M-token train array from pool.jsonl."""
import json, sys, numpy as np
from transformers import AutoTokenizer
POOL = "/workspace/data/pool.jsonl"
SEL = sys.argv[1] if len(sys.argv) > 1 else "/workspace/submission/selection.json"
OUT = sys.argv[2] if len(sys.argv) > 2 else "/tmp/dev_train.npy"
BUDGET = 12_000_000
tok = AutoTokenizer.from_pretrained("gpt2"); EOS = tok.eos_token_id
text = {}
for line in open(POOL):
r = json.loads(line); text[r["id"]] = r["text"]
sel = json.load(open(SEL))
parts, tot = [], 0
for i in sel:
ids = tok(text[i], add_special_tokens=False).input_ids
parts.extend(ids); parts.append(EOS); tot += len(ids) + 1
if tot >= BUDGET: break
arr = np.array(parts[:BUDGET], dtype=np.uint16)
np.save(OUT, arr)
print(f"packed {len(arr)} tokens from {len(sel)} ids -> {OUT}")
===== dev_eval.sh =====
#!/bin/bash
# Diagnostic: train the frozen 30M GPT on your selection and report DEV perplexity.
# Usage: bash dev_eval.sh [selection.json] (default /workspace/submission/selection.json)
# NOTE: the official target is a DIFFERENT (hidden) sample from the same HQ domain.
set -euo pipefail
export TOKENIZERS_PARALLELISM=false
SEL="${1:-/workspace/submission/selection.json}"
cd /workspace
python3 pack_selection.py "$SEL" /tmp/dev_train.npy
python3 train_nano.py --train_npy /tmp/dev_train.npy --heldout_npy /workspace/data/multi_dev.npy \
--out_json /tmp/dev.json --max_iters 3000 --seed 1337 2>&1 | grep HELDOUT_PPL
echo "(dev PPL on multi_dev; official uses a hidden disjoint sample of the same HQ domain)"
===== timer.sh =====
#!/usr/bin/env bash
# Budget timer daemon — writes /workspace/.timer/remaining_secs every 10s so the
# solver can poll time left instead of doing wall-clock arithmetic.
#
# Budget (seconds) comes from $TASK_BUDGET_SECS (set by the runner to the agent
# timeout). Idempotent via a PID file. On ScaleTrain the trial runner starts its
# own timer; this file is the fallback for the Modal/local harbor backends, which
# bootstrap /workspace/timer.sh on environment start. The fallback default below
# (7200 = 2 h) matches this task's [agent] timeout_sec and is only used if
# $TASK_BUDGET_SECS is unset.
set -u
TIMER_DIR="/workspace/.timer"
PID_FILE="$TIMER_DIR/timer.pid"
mkdir -p "$TIMER_DIR"
if [ -s "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE" 2>/dev/null)" 2>/dev/null; then
exit 0 # already running
fi
echo $$ > "$PID_FILE"
trap 'rm -f "$PID_FILE"' EXIT INT TERM
START=$(date +%s)
BUDGET="${TASK_BUDGET_SECS:-7200}"
echo "$START" > "$TIMER_DIR/start_epoch"
echo "$BUDGET" > "$TIMER_DIR/budget_secs"
while true; do
NOW=$(date +%s)
ELAPSED=$((NOW - START))
REMAINING=$((BUDGET - ELAPSED))
[ "$REMAINING" -lt 0 ] && REMAINING=0
echo "$REMAINING" > "$TIMER_DIR/remaining_secs"
echo "$ELAPSED" > "$TIMER_DIR/elapsed_secs"
[ "$REMAINING" -le 1800 ] && [ ! -f "$TIMER_DIR/alert_30min" ] && touch "$TIMER_DIR/alert_30min"
[ "$REMAINING" -le 600 ] && [ ! -f "$TIMER_DIR/alert_10min" ] && touch "$TIMER_DIR/alert_10min"
[ "$REMAINING" -le 0 ] && break
sleep 10
done
[metadata] {"noOutputExpected": false}I have ~90 min. Key facts: 12M token budget, target is broad multi-domain HQ English (Wikipedia/web prose/news/technical Q&A). Let me explore the data — decode the dev target and sample the pool.
args
{
"command": "cd /workspace; echo \"===== RAM =====\"; free -g; echo \"===== model.py =====\"; cat model.py | head -50; echo \"===== dev target shape =====\"; python3 -c \"\nimport numpy as np\nd = np.load('/workspace/data/multi_dev.npy')\nprint('dtype', d.dtype, 'shape', d.shape, 'min', d.min(), 'max', d.max())\nprint('tokens:', len(d))\nfrom transformers import AutoTokenizer\ntok = AutoTokenizer.from_pretrained('gpt2')\n# decode first chunk\nprint('==== DECODED SAMPLE (first 1500 chars) ====')\nprint(repr(tok.decode(d[:400])))\nprint('==== another chunk mid ====')\nn=len(d)//2\nprint(repr(tok.decode(d[n:n+400])))\n\"",
"description": "Decode dev target and check RAM/model"
}Bash result
===== RAM =====
total used free shared buff/cache available
Mem: 1024 0 1023 0 0 1023
Swap: 0 0 0
===== model.py =====
"""A small GPT (decoder-only Transformer) used as the distillation *student*.
Self-contained re-implementation in this repo's own idiom (no external GPT code).
GPT-2 byte-level BPE vocabulary (50257) so the student shares the teacher's
tokenizer. Standard pre-norm Transformer with weight-tied embeddings.
"""
from dataclasses import dataclass
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
@dataclass
class GPTConfig:
block_size: int = 256
vocab_size: int = 50257
n_layer: int = 6
n_head: int = 6
n_embd: int = 384
dropout: float = 0.0
bias: bool = False
class LayerNorm(nn.Module):
def __init__(self, ndim, bias):
super().__init__()
self.weight = nn.Parameter(torch.ones(ndim))
self.bias = nn.Parameter(torch.zeros(ndim)) if bias else None
def forward(self, x):
return F.layer_norm(x, self.weight.shape, self.weight, self.bias, 1e-5)
class CausalSelfAttention(nn.Module):
def __init__(self, cfg: GPTConfig):
super().__init__()
assert cfg.n_embd % cfg.n_head == 0
self.c_attn = nn.Linear(cfg.n_embd, 3 * cfg.n_embd, bias=cfg.bias)
self.c_proj = nn.Linear(cfg.n_embd, cfg.n_embd, bias=cfg.bias)
self.n_head = cfg.n_head
self.n_embd = cfg.n_embd
self.dropout = cfg.dropout
def forward(self, x):
B, T, C = x.size()
q, k, v = self.c_attn(x).split(self.n_embd, dim=2)
q = q.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
k = k.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
v = v.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
===== dev target shape =====
dtype uint16 shape (1000000,) min 0 max 50256
tokens: 1000000
==== DECODED SAMPLE (first 1500 chars) ====
" Beardmore was sufficiently impressed with Shackleton to offer financial support , but other donations proved hard to come by . Nevertheless , in February 1907 , Shackleton presented to the Royal Geographic Society his plans for an Antarctic expedition , the details of which , under the name British Antarctic Expedition , were published in the Royal Society 's newsletter , Geographic Journal . The aim was the conquest of both the geographical South Pole and the South Magnetic Pole . Shackleton then worked hard to persuade others of his wealthy friends and acquaintances to contribute , including Sir Philip Lee Brocklehurst , who subscribed £ 2 @,@ 000 ( 2011 equivalent £ 157 @,@ 000 ) to secure a place on the expedition ; author Campbell Mackellar ; and Guinness baron Lord Iveagh , whose contribution was secured less than two weeks before the departure of the expedition ship Nimrod . On 4 August 1907 , Shackleton was appointed a Member of the Royal Victorian Order , 4th Class ( MVO ; the present @-@ day grade of Lieutenant ) . \n<|endoftext|> On 1 January 1908 , Nimrod sailed for the Antarctic from Lyttelton Harbour , New Zealand . Shackleton 's original plans had envisaged using the old Discovery base in McMurdo Sound to launch his attempts on the South Pole and South Magnetic Pole . However , before leaving England , he had been pressured to give an undertaking to Scott that he would not base himself in the McMurdo area , which Scott was claiming as his own field of work . Shackleton reluctantly agreed to look for winter quarters at either the Barrier Inlet ( which Discovery had briefly visited in 1902 ) or King Edward VII Land . \n<|endoftext|> To conserve coal , the ship was towed 1 @,@ 650 miles ( 2 @,@ 655 km ) by the steamer Koonya to the Antarctic ice , after Shackleton had persuaded the New Zealand government and the Union Steamship Company to share the cost . In accordance with Shackleton 's promise to Scott , the"
==== another chunk mid ====
'I fucking hate when he does this shit pic.twitter.com/kpmcHnW4Cz — Miley Ray Cyrus (@MileyCyrus) April 22, 2018\nSinger-actress Miley Cyrus has shared a rare video of herself with her partner, actor Liam Hemsworth, on social media. She shared a video of them both in a car, which showed Hemsworth listening to rap music as he drove them to their destination.Cyrus captioned the image: "I f***ing hate it when he does this s**t."In the clip, she was sporting a top which had the word \'Sunday\' emblazoned across the front as she sat in the passenger seat. With his music blaring out, she filmed herself dancing and bopping her head to the music. Then all of a sudden, he made Cyrus jump as he suddenly screamed at her, causing to drop her phone in panic.(With IANS inputs)<|endoftext|>Uttar Pradesh chief minister Yogi Adityanath has maintained that 63 children in government-run Gorakhpur hospital died because of their ailments and not oxygen shortage, but grieving parents say their children were fine till the oxygen supply was cut.Some like Mohd Zahid, father of a five-year-old, alleged that BRD hospital authorities refused to declare their children dead, even as their bodies had turned ice cold as this would have further taken up the death toll.Another father said that while his son started bleeding from the nose, the hospital staff dismissed it saying, “Kachra nikal raha hai” (It’s just body waste that is coming out).In a harrowing tragedy exposing the sorry state of medical facilities in Uttar Pradesh, at least 32 children perished between August 10 and 11, allegedly due to no oxygen supply. A total of 63 children died within a span of five days, even as different ministers here could be seen making repeated tours'
[stdout]
===== RAM =====
total used free shared buff/cache available
Mem: 1024 0 1023 0 0 1023
Swap: 0 0 0
===== model.py =====
"""A small GPT (decoder-only Transformer) used as the distillation *student*.
Self-contained re-implementation in this repo's own idiom (no external GPT code).
GPT-2 byte-level BPE vocabulary (50257) so the student shares the teacher's
tokenizer. Standard pre-norm Transformer with weight-tied embeddings.
"""
from dataclasses import dataclass
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
@dataclass
class GPTConfig:
block_size: int = 256
vocab_size: int = 50257
n_layer: int = 6
n_head: int = 6
n_embd: int = 384
dropout: float = 0.0
bias: bool = False
class LayerNorm(nn.Module):
def __init__(self, ndim, bias):
super().__init__()
self.weight = nn.Parameter(torch.ones(ndim))
self.bias = nn.Parameter(torch.zeros(ndim)) if bias else None
def forward(self, x):
return F.layer_norm(x, self.weight.shape, self.weight, self.bias, 1e-5)
class CausalSelfAttention(nn.Module):
def __init__(self, cfg: GPTConfig):
super().__init__()
assert cfg.n_embd % cfg.n_head == 0
self.c_attn = nn.Linear(cfg.n_embd, 3 * cfg.n_embd, bias=cfg.bias)
self.c_proj = nn.Linear(cfg.n_embd, cfg.n_embd, bias=cfg.bias)
self.n_head = cfg.n_head
self.n_embd = cfg.n_embd
self.dropout = cfg.dropout
def forward(self, x):
B, T, C = x.size()
q, k, v = self.c_attn(x).split(self.n_embd, dim=2)
q = q.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
k = k.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
v = v.view(B, T, self.n_head, C // self.n_head).transpose(1, 2)
===== dev target shape =====
dtype uint16 shape (1000000,) min 0 max 50256
tokens: 1000000
==== DECODED SAMPLE (first 1500 chars) ====
" Beardmore was sufficiently impressed with Shackleton to offer financial support , but other donations proved hard to come by . Nevertheless , in February 1907 , Shackleton presented to the Royal Geographic Society his plans for an Antarctic expedition , the details of which , under the name British Antarctic Expedition , were published in the Royal Society 's newsletter , Geographic Journal . The aim was the conquest of both the geographical South Pole and the South Magnetic Pole . Shackleton then worked hard to persuade others of his wealthy friends and acquaintances to contribute , including Sir Philip Lee Brocklehurst , who subscribed £ 2 @,@ 000 ( 2011 equivalent £ 157 @,@ 000 ) to secure a place on the expedition ; author Campbell Mackellar ; and Guinness baron Lord Iveagh , whose contribution was secured less than two weeks before the departure of the expedition ship Nimrod . On 4 August 1907 , Shackleton was appointed a Member of the Royal Victorian Order , 4th Class ( MVO ; the present @-@ day grade of Lieutenant ) . \n<|endoftext|> On 1 January 1908 , Nimrod sailed for the Antarctic from Lyttelton Harbour , New Zealand . Shackleton 's original plans had envisaged using the old Discovery base in McMurdo Sound to launch his attempts on the South Pole and South Magnetic Pole . However , before leaving England , he had been pressured to give an undertaking to Scott that he would not base himself in the McMurdo area , which Scott was claiming as his own field of work . Shackleton reluctantly agreed to look for winter quarters at either the Barrier Inlet ( which Discovery had briefly visited in 1902 ) or King Edward VII Land . \n<|endoftext|> To conserve coal , the ship was towed 1 @,@ 650 miles ( 2 @,@ 655 km ) by the steamer Koonya to the Antarctic ice , after Shackleton had persuaded the New Zealand government and the Union Steamship Company to share the cost . In accordance with Shackleton 's promise to Scott , the"
==== another chunk mid ====
'I fucking hate when he does this shit pic.twitter.com/kpmcHnW4Cz — Miley Ray Cyrus (@MileyCyrus) April 22, 2018\nSinger-actress Miley Cyrus has shared a rare video of herself with her partner, actor Liam Hemsworth, on social media. She shared a video of them both in a car, which showed Hemsworth listening to rap music as he drove them to their destination.Cyrus captioned the image: "I f***ing hate it when he does this s**t."In the clip, she was sporting a top which had the word \'Sunday\' emblazoned across the front as she sat in the passenger seat. With his music blaring out, she filmed herself dancing and bopping her head to the music. Then all of a sudden, he made Cyrus jump as he suddenly screamed at her, causing to drop her phone in panic.(With IANS inputs)<|endoftext|>Uttar Pradesh chief minister Yogi Adityanath has maintained that 63 children in government-run Gorakhpur hospital died because of their ailments and not oxygen shortage, but grieving parents say their children were fine till the oxygen supply was cut.Some like Mohd Zahid, father of a five-year-old, alleged that BRD hospital authorities refused to declare their children dead, even as their bodies had turned ice cold as this would have further taken up the death toll.Another father said that while his son started bleeding from the nose, the hospital staff dismissed it saying, “Kachra nikal raha hai” (It’s just body waste that is coming out).In a harrowing tragedy exposing the sorry state of medical facilities in Uttar Pradesh, at least 32 children perished between August 10 and 11, allegedly due to no oxygen supply. A total of 63 children died within a span of five days, even as different ministers here could be seen making repeated tours'
[metadata] {"noOutputExpected": false}Now I understand the target: a mix of Wikipedia (WikiText-style), news, and web prose. I have 1TB RAM so I can load the whole pool. Let me explore the pool's characteristics and sample some documents.
args
{
"command": "cd /workspace; python3 -c \"\nimport json, random, re, time\nt0=time.time()\nlens=[]; wc=[]; samples=[]; n=0\nrandom.seed(0)\nwith open('/workspace/data/pool.jsonl') as f:\n for line in f:\n r=json.loads(line); t=r['text']; n+=1\n lens.append(len(t))\n w=len(t.split())\n wc.append(w)\n if random.random()<0.00008:\n samples.append((r['id'], t))\nprint('docs',n,'read_s',round(time.time()-t0,1))\nimport numpy as np\nlens=np.array(lens); wc=np.array(wc)\nprint('CHARS: mean %.0f median %.0f p10 %.0f p90 %.0f max %d'%(lens.mean(),np.median(lens),np.percentile(lens,10),np.percentile(lens,90),lens.max()))\nprint('WORDS: mean %.0f median %.0f p10 %.0f p90 %.0f max %d'%(wc.mean(),np.median(wc),np.percentile(wc,10),np.percentile(wc,90),wc.max()))\nprint('est total tokens (chars/4): %.1fM'%(lens.sum()/4/1e6))\nprint('frac docs < 50 words: %.3f'%((wc<50).mean()))\nprint('frac docs < 100 words: %.3f'%((wc<100).mean()))\nprint('=== %d RANDOM SAMPLES ==='%len(samples))\nfor i,(did,t) in enumerate(samples[:12]):\n print('--- id',did,'| words',len(t.split()),'---')\n print(t[:600].replace(chr(10),' ⏎ '))\n print()\n\"",
"description": "Pool statistics and random samples"
}Bash result
docs 182016 read_s 9.7
CHARS: mean 4233 median 2246 p10 561 p90 8458 max 522573
WORDS: mean 675 median 366 p10 92 p90 1359 max 93587
est total tokens (chars/4): 192.6M
frac docs < 50 words: 0.022
frac docs < 100 words: 0.116
=== 11 RANDOM SAMPLES ===
--- id 5755 | words 741 ---
I’ll admit, I am biased because I absolutely love chocolates from Bernard Callebaut. If you’re a Calgary resident, you know all about this chocolaterie, along with all of the recent press and drama surrounding the man who founded the company. Well now the company is in the hands of new owners, and I thought I’d pop in to see if any of my long-time favorites have changed with the change of ownership. ⏎ I popped into their 17th Avenue location not too long ago, and picked up a small bag of two favorites along with a new seasonal treat. I also was brave and asked permission to take photos – so got
--- id 20161 | words 277 ---
Our living room has lovely bones, elements that have outlasted many owners throughout its 100-year history. However, five of the best features of the room are also what make it so hard to decorate! The glass paned doors leading in from the foyer; the strangely pretty faux fireplace; the painted radiators, the shuttered windows and the pocket doors. Every few feet you bump into one of these five elements, limiting the options for furniture placement. ⏎ For the past few years, we have been happy with the way our arrangement looks — but finally I decided the room felt unwelcoming and there wasn't e
--- id 48749 | words 76 ---
<|endoftext|>One of the mysteries of the English language finally explained. ⏎ 1A stickleback (now rare). ⏎ 2A member of the family Stephanoberycidae of small deep-sea fishes of tropical and subtropical waters, which bear spines ventrally and dorsally in front of the caudal fin and typically have toothed scales with backward-pointing spines. ⏎ Mid 17th century; earliest use found in Walter Charleton (1620–1707), physician and natural philosopher. ⏎ In this article we explore how to impress employers with a spot-on CV
--- id 70778 | words 1439 ---
<|endoftext|>US 5305799 A ⏎ A flexible conduit for vehicle engine coolant circuits, which conduit comprises a series of at least a first relatively rigid portion and a second relatively deformable bellows portion capable of being deformed at least into a curved portion; and an inner and outer wall made of different plastic materials. ⏎ 1. A flexible conduit for connecting a coolant circuit of an engine to a radiator, comprising: ⏎ at least two successive conduit sections, each conduit section having a coaxially extruded inner wall and outer wall; ⏎ a pair of rigid end portions and at least one undulat
--- id 75453 | words 275 ---
<|endoftext|>Starts: Jun 14, 2013 9:00:00 AM ⏎ Starts: Jun 13, 2013 4:00:00 PM ⏎ Starts: Jun 13, 2013 9:00:00 AM ⏎ Themes in risk and disaster reduction ⏎ - public perception of risk ⏎ - how diverse societies deal with disaster ⏎ Understanding natural hazards: Geological and meteorological ⏎ - field and satellite observations ⏎ - laboratory simulations ⏎ - computational and statistical modelling ⏎ Understanding health risks and pandemics ⏎ - transmission characteristics of the infectious agents ⏎ - epidemiology of pandemics ⏎ - risks to radioactive waste and CO2 repositories ⏎ - complex engineered systems ⏎ Understanding c
--- id 75692 | words 159 ---
- A Frugal Chick - http://www.afrugalchick.com - ⏎ Groupon Deals of the Day- Carriage Rides, Fruit Baskets and Lunch Boxes ⏎ Posted By Laura On August 13, 2010 @ 8:14 am In Deals of the Day | Comments Disabled ⏎ The deal from Hampton Roads today is $89 for a Country Carriage Ride for Two and a Light Supper from Chariots for Hire in Suffolk ($180 Value). Might be nice for a romantic evening out! You have a year to use it from the date of purchase. ⏎ Boston (Side Deal)- Receive $50 to spend at Fruit Basket King for just $20. ⏎ Los Angeles (Deal Nearby)- Get a personalized photo classic metal lunchbox, i
--- id 117630 | words 263 ---
<|endoftext|> Hand Cursor ⏎ Hand Cursor ⏎ Site Map Feedback ⏎ Download: ⏎ Hand.cur ⏎ HandCursor.h ⏎ Controls Files Moving Data ⏎ Use a Hand Cursor without having one in your Resources ⏎ If you want to use a hand cursor (like web browsers use when the mouse is over a link) you either have to have Windows 2000 or above, or use a resource. [Yes, this is an old article, but it is kept in to demonstrate the technique] The trouble with resources is that you need to know the Resource ID and for the little classes offered on this site, that is not known. So this little class steals the Hand Cursor from a standard Wi
--- id 129069 | words 496 ---
BB Limited<|endoftext|>Freshmen' Guide To Enterprise Intelligence Tools | S-F ⏎ S-F BUSINESS ENTERPRENEUR ⏎ Learning ⏎ business ideas ⏎ how to start a business ⏎ small business loans ⏎ Management ⏎ business development ⏎ business management ⏎ small business ideas ⏎ starting a business ⏎ Market ⏎ business intelligence ⏎ business service ⏎ social security administration ⏎ Plan ⏎ business ethics ⏎ business plan ⏎ home based business ⏎ Freshmen’ Guide To Enterprise Intelligence Tools ⏎ There are lots of concepts and terms that it’s essential to know and handle when a crew working with Enterprise Intelligence points. Organizations select
--- id 131466 | words 106 ---
ishing | Origin and meaning of punishing by Online Etymology Dictionary ⏎ Advertisement ⏎ punishing (adj.) ⏎ "hard-hitting," 1811, present-participle adjective from punish (v.). Related: Punishingly. ⏎ Related Entries ⏎ punish ⏎ Others Are Reading ⏎ Share ⏎ Advertisement ⏎ Alphabetical list ⏎ pungent ⏎ Punic ⏎ punish ⏎ punishable ⏎ punisher ⏎ punishing ⏎ punishment ⏎ punitive ⏎ Punjab ⏎ punji ⏎ punk ⏎ A ⏎ B ⏎ C ⏎ D ⏎ E ⏎ F ⏎ G ⏎ H ⏎ I ⏎ J ⏎ K ⏎ L ⏎ M ⏎ N ⏎ O ⏎ P ⏎ Q ⏎ R ⏎ S ⏎ T ⏎ U ⏎ V ⏎ W ⏎ X ⏎ Y ⏎ Z ⏎ links ⏎ Classic VersionSourcesLinks ⏎ more ⏎ Chrome Extension词根词源词典 App培根词汇微信公众号 ⏎ about etymonline ⏎ Explanation of TermsWho did thisFollow on Facebook ⏎ support us ⏎ Donate with PayPalYe Olde Swag
--- id 156844 | words 279 ---
TS ⏎ Search ⏎ Eng Հայ ⏎ Donate ⏎ ABOUT US ⏎ Our mission Our management Our donors Our trustees ⏎ Why us ⏎ TRANSPARENCY ⏎ PROJECTS ⏎ President prize Ongoing Completed Proposed ⏎ MEDIA ⏎ News Announcements Notes Gallery ⏎ EVENTS ⏎ Board of trustees Telethon Phonethon ⏎ FUND WORLDWIDE ⏎ All Ongoing Completed Proposed ⏎ Regions ⏎ Armenia ⏎ Yerevan Aragatsotn Kotayk Syunik Vayots Dzor Ararat Armavir Gegharkunik Lori Shirak Tavush ⏎ Artsakh ⏎ Stepanakert Askeran Hadrut Martakert Martuni Shahumyan Shushi Qashatagh ⏎ Sponsored by ⏎ All Armenians Armenia Fund USA Armenia Fund, Inc Armenian community of Syria Government of Armenia Government of A
--- id 157150 | words 12181 ---
Audible Audiobooks To Check Out Now | PearTreePond ⏎ Home ⏎ Start here ⏎ Start A Profitable Blog ⏎ Find your business idea & branding strategy ⏎ Create a website & website optimization ⏎ Content writing & creating graphics ⏎ Marketing, promotion & ways to make money ⏎ Pinterest For Business ⏎ SEO & analytics ⏎ Work-Life-Balance, Productivity & Mindset ⏎ Solopreneur Toolkit ⏎ FREE Weekly Blog Planner ⏎ Business Plan Bundle ⏎ Home ⏎ Start here ⏎ Start A Profitable Blog ⏎ Find your business idea & branding strategy ⏎ Create a website & website optimization ⏎ Content writing & creating graphics ⏎ Marketing, promotion & ways to make mon
[stdout]
docs 182016 read_s 9.7
CHARS: mean 4233 median 2246 p10 561 p90 8458 max 522573
WORDS: mean 675 median 366 p10 92 p90 1359 max 93587
est total tokens (chars/4): 192.6M
frac docs < 50 words: 0.022
frac docs < 100 words: 0.116
=== 11 RANDOM SAMPLES ===
--- id 5755 | words 741 ---
I’ll admit, I am biased because I absolutely love chocolates from Bernard Callebaut. If you’re a Calgary resident, you know all about this chocolaterie, along with all of the recent press and drama surrounding the man who founded the company. Well now the company is in the hands of new owners, and I thought I’d pop in to see if any of my long-time favorites have changed with the change of ownership. ⏎ I popped into their 17th Avenue location not too long ago, and picked up a small bag of two favorites along with a new seasonal treat. I also was brave and asked permission to take photos – so got
--- id 20161 | words 277 ---
Our living room has lovely bones, elements that have outlasted many owners throughout its 100-year history. However, five of the best features of the room are also what make it so hard to decorate! The glass paned doors leading in from the foyer; the strangely pretty faux fireplace; the painted radiators, the shuttered windows and the pocket doors. Every few feet you bump into one of these five elements, limiting the options for furniture placement. ⏎ For the past few years, we have been happy with the way our arrangement looks — but finally I decided the room felt unwelcoming and there wasn't e
--- id 48749 | words 76 ---
<|endoftext|>One of the mysteries of the English language finally explained. ⏎ 1A stickleback (now rare). ⏎ 2A member of the family Stephanoberycidae of small deep-sea fishes of tropical and subtropical waters, which bear spines ventrally and dorsally in front of the caudal fin and typically have toothed scales with backward-pointing spines. ⏎ Mid 17th century; earliest use found in Walter Charleton (1620–1707), physician and natural philosopher. ⏎ In this article we explore how to impress employers with a spot-on CV
--- id 70778 | words 1439 ---
<|endoftext|>US 5305799 A ⏎ A flexible conduit for vehicle engine coolant circuits, which conduit comprises a series of at least a first relatively rigid portion and a second relatively deformable bellows portion capable of being deformed at least into a curved portion; and an inner and outer wall made of different plastic materials. ⏎ 1. A flexible conduit for connecting a coolant circuit of an engine to a radiator, comprising: ⏎ at least two successive conduit sections, each conduit section having a coaxially extruded inner wall and outer wall; ⏎ a pair of rigid end portions and at least one undulat
--- id 75453 | words 275 ---
<|endoftext|>Starts: Jun 14, 2013 9:00:00 AM ⏎ Starts: Jun 13, 2013 4:00:00 PM ⏎ Starts: Jun 13, 2013 9:00:00 AM ⏎ Themes in risk and disaster reduction ⏎ - public perception of risk ⏎ - how diverse societies deal with disaster ⏎ Understanding natural hazards: Geological and meteorological ⏎ - field and satellite observations ⏎ - laboratory simulations ⏎ - computational and statistical modelling ⏎ Understanding health risks and pandemics ⏎ - transmission characteristics of the infectious agents ⏎ - epidemiology of pandemics ⏎ - risks to radioactive waste and CO2 repositories ⏎ - complex engineered systems ⏎ Understanding c
--- id 75692 | words 159 ---
- A Frugal Chick - http://www.afrugalchick.com - ⏎ Groupon Deals of the Day- Carriage Rides, Fruit Baskets and Lunch Boxes ⏎ Posted By Laura On August 13, 2010 @ 8:14 am In Deals of the Day | Comments Disabled ⏎ The deal from Hampton Roads today is $89 for a Country Carriage Ride for Two and a Light Supper from Chariots for Hire in Suffolk ($180 Value). Might be nice for a romantic evening out! You have a year to use it from the date of purchase. ⏎ Boston (Side Deal)- Receive $50 to spend at Fruit Basket King for just $20. ⏎ Los Angeles (Deal Nearby)- Get a personalized photo classic metal lunchbox, i
--- id 117630 | words 263 ---
<|endoftext|> Hand Cursor ⏎ Hand Cursor ⏎ Site Map Feedback ⏎ Download: ⏎ Hand.cur ⏎ HandCursor.h ⏎ Controls Files Moving Data ⏎ Use a Hand Cursor without having one in your Resources ⏎ If you want to use a hand cursor (like web browsers use when the mouse is over a link) you either have to have Windows 2000 or above, or use a resource. [Yes, this is an old article, but it is kept in to demonstrate the technique] The trouble with resources is that you need to know the Resource ID and for the little classes offered on this site, that is not known. So this little class steals the Hand Cursor from a standard Wi
--- id 129069 | words 496 ---
BB Limited<|endoftext|>Freshmen' Guide To Enterprise Intelligence Tools | S-F ⏎ S-F BUSINESS ENTERPRENEUR ⏎ Learning ⏎ business ideas ⏎ how to start a business ⏎ small business loans ⏎ Management ⏎ business development ⏎ business management ⏎ small business ideas ⏎ starting a business ⏎ Market ⏎ business intelligence ⏎ business service ⏎ social security administration ⏎ Plan ⏎ business ethics ⏎ business plan ⏎ home based business ⏎ Freshmen’ Guide To Enterprise Intelligence Tools ⏎ There are lots of concepts and terms that it’s essential to know and handle when a crew working with Enterprise Intelligence points. Organizations select
--- id 131466 | words 106 ---
ishing | Origin and meaning of punishing by Online Etymology Dictionary ⏎ Advertisement ⏎ punishing (adj.) ⏎ "hard-hitting," 1811, present-participle adjective from punish (v.). Related: Punishingly. ⏎ Related Entries ⏎ punish ⏎ Others Are Reading ⏎ Share ⏎ Advertisement ⏎ Alphabetical list ⏎ pungent ⏎ Punic ⏎ punish ⏎ punishable ⏎ punisher ⏎ punishing ⏎ punishment ⏎ punitive ⏎ Punjab ⏎ punji ⏎ punk ⏎ A ⏎ B ⏎ C ⏎ D ⏎ E ⏎ F ⏎ G ⏎ H ⏎ I ⏎ J ⏎ K ⏎ L ⏎ M ⏎ N ⏎ O ⏎ P ⏎ Q ⏎ R ⏎ S ⏎ T ⏎ U ⏎ V ⏎ W ⏎ X ⏎ Y ⏎ Z ⏎ links ⏎ Classic VersionSourcesLinks ⏎ more ⏎ Chrome Extension词根词源词典 App培根词汇微信公众号 ⏎ about etymonline ⏎ Explanation of TermsWho did thisFollow on Facebook ⏎ support us ⏎ Donate with PayPalYe Olde Swag
--- id 156844 | words 279 ---
TS ⏎ Search ⏎ Eng Հայ ⏎ Donate ⏎ ABOUT US ⏎ Our mission Our management Our donors Our trustees ⏎ Why us ⏎ TRANSPARENCY ⏎ PROJECTS ⏎ President prize Ongoing Completed Proposed ⏎ MEDIA ⏎ News Announcements Notes Gallery ⏎ EVENTS ⏎ Board of trustees Telethon Phonethon ⏎ FUND WORLDWIDE ⏎ All Ongoing Completed Proposed ⏎ Regions ⏎ Armenia ⏎ Yerevan Aragatsotn Kotayk Syunik Vayots Dzor Ararat Armavir Gegharkunik Lori Shirak Tavush ⏎ Artsakh ⏎ Stepanakert Askeran Hadrut Martakert Martuni Shahumyan Shushi Qashatagh ⏎ Sponsored by ⏎ All Armenians Armenia Fund USA Armenia Fund, Inc Armenian community of Syria Government of Armenia Government of A
--- id 157150 | words 12181 ---
Audible Audiobooks To Check Out Now | PearTreePond ⏎ Home ⏎ Start here ⏎ Start A Profitable Blog ⏎ Find your business idea & branding strategy ⏎ Create a website & website optimization ⏎ Content writing & creating graphics ⏎ Marketing, promotion & ways to make money ⏎ Pinterest For Business ⏎ SEO & analytics ⏎ Work-Life-Balance, Productivity & Mindset ⏎ Solopreneur Toolkit ⏎ FREE Weekly Blog Planner ⏎ Business Plan Bundle ⏎ Home ⏎ Start here ⏎ Start A Profitable Blog ⏎ Find your business idea & branding strategy ⏎ Create a website & website optimization ⏎ Content writing & creating graphics ⏎ Marketing, promotion & ways to make mon
[metadata] {"noOutputExpected": false}This is classic raw web (FineWeb/C4-style) with heavy junk: navigation menus (id 156844, 131466), SEO keyword spam (id 129069), boilerplate (id 157150). The target is clean multi-register prose. The win is clear: filter junk + match the target distribution. Let me check available libraries and analyze the dev target's structure.
args
{
"command": "cd /workspace; python3 -c \"\nimport sklearn, scipy, numpy\nprint('sklearn', sklearn.__version__, 'scipy', scipy.__version__, 'numpy', numpy.__version__)\n\" 2>&1 | head; echo \"---DEV SEGMENTS---\"; python3 -c \"\nimport numpy as np\nfrom transformers import AutoTokenizer\ntok=AutoTokenizer.from_pretrained('gpt2')\nd=np.load('/workspace/data/multi_dev.npy')\n# split by EOS 50256\neos=50256\nidx=np.where(d==eos)[0]\nprint('num EOS separators:', len(idx))\nsegs=[]\nprev=0\nfor i in idx:\n segs.append((prev,i)); prev=i+1\nsegs.append((prev,len(d)))\nlens=[b-a for a,b in segs]\nlens=np.array(lens)\nprint('num segments:', len(segs), 'seg word/token lens: mean %.0f median %.0f min %d max %d'%(lens.mean(),np.median(lens),lens.min(),lens.max()))\n# show a few decoded segments to see registers\nimport random; random.seed(1)\nfor k in random.sample(range(len(segs)),6):\n a,b=segs[k]\n txt=tok.decode(d[a:b])\n print('--- seg',k,'len',b-a,'---')\n print(txt[:300].replace(chr(10),' | '))\n print()\n\"",
"description": "Check sklearn and analyze dev target segments"
}Bash result
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'sklearn'
---DEV SEGMENTS---
num EOS separators: 2704
num segments: 2705 seg word/token lens: mean 369 median 192 min 20 max 23346
--- seg 550 len 174 ---
Artillery and 90 mm tank fire destroyed seven more North Korean T @-@ 34 tanks , three more SU @-@ 76 towed guns , and several trucks and personnel carriers . This night battle , which was at times very intense , lasted about five hours . The US B Battery , 8th Field Artillery Battalion alone fired
--- seg 2331 len 234 ---
Actor Chris Pratt was spotted without his wedding gold band for the first time since announcing his split from wife Anna Faris.Pratt, 38, was seen greeting a friend as he took his son, Jack, to church here and the actor's ring was missing from his left hand, reported Us weekly.Faris, 40, and Pratt a
--- seg 258 len 70 ---
To profit from Monroe 's popularity , 20th Century @-@ Fox cultivated several lookalike actresses , including Jayne Mansfield and Sheree North . Other studios also attempted to create their own Monroes : Universal Pictures with Mamie Van Doren , Columbia Pictures with Kim Novak , and Rank Organisat
--- seg 1044 len 117 ---
Generally , fans reacted with confusion as to why the short existed . Bill Oakley and several other writers loved the short so much that they wanted to do more , but time limitations prevented them . As a result , Oakley and Josh Weinstein decided to produce an entire episode that was nothing but l
--- seg 482 len 21 ---
The maniples were typically deployed into three discrete lines based on the three heavy infantry types : |
--- seg 2029 len 658 ---
RRB Recruitment 2018 application process to fill 350 vacancies for Group ‘C’ or Group ‘D’ posts under General Departmental Competitive Examination (GDCE) scheme has begun on the official website of the North Eastern Railway, Gorakhpur - nergkp.org Interested and eligible candidates must apply for th
[stdout]
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'sklearn'
---DEV SEGMENTS---
num EOS separators: 2704
num segments: 2705 seg word/token lens: mean 369 median 192 min 20 max 23346
--- seg 550 len 174 ---
Artillery and 90 mm tank fire destroyed seven more North Korean T @-@ 34 tanks , three more SU @-@ 76 towed guns , and several trucks and personnel carriers . This night battle , which was at times very intense , lasted about five hours . The US B Battery , 8th Field Artillery Battalion alone fired
--- seg 2331 len 234 ---
Actor Chris Pratt was spotted without his wedding gold band for the first time since announcing his split from wife Anna Faris.Pratt, 38, was seen greeting a friend as he took his son, Jack, to church here and the actor's ring was missing from his left hand, reported Us weekly.Faris, 40, and Pratt a
--- seg 258 len 70 ---
To profit from Monroe 's popularity , 20th Century @-@ Fox cultivated several lookalike actresses , including Jayne Mansfield and Sheree North . Other studios also attempted to create their own Monroes : Universal Pictures with Mamie Van Doren , Columbia Pictures with Kim Novak , and Rank Organisat
--- seg 1044 len 117 ---
Generally , fans reacted with confusion as to why the short existed . Bill Oakley and several other writers loved the short so much that they wanted to do more , but time limitations prevented them . As a result , Oakley and Josh Weinstein decided to produce an entire episode that was nothing but l
--- seg 482 len 21 ---
The maniples were typically deployed into three discrete lines based on the three heavy infantry types : |
--- seg 2029 len 658 ---
RRB Recruitment 2018 application process to fill 350 vacancies for Group ‘C’ or Group ‘D’ posts under General Departmental Competitive Examination (GDCE) scheme has begun on the official website of the North Eastern Railway, Gorakhpur - nergkp.org Interested and eligible candidates must apply for th
[metadata] {"noOutputExpected": false}No sklearn, but I have numpy/torch. Dev target confirms the registers: Wikipedia (@-@ markers, spaced punctuation), news (Chris Pratt), Q&A/technical. My plan: DSIR-style target-matching (per-token log-likelihood ratio of target vs. pool background over hashed word n-grams) with quality gates to drop junk. Let me set up tasks and write curate.py.
args
{
"description": "Write curate.py scoring",
"subject": "Implement DSIR+quality curate.py and generate selection.json",
"activeForm": "Implementing curate.py"
}TaskCreate result
Task #1 created successfully: Implement DSIR+quality curate.py and generate selection.json
[metadata] {"task": {"id": "1", "subject": "Implement DSIR+quality curate.py and generate selection.json"}}encrypted chain-of-thought — recorded, not exposed
args
{
"description": "Validate selection with dev_eval",
"subject": "Run dev_eval on random baseline vs my selection, iterate",
"activeForm": "Validating with dev_eval training runs"
}TaskCreate result
Task #2 created successfully: Run dev_eval on random baseline vs my selection, iterate
[metadata] {"task": {"id": "2", "subject": "Run dev_eval on random baseline vs my selection, iterate"}}encrypted chain-of-thought — recorded, not exposed
args
{
"description": "Write claim.md",
"subject": "Write claim.md (Hypothesis/Mechanism/Falsification/Transfer)",
"activeForm": "Writing claim.md"
}TaskCreate result
Task #3 created successfully: Write claim.md (Hypothesis/Mechanism/Falsification/Transfer)
[metadata] {"task": {"id": "3", "subject": "Write claim.md (Hypothesis/Mechanism/Falsification/Transfer)"}}encrypted chain-of-thought — recorded, not exposed
args
{
"taskId": "1",
"status": "in_progress"
}TaskUpdate result
Updated task #1 status
[metadata] {"success": true, "taskId": "1", "updatedFields": ["status"], "statusChange": {"from": "pending", "to": "in_progress"}}Now let me write curate.py:
args
{
"file_path": "/workspace/submission/curate.py",
"content": "\"\"\"Curate a raw web pool into a priority-ordered training selection for a small LM.\n\nSTATED CRITERION\n----------------\nThe disclosed evaluation target is a BROAD, multi-domain, high-quality English\ndistribution (encyclopedic / general web prose / news / technical Q&A). We select\nthe pool documents whose token distribution most looks like that target while\nbeing clean, well-formed English prose.\n\nTwo ingredients, combined:\n\n1. TARGET-MATCHING (DSIR-style importance score). We model the target and the\n raw pool each as a bag of hashed word n-grams (unigrams + bigrams) and score\n every document by its *per-n-gram average log-likelihood ratio*\n s(d) = mean_{g in d} [ log p_target(g) - log p_pool(g) ].\n High s(d) => the document reads like the high-quality target domain; low s(d)\n => it reads like generic/boilerplate/off-domain web text. This is a\n Naive-Bayes / DSIR (Xie et al. 2023) log-odds toward the disclosed target.\n\n2. QUALITY GATES. Cheap Gopher/C4-style filters remove degenerate documents\n (too short, non-English, symbol/number soup, navigation-menu boilerplate,\n near-duplicate lines) so a document can't rank high on n-gram overlap alone.\n\nDocuments that fail any gate are dropped; survivors are emitted in DESCENDING\nscore order (best first). The training packer consumes this order until the\n12M-token budget is full, so the highest-quality, most on-target tokens are used.\n\nWord n-grams use a regex tokenizer over [a-z0-9]+, which incidentally normalises\nthe WikiText spacing artifacts (\"@-@\", \" , \") in the decoded target so they align\nwith normal raw-web punctuation.\n\nReproducible: deterministic (crc32 hashing, fixed params); no external labels.\n\"\"\"\nimport argparse, json, re, math, time, zlib\nimport numpy as np\nfrom transformers import AutoTokenizer\n\nPOOL = \"/workspace/data/pool.jsonl\"\nDEV = \"/workspace/data/multi_dev.npy\"\nOUT = \"/workspace/submission/selection.json\"\n\nD_UNI = 1 << 20 # unigram hash buckets\nD_BI = 1 << 20 # bigram hash buckets\nT = D_UNI + D_BI\nALPHA = 1.0 # additive smoothing on n-gram counts\nBUDGET = 12_000_000 # official token budget\n\nWTOK = re.compile(r\"[a-z0-9]+\")\n\n# Common English function words: prose has a high density of these; lists,\n# menus, keyword-spam and non-English text do not.\nSTOP = set((\"the be to of and a in that have i it for not on with he as you do at \"\n \"this but his by from they we say her she or an will my one all would there \"\n \"their what so up out if about who get which go me when make can like time no \"\n \"just him know take people into year your good some could them see other than \"\n \"then now look only come it's over think also back after use two how our work \"\n \"first well way even new want because any these give day most us is are was \"\n \"were been has had did does not no\").split())\n\n_uni_cache = {}\ndef _hw(w):\n h = _uni_cache.get(w)\n if h is None:\n h = zlib.crc32(w.encode()) & (D_UNI - 1)\n _uni_cache[w] = h\n return h\n\ndef doc_ngrams(words):\n \"\"\"hashed unigram+bigram ids for a token list -> int32 array.\"\"\"\n n = len(words)\n if n == 0:\n return np.empty(0, np.int32)\n uni = np.fromiter((_hw(w) for w in words), np.int64, n)\n if n == 1:\n return uni.astype(np.int32)\n bi = (((uni[:-1] * 1000003) ^ uni[1:]) & (D_BI - 1)) + D_UNI\n return np.concatenate([uni, bi]).astype(np.int32)\n\ndef quality(text, words):\n \"\"\"Return (pass_bool, feats dict). Gopher/C4-style cheap gates.\"\"\"\n nw = len(words)\n nchars = len(text)\n alpha = sum(c.isalpha() for c in text)\n frac_alpha = alpha / max(1, nchars)\n sw = sum(w in STOP for w in words)\n sw_ratio = sw / max(1, nw)\n mwl = sum(len(w) for w in words) / max(1, nw)\n lines = [ln for ln in text.split(\"\\n\") if ln.strip()]\n if lines:\n short = sum(len(ln.split()) < 4 for ln in lines)\n frac_short = short / len(lines)\n # near-duplicate line fraction (boilerplate / menus repeat lines)\n frac_dup = 1.0 - len(set(lines)) / len(lines)\n else:\n frac_short, frac_dup = 1.0, 0.0\n ok = (50 <= nw <= 50000 and frac_alpha >= 0.60 and sw_ratio >= 0.22\n and 3.0 <= mwl <= 9.0 and frac_short <= 0.5 and frac_dup <= 0.30)\n return ok, dict(nw=nw, frac_alpha=frac_alpha, sw_ratio=sw_ratio, mwl=mwl,\n frac_short=frac_short, frac_dup=frac_dup, nchars=nchars)\n\n\ndef build_target_counts():\n \"\"\"Decode the disclosed dev target into per-segment text; count n-grams.\"\"\"\n tok = AutoTokenizer.from_pretrained(\"gpt2\")\n d = np.load(DEV)\n eos = 50256\n idx = np.where(d == eos)[0]\n segs, prev = [], 0\n for i in idx:\n segs.append((prev, i)); prev = i + 1\n segs.append((prev, len(d)))\n Ct = np.zeros(T, np.float64)\n for a, b in segs:\n if b - a < 5:\n continue\n txt = tok.decode(d[a:b]).lower()\n words = WTOK.findall(txt)\n g = doc_ngrams(words)\n if len(g):\n Ct += np.bincount(g, minlength=T)\n return Ct\n\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--out\", default=OUT)\n ap.add_argument(\"--top\", type=int, default=60000, help=\"max ids to emit\")\n ap.add_argument(\"--diag\", action=\"store_true\")\n a = ap.parse_args()\n t0 = time.time()\n\n print(\"[1/5] target n-gram profile ...\", flush=True)\n Ct = build_target_counts()\n Nt = Ct.sum()\n\n print(\"[2/5] load pool + featurize ...\", flush=True)\n ids, texts, feats, quals, keep = [], [], [], [], []\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n t = r[\"text\"]\n low = t.replace(\"<|endoftext|>\", \" \").lower()\n words = WTOK.findall(low)\n ok, q = quality(t, words)\n g = doc_ngrams(words)\n ids.append(r[\"id\"]); feats.append(g); quals.append(q); keep.append(ok)\n ids = np.array(ids)\n print(f\" {len(ids)} docs, featurized in {time.time()-t0:.0f}s\", flush=True)\n\n print(\"[3/5] background n-gram profile ...\", flush=True)\n Cr = np.bincount(np.concatenate(feats), minlength=T).astype(np.float64)\n Nr = Cr.sum()\n\n # per-n-gram log-likelihood ratio log p_target - log p_pool\n lr = (np.log(Ct + ALPHA) - math.log(Nt + ALPHA * T)) \\\n - (np.log(Cr + ALPHA) - math.log(Nr + ALPHA * T))\n\n print(\"[4/5] score docs ...\", flush=True)\n scores = np.full(len(ids), -1e9, np.float64)\n for i, g in enumerate(feats):\n if keep[i] and len(g):\n scores[i] = lr[g].mean()\n\n order = np.argsort(-scores)\n passing = [j for j in order if scores[j] > -1e8]\n sel_ids = [int(ids[j]) for j in passing]\n\n # emit enough ids to comfortably exceed the token budget\n est = np.array([quals[j][\"nchars\"] for j in passing]) / 4.0\n cum = np.cumsum(est)\n n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: max(a.top, 0) or len(sel_ids)]\n emit = sel_ids[: a.top]\n json.dump(emit, open(a.out, \"w\"))\n print(f\"[5/5] wrote {len(emit)} ids -> {a.out} ({time.time()-t0:.0f}s)\")\n print(f\" passing gates: {len(passing)}/{len(ids)} \"\n f\"({100*len(passing)/len(ids):.1f}%)\")\n print(f\" ~{n_budget} docs (~{cum[min(n_budget,len(cum))-1]/1e6:.1f}M est tokens) \"\n f\"fill the 12M budget; emitting {len(emit)} for margin\")\n\n if a.diag:\n def show(js, tag):\n print(f\"\\n===== {tag} =====\")\n for j in js:\n q = quals[j]\n snip = texts_by_id.get(int(ids[j]), \"\")\n print(f\"[score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f}] id={ids[j]}\")\n # reload a few texts for display\n want = set(int(ids[j]) for j in passing[:8]) | \\\n set(int(ids[j]) for j in passing[-4:]) | \\\n set(int(ids[j]) for j in order[-6:])\n texts_by_id = {}\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n if r[\"id\"] in want:\n texts_by_id[r[\"id\"]] = r[\"text\"]\n print(\"\\n----- TOP 8 (best on-target) -----\")\n for j in passing[:8]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- BOTTOM 4 of PASSING -----\")\n for j in passing[-4:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- 6 GATE-REJECTED (lowest score overall) -----\")\n for j in order[-6:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"id={ids[j]}: {texts_by_id.get(int(ids[j]),'')[:150].strip().replace(chr(10),' | ')}\")\n\n\nif __name__ == \"__main__\":\n main()\n"
}Write result
File created successfully at: /workspace/submission/curate.py (file state is current in your context — no need to Read it back)
[metadata] {"type": "create", "filePath": "/workspace/submission/curate.py", "content": "\"\"\"Curate a raw web pool into a priority-ordered training selection for a small LM.\n\nSTATED CRITERION\n----------------\nThe disclosed evaluation target is a BROAD, multi-domain, high-quality English\ndistribution (encyclopedic / general web prose / news / technical Q&A). We select\nthe pool documents whose token distribution most looks like that target while\nbeing clean, well-formed English prose.\n\nTwo ingredients, combined:\n\n1. TARGET-MATCHING (DSIR-style importance score). We model the target and the\n raw pool each as a bag of hashed word n-grams (unigrams + bigrams) and score\n every document by its *per-n-gram average log-likelihood ratio*\n s(d) = mean_{g in d} [ log p_target(g) - log p_pool(g) ].\n High s(d) => the document reads like the high-quality target domain; low s(d)\n => it reads like generic/boilerplate/off-domain web text. This is a\n Naive-Bayes / DSIR (Xie et al. 2023) log-odds toward the disclosed target.\n\n2. QUALITY GATES. Cheap Gopher/C4-style filters remove degenerate documents\n (too short, non-English, symbol/number soup, navigation-menu boilerplate,\n near-duplicate lines) so a document can't rank high on n-gram overlap alone.\n\nDocuments that fail any gate are dropped; survivors are emitted in DESCENDING\nscore order (best first). The training packer consumes this order until the\n12M-token budget is full, so the highest-quality, most on-target tokens are used.\n\nWord n-grams use a regex tokenizer over [a-z0-9]+, which incidentally normalises\nthe WikiText spacing artifacts (\"@-@\", \" , \") in the decoded target so they align\nwith normal raw-web punctuation.\n\nReproducible: deterministic (crc32 hashing, fixed params); no external labels.\n\"\"\"\nimport argparse, json, re, math, time, zlib\nimport numpy as np\nfrom transformers import AutoTokenizer\n\nPOOL = \"/workspace/data/pool.jsonl\"\nDEV = \"/workspace/data/multi_dev.npy\"\nOUT = \"/workspace/submission/selection.json\"\n\nD_UNI = 1 << 20 # unigram hash buckets\nD_BI = 1 << 20 # bigram hash buckets\nT = D_UNI + D_BI\nALPHA = 1.0 # additive smoothing on n-gram counts\nBUDGET = 12_000_000 # official token budget\n\nWTOK = re.compile(r\"[a-z0-9]+\")\n\n# Common English function words: prose has a high density of these; lists,\n# menus, keyword-spam and non-English text do not.\nSTOP = set((\"the be to of and a in that have i it for not on with he as you do at \"\n \"this but his by from they we say her she or an will my one all would there \"\n \"their what so up out if about who get which go me when make can like time no \"\n \"just him know take people into year your good some could them see other than \"\n \"then now look only come it's over think also back after use two how our work \"\n \"first well way even new want because any these give day most us is are was \"\n \"were been has had did does not no\").split())\n\n_uni_cache = {}\ndef _hw(w):\n h = _uni_cache.get(w)\n if h is None:\n h = zlib.crc32(w.encode()) & (D_UNI - 1)\n _uni_cache[w] = h\n return h\n\ndef doc_ngrams(words):\n \"\"\"hashed unigram+bigram ids for a token list -> int32 array.\"\"\"\n n = len(words)\n if n == 0:\n return np.empty(0, np.int32)\n uni = np.fromiter((_hw(w) for w in words), np.int64, n)\n if n == 1:\n return uni.astype(np.int32)\n bi = (((uni[:-1] * 1000003) ^ uni[1:]) & (D_BI - 1)) + D_UNI\n return np.concatenate([uni, bi]).astype(np.int32)\n\ndef quality(text, words):\n \"\"\"Return (pass_bool, feats dict). Gopher/C4-style cheap gates.\"\"\"\n nw = len(words)\n nchars = len(text)\n alpha = sum(c.isalpha() for c in text)\n frac_alpha = alpha / max(1, nchars)\n sw = sum(w in STOP for w in words)\n sw_ratio = sw / max(1, nw)\n mwl = sum(len(w) for w in words) / max(1, nw)\n lines = [ln for ln in text.split(\"\\n\") if ln.strip()]\n if lines:\n short = sum(len(ln.split()) < 4 for ln in lines)\n frac_short = short / len(lines)\n # near-duplicate line fraction (boilerplate / menus repeat lines)\n frac_dup = 1.0 - len(set(lines)) / len(lines)\n else:\n frac_short, frac_dup = 1.0, 0.0\n ok = (50 <= nw <= 50000 and frac_alpha >= 0.60 and sw_ratio >= 0.22\n and 3.0 <= mwl <= 9.0 and frac_short <= 0.5 and frac_dup <= 0.30)\n return ok, dict(nw=nw, frac_alpha=frac_alpha, sw_ratio=sw_ratio, mwl=mwl,\n frac_short=frac_short, frac_dup=frac_dup, nchars=nchars)\n\n\ndef build_target_counts():\n \"\"\"Decode the disclosed dev target into per-segment text; count n-grams.\"\"\"\n tok = AutoTokenizer.from_pretrained(\"gpt2\")\n d = np.load(DEV)\n eos = 50256\n idx = np.where(d == eos)[0]\n segs, prev = [], 0\n for i in idx:\n segs.append((prev, i)); prev = i + 1\n segs.append((prev, len(d)))\n Ct = np.zeros(T, np.float64)\n for a, b in segs:\n if b - a < 5:\n continue\n txt = tok.decode(d[a:b]).lower()\n words = WTOK.findall(txt)\n g = doc_ngrams(words)\n if len(g):\n Ct += np.bincount(g, minlength=T)\n return Ct\n\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--out\", default=OUT)\n ap.add_argument(\"--top\", type=int, default=60000, help=\"max ids to emit\")\n ap.add_argument(\"--diag\", action=\"store_true\")\n a = ap.parse_args()\n t0 = time.time()\n\n print(\"[1/5] target n-gram profile ...\", flush=True)\n Ct = build_target_counts()\n Nt = Ct.sum()\n\n print(\"[2/5] load pool + featurize ...\", flush=True)\n ids, texts, feats, quals, keep = [], [], [], [], []\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n t = r[\"text\"]\n low = t.replace(\"<|endoftext|>\", \" \").lower()\n words = WTOK.findall(low)\n ok, q = quality(t, words)\n g = doc_ngrams(words)\n ids.append(r[\"id\"]); feats.append(g); quals.append(q); keep.append(ok)\n ids = np.array(ids)\n print(f\" {len(ids)} docs, featurized in {time.time()-t0:.0f}s\", flush=True)\n\n print(\"[3/5] background n-gram profile ...\", flush=True)\n Cr = np.bincount(np.concatenate(feats), minlength=T).astype(np.float64)\n Nr = Cr.sum()\n\n # per-n-gram log-likelihood ratio log p_target - log p_pool\n lr = (np.log(Ct + ALPHA) - math.log(Nt + ALPHA * T)) \\\n - (np.log(Cr + ALPHA) - math.log(Nr + ALPHA * T))\n\n print(\"[4/5] score docs ...\", flush=True)\n scores = np.full(len(ids), -1e9, np.float64)\n for i, g in enumerate(feats):\n if keep[i] and len(g):\n scores[i] = lr[g].mean()\n\n order = np.argsort(-scores)\n passing = [j for j in order if scores[j] > -1e8]\n sel_ids = [int(ids[j]) for j in passing]\n\n # emit enough ids to comfortably exceed the token budget\n est = np.array([quals[j][\"nchars\"] for j in passing]) / 4.0\n cum = np.cumsum(est)\n n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: max(a.top, 0) or len(sel_ids)]\n emit = sel_ids[: a.top]\n json.dump(emit, open(a.out, \"w\"))\n print(f\"[5/5] wrote {len(emit)} ids -> {a.out} ({time.time()-t0:.0f}s)\")\n print(f\" passing gates: {len(passing)}/{len(ids)} \"\n f\"({100*len(passing)/len(ids):.1f}%)\")\n print(f\" ~{n_budget} docs (~{cum[min(n_budget,len(cum))-1]/1e6:.1f}M est tokens) \"\n f\"fill the 12M budget; emitting {len(emit)} for margin\")\n\n if a.diag:\n def show(js, tag):\n print(f\"\\n===== {tag} =====\")\n for j in js:\n q = quals[j]\n snip = texts_by_id.get(int(ids[j]), \"\")\n print(f\"[score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f}] id={ids[j]}\")\n # reload a few texts for display\n want = set(int(ids[j]) for j in passing[:8]) | \\\n set(int(ids[j]) for j in passing[-4:]) | \\\n set(int(ids[j]) for j in order[-6:])\n texts_by_id = {}\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n if r[\"id\"] in want:\n texts_by_id[r[\"id\"]] = r[\"text\"]\n print(\"\\n----- TOP 8 (best on-target) -----\")\n for j in passing[:8]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- BOTTOM 4 of PASSING -----\")\n for j in passing[-4:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- 6 GATE-REJECTED (lowest score overall) -----\")\n for j in order[-6:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"id={ids[j]}: {texts_by_id.get(int(ids[j]),'')[:150].strip().replace(chr(10),' | ')}\")\n\n\nif __name__ == \"__main__\":\n main()\n", "structuredPatch": [], "originalFile": null, "userModified": false}Let me fix a small duplication bug (two emit = lines) before running:
args
{
"replace_all": false,
"file_path": "/workspace/submission/curate.py",
"old_string": " n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: max(a.top, 0) or len(sel_ids)]\n emit = sel_ids[: a.top]",
"new_string": " n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: a.top]"
}Edit result
The file /workspace/submission/curate.py has been updated successfully. (file state is current in your context — no need to Read it back)
[metadata] {"filePath": "/workspace/submission/curate.py", "oldString": " n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: max(a.top, 0) or len(sel_ids)]\n emit = sel_ids[: a.top]", "newString": " n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: a.top]", "originalFile": "\"\"\"Curate a raw web pool into a priority-ordered training selection for a small LM.\n\nSTATED CRITERION\n----------------\nThe disclosed evaluation target is a BROAD, multi-domain, high-quality English\ndistribution (encyclopedic / general web prose / news / technical Q&A). We select\nthe pool documents whose token distribution most looks like that target while\nbeing clean, well-formed English prose.\n\nTwo ingredients, combined:\n\n1. TARGET-MATCHING (DSIR-style importance score). We model the target and the\n raw pool each as a bag of hashed word n-grams (unigrams + bigrams) and score\n every document by its *per-n-gram average log-likelihood ratio*\n s(d) = mean_{g in d} [ log p_target(g) - log p_pool(g) ].\n High s(d) => the document reads like the high-quality target domain; low s(d)\n => it reads like generic/boilerplate/off-domain web text. This is a\n Naive-Bayes / DSIR (Xie et al. 2023) log-odds toward the disclosed target.\n\n2. QUALITY GATES. Cheap Gopher/C4-style filters remove degenerate documents\n (too short, non-English, symbol/number soup, navigation-menu boilerplate,\n near-duplicate lines) so a document can't rank high on n-gram overlap alone.\n\nDocuments that fail any gate are dropped; survivors are emitted in DESCENDING\nscore order (best first). The training packer consumes this order until the\n12M-token budget is full, so the highest-quality, most on-target tokens are used.\n\nWord n-grams use a regex tokenizer over [a-z0-9]+, which incidentally normalises\nthe WikiText spacing artifacts (\"@-@\", \" , \") in the decoded target so they align\nwith normal raw-web punctuation.\n\nReproducible: deterministic (crc32 hashing, fixed params); no external labels.\n\"\"\"\nimport argparse, json, re, math, time, zlib\nimport numpy as np\nfrom transformers import AutoTokenizer\n\nPOOL = \"/workspace/data/pool.jsonl\"\nDEV = \"/workspace/data/multi_dev.npy\"\nOUT = \"/workspace/submission/selection.json\"\n\nD_UNI = 1 << 20 # unigram hash buckets\nD_BI = 1 << 20 # bigram hash buckets\nT = D_UNI + D_BI\nALPHA = 1.0 # additive smoothing on n-gram counts\nBUDGET = 12_000_000 # official token budget\n\nWTOK = re.compile(r\"[a-z0-9]+\")\n\n# Common English function words: prose has a high density of these; lists,\n# menus, keyword-spam and non-English text do not.\nSTOP = set((\"the be to of and a in that have i it for not on with he as you do at \"\n \"this but his by from they we say her she or an will my one all would there \"\n \"their what so up out if about who get which go me when make can like time no \"\n \"just him know take people into year your good some could them see other than \"\n \"then now look only come it's over think also back after use two how our work \"\n \"first well way even new want because any these give day most us is are was \"\n \"were been has had did does not no\").split())\n\n_uni_cache = {}\ndef _hw(w):\n h = _uni_cache.get(w)\n if h is None:\n h = zlib.crc32(w.encode()) & (D_UNI - 1)\n _uni_cache[w] = h\n return h\n\ndef doc_ngrams(words):\n \"\"\"hashed unigram+bigram ids for a token list -> int32 array.\"\"\"\n n = len(words)\n if n == 0:\n return np.empty(0, np.int32)\n uni = np.fromiter((_hw(w) for w in words), np.int64, n)\n if n == 1:\n return uni.astype(np.int32)\n bi = (((uni[:-1] * 1000003) ^ uni[1:]) & (D_BI - 1)) + D_UNI\n return np.concatenate([uni, bi]).astype(np.int32)\n\ndef quality(text, words):\n \"\"\"Return (pass_bool, feats dict). Gopher/C4-style cheap gates.\"\"\"\n nw = len(words)\n nchars = len(text)\n alpha = sum(c.isalpha() for c in text)\n frac_alpha = alpha / max(1, nchars)\n sw = sum(w in STOP for w in words)\n sw_ratio = sw / max(1, nw)\n mwl = sum(len(w) for w in words) / max(1, nw)\n lines = [ln for ln in text.split(\"\\n\") if ln.strip()]\n if lines:\n short = sum(len(ln.split()) < 4 for ln in lines)\n frac_short = short / len(lines)\n # near-duplicate line fraction (boilerplate / menus repeat lines)\n frac_dup = 1.0 - len(set(lines)) / len(lines)\n else:\n frac_short, frac_dup = 1.0, 0.0\n ok = (50 <= nw <= 50000 and frac_alpha >= 0.60 and sw_ratio >= 0.22\n and 3.0 <= mwl <= 9.0 and frac_short <= 0.5 and frac_dup <= 0.30)\n return ok, dict(nw=nw, frac_alpha=frac_alpha, sw_ratio=sw_ratio, mwl=mwl,\n frac_short=frac_short, frac_dup=frac_dup, nchars=nchars)\n\n\ndef build_target_counts():\n \"\"\"Decode the disclosed dev target into per-segment text; count n-grams.\"\"\"\n tok = AutoTokenizer.from_pretrained(\"gpt2\")\n d = np.load(DEV)\n eos = 50256\n idx = np.where(d == eos)[0]\n segs, prev = [], 0\n for i in idx:\n segs.append((prev, i)); prev = i + 1\n segs.append((prev, len(d)))\n Ct = np.zeros(T, np.float64)\n for a, b in segs:\n if b - a < 5:\n continue\n txt = tok.decode(d[a:b]).lower()\n words = WTOK.findall(txt)\n g = doc_ngrams(words)\n if len(g):\n Ct += np.bincount(g, minlength=T)\n return Ct\n\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--out\", default=OUT)\n ap.add_argument(\"--top\", type=int, default=60000, help=\"max ids to emit\")\n ap.add_argument(\"--diag\", action=\"store_true\")\n a = ap.parse_args()\n t0 = time.time()\n\n print(\"[1/5] target n-gram profile ...\", flush=True)\n Ct = build_target_counts()\n Nt = Ct.sum()\n\n print(\"[2/5] load pool + featurize ...\", flush=True)\n ids, texts, feats, quals, keep = [], [], [], [], []\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n t = r[\"text\"]\n low = t.replace(\"<|endoftext|>\", \" \").lower()\n words = WTOK.findall(low)\n ok, q = quality(t, words)\n g = doc_ngrams(words)\n ids.append(r[\"id\"]); feats.append(g); quals.append(q); keep.append(ok)\n ids = np.array(ids)\n print(f\" {len(ids)} docs, featurized in {time.time()-t0:.0f}s\", flush=True)\n\n print(\"[3/5] background n-gram profile ...\", flush=True)\n Cr = np.bincount(np.concatenate(feats), minlength=T).astype(np.float64)\n Nr = Cr.sum()\n\n # per-n-gram log-likelihood ratio log p_target - log p_pool\n lr = (np.log(Ct + ALPHA) - math.log(Nt + ALPHA * T)) \\\n - (np.log(Cr + ALPHA) - math.log(Nr + ALPHA * T))\n\n print(\"[4/5] score docs ...\", flush=True)\n scores = np.full(len(ids), -1e9, np.float64)\n for i, g in enumerate(feats):\n if keep[i] and len(g):\n scores[i] = lr[g].mean()\n\n order = np.argsort(-scores)\n passing = [j for j in order if scores[j] > -1e8]\n sel_ids = [int(ids[j]) for j in passing]\n\n # emit enough ids to comfortably exceed the token budget\n est = np.array([quals[j][\"nchars\"] for j in passing]) / 4.0\n cum = np.cumsum(est)\n n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: max(a.top, 0) or len(sel_ids)]\n emit = sel_ids[: a.top]\n json.dump(emit, open(a.out, \"w\"))\n print(f\"[5/5] wrote {len(emit)} ids -> {a.out} ({time.time()-t0:.0f}s)\")\n print(f\" passing gates: {len(passing)}/{len(ids)} \"\n f\"({100*len(passing)/len(ids):.1f}%)\")\n print(f\" ~{n_budget} docs (~{cum[min(n_budget,len(cum))-1]/1e6:.1f}M est tokens) \"\n f\"fill the 12M budget; emitting {len(emit)} for margin\")\n\n if a.diag:\n def show(js, tag):\n print(f\"\\n===== {tag} =====\")\n for j in js:\n q = quals[j]\n snip = texts_by_id.get(int(ids[j]), \"\")\n print(f\"[score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f}] id={ids[j]}\")\n # reload a few texts for display\n want = set(int(ids[j]) for j in passing[:8]) | \\\n set(int(ids[j]) for j in passing[-4:]) | \\\n set(int(ids[j]) for j in order[-6:])\n texts_by_id = {}\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n if r[\"id\"] in want:\n texts_by_id[r[\"id\"]] = r[\"text\"]\n print(\"\\n----- TOP 8 (best on-target) -----\")\n for j in passing[:8]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- BOTTOM 4 of PASSING -----\")\n for j in passing[-4:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- 6 GATE-REJECTED (lowest score overall) -----\")\n for j in order[-6:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"id={ids[j]}: {texts_by_id.get(int(ids[j]),'')[:150].strip().replace(chr(10),' | ')}\")\n\n\nif __name__ == \"__main__\":\n main()\n", "structuredPatch": [{"oldStart": 169, "oldLines": 7, "newStart": 169, "newLines": 6, "lines": [" est = np.array([quals[j][\"nchars\"] for j in passing]) / 4.0", " cum = np.cumsum(est)", " n_budget = int(np.searchsorted(cum, BUDGET)) + 1", "- emit = sel_ids[: max(a.top, 0) or len(sel_ids)]", " emit = sel_ids[: a.top]", " json.dump(emit, open(a.out, \"w\"))", " print(f\"[5/5] wrote {len(emit)} ids -> {a.out} ({time.time()-t0:.0f}s)\")"]}], "userModified": false, "replaceAll": false}Now let me run curate.py with diagnostics to verify the scoring separates good prose from junk:
args
{
"command": "export TOKENIZERS_PARALLELISM=false && python3 submission/curate.py --diag 2>&1 | tail -40",
"description": "Run curate.py with diagnostics"
}Bash result
Command did not complete within its 120s timeout and was moved to the background (ID: b4po5pqxe). Output is being written to: /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/b4po5pqxe.output. You will be notified when it completes. To check interim output, use Read on that file path.
[metadata] {"noOutputExpected": false, "backgroundTaskId": "b4po5pqxe", "timedOutAfterMs": 120000}It's running in the background (featurization takes a bit). Let me check progress:
args
{
"command": "sleep 30; cat /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/b4po5pqxe.output 2>/dev/null; echo \"---timer---\"; cat /workspace/.timer/remaining_secs",
"description": "Check curate.py progress"
}Bash result
[1/5] target n-gram profile ...
[2/5] load pool + featurize ...
182016 docs, featurized in 131s
[3/5] background n-gram profile ...
[4/5] score docs ...
[5/5] wrote 60000 ids -> /workspace/submission/selection.json (135s)
passing gates: 120480/182016 (66.2%)
~12464 docs (~12.0M est tokens) fill the 12M budget; emitting 60000 for margin
----- TOP 8 (best on-target) -----
score +0.296 nw 1436 sw 0.23 short 0.06 id=18830: Archaeological dating methods | Futilities must undress thitherward convened dismissively towerish tomato. | Possessory tongs being very mechanically fugued calendering. | Burdensomely t
score +0.235 nw 975 sw 0.25 short 0.04 id=73993: |PREDECESSORS AND SHORT HISTORY: | in the 16th century by Rao Gopalji fl.1550, 4th son of Raja Prithviraj | Singhji I of Jaipur. Rulers were… | - Rao GOPAL SINGH, | Thakur Saheb of Chomu f
score +0.202 nw 240 sw 0.33 short 0.00 id=98806: hesiall, Loo. Micks. The ness arou shis. I therrying ot! Mmmend bou. Mays 14 he sairry, by norms nexpren I ateseel ing thaver. Waying aroolvere up thishe lie thought wasse whelf e
score +0.179 nw 95 sw 0.46 short 0.00 id=88750: ggor Domm II (375BDW-51ADW) is widely considered to be the greatest ruler in the history of the Nethereigons. He reigned the Northern Dividend of the Nethereigons from 310BDW to 7A
score +0.168 nw 554 sw 0.25 short 0.45 id=170082: bloggers like this:<|endoftext|>Astrologer, Solar and Lunar Eclipse, Blood Moon, | Lunar Insight. | Mission StatementORDER YOUR REPORTShooting Botham JeanLiving In Harmony With God.Th
score +0.147 nw 83 sw 0.30 short 0.00 id=63063: Re: Yellow belt requirments | 5th kyu is representitave of yellow in our org. | It comprises of: Mae ukemi, Ushiro Ukemi, Shikko, Tai-sabaki and Tai-No-Henko. | Then Against Ai hanmi kat
score +0.087 nw 354 sw 0.34 short 0.00 id=76686: Created by: brenna wilson | - Created on: 26-03-13 20:16 | Quod ubi est Philodamo nuntiatum, tametsi erat ignarus quantum sibi ac liberis suis iam tum mali constitueretur, tamen ad is
score +0.086 nw 61 sw 0.36 short 0.00 id=8203: House Kleef - Under The Drake Duck Banner | Lord Halys Hornwood of Hornwood | Lord Halys Hornwood of Hornwood rules the house with his wife Lady Donella, a cousin to Lord Manderly, and
----- BOTTOM 4 of PASSING -----
score -1.904 nw 175 id=123947: administrator.<|endoftext|>michaeljeans9885 | Michael Jeans | Michael Jeans | +64274963802 | m@michaeljeans.nz | Menu | Skip to content | Home | About | Contact | April 2019 | Search for: | michaelje
score -1.904 nw 175 id=146603: administrator.<|endoftext|>michaeljeans9885 | Michael Jeans | Michael Jeans | +64274963802 | m@michaeljeans.nz | Menu | Skip to content | Home | About | Contact | April 2019 | Search for: | michaelje
score -1.926 nw 138 id=138085: x y z<|endoftext|>صور مشبات (1600) | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات ,صور مشبات رخام,صور مشبات,صور مشبات مودرن,صور م
score -1.926 nw 138 id=115429: x y z<|endoftext|>صور مشبات (1600) | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات ,صور مشبات رخام,صور مشبات,صور مشبات مودرن,صور م
----- 6 GATE-REJECTED (lowest score overall) -----
score -1000000000.000 nw 1633 sw 0.22 id=182013: - Part 79 | Latest | Senate President blames lyrical content as contributing factor to sexual offences | 20 mins ago | ITU – Caribbean Girls Hack events show
score -1000000000.000 nw 551 sw 0.17 id=182012: the Hydrogen and Lithium Substructure of Poly(triazine imide)/LiCl Using NMR Crystallography | Mesch MB, Baerwinkel K, Krysiak Y, et al. (2016) | Chemist
score -1000000000.000 nw 291 sw 0.14 id=182011: Templates | Back to top<|endoftext|>carbon footprint reduction | Carbon Neutral Shredding | HOME | SHREDDING SERVICES | Mobile On-Site Shredding | Off-Site Shr
score -1000000000.000 nw 137 sw 0.30 id=182009: pictures | Home | About Us | Rates | Kit | Video Services | Advertisements and TV commercial | Wedding Video | Interview, TV reports | Music, Concert Video | Farewell Pa
score -1000000000.000 nw 5421 sw 0.16 id=38: Larry Kim, Founder and Chief Technology Officer | Larry Kim founded WordStream in 2007. He bootstrapped the company by providing internet consulting ser
score -1000000000.000 nw 293 sw 0.08 id=182008: WV capitol - wvuphotos | Log In | Support | Skip to main content | West Virginia University Photos | Search | Home | Print Prices | Monthly Favorites | Monthly Photo G
---timer---
4789
[stdout]
[1/5] target n-gram profile ...
[2/5] load pool + featurize ...
182016 docs, featurized in 131s
[3/5] background n-gram profile ...
[4/5] score docs ...
[5/5] wrote 60000 ids -> /workspace/submission/selection.json (135s)
passing gates: 120480/182016 (66.2%)
~12464 docs (~12.0M est tokens) fill the 12M budget; emitting 60000 for margin
----- TOP 8 (best on-target) -----
score +0.296 nw 1436 sw 0.23 short 0.06 id=18830: Archaeological dating methods | Futilities must undress thitherward convened dismissively towerish tomato. | Possessory tongs being very mechanically fugued calendering. | Burdensomely t
score +0.235 nw 975 sw 0.25 short 0.04 id=73993: |PREDECESSORS AND SHORT HISTORY: | in the 16th century by Rao Gopalji fl.1550, 4th son of Raja Prithviraj | Singhji I of Jaipur. Rulers were… | - Rao GOPAL SINGH, | Thakur Saheb of Chomu f
score +0.202 nw 240 sw 0.33 short 0.00 id=98806: hesiall, Loo. Micks. The ness arou shis. I therrying ot! Mmmend bou. Mays 14 he sairry, by norms nexpren I ateseel ing thaver. Waying aroolvere up thishe lie thought wasse whelf e
score +0.179 nw 95 sw 0.46 short 0.00 id=88750: ggor Domm II (375BDW-51ADW) is widely considered to be the greatest ruler in the history of the Nethereigons. He reigned the Northern Dividend of the Nethereigons from 310BDW to 7A
score +0.168 nw 554 sw 0.25 short 0.45 id=170082: bloggers like this:<|endoftext|>Astrologer, Solar and Lunar Eclipse, Blood Moon, | Lunar Insight. | Mission StatementORDER YOUR REPORTShooting Botham JeanLiving In Harmony With God.Th
score +0.147 nw 83 sw 0.30 short 0.00 id=63063: Re: Yellow belt requirments | 5th kyu is representitave of yellow in our org. | It comprises of: Mae ukemi, Ushiro Ukemi, Shikko, Tai-sabaki and Tai-No-Henko. | Then Against Ai hanmi kat
score +0.087 nw 354 sw 0.34 short 0.00 id=76686: Created by: brenna wilson | - Created on: 26-03-13 20:16 | Quod ubi est Philodamo nuntiatum, tametsi erat ignarus quantum sibi ac liberis suis iam tum mali constitueretur, tamen ad is
score +0.086 nw 61 sw 0.36 short 0.00 id=8203: House Kleef - Under The Drake Duck Banner | Lord Halys Hornwood of Hornwood | Lord Halys Hornwood of Hornwood rules the house with his wife Lady Donella, a cousin to Lord Manderly, and
----- BOTTOM 4 of PASSING -----
score -1.904 nw 175 id=123947: administrator.<|endoftext|>michaeljeans9885 | Michael Jeans | Michael Jeans | +64274963802 | m@michaeljeans.nz | Menu | Skip to content | Home | About | Contact | April 2019 | Search for: | michaelje
score -1.904 nw 175 id=146603: administrator.<|endoftext|>michaeljeans9885 | Michael Jeans | Michael Jeans | +64274963802 | m@michaeljeans.nz | Menu | Skip to content | Home | About | Contact | April 2019 | Search for: | michaelje
score -1.926 nw 138 id=138085: x y z<|endoftext|>صور مشبات (1600) | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات ,صور مشبات رخام,صور مشبات,صور مشبات مودرن,صور م
score -1.926 nw 138 id=115429: x y z<|endoftext|>صور مشبات (1600) | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات رخام حجر فخمه مشبات0504210110 | صور مشبات ,صور مشبات رخام,صور مشبات,صور مشبات مودرن,صور م
----- 6 GATE-REJECTED (lowest score overall) -----
score -1000000000.000 nw 1633 sw 0.22 id=182013: - Part 79 | Latest | Senate President blames lyrical content as contributing factor to sexual offences | 20 mins ago | ITU – Caribbean Girls Hack events show
score -1000000000.000 nw 551 sw 0.17 id=182012: the Hydrogen and Lithium Substructure of Poly(triazine imide)/LiCl Using NMR Crystallography | Mesch MB, Baerwinkel K, Krysiak Y, et al. (2016) | Chemist
score -1000000000.000 nw 291 sw 0.14 id=182011: Templates | Back to top<|endoftext|>carbon footprint reduction | Carbon Neutral Shredding | HOME | SHREDDING SERVICES | Mobile On-Site Shredding | Off-Site Shr
score -1000000000.000 nw 137 sw 0.30 id=182009: pictures | Home | About Us | Rates | Kit | Video Services | Advertisements and TV commercial | Wedding Video | Interview, TV reports | Music, Concert Video | Farewell Pa
score -1000000000.000 nw 5421 sw 0.16 id=38: Larry Kim, Founder and Chief Technology Officer | Larry Kim founded WordStream in 2007. He bootstrapped the company by providing internet consulting ser
score -1000000000.000 nw 293 sw 0.08 id=182008: WV capitol - wvuphotos | Log In | Support | Skip to main content | West Virginia University Photos | Search | Home | Print Prices | Monthly Favorites | Monthly Photo G
---timer---
4789
[metadata] {"noOutputExpected": false}The scoring has a critical bug: the top-ranked docs are gibberish (id=18830 "Futilities must undress thitherward...", id=98806 garbled text) and Latin (id=76686). This is the classic DSIR smoothing pitfall: because the target corpus (~2M n-grams) is far smaller than the pool (~246M), the additive-smoothing floor makes any rare/novel n-gram (gibberish, foreign, misspellings) score positively — rarity gets rewarded.
The fix: an n-gram may only earn positive credit if it genuinely appears in the target (Ct≥2); otherwise it can only be neutral or penalized. This kills the rarity reward while keeping the junk penalty. Let me also add caching so I can iterate on scoring without the 130s re-featurization.
args
{
"file_path": "/workspace/submission/curate.py",
"content": "\"\"\"Curate a raw web pool into a priority-ordered training selection for a small LM.\n\nSTATED CRITERION\n----------------\nThe disclosed evaluation target is a BROAD, multi-domain, high-quality English\ndistribution (encyclopedic / general web prose / news / technical Q&A). We select\nthe pool documents whose token distribution most looks like that target while\nbeing clean, well-formed English prose.\n\nTwo ingredients, combined:\n\n1. TARGET-MATCHING (DSIR-style importance score). Model the target and the raw\n pool each as a bag of hashed word n-grams (unigrams + bigrams). Score every\n document by its per-token average log-likelihood ratio\n s(d) = mean_{g in d} w(g), w(g) = log p_target(g) - log p_pool(g).\n High s(d) => reads like the high-quality target domain; low s(d) => reads like\n generic/boilerplate/off-domain web text (Naive-Bayes / DSIR log-odds, Xie 2023).\n\n RARITY CORRECTION. The target corpus (~2M n-grams) is ~100x smaller than the\n pool (~250M). Naive additive smoothing then gives *any* n-gram unseen in the\n target (gibberish, foreign text, misspellings, rare jargon) a positive weight,\n because the smoothing floor of p_target exceeds a genuinely-rare p_pool. We\n correct this: an n-gram may earn POSITIVE weight only if it is actually present\n in the target (count >= MINCT); otherwise its weight is clamped to <= 0 (it may\n still PENALISE a document when it is common in the pool but absent from target).\n So a document is rewarded only for n-grams the target genuinely uses.\n\n2. QUALITY GATES. Cheap Gopher/C4-style filters remove degenerate documents\n (too short, non-English, symbol/number soup, navigation-menu boilerplate,\n near-duplicate lines) so nothing ranks purely on n-gram artefacts.\n\nDocuments that fail any gate are dropped; survivors are emitted in DESCENDING\nscore order (best first). The training packer consumes this order until the\n12M-token budget is full, so the highest-quality, most on-target tokens are used.\n\nWord n-grams use a regex tokenizer over [a-z0-9]+, which also normalises the\ndecoded target's WikiText spacing artifacts (\"@-@\", \" , \") so they align with\nnormal raw-web punctuation. Deterministic (crc32 hashing); no external labels.\n\"\"\"\nimport argparse, json, re, math, os, time, zlib\nimport numpy as np\nfrom transformers import AutoTokenizer\n\nPOOL = \"/workspace/data/pool.jsonl\"\nDEV = \"/workspace/data/multi_dev.npy\"\nOUT = \"/workspace/submission/selection.json\"\nCACHE = \"/tmp/feat_cache.npz\"\n\nD_UNI = 1 << 20\nD_BI = 1 << 20\nT = D_UNI + D_BI\nALPHA = 1.0 # additive smoothing on n-gram counts\nMINCT = 2 # min target count for an n-gram to earn positive weight\nBUDGET = 12_000_000\n\nWTOK = re.compile(r\"[a-z0-9]+\")\n\nSTOP = set((\"the be to of and a in that have i it for not on with he as you do at \"\n \"this but his by from they we say her she or an will my one all would there \"\n \"their what so up out if about who get which go me when make can like time no \"\n \"just him know take people into year your good some could them see other than \"\n \"then now look only come it's over think also back after use two how our work \"\n \"first well way even new want because any these give day most us is are was \"\n \"were been has had did does\").split())\n\n_uni_cache = {}\ndef _hw(w):\n h = _uni_cache.get(w)\n if h is None:\n h = zlib.crc32(w.encode()) & (D_UNI - 1)\n _uni_cache[w] = h\n return h\n\ndef doc_ngrams(words):\n n = len(words)\n if n == 0:\n return np.empty(0, np.int32)\n uni = np.fromiter((_hw(w) for w in words), np.int64, n)\n if n == 1:\n return uni.astype(np.int32)\n bi = (((uni[:-1] * 1000003) ^ uni[1:]) & (D_BI - 1)) + D_UNI\n return np.concatenate([uni, bi]).astype(np.int32)\n\ndef quality(text, words):\n nw = len(words)\n nchars = len(text)\n alpha = sum(c.isalpha() for c in text)\n frac_alpha = alpha / max(1, nchars)\n sw_ratio = sum(w in STOP for w in words) / max(1, nw)\n mwl = sum(len(w) for w in words) / max(1, nw)\n lines = [ln for ln in text.split(\"\\n\") if ln.strip()]\n if lines:\n frac_short = sum(len(ln.split()) < 4 for ln in lines) / len(lines)\n frac_dup = 1.0 - len(set(lines)) / len(lines)\n else:\n frac_short, frac_dup = 1.0, 0.0\n ok = (50 <= nw <= 50000 and frac_alpha >= 0.60 and sw_ratio >= 0.22\n and 3.0 <= mwl <= 9.0 and frac_short <= 0.5 and frac_dup <= 0.30)\n return ok, nchars\n\ndef build_target_counts():\n tok = AutoTokenizer.from_pretrained(\"gpt2\")\n d = np.load(DEV)\n idx = np.where(d == 50256)[0]\n segs, prev = [], 0\n for i in idx:\n segs.append((prev, i)); prev = i + 1\n segs.append((prev, len(d)))\n Ct = np.zeros(T, np.float64)\n for a, b in segs:\n if b - a < 5:\n continue\n words = WTOK.findall(tok.decode(d[a:b]).lower())\n g = doc_ngrams(words)\n if len(g):\n Ct += np.bincount(g, minlength=T)\n return Ct\n\ndef build_cache():\n \"\"\"Featurize the whole pool once; cache concatenated n-grams + metadata.\"\"\"\n t0 = time.time()\n Ct = build_target_counts()\n ids, keep, nchars, off = [], [], [], [0]\n chunks = []\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n t = r[\"text\"]\n words = WTOK.findall(t.replace(\"<|endoftext|>\", \" \").lower())\n ok, nc = quality(t, words)\n g = doc_ngrams(words)\n ids.append(r[\"id\"]); keep.append(ok); nchars.append(nc)\n chunks.append(g); off.append(off[-1] + len(g))\n allfeats = np.concatenate(chunks).astype(np.int32)\n ids = np.array(ids, np.int64)\n keep = np.array(keep, bool)\n nchars = np.array(nchars, np.int64)\n off = np.array(off, np.int64)\n Cr = np.bincount(allfeats, minlength=T).astype(np.float64)\n np.savez(CACHE, allfeats=allfeats, ids=ids, keep=keep, nchars=nchars,\n off=off, Ct=Ct, Cr=Cr)\n print(f\" featurized {len(ids)} docs in {time.time()-t0:.0f}s -> {CACHE}\")\n return dict(allfeats=allfeats, ids=ids, keep=keep, nchars=nchars,\n off=off, Ct=Ct, Cr=Cr)\n\ndef load_cache(force=False):\n if not force and os.path.exists(CACHE):\n z = np.load(CACHE)\n return {k: z[k] for k in z.files}\n return build_cache()\n\ndef score(cache, alpha=ALPHA, minct=MINCT):\n Ct, Cr = cache[\"Ct\"], cache[\"Cr\"]\n Nt, Nr = Ct.sum(), Cr.sum()\n lr = (np.log(Ct + alpha) - math.log(Nt + alpha * T)) \\\n - (np.log(Cr + alpha) - math.log(Nr + alpha * T))\n # rarity correction: n-grams not solidly in target may only penalise, not reward\n weak = Ct < minct\n lr[weak] = np.minimum(lr[weak], 0.0)\n off = cache[\"off\"]\n vals = lr[cache[\"allfeats\"]]\n counts = np.diff(off)\n sums = np.add.reduceat(vals, off[:-1])\n sums[counts == 0] = -1e18\n s = sums / np.maximum(counts, 1)\n s[~cache[\"keep\"]] = -1e18\n return s\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--out\", default=OUT)\n ap.add_argument(\"--top\", type=int, default=60000)\n ap.add_argument(\"--rebuild\", action=\"store_true\")\n ap.add_argument(\"--diag\", action=\"store_true\")\n a = ap.parse_args()\n\n cache = load_cache(force=a.rebuild)\n s = score(cache)\n ids = cache[\"ids\"]\n order = np.argsort(-s)\n passing = order[s[order] > -1e17]\n sel = [int(ids[j]) for j in passing]\n json.dump(sel[: a.top], open(a.out, \"w\"))\n\n est = cache[\"nchars\"][passing] / 4.0\n cum = np.cumsum(est)\n nb = int(np.searchsorted(cum, BUDGET)) + 1\n print(f\"passing gates: {len(passing)}/{len(ids)} \"\n f\"({100*len(passing)/len(ids):.1f}%)\")\n print(f\"wrote {min(a.top,len(sel))} ids -> {a.out}\")\n print(f\"~{nb} docs (~{cum[min(nb,len(cum))-1]/1e6:.1f}M est tok) fill 12M budget\")\n\n if a.diag:\n want = set(int(ids[j]) for j in passing[:10]) | \\\n set(int(ids[j]) for j in passing[len(passing)//2:len(passing)//2+3])\n txt = {}\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n if r[\"id\"] in want:\n txt[r[\"id\"]] = r[\"text\"]\n print(\"\\n--- TOP 10 ---\")\n for j in passing[:10]:\n i = int(ids[j])\n print(f\"{s[j]:+.3f} id={i}: {txt[i][:170].strip().replace(chr(10),' | ')}\")\n print(\"\\n--- MEDIAN-RANK 3 ---\")\n for j in passing[len(passing)//2:len(passing)//2+3]:\n i = int(ids[j])\n print(f\"{s[j]:+.3f} id={i}: {txt[i][:170].strip().replace(chr(10),' | ')}\")\n\nif __name__ == \"__main__\":\n main()\n"
}Write result
The file /workspace/submission/curate.py has been updated successfully. (file state is current in your context — no need to Read it back)
[metadata] {"type": "update", "filePath": "/workspace/submission/curate.py", "content": "\"\"\"Curate a raw web pool into a priority-ordered training selection for a small LM.\n\nSTATED CRITERION\n----------------\nThe disclosed evaluation target is a BROAD, multi-domain, high-quality English\ndistribution (encyclopedic / general web prose / news / technical Q&A). We select\nthe pool documents whose token distribution most looks like that target while\nbeing clean, well-formed English prose.\n\nTwo ingredients, combined:\n\n1. TARGET-MATCHING (DSIR-style importance score). Model the target and the raw\n pool each as a bag of hashed word n-grams (unigrams + bigrams). Score every\n document by its per-token average log-likelihood ratio\n s(d) = mean_{g in d} w(g), w(g) = log p_target(g) - log p_pool(g).\n High s(d) => reads like the high-quality target domain; low s(d) => reads like\n generic/boilerplate/off-domain web text (Naive-Bayes / DSIR log-odds, Xie 2023).\n\n RARITY CORRECTION. The target corpus (~2M n-grams) is ~100x smaller than the\n pool (~250M). Naive additive smoothing then gives *any* n-gram unseen in the\n target (gibberish, foreign text, misspellings, rare jargon) a positive weight,\n because the smoothing floor of p_target exceeds a genuinely-rare p_pool. We\n correct this: an n-gram may earn POSITIVE weight only if it is actually present\n in the target (count >= MINCT); otherwise its weight is clamped to <= 0 (it may\n still PENALISE a document when it is common in the pool but absent from target).\n So a document is rewarded only for n-grams the target genuinely uses.\n\n2. QUALITY GATES. Cheap Gopher/C4-style filters remove degenerate documents\n (too short, non-English, symbol/number soup, navigation-menu boilerplate,\n near-duplicate lines) so nothing ranks purely on n-gram artefacts.\n\nDocuments that fail any gate are dropped; survivors are emitted in DESCENDING\nscore order (best first). The training packer consumes this order until the\n12M-token budget is full, so the highest-quality, most on-target tokens are used.\n\nWord n-grams use a regex tokenizer over [a-z0-9]+, which also normalises the\ndecoded target's WikiText spacing artifacts (\"@-@\", \" , \") so they align with\nnormal raw-web punctuation. Deterministic (crc32 hashing); no external labels.\n\"\"\"\nimport argparse, json, re, math, os, time, zlib\nimport numpy as np\nfrom transformers import AutoTokenizer\n\nPOOL = \"/workspace/data/pool.jsonl\"\nDEV = \"/workspace/data/multi_dev.npy\"\nOUT = \"/workspace/submission/selection.json\"\nCACHE = \"/tmp/feat_cache.npz\"\n\nD_UNI = 1 << 20\nD_BI = 1 << 20\nT = D_UNI + D_BI\nALPHA = 1.0 # additive smoothing on n-gram counts\nMINCT = 2 # min target count for an n-gram to earn positive weight\nBUDGET = 12_000_000\n\nWTOK = re.compile(r\"[a-z0-9]+\")\n\nSTOP = set((\"the be to of and a in that have i it for not on with he as you do at \"\n \"this but his by from they we say her she or an will my one all would there \"\n \"their what so up out if about who get which go me when make can like time no \"\n \"just him know take people into year your good some could them see other than \"\n \"then now look only come it's over think also back after use two how our work \"\n \"first well way even new want because any these give day most us is are was \"\n \"were been has had did does\").split())\n\n_uni_cache = {}\ndef _hw(w):\n h = _uni_cache.get(w)\n if h is None:\n h = zlib.crc32(w.encode()) & (D_UNI - 1)\n _uni_cache[w] = h\n return h\n\ndef doc_ngrams(words):\n n = len(words)\n if n == 0:\n return np.empty(0, np.int32)\n uni = np.fromiter((_hw(w) for w in words), np.int64, n)\n if n == 1:\n return uni.astype(np.int32)\n bi = (((uni[:-1] * 1000003) ^ uni[1:]) & (D_BI - 1)) + D_UNI\n return np.concatenate([uni, bi]).astype(np.int32)\n\ndef quality(text, words):\n nw = len(words)\n nchars = len(text)\n alpha = sum(c.isalpha() for c in text)\n frac_alpha = alpha / max(1, nchars)\n sw_ratio = sum(w in STOP for w in words) / max(1, nw)\n mwl = sum(len(w) for w in words) / max(1, nw)\n lines = [ln for ln in text.split(\"\\n\") if ln.strip()]\n if lines:\n frac_short = sum(len(ln.split()) < 4 for ln in lines) / len(lines)\n frac_dup = 1.0 - len(set(lines)) / len(lines)\n else:\n frac_short, frac_dup = 1.0, 0.0\n ok = (50 <= nw <= 50000 and frac_alpha >= 0.60 and sw_ratio >= 0.22\n and 3.0 <= mwl <= 9.0 and frac_short <= 0.5 and frac_dup <= 0.30)\n return ok, nchars\n\ndef build_target_counts():\n tok = AutoTokenizer.from_pretrained(\"gpt2\")\n d = np.load(DEV)\n idx = np.where(d == 50256)[0]\n segs, prev = [], 0\n for i in idx:\n segs.append((prev, i)); prev = i + 1\n segs.append((prev, len(d)))\n Ct = np.zeros(T, np.float64)\n for a, b in segs:\n if b - a < 5:\n continue\n words = WTOK.findall(tok.decode(d[a:b]).lower())\n g = doc_ngrams(words)\n if len(g):\n Ct += np.bincount(g, minlength=T)\n return Ct\n\ndef build_cache():\n \"\"\"Featurize the whole pool once; cache concatenated n-grams + metadata.\"\"\"\n t0 = time.time()\n Ct = build_target_counts()\n ids, keep, nchars, off = [], [], [], [0]\n chunks = []\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n t = r[\"text\"]\n words = WTOK.findall(t.replace(\"<|endoftext|>\", \" \").lower())\n ok, nc = quality(t, words)\n g = doc_ngrams(words)\n ids.append(r[\"id\"]); keep.append(ok); nchars.append(nc)\n chunks.append(g); off.append(off[-1] + len(g))\n allfeats = np.concatenate(chunks).astype(np.int32)\n ids = np.array(ids, np.int64)\n keep = np.array(keep, bool)\n nchars = np.array(nchars, np.int64)\n off = np.array(off, np.int64)\n Cr = np.bincount(allfeats, minlength=T).astype(np.float64)\n np.savez(CACHE, allfeats=allfeats, ids=ids, keep=keep, nchars=nchars,\n off=off, Ct=Ct, Cr=Cr)\n print(f\" featurized {len(ids)} docs in {time.time()-t0:.0f}s -> {CACHE}\")\n return dict(allfeats=allfeats, ids=ids, keep=keep, nchars=nchars,\n off=off, Ct=Ct, Cr=Cr)\n\ndef load_cache(force=False):\n if not force and os.path.exists(CACHE):\n z = np.load(CACHE)\n return {k: z[k] for k in z.files}\n return build_cache()\n\ndef score(cache, alpha=ALPHA, minct=MINCT):\n Ct, Cr = cache[\"Ct\"], cache[\"Cr\"]\n Nt, Nr = Ct.sum(), Cr.sum()\n lr = (np.log(Ct + alpha) - math.log(Nt + alpha * T)) \\\n - (np.log(Cr + alpha) - math.log(Nr + alpha * T))\n # rarity correction: n-grams not solidly in target may only penalise, not reward\n weak = Ct < minct\n lr[weak] = np.minimum(lr[weak], 0.0)\n off = cache[\"off\"]\n vals = lr[cache[\"allfeats\"]]\n counts = np.diff(off)\n sums = np.add.reduceat(vals, off[:-1])\n sums[counts == 0] = -1e18\n s = sums / np.maximum(counts, 1)\n s[~cache[\"keep\"]] = -1e18\n return s\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--out\", default=OUT)\n ap.add_argument(\"--top\", type=int, default=60000)\n ap.add_argument(\"--rebuild\", action=\"store_true\")\n ap.add_argument(\"--diag\", action=\"store_true\")\n a = ap.parse_args()\n\n cache = load_cache(force=a.rebuild)\n s = score(cache)\n ids = cache[\"ids\"]\n order = np.argsort(-s)\n passing = order[s[order] > -1e17]\n sel = [int(ids[j]) for j in passing]\n json.dump(sel[: a.top], open(a.out, \"w\"))\n\n est = cache[\"nchars\"][passing] / 4.0\n cum = np.cumsum(est)\n nb = int(np.searchsorted(cum, BUDGET)) + 1\n print(f\"passing gates: {len(passing)}/{len(ids)} \"\n f\"({100*len(passing)/len(ids):.1f}%)\")\n print(f\"wrote {min(a.top,len(sel))} ids -> {a.out}\")\n print(f\"~{nb} docs (~{cum[min(nb,len(cum))-1]/1e6:.1f}M est tok) fill 12M budget\")\n\n if a.diag:\n want = set(int(ids[j]) for j in passing[:10]) | \\\n set(int(ids[j]) for j in passing[len(passing)//2:len(passing)//2+3])\n txt = {}\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n if r[\"id\"] in want:\n txt[r[\"id\"]] = r[\"text\"]\n print(\"\\n--- TOP 10 ---\")\n for j in passing[:10]:\n i = int(ids[j])\n print(f\"{s[j]:+.3f} id={i}: {txt[i][:170].strip().replace(chr(10),' | ')}\")\n print(\"\\n--- MEDIAN-RANK 3 ---\")\n for j in passing[len(passing)//2:len(passing)//2+3]:\n i = int(ids[j])\n print(f\"{s[j]:+.3f} id={i}: {txt[i][:170].strip().replace(chr(10),' | ')}\")\n\nif __name__ == \"__main__\":\n main()\n", "structuredPatch": [{"oldStart": 9, "oldLines": 53, "newStart": 9, "newLines": 59, "lines": [" ", " Two ingredients, combined:", " ", "-1. TARGET-MATCHING (DSIR-style importance score). We model the target and the", "- raw pool each as a bag of hashed word n-grams (unigrams + bigrams) and score", "- every document by its *per-n-gram average log-likelihood ratio*", "- s(d) = mean_{g in d} [ log p_target(g) - log p_pool(g) ].", "- High s(d) => the document reads like the high-quality target domain; low s(d)", "- => it reads like generic/boilerplate/off-domain web text. This is a", "- Naive-Bayes / DSIR (Xie et al. 2023) log-odds toward the disclosed target.", "+1. TARGET-MATCHING (DSIR-style importance score). Model the target and the raw", "+ pool each as a bag of hashed word n-grams (unigrams + bigrams). Score every", "+ document by its per-token average log-likelihood ratio", "+ s(d) = mean_{g in d} w(g), w(g) = log p_target(g) - log p_pool(g).", "+ High s(d) => reads like the high-quality target domain; low s(d) => reads like", "+ generic/boilerplate/off-domain web text (Naive-Bayes / DSIR log-odds, Xie 2023).", " ", "+ RARITY CORRECTION. The target corpus (~2M n-grams) is ~100x smaller than the", "+ pool (~250M). Naive additive smoothing then gives *any* n-gram unseen in the", "+ target (gibberish, foreign text, misspellings, rare jargon) a positive weight,", "+ because the smoothing floor of p_target exceeds a genuinely-rare p_pool. We", "+ correct this: an n-gram may earn POSITIVE weight only if it is actually present", "+ in the target (count >= MINCT); otherwise its weight is clamped to <= 0 (it may", "+ still PENALISE a document when it is common in the pool but absent from target).", "+ So a document is rewarded only for n-grams the target genuinely uses.", "+", " 2. QUALITY GATES. Cheap Gopher/C4-style filters remove degenerate documents", " (too short, non-English, symbol/number soup, navigation-menu boilerplate,", "- near-duplicate lines) so a document can't rank high on n-gram overlap alone.", "+ near-duplicate lines) so nothing ranks purely on n-gram artefacts.", " ", " Documents that fail any gate are dropped; survivors are emitted in DESCENDING", " score order (best first). The training packer consumes this order until the", " 12M-token budget is full, so the highest-quality, most on-target tokens are used.", " ", "-Word n-grams use a regex tokenizer over [a-z0-9]+, which incidentally normalises", "-the WikiText spacing artifacts (\"@-@\", \" , \") in the decoded target so they align", "-with normal raw-web punctuation.", "-", "-Reproducible: deterministic (crc32 hashing, fixed params); no external labels.", "+Word n-grams use a regex tokenizer over [a-z0-9]+, which also normalises the", "+decoded target's WikiText spacing artifacts (\"@-@\", \" , \") so they align with", "+normal raw-web punctuation. Deterministic (crc32 hashing); no external labels.", " \"\"\"", "-import argparse, json, re, math, time, zlib", "+import argparse, json, re, math, os, time, zlib", " import numpy as np", " from transformers import AutoTokenizer", " ", " POOL = \"/workspace/data/pool.jsonl\"", " DEV = \"/workspace/data/multi_dev.npy\"", " OUT = \"/workspace/submission/selection.json\"", "+CACHE = \"/tmp/feat_cache.npz\"", " ", "-D_UNI = 1 << 20 # unigram hash buckets", "-D_BI = 1 << 20 # bigram hash buckets", "+D_UNI = 1 << 20", "+D_BI = 1 << 20", " T = D_UNI + D_BI", " ALPHA = 1.0 # additive smoothing on n-gram counts", "-BUDGET = 12_000_000 # official token budget", "+MINCT = 2 # min target count for an n-gram to earn positive weight", "+BUDGET = 12_000_000", " ", " WTOK = re.compile(r\"[a-z0-9]+\")", " ", "-# Common English function words: prose has a high density of these; lists,", "-# menus, keyword-spam and non-English text do not.", " STOP = set((\"the be to of and a in that have i it for not on with he as you do at \"", " \"this but his by from they we say her she or an will my one all would there \"", " \"their what so up out if about who get which go me when make can like time no \"", " \"just him know take people into year your good some could them see other than \"", " \"then now look only come it's over think also back after use two how our work \"", " \"first well way even new want because any these give day most us is are was \"", "- \"were been has had did does not no\").split())", "+ \"were been has had did does\").split())", " ", " _uni_cache = {}", " def _hw(w):"]}, {"oldStart": 66, "oldLines": 7, "newStart": 72, "newLines": 6, "lines": [" return h", " ", " def doc_ngrams(words):", "- \"\"\"hashed unigram+bigram ids for a token list -> int32 array.\"\"\"", " n = len(words)", " if n == 0:", " return np.empty(0, np.int32)"]}, {"oldStart": 77, "oldLines": 34, "newStart": 82, "newLines": 26, "lines": [" return np.concatenate([uni, bi]).astype(np.int32)", " ", " def quality(text, words):", "- \"\"\"Return (pass_bool, feats dict). Gopher/C4-style cheap gates.\"\"\"", " nw = len(words)", " nchars = len(text)", " alpha = sum(c.isalpha() for c in text)", " frac_alpha = alpha / max(1, nchars)", "- sw = sum(w in STOP for w in words)", "- sw_ratio = sw / max(1, nw)", "+ sw_ratio = sum(w in STOP for w in words) / max(1, nw)", " mwl = sum(len(w) for w in words) / max(1, nw)", " lines = [ln for ln in text.split(\"\\n\") if ln.strip()]", " if lines:", "- short = sum(len(ln.split()) < 4 for ln in lines)", "- frac_short = short / len(lines)", "- # near-duplicate line fraction (boilerplate / menus repeat lines)", "+ frac_short = sum(len(ln.split()) < 4 for ln in lines) / len(lines)", " frac_dup = 1.0 - len(set(lines)) / len(lines)", " else:", " frac_short, frac_dup = 1.0, 0.0", " ok = (50 <= nw <= 50000 and frac_alpha >= 0.60 and sw_ratio >= 0.22", " and 3.0 <= mwl <= 9.0 and frac_short <= 0.5 and frac_dup <= 0.30)", "- return ok, dict(nw=nw, frac_alpha=frac_alpha, sw_ratio=sw_ratio, mwl=mwl,", "- frac_short=frac_short, frac_dup=frac_dup, nchars=nchars)", "+ return ok, nchars", " ", "-", " def build_target_counts():", "- \"\"\"Decode the disclosed dev target into per-segment text; count n-grams.\"\"\"", " tok = AutoTokenizer.from_pretrained(\"gpt2\")", " d = np.load(DEV)", "- eos = 50256", "- idx = np.where(d == eos)[0]", "+ idx = np.where(d == 50256)[0]", " segs, prev = [], 0", " for i in idx:", " segs.append((prev, i)); prev = i + 1"]}, {"oldStart": 113, "oldLines": 105, "newStart": 110, "newLines": 103, "lines": [" for a, b in segs:", " if b - a < 5:", " continue", "- txt = tok.decode(d[a:b]).lower()", "- words = WTOK.findall(txt)", "+ words = WTOK.findall(tok.decode(d[a:b]).lower())", " g = doc_ngrams(words)", " if len(g):", " Ct += np.bincount(g, minlength=T)", " return Ct", " ", "-", "-def main():", "- ap = argparse.ArgumentParser()", "- ap.add_argument(\"--out\", default=OUT)", "- ap.add_argument(\"--top\", type=int, default=60000, help=\"max ids to emit\")", "- ap.add_argument(\"--diag\", action=\"store_true\")", "- a = ap.parse_args()", "+def build_cache():", "+ \"\"\"Featurize the whole pool once; cache concatenated n-grams + metadata.\"\"\"", " t0 = time.time()", "-", "- print(\"[1/5] target n-gram profile ...\", flush=True)", " Ct = build_target_counts()", "- Nt = Ct.sum()", "-", "- print(\"[2/5] load pool + featurize ...\", flush=True)", "- ids, texts, feats, quals, keep = [], [], [], [], []", "+ ids, keep, nchars, off = [], [], [], [0]", "+ chunks = []", " with open(POOL) as f:", " for line in f:", " r = json.loads(line)", " t = r[\"text\"]", "- low = t.replace(\"<|endoftext|>\", \" \").lower()", "- words = WTOK.findall(low)", "- ok, q = quality(t, words)", "+ words = WTOK.findall(t.replace(\"<|endoftext|>\", \" \").lower())", "+ ok, nc = quality(t, words)", " g = doc_ngrams(words)", "- ids.append(r[\"id\"]); feats.append(g); quals.append(q); keep.append(ok)", "- ids = np.array(ids)", "- print(f\" {len(ids)} docs, featurized in {time.time()-t0:.0f}s\", flush=True)", "+ ids.append(r[\"id\"]); keep.append(ok); nchars.append(nc)", "+ chunks.append(g); off.append(off[-1] + len(g))", "+ allfeats = np.concatenate(chunks).astype(np.int32)", "+ ids = np.array(ids, np.int64)", "+ keep = np.array(keep, bool)", "+ nchars = np.array(nchars, np.int64)", "+ off = np.array(off, np.int64)", "+ Cr = np.bincount(allfeats, minlength=T).astype(np.float64)", "+ np.savez(CACHE, allfeats=allfeats, ids=ids, keep=keep, nchars=nchars,", "+ off=off, Ct=Ct, Cr=Cr)", "+ print(f\" featurized {len(ids)} docs in {time.time()-t0:.0f}s -> {CACHE}\")", "+ return dict(allfeats=allfeats, ids=ids, keep=keep, nchars=nchars,", "+ off=off, Ct=Ct, Cr=Cr)", " ", "- print(\"[3/5] background n-gram profile ...\", flush=True)", "- Cr = np.bincount(np.concatenate(feats), minlength=T).astype(np.float64)", "- Nr = Cr.sum()", "+def load_cache(force=False):", "+ if not force and os.path.exists(CACHE):", "+ z = np.load(CACHE)", "+ return {k: z[k] for k in z.files}", "+ return build_cache()", " ", "- # per-n-gram log-likelihood ratio log p_target - log p_pool", "- lr = (np.log(Ct + ALPHA) - math.log(Nt + ALPHA * T)) \\", "- - (np.log(Cr + ALPHA) - math.log(Nr + ALPHA * T))", "+def score(cache, alpha=ALPHA, minct=MINCT):", "+ Ct, Cr = cache[\"Ct\"], cache[\"Cr\"]", "+ Nt, Nr = Ct.sum(), Cr.sum()", "+ lr = (np.log(Ct + alpha) - math.log(Nt + alpha * T)) \\", "+ - (np.log(Cr + alpha) - math.log(Nr + alpha * T))", "+ # rarity correction: n-grams not solidly in target may only penalise, not reward", "+ weak = Ct < minct", "+ lr[weak] = np.minimum(lr[weak], 0.0)", "+ off = cache[\"off\"]", "+ vals = lr[cache[\"allfeats\"]]", "+ counts = np.diff(off)", "+ sums = np.add.reduceat(vals, off[:-1])", "+ sums[counts == 0] = -1e18", "+ s = sums / np.maximum(counts, 1)", "+ s[~cache[\"keep\"]] = -1e18", "+ return s", " ", "- print(\"[4/5] score docs ...\", flush=True)", "- scores = np.full(len(ids), -1e9, np.float64)", "- for i, g in enumerate(feats):", "- if keep[i] and len(g):", "- scores[i] = lr[g].mean()", "+def main():", "+ ap = argparse.ArgumentParser()", "+ ap.add_argument(\"--out\", default=OUT)", "+ ap.add_argument(\"--top\", type=int, default=60000)", "+ ap.add_argument(\"--rebuild\", action=\"store_true\")", "+ ap.add_argument(\"--diag\", action=\"store_true\")", "+ a = ap.parse_args()", " ", "- order = np.argsort(-scores)", "- passing = [j for j in order if scores[j] > -1e8]", "- sel_ids = [int(ids[j]) for j in passing]", "+ cache = load_cache(force=a.rebuild)", "+ s = score(cache)", "+ ids = cache[\"ids\"]", "+ order = np.argsort(-s)", "+ passing = order[s[order] > -1e17]", "+ sel = [int(ids[j]) for j in passing]", "+ json.dump(sel[: a.top], open(a.out, \"w\"))", " ", "- # emit enough ids to comfortably exceed the token budget", "- est = np.array([quals[j][\"nchars\"] for j in passing]) / 4.0", "+ est = cache[\"nchars\"][passing] / 4.0", " cum = np.cumsum(est)", "- n_budget = int(np.searchsorted(cum, BUDGET)) + 1", "- emit = sel_ids[: a.top]", "- json.dump(emit, open(a.out, \"w\"))", "- print(f\"[5/5] wrote {len(emit)} ids -> {a.out} ({time.time()-t0:.0f}s)\")", "- print(f\" passing gates: {len(passing)}/{len(ids)} \"", "+ nb = int(np.searchsorted(cum, BUDGET)) + 1", "+ print(f\"passing gates: {len(passing)}/{len(ids)} \"", " f\"({100*len(passing)/len(ids):.1f}%)\")", "- print(f\" ~{n_budget} docs (~{cum[min(n_budget,len(cum))-1]/1e6:.1f}M est tokens) \"", "- f\"fill the 12M budget; emitting {len(emit)} for margin\")", "+ print(f\"wrote {min(a.top,len(sel))} ids -> {a.out}\")", "+ print(f\"~{nb} docs (~{cum[min(nb,len(cum))-1]/1e6:.1f}M est tok) fill 12M budget\")", " ", " if a.diag:", "- def show(js, tag):", "- print(f\"\\n===== {tag} =====\")", "- for j in js:", "- q = quals[j]", "- snip = texts_by_id.get(int(ids[j]), \"\")", "- print(f\"[score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"", "- f\"short {q['frac_short']:.2f}] id={ids[j]}\")", "- # reload a few texts for display", "- want = set(int(ids[j]) for j in passing[:8]) | \\", "- set(int(ids[j]) for j in passing[-4:]) | \\", "- set(int(ids[j]) for j in order[-6:])", "- texts_by_id = {}", "+ want = set(int(ids[j]) for j in passing[:10]) | \\", "+ set(int(ids[j]) for j in passing[len(passing)//2:len(passing)//2+3])", "+ txt = {}", " with open(POOL) as f:", " for line in f:", " r = json.loads(line)", " if r[\"id\"] in want:", "- texts_by_id[r[\"id\"]] = r[\"text\"]", "- print(\"\\n----- TOP 8 (best on-target) -----\")", "- for j in passing[:8]:", "- q = quals[j]", "- print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"", "- f\"short {q['frac_short']:.2f} id={ids[j]}: \"", "- f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")", "- print(\"\\n----- BOTTOM 4 of PASSING -----\")", "- for j in passing[-4:]:", "- q = quals[j]", "- print(f\"score {scores[j]:+.3f} nw {q['nw']} id={ids[j]}: \"", "- f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")", "- print(\"\\n----- 6 GATE-REJECTED (lowest score overall) -----\")", "- for j in order[-6:]:", "- q = quals[j]", "- print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"", "- f\"id={ids[j]}: {texts_by_id.get(int(ids[j]),'')[:150].strip().replace(chr(10),' | ')}\")", "+ txt[r[\"id\"]] = r[\"text\"]", "+ print(\"\\n--- TOP 10 ---\")", "+ for j in passing[:10]:", "+ i = int(ids[j])", "+ print(f\"{s[j]:+.3f} id={i}: {txt[i][:170].strip().replace(chr(10),' | ')}\")", "+ print(\"\\n--- MEDIAN-RANK 3 ---\")", "+ for j in passing[len(passing)//2:len(passing)//2+3]:", "+ i = int(ids[j])", "+ print(f\"{s[j]:+.3f} id={i}: {txt[i][:170].strip().replace(chr(10),' | ')}\")", " ", "-", " if __name__ == \"__main__\":", " main()"]}], "originalFile": "\"\"\"Curate a raw web pool into a priority-ordered training selection for a small LM.\n\nSTATED CRITERION\n----------------\nThe disclosed evaluation target is a BROAD, multi-domain, high-quality English\ndistribution (encyclopedic / general web prose / news / technical Q&A). We select\nthe pool documents whose token distribution most looks like that target while\nbeing clean, well-formed English prose.\n\nTwo ingredients, combined:\n\n1. TARGET-MATCHING (DSIR-style importance score). We model the target and the\n raw pool each as a bag of hashed word n-grams (unigrams + bigrams) and score\n every document by its *per-n-gram average log-likelihood ratio*\n s(d) = mean_{g in d} [ log p_target(g) - log p_pool(g) ].\n High s(d) => the document reads like the high-quality target domain; low s(d)\n => it reads like generic/boilerplate/off-domain web text. This is a\n Naive-Bayes / DSIR (Xie et al. 2023) log-odds toward the disclosed target.\n\n2. QUALITY GATES. Cheap Gopher/C4-style filters remove degenerate documents\n (too short, non-English, symbol/number soup, navigation-menu boilerplate,\n near-duplicate lines) so a document can't rank high on n-gram overlap alone.\n\nDocuments that fail any gate are dropped; survivors are emitted in DESCENDING\nscore order (best first). The training packer consumes this order until the\n12M-token budget is full, so the highest-quality, most on-target tokens are used.\n\nWord n-grams use a regex tokenizer over [a-z0-9]+, which incidentally normalises\nthe WikiText spacing artifacts (\"@-@\", \" , \") in the decoded target so they align\nwith normal raw-web punctuation.\n\nReproducible: deterministic (crc32 hashing, fixed params); no external labels.\n\"\"\"\nimport argparse, json, re, math, time, zlib\nimport numpy as np\nfrom transformers import AutoTokenizer\n\nPOOL = \"/workspace/data/pool.jsonl\"\nDEV = \"/workspace/data/multi_dev.npy\"\nOUT = \"/workspace/submission/selection.json\"\n\nD_UNI = 1 << 20 # unigram hash buckets\nD_BI = 1 << 20 # bigram hash buckets\nT = D_UNI + D_BI\nALPHA = 1.0 # additive smoothing on n-gram counts\nBUDGET = 12_000_000 # official token budget\n\nWTOK = re.compile(r\"[a-z0-9]+\")\n\n# Common English function words: prose has a high density of these; lists,\n# menus, keyword-spam and non-English text do not.\nSTOP = set((\"the be to of and a in that have i it for not on with he as you do at \"\n \"this but his by from they we say her she or an will my one all would there \"\n \"their what so up out if about who get which go me when make can like time no \"\n \"just him know take people into year your good some could them see other than \"\n \"then now look only come it's over think also back after use two how our work \"\n \"first well way even new want because any these give day most us is are was \"\n \"were been has had did does not no\").split())\n\n_uni_cache = {}\ndef _hw(w):\n h = _uni_cache.get(w)\n if h is None:\n h = zlib.crc32(w.encode()) & (D_UNI - 1)\n _uni_cache[w] = h\n return h\n\ndef doc_ngrams(words):\n \"\"\"hashed unigram+bigram ids for a token list -> int32 array.\"\"\"\n n = len(words)\n if n == 0:\n return np.empty(0, np.int32)\n uni = np.fromiter((_hw(w) for w in words), np.int64, n)\n if n == 1:\n return uni.astype(np.int32)\n bi = (((uni[:-1] * 1000003) ^ uni[1:]) & (D_BI - 1)) + D_UNI\n return np.concatenate([uni, bi]).astype(np.int32)\n\ndef quality(text, words):\n \"\"\"Return (pass_bool, feats dict). Gopher/C4-style cheap gates.\"\"\"\n nw = len(words)\n nchars = len(text)\n alpha = sum(c.isalpha() for c in text)\n frac_alpha = alpha / max(1, nchars)\n sw = sum(w in STOP for w in words)\n sw_ratio = sw / max(1, nw)\n mwl = sum(len(w) for w in words) / max(1, nw)\n lines = [ln for ln in text.split(\"\\n\") if ln.strip()]\n if lines:\n short = sum(len(ln.split()) < 4 for ln in lines)\n frac_short = short / len(lines)\n # near-duplicate line fraction (boilerplate / menus repeat lines)\n frac_dup = 1.0 - len(set(lines)) / len(lines)\n else:\n frac_short, frac_dup = 1.0, 0.0\n ok = (50 <= nw <= 50000 and frac_alpha >= 0.60 and sw_ratio >= 0.22\n and 3.0 <= mwl <= 9.0 and frac_short <= 0.5 and frac_dup <= 0.30)\n return ok, dict(nw=nw, frac_alpha=frac_alpha, sw_ratio=sw_ratio, mwl=mwl,\n frac_short=frac_short, frac_dup=frac_dup, nchars=nchars)\n\n\ndef build_target_counts():\n \"\"\"Decode the disclosed dev target into per-segment text; count n-grams.\"\"\"\n tok = AutoTokenizer.from_pretrained(\"gpt2\")\n d = np.load(DEV)\n eos = 50256\n idx = np.where(d == eos)[0]\n segs, prev = [], 0\n for i in idx:\n segs.append((prev, i)); prev = i + 1\n segs.append((prev, len(d)))\n Ct = np.zeros(T, np.float64)\n for a, b in segs:\n if b - a < 5:\n continue\n txt = tok.decode(d[a:b]).lower()\n words = WTOK.findall(txt)\n g = doc_ngrams(words)\n if len(g):\n Ct += np.bincount(g, minlength=T)\n return Ct\n\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument(\"--out\", default=OUT)\n ap.add_argument(\"--top\", type=int, default=60000, help=\"max ids to emit\")\n ap.add_argument(\"--diag\", action=\"store_true\")\n a = ap.parse_args()\n t0 = time.time()\n\n print(\"[1/5] target n-gram profile ...\", flush=True)\n Ct = build_target_counts()\n Nt = Ct.sum()\n\n print(\"[2/5] load pool + featurize ...\", flush=True)\n ids, texts, feats, quals, keep = [], [], [], [], []\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n t = r[\"text\"]\n low = t.replace(\"<|endoftext|>\", \" \").lower()\n words = WTOK.findall(low)\n ok, q = quality(t, words)\n g = doc_ngrams(words)\n ids.append(r[\"id\"]); feats.append(g); quals.append(q); keep.append(ok)\n ids = np.array(ids)\n print(f\" {len(ids)} docs, featurized in {time.time()-t0:.0f}s\", flush=True)\n\n print(\"[3/5] background n-gram profile ...\", flush=True)\n Cr = np.bincount(np.concatenate(feats), minlength=T).astype(np.float64)\n Nr = Cr.sum()\n\n # per-n-gram log-likelihood ratio log p_target - log p_pool\n lr = (np.log(Ct + ALPHA) - math.log(Nt + ALPHA * T)) \\\n - (np.log(Cr + ALPHA) - math.log(Nr + ALPHA * T))\n\n print(\"[4/5] score docs ...\", flush=True)\n scores = np.full(len(ids), -1e9, np.float64)\n for i, g in enumerate(feats):\n if keep[i] and len(g):\n scores[i] = lr[g].mean()\n\n order = np.argsort(-scores)\n passing = [j for j in order if scores[j] > -1e8]\n sel_ids = [int(ids[j]) for j in passing]\n\n # emit enough ids to comfortably exceed the token budget\n est = np.array([quals[j][\"nchars\"] for j in passing]) / 4.0\n cum = np.cumsum(est)\n n_budget = int(np.searchsorted(cum, BUDGET)) + 1\n emit = sel_ids[: a.top]\n json.dump(emit, open(a.out, \"w\"))\n print(f\"[5/5] wrote {len(emit)} ids -> {a.out} ({time.time()-t0:.0f}s)\")\n print(f\" passing gates: {len(passing)}/{len(ids)} \"\n f\"({100*len(passing)/len(ids):.1f}%)\")\n print(f\" ~{n_budget} docs (~{cum[min(n_budget,len(cum))-1]/1e6:.1f}M est tokens) \"\n f\"fill the 12M budget; emitting {len(emit)} for margin\")\n\n if a.diag:\n def show(js, tag):\n print(f\"\\n===== {tag} =====\")\n for j in js:\n q = quals[j]\n snip = texts_by_id.get(int(ids[j]), \"\")\n print(f\"[score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f}] id={ids[j]}\")\n # reload a few texts for display\n want = set(int(ids[j]) for j in passing[:8]) | \\\n set(int(ids[j]) for j in passing[-4:]) | \\\n set(int(ids[j]) for j in order[-6:])\n texts_by_id = {}\n with open(POOL) as f:\n for line in f:\n r = json.loads(line)\n if r[\"id\"] in want:\n texts_by_id[r[\"id\"]] = r[\"text\"]\n print(\"\\n----- TOP 8 (best on-target) -----\")\n for j in passing[:8]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"short {q['frac_short']:.2f} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- BOTTOM 4 of PASSING -----\")\n for j in passing[-4:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} id={ids[j]}: \"\n f\"{texts_by_id[int(ids[j])][:180].strip().replace(chr(10),' | ')}\")\n print(\"\\n----- 6 GATE-REJECTED (lowest score overall) -----\")\n for j in order[-6:]:\n q = quals[j]\n print(f\"score {scores[j]:+.3f} nw {q['nw']} sw {q['sw_ratio']:.2f} \"\n f\"id={ids[j]}: {texts_by_id.get(int(ids[j]),'')[:150].strip().replace(chr(10),' | ')}\")\n\n\nif __name__ == \"__main__\":\n main()\n", "userModified": false}Now let me run it — this rebuilds the cache (~130s featurization) then scores with the fix. Running in background:
args
{
"command": "export TOKENIZERS_PARALLELISM=false && python3 submission/curate.py --diag 2>&1 | tail -45",
"description": "Rebuild cache and score with rarity fix",
"run_in_background": true
}Bash result
Command running in background with ID: bnc1l6toh. Output is being written to: /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/bnc1l6toh.output. You will be notified when it completes. To check interim output, use Read on that file path.
[metadata] {"noOutputExpected": false, "backgroundTaskId": "bnc1l6toh"}While the cache builds (~2.5 min), let me prepare a random-baseline selection for calibration (written to a separate path, not my submission):
args
{
"command": "sleep 55; echo \"=== curate progress ===\"; cat /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/bnc1l6toh.output 2>/dev/null; echo \"=== timer ===\"; cat /workspace/.timer/remaining_secs",
"description": "Check cache build progress"
}Bash result
=== curate progress ===
=== timer ===
4569
[stdout]
=== curate progress ===
=== timer ===
4569
[metadata] {"noOutputExpected": false}Still featurizing. Let me wait for it to complete:
args
{
"command": "sleep 75; echo \"=== curate output ===\"; cat /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/bnc1l6toh.output 2>/dev/null; echo \"=== timer ===\"; cat /workspace/.timer/remaining_secs; echo \"=== cache? ===\"; ls -la /tmp/feat_cache.npz 2>/dev/null",
"description": "Check cache build completion"
}Bash result
=== curate output ===
featurized 182016 docs in 124s -> /tmp/feat_cache.npz
passing gates: 120480/182016 (66.2%)
wrote 60000 ids -> /workspace/submission/selection.json
~12437 docs (~12.0M est tok) fill 12M budget
--- TOP 10 ---
-0.092 id=58452: <|endoftext|>New Delhi: Five new Supreme Court judges were today sworn in, taking the top court’s strength to 28, including the Chief Justice of India. Justices Sanjay Ki
-0.120 id=85430: to Filmibeat Malayalam | Actress Aishwarya Rai Bachchan's father Krishnaraj Rai passed away on Saturday at a suburban hospital in Mumbai. Rai was hospitalised a few weeks
-0.130 id=73993: |PREDECESSORS AND SHORT HISTORY: | in the 16th century by Rao Gopalji fl.1550, 4th son of Raja Prithviraj | Singhji I of Jaipur. Rulers were… | - Rao GOPAL SINGH, | Thakur Saheb
-0.140 id=43758: vel (Maharashtra), June 14 (ANI): A magistrate's court in Panvel, Maharashtra, on Sunday extended suspended senior Nationalist Congress Party (NCP) leader Padamsinh Patil
-0.146 id=63278: leging that Prime Minister Narendra Modi was trying to see there won’t be any Opposition in the country, AICC secretary V Hanumanth Rao said the people were watching Modi
-0.150 id=28825: WASHINGTON (Reuters) - U.S.-led forces conducted 14 air strikes against Islamic State militants in Syria and nine in Iraq on Friday, the task force conducting the operati
-0.152 id=37064: The Bharatiya Janata Party (BJP) leaders of the West Bengal unit will meet Union Home Minister Rajnath Singh on Thursday to lodge protest against the vandalising of its p
-0.155 id=37522: Prime Minister Imran Khan on Thursday congratulated India’s premier Narendra Modi on his victory in the country's national elections. | "I congratulate Prime Minister Modi
-0.159 id=79735: <|endoftext|>India’s PM Narendra Modi has tweeted pictures of his mother’s first visit to his official residence in Delhi. | Twitter users have praised Narendra Modi’s deci
-0.166 id=4620: Agartala, Sep 15 (IANS) The BJP on Tuesday said it would soon launch a stir if Tripura’s Left Front government evicted tribals to set up a firing range for a paramilitary
--- MEDIAN-RANK 3 ---
-0.722 id=62089: View larger image | - Input Projects | - St. Clair River State Space Modelling | - Dependent Projects | - St. Clair Ice Jam Modelling | Potential ice impacts on the conveyance of t
-0.722 id=172720: guarantee. | Shipping | Customer Reviews<|endoftext|>SmartCode ViewerX Version History - Remote Desktop Management and Monitoring - SmartCode | Products | SmartCode VNC Manager
-0.722 id=56483: leratec is now shipping its new Aleratec color coded duplicator grade LightScribe DVD-R recording media. | Aleratec duplicator grade LightScribe media is optimized for Ligh
=== timer ===
4488
=== cache? ===
-rw-r--r-- 1 root root 1063285654 Aug 4 04:46 /tmp/feat_cache.npz
[stdout]
=== curate output ===
featurized 182016 docs in 124s -> /tmp/feat_cache.npz
passing gates: 120480/182016 (66.2%)
wrote 60000 ids -> /workspace/submission/selection.json
~12437 docs (~12.0M est tok) fill 12M budget
--- TOP 10 ---
-0.092 id=58452: <|endoftext|>New Delhi: Five new Supreme Court judges were today sworn in, taking the top court’s strength to 28, including the Chief Justice of India. Justices Sanjay Ki
-0.120 id=85430: to Filmibeat Malayalam | Actress Aishwarya Rai Bachchan's father Krishnaraj Rai passed away on Saturday at a suburban hospital in Mumbai. Rai was hospitalised a few weeks
-0.130 id=73993: |PREDECESSORS AND SHORT HISTORY: | in the 16th century by Rao Gopalji fl.1550, 4th son of Raja Prithviraj | Singhji I of Jaipur. Rulers were… | - Rao GOPAL SINGH, | Thakur Saheb
-0.140 id=43758: vel (Maharashtra), June 14 (ANI): A magistrate's court in Panvel, Maharashtra, on Sunday extended suspended senior Nationalist Congress Party (NCP) leader Padamsinh Patil
-0.146 id=63278: leging that Prime Minister Narendra Modi was trying to see there won’t be any Opposition in the country, AICC secretary V Hanumanth Rao said the people were watching Modi
-0.150 id=28825: WASHINGTON (Reuters) - U.S.-led forces conducted 14 air strikes against Islamic State militants in Syria and nine in Iraq on Friday, the task force conducting the operati
-0.152 id=37064: The Bharatiya Janata Party (BJP) leaders of the West Bengal unit will meet Union Home Minister Rajnath Singh on Thursday to lodge protest against the vandalising of its p
-0.155 id=37522: Prime Minister Imran Khan on Thursday congratulated India’s premier Narendra Modi on his victory in the country's national elections. | "I congratulate Prime Minister Modi
-0.159 id=79735: <|endoftext|>India’s PM Narendra Modi has tweeted pictures of his mother’s first visit to his official residence in Delhi. | Twitter users have praised Narendra Modi’s deci
-0.166 id=4620: Agartala, Sep 15 (IANS) The BJP on Tuesday said it would soon launch a stir if Tripura’s Left Front government evicted tribals to set up a firing range for a paramilitary
--- MEDIAN-RANK 3 ---
-0.722 id=62089: View larger image | - Input Projects | - St. Clair River State Space Modelling | - Dependent Projects | - St. Clair Ice Jam Modelling | Potential ice impacts on the conveyance of t
-0.722 id=172720: guarantee. | Shipping | Customer Reviews<|endoftext|>SmartCode ViewerX Version History - Remote Desktop Management and Monitoring - SmartCode | Products | SmartCode VNC Manager
-0.722 id=56483: leratec is now shipping its new Aleratec color coded duplicator grade LightScribe DVD-R recording media. | Aleratec duplicator grade LightScribe media is optimized for Ligh
=== timer ===
4488
=== cache? ===
-rw-r--r-- 1 root root 1063285654 Aug 4 04:46 /tmp/feat_cache.npz
[metadata] {"noOutputExpected": false}The rarity fix worked — the top-ranked docs are now clean news prose (Supreme Court, Reuters, obituaries), gibberish/Latin gone. But I notice the very top is news-heavy. Since the target is equal parts wiki/news/web/QA, register balance may matter. Let me first establish the win: run dev_eval on my V1 selection and a random baseline. Let me create the baseline and launch the V1 eval.
args
{
"command": "cd /workspace; python3 -c \"\nimport numpy as np, json\nz=np.load('/tmp/feat_cache.npz')\nids=z['ids']\nrng=np.random.default_rng(1337)\nperm=rng.permutation(len(ids))\n# take 40k random ids -> way more than 12M tokens\nsel=[int(ids[i]) for i in perm[:40000]]\njson.dump(sel, open('/tmp/random_sel.json','w'))\nprint('random baseline:', len(sel), 'ids')\n\"\necho \"=== launching V1 (my selection) dev_eval ===\"\nexport TOKENIZERS_PARALLELISM=false\nnohup bash dev_eval.sh /workspace/submission/selection.json > /tmp/eval_v1.log 2>&1 &\necho \"started V1 eval pid $!\"",
"description": "Create random baseline and launch V1 eval"
}Bash result
random baseline: 40000 ids
=== launching V1 (my selection) dev_eval ===
started V1 eval pid 1472
[stdout]
random baseline: 40000 ids
=== launching V1 (my selection) dev_eval ===
started V1 eval pid 1472
[metadata] {"noOutputExpected": false}V1 eval is training. While it runs, let me quantify the register mix of the top ~12.4k docs that actually fill the budget — this tells me whether balancing is needed. I'll use crude heuristics:
args
{
"command": "cd /workspace; python3 -c \"\nimport numpy as np, json, re, math\nz=np.load('/tmp/feat_cache.npz')\n# recompute scores quickly (same logic as curate.score)\nCt,Cr=z['Ct'],z['Cr']; T=len(Ct); ALPHA=1.0\nNt,Nr=Ct.sum(),Cr.sum()\nlr=(np.log(Ct+ALPHA)-math.log(Nt+ALPHA*T))-(np.log(Cr+ALPHA)-math.log(Nr+ALPHA*T))\nweak=Ct<2; lr[weak]=np.minimum(lr[weak],0.0)\noff=z['off']; vals=lr[z['allfeats']]; counts=np.diff(off)\nsums=np.add.reduceat(vals,off[:-1]); sums[counts==0]=-1e18\ns=sums/np.maximum(counts,1); s[~z['keep']]=-1e18\norder=np.argsort(-s); ids=z['ids']\n# top docs filling ~12M tokens\nest=z['nchars']/4.0\npassing=order[s[order]>-1e17]\ncum=np.cumsum(est[passing]); nb=int(np.searchsorted(cum,12_000_000))+1\ntop_ids=set(int(ids[j]) for j in passing[:nb])\nprint('top docs filling budget:',nb)\n# grab texts\ntxt={}\nwith open('/workspace/data/pool.jsonl') as f:\n for line in f:\n r=json.loads(line)\n if r['id'] in top_ids: txt[r['id']]=r['text']\n# crude register heuristics\nagency=re.compile(r'\\b(Reuters|ANI|IANS|PTI|AFP|AP|Bloomberg|Xinhua|Agencies|dpa)\\b')\ndateline=re.compile(r'^\\s*[A-Z][A-Za-z .]{2,25}[,]?\\s*\\([A-Za-z ]+\\)\\s*[:\\-]')\ncnt={'news':0,'wiki':0,'qa_tech':0,'web_blog':0,'other':0}\nfor i,t in txt.items():\n low=t.lower(); head=t[:120]\n said=low.count(' said')\n q=t.count('?')\n firstp=low.count(' i ')+low.count(' my ')+low.count(\\\"i'm\\\")\n if agency.search(t) or dateline.search(head) or said>=3:\n cnt['news']+=1\n elif (' was a ' in low or ' is a ' in low or ' was an ' in low or '( born' in low or 'references' in low[-400:]) and firstp<=1:\n cnt['wiki']+=1\n elif q>=3 or 'how to' in low or 'stack' in low or 'function' in low or 'install' in low or 'error' in low:\n cnt['qa_tech']+=1\n elif firstp>=2:\n cnt['web_blog']+=1\n else:\n cnt['other']+=1\ntot=sum(cnt.values())\nprint('REGISTER MIX of budget-filling docs:')\nfor k,v in cnt.items(): print(' %-9s %5d %.1f%%'%(k,v,100*v/tot))\n\" 2>/dev/null",
"description": "Estimate register mix of top selected docs"
}Bash result
top docs filling budget: 12437
REGISTER MIX of budget-filling docs:
news 3183 25.6%
wiki 2855 23.0%
qa_tech 1337 10.8%
web_blog 929 7.5%
other 4133 33.2%
[stdout]
top docs filling budget: 12437
REGISTER MIX of budget-filling docs:
news 3183 25.6%
wiki 2855 23.0%
qa_tech 1337 10.8%
web_blog 929 7.5%
other 4133 33.2%
[metadata] {"noOutputExpected": false}The mix is actually reasonably balanced (news 26%, wiki 23%, qa/tech 11%, web 8%, other 33%) — not catastrophically skewed, since the combined-target DSIR captures all registers. Let me check the V1 eval result:
args
{
"command": "cd /workspace; echo \"=== V1 eval log ===\"; cat /tmp/eval_v1.log 2>/dev/null; echo \"=== timer ===\"; cat /workspace/.timer/remaining_secs",
"description": "Check V1 eval result"
}Bash result
=== V1 eval log ===
Token indices sequence length is longer than the specified maximum sequence length for this model (2170 > 1024). Running this sequence through the model will result in indexing errors
packed 12000000 tokens from 60000 ids -> /tmp/dev_train.npy
=== timer ===
4358
[stdout]
=== V1 eval log ===
Token indices sequence length is longer than the specified maximum sequence length for this model (2170 > 1024). Running this sequence through the model will result in indexing errors
packed 12000000 tokens from 60000 ids -> /tmp/dev_train.npy
=== timer ===
4358
[metadata] {"noOutputExpected": false}Pack done (12M tokens), training now. Let me wait for it and then immediately launch the baseline eval:
args
{
"command": "cd /workspace; sleep 45; echo \"=== V1 result ===\"; grep HELDOUT_PPL /tmp/eval_v1.log 2>/dev/null || echo \"still training...\"; tail -3 /tmp/eval_v1.log",
"description": "Wait for V1 training result"
}Bash result
=== V1 result ===
HELDOUT_PPL 362.930 loss 5.8942 train_s 56 /tmp/dev_train.npy
packed 12000000 tokens from 60000 ids -> /tmp/dev_train.npy
HELDOUT_PPL 362.930 loss 5.8942 train_s 56 /tmp/dev_train.npy
(dev PPL on multi_dev; official uses a hidden disjoint sample of the same HQ domain)
[stdout]
=== V1 result ===
HELDOUT_PPL 362.930 loss 5.8942 train_s 56 /tmp/dev_train.npy
packed 12000000 tokens from 60000 ids -> /tmp/dev_train.npy
HELDOUT_PPL 362.930 loss 5.8942 train_s 56 /tmp/dev_train.npy
(dev PPL on multi_dev; official uses a hidden disjoint sample of the same HQ domain)
[metadata] {"noOutputExpected": false}V1 = 362.93 ppl. Now I need the baseline to measure the gain. Launching random-baseline eval:
args
{
"command": "cd /workspace; export TOKENIZERS_PARALLELISM=false; nohup bash dev_eval.sh /tmp/random_sel.json > /tmp/eval_base.log 2>&1 & echo \"started baseline eval pid $!\"; sleep 3; cat /workspace/.timer/remaining_secs",
"description": "Launch random baseline eval"
}Bash result
started baseline eval pid 1696
4288
[stdout]
started baseline eval pid 1696
4288
[metadata] {"noOutputExpected": false}While the baseline trains, let me check a likely lever: near-duplicate syndicated content in my top picks (the top-10 had 4 Modi/BJP news items — possibly syndicated copies). Redundant tokens waste the budget. Let me estimate duplication in the budget-filling set using MinHash sketches from the cached n-grams:
args
{
"command": "cd /workspace; python3 -c \"\nimport numpy as np, math\nz=np.load('/tmp/feat_cache.npz')\nCt,Cr=z['Ct'],z['Cr']; T=len(Ct); A=1.0\nlr=(np.log(Ct+A)-math.log(Ct.sum()+A*T))-(np.log(Cr+A)-math.log(Cr.sum()+A*T))\nweak=Ct<2; lr[weak]=np.minimum(lr[weak],0.0)\noff=z['off']; vals=lr[z['allfeats']]; counts=np.diff(off)\nsums=np.add.reduceat(vals,off[:-1]); sums[counts==0]=-1e18\ns=sums/np.maximum(counts,1); s[~z['keep']]=-1e18\norder=np.argsort(-s); ids=z['ids']; est=z['nchars']/4.0\npassing=order[s[order]>-1e17]\ncum=np.cumsum(est[passing]); nb=int(np.searchsorted(cum,12_000_000))+1\ntop=passing[:nb]\nD_UNI=1<<20\n# MinHash sketch: k smallest DISTINCT unigram hashes per doc (unigrams are ids<D_UNI)\nK=12\nsketches=[]\nfor j in top:\n a,b=off[j],off[j+1]\n f=z['allfeats'][a:b]\n uni=np.unique(f[f<D_UNI])\n if len(uni)>=K: sk=uni[:K] # already sorted by np.unique -> smallest K hashes\n else: sk=uni\n sketches.append(sk)\n# band LSH: signature = tuple of first 4 minhashes; count collisions\nfrom collections import Counter,defaultdict\nband=Counter()\nfor sk in sketches:\n if len(sk)>=4: band[tuple(sk[:4].tolist())]+=1\ndups=sum(c-1 for c in band.values() if c>1)\nclusters=sum(1 for c in band.values() if c>1)\nprint('budget docs:',nb)\nprint('near-dup docs (share 4-minhash band):',dups,'in',clusters,'clusters')\nprint('=> %.1f%% of budget docs are near-duplicates'%(100*dups/nb))\n# also exact-token-length dup proxy: identical counts\nprint('biggest dup clusters:')\nfor sig,c in band.most_common(6):\n if c>1: print(' cluster size',c)\n\" 2>/dev/null; echo \"=== baseline eval ===\"; grep HELDOUT_PPL /tmp/eval_base.log 2>/dev/null || echo \"still training...\"",
"description": "Estimate near-duplicate fraction in budget docs"
}Bash result
Command did not complete within its 120s timeout and was moved to the background (ID: bwxgzhj46). Output is being written to: /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/bwxgzhj46.output. You will be notified when it completes. To check interim output, use Read on that file path.
Session cwd remains /workspace; directory changes made by the backgrounded command do not apply to subsequent commands.
[metadata] {"noOutputExpected": false, "backgroundTaskId": "bwxgzhj46", "timedOutAfterMs": 120000, "backgroundCwdHint": "Session cwd remains /workspace; directory changes made by the backgrounded command do not apply to subsequent commands."}The dedup analysis got backgrounded (loading the 1GB cache under contention). Let me check both it and the baseline result:
args
{
"command": "sleep 20; echo \"=== baseline eval ===\"; grep HELDOUT_PPL /tmp/eval_base.log 2>/dev/null || echo \"still training...\"; echo \"=== dedup analysis ===\"; cat /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/bwxgzhj46.output 2>/dev/null; echo \"=== timer ===\"; cat /workspace/.timer/remaining_secs",
"description": "Check baseline and dedup analysis"
}Bash result
=== baseline eval ===
HELDOUT_PPL 457.226 loss 6.1252 train_s 56 /tmp/dev_train.npy
=== dedup analysis ===
=== timer ===
4098
[stdout]
=== baseline eval ===
HELDOUT_PPL 457.226 loss 6.1252 train_s 56 /tmp/dev_train.npy
=== dedup analysis ===
=== timer ===
4098
[metadata] {"noOutputExpected": false}Baseline = 457.23, V1 = 362.93 — a solid 20.6% perplexity reduction from curation. Let me record this and wait for the dedup analysis:
args
{
"taskId": "1",
"status": "completed"
}TaskUpdate result
Updated task #1 status
[metadata] {"success": true, "taskId": "1", "updatedFields": ["status"], "statusChange": {"from": "in_progress", "to": "completed"}}