Publish Constoloop checkpoints and training details
Browse filesFiles changed (11)
- README.mdAdded+49
- base.ptAdded+3
- chat.pyAdded+159
- chat_format.pyAdded+38
- distill-sft.ptAdded+3
- dpo-eval.jsonAdded+118
- dpo-pilot.ptAdded+3
- model.pyAdded+247
- model2.pyAdded+304
- pretrain.htmlAdded+49
- ultrachat-sft.ptAdded+3
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849---language:- enlibrary_name: pytorchpipeline_tag: text-generationtags:- recurrent-depth- fineweb-edudatasets:- HuggingFaceFW/fineweb-edu- aldigobbler/constoloop-distill- HuggingFaceH4/ultrachat_200k---
# Constoloop
Constoloop is an experimental 214.75M-parameter English language model trained from scratch. Its shared core can run one to three times per token at inference. The model uses a width of 1,024, 16 query heads, eight key/value heads, and alternating gated short convolution and grouped-query attention blocks. The two-block prelude and coda surround a ten-block shared core. The embedding and output weights are tied.
## Checkpoints
| File | Training ||---|---|| `base.pt` | Final pretraining checkpoint, step 38,147 || `distill-sft.pt` | Best of three epochs on the original single-turn DeepSeek distillation subset, epoch 2 at step 1,220 || `ultrachat-sft.pt` | Best of two epochs on length-filtered UltraChat conversations, epoch 2 at step 1,220 || `dpo-pilot.pt` | One local DPO pass over 27 DeepSeek-reviewed preference pairs, initialized from `ultrachat-sft.pt` |
## Run locally
Download this repository with the Hugging Face CLI. The weights use a custom PyTorch checkpoint format. The included runner loads them with `weights_only=True` and fetches the pinned LFM2.5 tokenizer on first use.
```bashhf download aldigobbler/constoloop --local-dir constoloopcd constoloopuv run chat.py base.pt --raw --loops 1 --max-new 120 "The history of Dublin begins"uv run chat.py ultrachat-sft.pt --loops 2 --max-new 120```
## Training and evaluation
Pretraining used seven shards of FineWeb-Edu from the `CC-MAIN-2024-10` crawl, with approximately 4.568B source tokens after tokenization. The run completed 38,147 optimizer steps at 131,072 tokens per step, or about 5.0B token positions processed. It ran on Modal GPUs with Muon and AdamW. At the final step, held-out cross-entropy was **2.694 / 2.634 / 2.628 nats per token** for R=1/2/3. The interactive pretraining curves are included in `pretrain.html`.
Both SFT runs used 19,500 training examples and 500 validation examples and supervised assistant text and its end-of-turn marker. The original distillation run used single-turn prompt/reply pairs. Its best R=2 validation loss was **2.384**, compared with **3.388** from the base on that split. UltraChat SFT used complete multi-turn conversations fitting within 1,024 tokens. Its best R=2 validation loss was **1.557**, compared with **2.010** from the base on the UltraChat split. Validation losses come from different evaluation sets.
The DPO pilot used DeepSeek V4.1 Flash to generate prompts and review student answers. The local run used R=2, a fixed UltraChat reference, beta 0.1, and AdamW at 5e-6. On eight held-out prompts requiring exact answers and an end token, both the reference and the DPO checkpoint scored **0/8**. See `dpo-eval.json` for the outputs.
## Limitations
The base checkpoint can produce readable prose but frequently invents facts. The chat checkpoints can produce stock disclaimers, lose track of earlier turns, miss simple arithmetic, and ignore exact-output constraints. These checkpoints are intended for experimentation.123version https://git-lfs.github.com/spec/v1oid sha256:48e9b64eb0ad0d9319c5d3d72e181ee56740d8e36db4451d0a6cfdd5195d248asize 859038559123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159# /// script# requires-python = ">=3.11,<3.14"# dependencies = ["huggingface_hub", "numpy", "tokenizers", "torch"]# ///"""Chat with a fine-tuned model, or continue text with a base model.
uv run chat.py ../models/chunklm/chat.pt ["one-off message"] uv run chat.py ../models/chunklm/base.pt --raw ["text to continue"]"""import argparseimport mathfrom concurrent.futures import ThreadPoolExecutorfrom difflib import SequenceMatcherimport reimport sysfrom threading import Eventimport time
import torch
from chat_format import BOS, END_DOC, IM_END, encode_chat, load_tokenizerfrom model import Config, LoopLMfrom model2 import ChunkLM, Config2
ap = argparse.ArgumentParser()ap.add_argument("checkpoint")ap.add_argument("message", nargs="?")ap.add_argument("--raw", action="store_true", help="continue the text instead of chatting (base models)")loop_options = ap.add_mutually_exclusive_group()loop_options.add_argument("--compare-loops", action="store_true", help="compare R=1, R=2 and R=3 (LoopLM)")loop_options.add_argument("--loops", type=int, help="passes through the core; default is what the model was trained for")ap.add_argument("--device", choices=["cpu", "mps", "cuda"], help="default: fastest measured for the model")ap.add_argument("--rep", type=float, default=1.1, help="repetition penalty; 1 = off")ap.add_argument("--max-new", type=int, default=300, help="soft limit; the current sentence is finished")ap.add_argument("--sampler", choices=["sample", "greedy"], default="sample", help="sample by token probability or always pick the highest-scoring token")ap.add_argument("--temperature", type=float, default=0.7, help="sampling temperature; 0 is greedy")ap.add_argument("--top-k", type=int, default=0, help="sample from at most K candidates; 0 disables")ap.add_argument("--top-p", type=float, default=0.9, help="nucleus probability threshold; 1 disables")args = ap.parse_intermixed_args()if not math.isfinite(args.temperature) or args.temperature < 0: ap.error("--temperature must be finite and nonnegative")if args.top_k < 0: ap.error("--top-k must be nonnegative")if not 0 < args.top_p <= 1: ap.error("--top-p must be greater than 0 and at most 1")temperature = 0 if args.sampler == "greedy" else args.temperatureck = torch.load(args.checkpoint, map_location="cpu", weights_only=True)chunked = "experts" in ck["config"]if args.compare_loops and chunked: ap.error("--compare-loops requires a LoopLM checkpoint")gpu = "mps" if torch.backends.mps.is_available() else "cuda" if torch.cuda.is_available() else "cpu"device = args.device or ("cpu" if chunked else gpu)loops = args.loops or (1 if chunked else 2)model = ChunkLM(Config2(**ck["config"])) if chunked else LoopLM(Config(**ck["config"]))model.load_state_dict(ck["model"])model.eval().to(device)loop_label = "R=1 / R=2 / R=3" if args.compare_loops else f"{loops} loop(s)"print(f"{type(model).__name__} step {ck['step']:,} on {device}, {loop_label}", file=sys.stderr)tok = load_tokenizer()
def complete(ids, loops, *, stream=False, generator=None, cancelled=None): start = time.perf_counter() out, shown, why = [], "", "end token" try: # Past --max-new, finish the sentence instead of cutting off mid-word. for t in model.generate(ids, args.max_new + 60, {IM_END, END_DOC}, loops, temperature, top_p=args.top_p, rep=args.rep, top_k=args.top_k, generator=generator): if cancelled is not None and cancelled.is_set(): why = "Ctrl-C" break out.append(t) full = tok.decode(out) if stream and not full.endswith("\ufffd"): # wait for complete characters sys.stdout.write(full[len(shown):]) sys.stdout.flush() shown = full if len(out) >= args.max_new and full.rstrip(" \"')”’").endswith((".", "!", "?", "\n")): why = "length limit, at sentence end" break else: if len(out) >= args.max_new + 60: why = "length limit" except KeyboardInterrupt: if not stream: raise why = "Ctrl-C" rate = len(out) / (time.perf_counter() - start) return tok.decode(out), f"[{len(out)} tokens, {rate:.0f} tok/s; stopped: {why}]"
def run_prompt(text, history, loops, *, seed=None, cancelled=None): if args.raw: ids = [BOS] + tok.encode(text, add_special_tokens=False).ids if seed is None: print(text, end="", flush=True) else: history.append({"role": "user", "content": text}) ids, _ = encode_chat(tok, history, add_reply=True) generator = torch.Generator().manual_seed(seed) if seed is not None else None reply, stats = complete(ids, loops, stream=seed is None, generator=generator, cancelled=cancelled) if not args.raw: history.append({"role": "assistant", "content": reply}) return reply, stats
def highlight(baseline, reply, color): if not sys.stdout.isatty(): return reply # Align words and punctuation so a small insertion doesn't color the entire suffix. words = r"\s*(?:\w+|[^\w\s])|\s+" reference, actual = re.findall(words, baseline), re.findall(words, reply) diff = SequenceMatcher(None, reference, actual, autojunk=False) return "".join( ("\033[37m" if tag == "equal" else color) + "".join(actual[lo:hi]) for tag, _, _, lo, hi in diff.get_opcodes() if lo != hi ) + "\033[0m"
loop_counts = (1, 2, 3)histories = {r: [] for r in loop_counts} if args.compare_loops else {loops: []}while True: if args.message is None: try: text = input("\n> ").strip() except (EOFError, KeyboardInterrupt): break if not text: continue else: text = args.message if args.compare_loops: seed = torch.seed() cancelled = Event() with ThreadPoolExecutor(max_workers=3) as pool: jobs = [ pool.submit(run_prompt, text, histories[r], r, seed=seed, cancelled=cancelled) for r in loop_counts ] try: results = [job.result() for job in jobs] except KeyboardInterrupt: cancelled.set() break baseline = results[1][0] print("R=2 reference · yellow R=1 changes · red R=3 changes") for r, (reply, stats), color in zip(loop_counts, results, ("\033[33m", "\033[37m", "\033[31m")): print(f"\nR={r} {stats}") print((text if args.raw else "") + highlight(baseline, reply, color)) else: _, stats = run_prompt(text, histories[loops], loops) print() print(stats, file=sys.stderr) if args.message is not None: break1234567891011121314151617181920212223242526272829303132333435363738"""LFM2.5 tokenizer helpers and the chat format."""import re
TOKENIZER, REVISION = "LiquidAI/LFM2.5-230M", "40cb2ad3b3044d5a41eee083a6103c8b523afa45"BOS, END_DOC, IM_START, IM_END = 1, 2, 6, 7
def load_tokenizer(): from tokenizers import Tokenizer tok = Tokenizer.from_pretrained(TOKENIZER, revision=REVISION) for name, want in (("<|startoftext|>", BOS), ("<|endoftext|>", END_DOC), ("<|im_start|>", IM_START), ("<|im_end|>", IM_END)): assert tok.token_to_id(name) == want, name tok.encode_special_tokens = True # special-token text inside data stays plain text return tok
def strip_think(text): """Remove <think>...</think>; an unclosed block means the answer never came.""" text = re.sub(r"<think>.*?</think>", "", text, flags=re.S) return "" if "<think>" in text else text.split("</think>")[-1].strip()
def encode_chat(tok, messages, add_reply=False): """-> (ids, labels); only assistant text and its <|im_end|> are trained on.""" enc = lambda s: tok.encode(s, add_special_tokens=False).ids ids, train = [BOS], [False] for m in messages: head = [IM_START] + enc(m["role"] + "\n") body = enc(m["content"]) + [IM_END] mine = m["role"] == "assistant" ids += head + body + enc("\n") train += [False] * len(head) + [mine] * len(body) + [False] * len(enc("\n")) if add_reply: head = [IM_START] + enc("assistant\n") ids += head train += [False] * len(head) return ids, [t if on else -100 for t, on in zip(ids, train)]123version https://git-lfs.github.com/spec/v1oid sha256:547c5e4d6d2dfd35185568f30320c6b42a6eaf252f8a1c42467dc5574fa3d6efsize 859038436123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118{ "before": [ { "prompt": "What is 7 + 6? Output just the number.", "expected": "13", "reply": "I do not have the capability to determine the exact number of 7 + 6. However, in general,", "stopped": false, "pass": false }, { "prompt": "Continue by one term: 3, 6, 12, 24. Output just the number.", "expected": "48", "reply": "The output will be: 24.", "stopped": true, "pass": false }, { "prompt": "Return only the second item: plum, kiwi, peach.", "expected": "kiwi", "reply": "I do not have the ability to return items. However, I can provide you with a description of the second item in", "stopped": false, "pass": false }, { "prompt": "Output exactly this label: READY_93", "expected": "READY_93", "reply": "I don't have the capability to read or write. However, I can provide you with a sample text that you can", "stopped": false, "pass": false }, { "prompt": "Earlier I picked the blue notebook. Which color did I pick? Output just the color.", "expected": "blue", "reply": "I do not have the ability to pick colors. However, I can provide you with the information you need. The blue", "stopped": false, "pass": false }, { "prompt": "Return the uppercase form of 'maple' and nothing else.", "expected": "MAPLE", "reply": "The uppercase form of 'maple' is 'maple'.", "stopped": true, "pass": false }, { "prompt": "Which is larger, 23 or 32? Output just the number.", "expected": "32", "reply": "I do not have the capability to determine the size of an object or determine its properties.", "stopped": true, "pass": false }, { "prompt": "Write only the last word in 'a quiet red fox'.", "expected": "fox", "reply": "A quiet red fox.", "stopped": true, "pass": false } ], "after": [ { "prompt": "What is 7 + 6? Output just the number.", "expected": "13", "reply": "7 + 6\n\nThe answer is 7.", "stopped": true, "pass": false }, { "prompt": "Continue by one term: 3, 6, 12, 24. Output just the number.", "expected": "48", "reply": "4\n\n6\n\n12\n\n24\n\n24\n\n24\n\n24\n\n24\n\n24\n\n24\n\n24\n\n24", "stopped": false, "pass": false }, { "prompt": "Return only the second item: plum, kiwi, peach.", "expected": "kiwi", "reply": "I do not have the ability to return items.", "stopped": true, "pass": false }, { "prompt": "Output exactly this label: READY_93", "expected": "READY_93", "reply": "Sweetness in my mouth\n\nHappy birthday\n\nHappy day\n\nHappy day\n\nHappy day\n\nHappy day\n\nHappy day", "stopped": false, "pass": false }, { "prompt": "Earlier I picked the blue notebook. Which color did I pick? Output just the color.", "expected": "blue", "reply": "Blue notebook\n\nI picked the blue notebook because blue is a calming color that helps to reduce stress and anxiety.", "stopped": true, "pass": false }, { "prompt": "Return the uppercase form of 'maple' and nothing else.", "expected": "MAPLE", "reply": "Maple\n\n[Maple]\n\n[Maple]\n\n[Maple]\n\n[Maple]\n\n[", "stopped": false, "pass": false }, { "prompt": "Which is larger, 23 or 32? Output just the number.", "expected": "32", "reply": "Which is larger, 23 or 32?", "stopped": true, "pass": false }, { "prompt": "Write only the last word in 'a quiet red fox'.", "expected": "fox", "reply": "A quiet red fox\n\nA fox's voice was a soft, low, and distant sound.", "stopped": true, "pass": false } ]}123version https://git-lfs.github.com/spec/v1oid sha256:69bdcfb31c04c956d8cf0b8f652e53900f98e4ac83a427f3b352bb393a5fb94csize 859031844123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247"""Looped hybrid transformer.
embed -> prelude (2 blocks) -> core (10 blocks, run R times, shared weights) -> coda (2 blocks) -> tied output
Blocks alternate a gated short convolution (cheap, 2-token state) with grouped-queryattention, so only half of them need a KV cache. Looping adds depth without addingparameters, and R can be chosen at inference to trade speed for quality."""from dataclasses import asdict, dataclass
import torchimport torch.nn as nnimport torch.nn.functional as Fimport torch.utils.checkpoint
@dataclassclass Config: vocab: int = 64512 # 64,402 LFM2.5 tokens padded to a multiple of 128 dim: int = 1024 ff: int = 2432 heads: int = 16 kv_heads: int = 8 prelude: int = 2 core: int = 10 coda: int = 2 max_loops: int = 3 rope_theta: float = 50_000.0
class TiedCE(torch.autograd.Function): """Mean cross-entropy over a large tied vocabulary. Gradients are formed slice by slice during the forward pass, so logits are computed once and never stored."""
@staticmethod def forward(ctx, h, weight, y, chunk): n = max(1, len(y)) need = ctx.needs_input_grad[0] or ctx.needs_input_grad[1] dtype = h.dtype E = weight.to(dtype) total = h.new_zeros((), dtype=torch.float32) gh = torch.empty_like(h) if need else None gE = torch.zeros_like(weight) if need else None with torch.autocast(h.device.type, enabled=False): for lo in range(0, len(y), chunk): a, t = h[lo:lo + chunk], y[lo:lo + chunk] p = torch.softmax(a @ E.T, -1, dtype=torch.float32) t = t[:, None] gold = p.gather(1, t) total -= gold.clamp(min=1e-30).log().sum() if need: p.scatter_(1, t, gold - 1) p = p.to(dtype) gh[lo:lo + chunk] = p @ E gE += p.T @ a if need: ctx.save_for_backward(gh, gE) ctx.n = n return total / n
@staticmethod def backward(ctx, g): gh, gE = ctx.saved_tensors return gh * (g / ctx.n).to(gh.dtype), gE * (g / ctx.n), None, None
class RMSNorm(nn.Module): def __init__(self, dim): super().__init__() self.weight = nn.Parameter(torch.ones(dim))
def forward(self, x): return F.rms_norm(x, (x.shape[-1],), self.weight.to(x.dtype), 1e-5)
def sample(l, seen, temperature=0.7, top_p=0.9, rep=1.1, *, top_k=0, generator=None): """Pick a token id from logits, penalizing those in the last 128 seen.""" l = l.float().cpu() if rep != 1: u = torch.tensor(sorted(set(seen[-128:]))) l[u] = torch.where(l[u] > 0, l[u] / rep, l[u] * rep) if temperature == 0: return int(l.argmax()) if 0 < top_k < l.numel(): l, idx = l.topk(top_k) p = (l / temperature).softmax(-1) else: p, idx = (l / temperature).softmax(-1).sort(descending=True) if top_p < 1: p[p.cumsum(-1) - p > top_p] = 0 return int(idx[torch.multinomial(p, 1, generator=generator)])
def rope(q, pos, theta): """Rotary embedding; q is [B, H, T, D], pos is [T].""" d = q.shape[-1] freq = theta ** (-torch.arange(0, d, 2, device=q.device, dtype=torch.float32) / d) ang = pos.float()[:, None] * freq cos, sin = ang.cos().to(q.dtype), ang.sin().to(q.dtype) a, b = q[..., : d // 2], q[..., d // 2:] return torch.cat((a * cos - b * sin, a * sin + b * cos), -1)
class Attention(nn.Module): def __init__(self, c): super().__init__() self.c, self.hd = c, c.dim // c.heads self.q = nn.Linear(c.dim, c.dim, bias=False) self.kv = nn.Linear(c.dim, 2 * c.kv_heads * self.hd, bias=False) self.out = nn.Linear(c.dim, c.dim, bias=False) self.qn, self.kn = RMSNorm(self.hd), RMSNorm(self.hd)
def forward(self, x, pos, cache=None): B, T, D = x.shape c = self.c q = self.qn(self.q(x).view(B, T, c.heads, self.hd)).transpose(1, 2) k, v = self.kv(x).view(B, T, c.kv_heads, 2 * self.hd).chunk(2, -1) k, v = self.kn(k).transpose(1, 2), v.transpose(1, 2) q, k = rope(q, pos, c.rope_theta), rope(k, pos, c.rope_theta) new = None if cache is not None: if cache: k, v = torch.cat((cache[0], k), 2), torch.cat((cache[1], v), 2) new = (k, v) rep = c.heads // c.kv_heads k = k[:, :, None].expand(-1, -1, rep, -1, -1).flatten(1, 2) v = v[:, :, None].expand(-1, -1, rep, -1, -1).flatten(1, 2) if cache and T > 1: raise ValueError("feed the prompt at once, then one token at a time") y = F.scaled_dot_product_attention(q, k, v, is_causal=T > 1) return self.out(y.transpose(1, 2).reshape(B, T, D)), new
class ShortConv(nn.Module): """Gated causal depthwise convolution of width 3."""
def __init__(self, c): super().__init__() self.inp = nn.Linear(c.dim, 2 * c.dim, bias=False) self.out = nn.Linear(c.dim, c.dim, bias=False) self.w = nn.Parameter(torch.tensor([1.0, 0.0, 0.0])[:, None].repeat(1, c.dim))
def forward(self, x, pos, cache=None): gate, v = self.inp(x).chunk(2, -1) past = cache[0] if cache else v.new_zeros(v.shape[0], 2, v.shape[2]) h = torch.cat((past, v), 1) w = self.w.to(v.dtype) y = w[0] * v + w[1] * h[:, 1:-1] + w[2] * h[:, :-2] return self.out(gate * y), None if cache is None else (h[:, -2:],)
class Block(nn.Module): def __init__(self, c, kind): super().__init__() self.n1, self.n2 = RMSNorm(c.dim), RMSNorm(c.dim) self.mix = Attention(c) if kind == "attn" else ShortConv(c) self.up = nn.Linear(c.dim, 2 * c.ff, bias=False) self.down = nn.Linear(c.ff, c.dim, bias=False)
def forward(self, x, pos, cache=None): y, new = self.mix(self.n1(x), pos, cache) x = x + y a, b = self.up(self.n2(x)).chunk(2, -1) return x + self.down(F.silu(a) * b), new
class LoopLM(nn.Module): def __init__(self, c: Config): super().__init__() self.c = c stack = lambda n: nn.ModuleList(Block(c, "attn" if i % 2 else "conv") for i in range(n)) self.embed = nn.Embedding(c.vocab, c.dim) self.prelude, self.core, self.coda = stack(c.prelude), stack(c.core), stack(c.coda) self.loop_norm, self.inject_norm, self.norm = RMSNorm(c.dim), RMSNorm(c.dim), RMSNorm(c.dim) self.inject = nn.Parameter(torch.full((c.dim,), 0.5)) depth = c.prelude + 2 * c.core + c.coda for n, p in self.named_parameters(): if p.ndim == 2 and not n.endswith(".w"): last = n.endswith(("out.weight", "down.weight")) nn.init.normal_(p, std=0.02 / (2 * depth) ** 0.5 if last else 0.02)
def count(self): total = sum(p.numel() for p in self.parameters()) return total, total - self.embed.weight.numel()
def forward(self, ids, loops=2, pos=0, caches=None): """Hidden states; caches is a list to fill/reuse when generating.""" positions = torch.arange(pos, pos + ids.shape[1], device=ids.device) fresh = caches is not None and not caches i = 0
def run(block, x): nonlocal i if caches is None: return block(x, positions)[0] x, new = block(x, positions, () if fresh else caches[i]) if fresh: caches.append(new) else: caches[i] = new i += 1 return x
x = self.embed(ids) for b in self.prelude: x = run(b, x) first = x for r in range(loops): if r: # re-read the input so repeated passes stay anchored to it x = self.loop_norm(x) + self.inject.to(x.dtype) * self.inject_norm(first) for b in self.core: x = run(b, x) for b in self.coda: x = run(b, x) return self.norm(x)
def logits(self, h): return F.linear(h, self.embed.weight)
def loss(self, h, y, chunk=8192): h, y = h.flatten(0, 1), y.flatten() if (y < 0).any(): # fine-tuning: skip masked positions before the softmax keep = y >= 0 h, y = h[keep], y[keep] if torch.is_autocast_enabled(h.device.type): h = h.to(torch.get_autocast_dtype(h.device.type)) return TiedCE.apply(h, self.embed.weight, y, chunk)
@torch.no_grad() def generate(self, ids, max_new, stop, loops=2, temperature=0.7, top_p=0.9, rep=1.1, *, top_k=0, generator=None): """Yield token ids.""" caches, pos, feed, seen = [], 0, ids, list(ids) dev = self.embed.weight.device for _ in range(max_new): h = self(torch.tensor([feed], device=dev), loops, pos, caches) pos += len(feed) w = sample(self.logits(h[0, -1]), seen, temperature, top_p, rep, top_k=top_k, generator=generator) if w in stop: return yield w seen.append(w) feed = [w]
def save_config(c): return asdict(c)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304"""O(n) sparse transformer built to read few bytes per generated token.
Mixer: text is cut into chunks of 128 tokens. A token attends exactly (softmax, RoPE) to itsown chunk so far and the previous chunk. Older chunks are evicted into a fixed-size linearmemory per head that fades at a learned rate; the memory is constant within a chunk. Statesize never grows, so training is O(n) and generation O(1) per token.
Feed-forward: 8 experts, 2 used per token, so most parameters are not read for any one token.Looping: the middle 8 blocks run `loops` times with shared weights. Each pass after the firstre-reads the prelude output and adds a learned pass embedding, which also steers the expertrouter, so passes can specialize.Embedding and output share a rank-256 table, which shrinks the softmax 3x."""from dataclasses import dataclass
import torchimport torch.nn as nnimport torch.nn.functional as F
from model import RMSNorm, TiedCE, rope, sample
@dataclassclass Config2: vocab: int = 64512 rank: int = 256 dim: int = 768 layers: int = 12 prelude: int = 2 coda: int = 2 max_loops: int = 3 heads: int = 12 kv_heads: int = 4 chunk: int = 128 experts: int = 8 active: int = 2 ff: int = 592 capacity: float = 1.25 rope_theta: float = 10_000.0
phi = lambda x: F.elu(x) + 1
class Mixer(nn.Module): def __init__(self, c): super().__init__() self.c, self.hd, self.rep = c, c.dim // c.heads, c.heads // c.kv_heads self.q = nn.Linear(c.dim, c.dim, bias=False) self.kv = nn.Linear(c.dim, 2 * c.kv_heads * self.hd, bias=False) self.gate = nn.Linear(c.dim, c.heads) self.out = nn.Linear(c.dim, c.dim, bias=False) self.qn, self.kn = RMSNorm(self.hd), RMSNorm(self.hd) self.decay = nn.Parameter(torch.linspace(0.0, 4.0, c.kv_heads)) # sigmoid, per chunk nn.init.zeros_(self.gate.weight) nn.init.constant_(self.gate.bias, -2.0)
def qkv(self, x): B, T, _ = x.shape q = self.qn(self.q(x).view(B, T, self.c.heads, self.hd)).transpose(1, 2) k, v = self.kv(x).view(B, T, self.c.kv_heads, 2 * self.hd).chunk(2, -1) return q, self.kn(k).transpose(1, 2), v.transpose(1, 2)
def expand(self, t): # [B, K, ...] -> [B, H, ...] return t.repeat_interleave(self.rep, 1)
def forward(self, x, pos): B, T, D = x.shape c, w, K, rep = self.c, self.c.chunk, self.c.kv_heads, self.rep C = T // w q, k, v = self.qkv(x) # Exact attention over [previous chunk, own chunk]: causal windows of two chunks, half # overlapping, so the fast is_causal kernel applies. The first window also yields chunk 0. qr, kr = rope(q, pos, c.rope_theta), rope(k, pos, c.rope_theta) if C > 1: def win(t): # [B,heads,T,D] -> [B,C-1,heads,2w,D] t = t.unflatten(2, (C, w)).transpose(1, 2) return torch.cat((t[:, :-1], t[:, 1:]), 3)
grow = lambda t: t[:, :, :, None].expand(-1, -1, -1, rep, -1, -1).flatten(2, 3) y = F.scaled_dot_product_attention(win(qr).flatten(0, 1), grow(win(kr)).flatten(0, 1), grow(win(v)).flatten(0, 1), is_causal=True).unflatten(0, (B, C - 1)) y = torch.cat((y[:, 0, :, :w], y[:, :, :, w:].transpose(1, 2).flatten(2, 3)), 2) # [B,H,T,D] else: y = F.scaled_dot_product_attention(qr, self.expand(kr), self.expand(v), is_causal=True) # Fading memory of everything older. if C > 2: with torch.autocast(x.device.type, enabled=False): # accumulate in fp32 fk, vb = phi(k.float()).unflatten(2, (C, w)), v.float().unflatten(2, (C, w)) U, S = fk[:, :, :-2].transpose(-1, -2) @ vb[:, :, :-2], fk[:, :, :-2].sum(3) lag = (torch.arange(C - 2, device=x.device)[:, None] - torch.arange(C - 2, device=x.device)[None]).float() W = torch.where(lag >= 0, torch.sigmoid(self.decay)[:, None, None] ** lag.clamp(min=0), 0.0) M = torch.einsum("kcj,bkjde->bkcde", W, U) Z = torch.einsum("kcj,bkjd->bkcd", W, S) scale = Z.mean(-1, keepdim=True) + 1e-3 # same ratio, but safe to read in bf16 M, Z, eps = M / scale.unsqueeze(-1), Z / scale, 1e-3 / scale # queries of one key/value head are read together, so nothing is copied f = phi(q[:, :, 2 * w:]).unflatten(1, (K, rep)).unflatten(3, (C - 2, w)) # [B,K,rep,C-2,w,D] f = f.transpose(2, 3).flatten(3, 4) # [B,K,C-2,rep*w,D] num = f @ M.to(f.dtype) den = f.float() @ Z.unsqueeze(-1) + eps.unsqueeze(-1) r = num / den.to(num.dtype) r = r.unflatten(3, (rep, w)).transpose(2, 3).flatten(3, 4).flatten(1, 2) # [B,H,T-2w,D] g = torch.sigmoid(self.gate(x[:, 2 * w:])).transpose(1, 2).unsqueeze(-1) y = torch.cat((y[:, :, :2 * w], y[:, :, 2 * w:] + (g.to(r.dtype) * r).to(y.dtype)), 2) return self.out(y.transpose(1, 2).reshape(B, T, D))
def step(self, x, pos, st): """A segment inside one chunk. st: dict with M, Z, prev (k,v), cur (k,v).""" B, T, D = x.shape c = self.c q, k, v = self.qkv(x) kr = rope(k, pos, c.rope_theta) if not st: z = k.new_zeros(B, c.kv_heads, self.hd, self.hd, dtype=torch.float32) st.update(M=z, Z=z[..., 0], prev=None, cur=None) if st["cur"] is not None and st["cur"][0].shape[2] == c.chunk: # chunk finished: evict the older one if st["prev"] is not None: g = torch.sigmoid(self.decay).view(1, -1, 1, 1) f = phi(st["prev"][2].float()) st["M"] = g * st["M"] + f.transpose(-1, -2) @ st["prev"][1].float() st["Z"] = g[..., 0] * st["Z"] + f.sum(2) st["prev"], st["cur"] = st["cur"], None new = (kr, v, k) # rotated keys for attention, plain keys for the memory st["cur"] = new if st["cur"] is None else tuple(torch.cat(p, 2) for p in zip(st["cur"], new)) K, V = st["cur"][0], st["cur"][1] if st["prev"] is not None: K, V = torch.cat((st["prev"][0], K), 2), torch.cat((st["prev"][1], V), 2) n = K.shape[2] mask = torch.ones(T, n, dtype=torch.bool, device=x.device).tril(n - T) y = F.scaled_dot_product_attention(rope(q, pos, c.rope_theta), self.expand(K), self.expand(V), attn_mask=mask) f = phi(q.float()) r = (f @ self.expand(st["M"])) / ((f * self.expand(st["Z"]).unsqueeze(2)).sum(-1, keepdim=True) + 1e-3) y = y + torch.sigmoid(self.gate(x)).transpose(1, 2).unsqueeze(-1) * r.to(y.dtype) return self.out(y.transpose(1, 2).reshape(B, T, D))
class Experts(nn.Module): def __init__(self, c): super().__init__() self.c = c self.route = nn.Linear(c.dim, c.experts, bias=False) self.up = nn.Parameter(torch.empty(c.experts, c.dim, 2 * c.ff)) self.down = nn.Parameter(torch.empty(c.experts, c.ff, c.dim)) self.register_buffer("bias", torch.zeros(c.experts)) # keeps expert load even
def forward(self, x): """-> (output, pairs per expert, dropped pairs)""" c = self.c B, T, D = x.shape flat = x.reshape(-1, D) N = len(flat) logit = self.route(flat).float() pick = (logit + self.bias).topk(c.active, -1).indices # balancing affects choice only weight = logit.gather(1, pick).softmax(-1).flatten() expert = pick.flatten() # N * active pairs token = torch.arange(N, device=x.device).repeat_interleave(c.active) cap = int(N * c.active / c.experts * c.capacity) if self.training else N empty = c.experts * cap with torch.no_grad(): # integer bookkeeping only; features move in two gathers order = torch.argsort(expert, stable=True) e = expert[order] load = torch.zeros(c.experts, dtype=torch.long, device=x.device).scatter_add_(0, expert, torch.ones_like(expert)) rank = torch.arange(len(e), device=x.device) - (load.cumsum(0) - load)[e] ok = rank < cap slot = torch.where(ok, e * cap + rank, empty) # overflow -> the zero row source = torch.full((empty + 1,), N, device=x.device).scatter_(0, slot, torch.where(ok, token[order], N)) where = torch.empty_like(slot).scatter_(0, order, slot) # slot of each (token, pick) pair pad = lambda t: torch.cat((t, t.new_zeros(1, D))) h = pad(flat).index_select(0, source[:-1]).view(c.experts, cap, D) a, b = torch.bmm(h, self.up.to(h.dtype)).chunk(2, -1) o = torch.bmm(F.silu(a) * b, self.down.to(h.dtype)).reshape(-1, D) o = pad(o).index_select(0, where).view(N, c.active, D) y = (o * weight.view(N, c.active, 1).to(o.dtype)).sum(1) return y.view(B, T, D), load, (~ok).sum()
def infer(self, x): """Small batches: run only the experts that were chosen.""" flat = x.reshape(-1, x.shape[-1]) logit = self.route(flat).float() pick = (logit + self.bias).topk(self.c.active, -1).indices weight = logit.gather(1, pick).softmax(-1).to(x.dtype) y = torch.zeros_like(flat) for e in pick.unique().tolist(): i, j = (pick == e).nonzero(as_tuple=True) a, b = (flat[i] @ self.up[e]).chunk(2, -1) y[i] += (F.silu(a) * b) @ self.down[e] * weight[i, j][:, None] return y.view_as(x)
class Block2(nn.Module): def __init__(self, c): super().__init__() self.n1, self.n2, self.mix, self.ff = RMSNorm(c.dim), RMSNorm(c.dim), Mixer(c), Experts(c)
def forward(self, x, pos): x = x + self.mix(self.n1(x), pos) y, load, dropped = self.ff(self.n2(x)) return x + y, load, dropped
class ChunkLM(nn.Module): def __init__(self, c: Config2): super().__init__() self.c = c self.embed = nn.Embedding(c.vocab, c.rank) self.inp, self.outp = nn.Linear(c.rank, c.dim, bias=False), nn.Linear(c.dim, c.rank, bias=False) self.blocks = nn.ModuleList(Block2(c) for _ in range(c.layers)) self.norm, self.loop_norm, self.inject_norm = RMSNorm(c.dim), RMSNorm(c.dim), RMSNorm(c.dim) self.inject = nn.Parameter(torch.full((c.dim,), 0.5)) self.pass_emb = nn.Parameter(torch.zeros(c.max_loops, c.dim)) for n, p in self.named_parameters(): if p.ndim >= 2 and "gate" not in n and n != "pass_emb": last = n.endswith(("out.weight", "down")) nn.init.normal_(p, std=0.02 / (2 * c.layers) ** 0.5 if last else 0.02) nn.init.normal_(self.inp.weight, std=c.rank ** -0.5) nn.init.normal_(self.outp.weight, std=c.dim ** -0.5)
def count(self): total = sum(p.numel() for p in self.parameters()) experts = sum(b.ff.up.numel() + b.ff.down.numel() for b in self.blocks) emb = self.embed.weight.numel() fixed, per = total - experts, experts * self.c.active // self.c.experts core = (self.c.layers - self.c.prelude - self.c.coda) / self.c.layers mixers = fixed - emb read = lambda r: emb + (mixers + per) * (1 + core * (r - 1)) return {"total": total, "excl_embed": total - emb, **{f"read_R{r}": read(r) for r in (1, 2, 3)}}
def run(self, x, loops, call): """Apply prelude, looped core and coda; call(i, pass_no, x) runs block i.""" c = self.c end = c.layers - c.coda for i in range(c.prelude): x = call(i, 0, x) first = x for r in range(loops): if r: x = self.loop_norm(x) + self.inject.to(x.dtype) * self.inject_norm(first) + self.pass_emb[r].to(x.dtype) for i in range(c.prelude, end): x = call(i, r, x) for i in range(end, c.layers): x = call(i, 0, x) return self.norm(x)
def forward(self, ids, loops=2): T = ids.shape[1] pad = -T % self.c.chunk pos = torch.arange(T + pad, device=ids.device) self.loads, self.dropped = [0] * self.c.layers, 0
def call(i, r, x): x, load, d = self.blocks[i](x, pos) self.loads[i] = self.loads[i] + load self.dropped = self.dropped + d return x
return self.outp(self.run(self.inp(self.embed(F.pad(ids, (0, pad)))), loops, call)[:, :T])
@torch.no_grad() def balance(self, rate=0.01): """Nudge routing toward equal expert load (call once per step).""" for b, load in zip(self.blocks, self.loads): b.ff.bias += rate * (load.float().mean() - load).sign()
def logits(self, h): return F.linear(h, self.embed.weight)
def loss(self, h, y, chunk=8192): h, y = h.flatten(0, 1), y.flatten() if (y < 0).any(): keep = y >= 0 h, y = h[keep], y[keep] return TiedCE.apply(h, self.embed.weight, y, chunk)
def step(self, ids, pos, state, loops=2): """Feed ids (any length) after `pos` tokens; state maps (block, pass) to its memory.""" outs, w = [], self.c.chunk while ids.shape[1]: n = min(ids.shape[1], w - pos % w) # stay inside one chunk p = torch.arange(pos, pos + n, device=ids.device)
def call(i, r, x): b = self.blocks[i] x = x + b.mix.step(b.n1(x), p, state.setdefault((i, r), {})) return x + b.ff.infer(b.n2(x))
outs.append(self.outp(self.run(self.inp(self.embed(ids[:, :n])), loops, call))) ids, pos = ids[:, n:], pos + n return torch.cat(outs, 1)
@torch.inference_mode() def generate(self, ids, max_new, stop, loops=1, temperature=0.7, top_p=0.9, rep=1.1, *, top_k=0, generator=None): """Yield token ids.""" state, pos, feed, seen = {}, 0, ids, list(ids) dev = self.embed.weight.device for _ in range(max_new): h = self.step(torch.tensor([feed], device=dev), pos, state, loops) pos += len(feed) w = sample(self.logits(h[0, -1]), seen, temperature, top_p, rep, top_k=top_k, generator=generator) if w in stop: return yield w seen.append(w) feed = [w]12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849<!doctype html><html lang="en"><meta charset="utf-8"><title>Pretraining loss</title><meta name="viewport" content="width=device-width,initial-scale=1"><style>.viz-root{color-scheme:light;--s:#fcfcfb;--t1:#0b0b0b;--t2:#52514e;--grid:#e4e3df;--c1:#2a78d6;--c2:#eb6834}@media (prefers-color-scheme:dark){.viz-root{color-scheme:dark;--s:#1a1a19;--t1:#f0efec;--t2:#c3c2b7;--grid:#343432;--c1:#3987e5;--c2:#d95926}}body{margin:0;background:var(--s);color:var(--t1);font:14px/1.45 system-ui,sans-serif}main{max-width:820px;margin:0 auto;padding:28px 20px}h1{font-size:22px;margin:0 0 4px}h2{font-size:15px;margin:30px 0 2px}p{margin:0 0 8px;color:var(--t2)}svg{width:100%;display:block;overflow:visible}svg text{fill:var(--t2);font-size:12px;font-variant-numeric:tabular-nums}.leg{display:flex;gap:18px;color:var(--t2);margin:4px 0}.leg i{display:inline-block;width:16px;height:2px;background:var(--c1);vertical-align:middle;margin-right:6px}.leg i.d{width:10px;height:10px;border-radius:50%;background:var(--c2)}.box{position:relative}.tip{position:absolute;pointer-events:none;background:var(--s);border:1px solid var(--grid);border-radius:6px;padding:6px 9px;display:none;white-space:nowrap;color:var(--t2)}.tip b{color:var(--t1)}table{border-collapse:collapse;margin-top:8px;font-variant-numeric:tabular-nums}td,th{text-align:right;padding:3px 18px 3px 0;border-bottom:1px solid var(--grid)}th{color:var(--t2);font-weight:500}td:first-child,th:first-child{text-align:left}</style><body class="viz-root"><main><h1>Pretraining loss</h1><p id="sub"></p><h2>Training loss, full run</h2><p>The steep early drop makes everything after it look flat.</p><div class="box" id="a"></div><h2>The same run after step 1,000, zoomed in</h2><p>The vertical axis does not start at zero.</p><div class="leg"><span><i></i>Training loss</span><span><i class="d"></i>Validation loss (2 loops)</span></div><div class="box" id="b"></div><h2>Average training loss per 500 steps</h2><table id="t1"></table><h2>Validation loss by number of loops</h2><table id="t2"></table></main><script>const D={"train":[[20,10.334],[40,8.189],[60,6.943],[80,6.419],[100,6.134],[120,5.924],[140,5.724],[160,5.535],[180,5.336],[200,5.166],[220,5.036],[240,4.912],[260,4.801],[280,4.682],[300,4.606],[320,4.544],[340,4.488],[360,4.424],[380,4.379],[400,4.308],[420,4.254],[440,4.178],[460,4.153],[480,4.109],[500,4.071],[520,4.051],[540,4.019],[560,3.965],[580,3.929],[600,3.893],[620,3.89],[640,3.872],[660,3.852],[680,3.832],[700,3.803],[720,3.782],[740,3.768],[760,3.762],[780,3.752],[800,3.715],[820,3.708],[840,3.691],[860,3.68],[880,3.679],[900,3.675],[920,3.658],[940,3.648],[960,3.618],[980,3.599],[1000,3.629],[1020,3.6],[1040,3.593],[1060,3.599],[1080,3.579],[1100,3.582],[1120,3.577],[1140,3.563],[1160,3.547],[1180,3.563],[1200,3.551],[1220,3.542],[1240,3.53],[1260,3.54],[1280,3.5],[1300,3.504],[1320,3.49],[1340,3.508],[1360,3.482],[1380,3.477],[1400,3.479],[1420,3.467],[1440,3.47],[1460,3.482],[1480,3.466],[1500,3.444],[1520,3.455],[1540,3.454],[1560,3.444],[1580,3.422],[1600,3.449],[1620,3.428],[1640,3.423],[1660,3.438],[1680,3.413],[1700,3.411],[1720,3.427],[1740,3.418],[1760,3.409],[1780,3.393],[1800,3.396],[1820,3.387],[1840,3.384],[1860,3.385],[1880,3.386],[1900,3.387],[1920,3.396],[1940,3.381],[1960,3.375],[1980,3.377],[2000,3.366],[2020,3.373],[2040,3.337],[2060,3.362],[2080,3.377],[2100,3.355],[2120,3.363],[2140,3.359],[2160,3.335],[2180,3.36],[2200,3.331],[2220,3.301],[2240,3.32],[2260,3.306],[2280,3.335],[2300,3.321],[2320,3.32],[2340,3.349],[2360,3.325],[2380,3.32],[2400,3.326],[2420,3.309],[2440,3.331],[2460,3.279],[2480,3.298],[2500,3.294],[2520,3.302],[2540,3.301],[2560,3.298],[2580,3.295],[2600,3.294],[2620,3.312],[2640,3.29],[2660,3.279],[2680,3.294],[2700,3.276],[2720,3.284],[2740,3.26],[2760,3.297],[2780,3.276],[2800,3.287],[2820,3.276],[2840,3.27],[2860,3.254],[2880,3.278],[2900,3.249],[2920,3.273],[2940,3.269],[2960,3.275],[2980,3.257],[3000,3.248],[3020,3.249],[3040,3.276],[3060,3.237],[3080,3.248],[3100,3.259],[3120,3.236],[3140,3.239],[3160,3.244],[3180,3.24],[3200,3.251],[3220,3.217],[3240,3.222],[3260,3.255],[3280,3.244],[3300,3.215],[3320,3.233],[3340,3.232],[3360,3.227],[3380,3.219],[3400,3.212],[3420,3.234],[3440,3.223],[3460,3.213],[3480,3.234],[3500,3.222],[3520,3.2],[3540,3.227],[3560,3.211],[3580,3.209],[3600,3.191],[3620,3.203],[3640,3.21],[3660,3.209],[3680,3.199],[3700,3.209],[3720,3.209],[3740,3.224],[3760,3.21],[3780,3.188],[3800,3.184],[3820,3.19],[3840,3.192],[3860,3.185],[3880,3.206],[3900,3.186],[3920,3.199],[3940,3.211],[3960,3.204],[3980,3.184],[4000,3.199],[4020,3.183],[4040,3.159],[4060,3.173],[4080,3.173],[4100,3.174],[4120,3.16],[4140,3.197],[4160,3.196],[4180,3.169],[4200,3.184],[4220,3.185],[4240,3.186],[4260,3.198],[4280,3.158],[4300,3.155],[4320,3.169],[4340,3.178],[4360,3.156],[4380,3.151],[4400,3.195],[4420,3.156],[4440,3.177],[4460,3.166],[4480,3.179],[4500,3.17],[4520,3.159],[4540,3.176],[4560,3.16],[4580,3.164],[4600,3.16],[4620,3.17],[4640,3.166],[4660,3.147],[4680,3.145],[4700,3.163],[4720,3.142],[4740,3.142],[4760,3.169],[4780,3.154],[4800,3.146],[4820,3.133],[4840,3.155],[4860,3.153],[4880,3.133],[4900,3.141],[4920,3.152],[4940,3.151],[4960,3.139],[4980,3.137],[5000,3.131],[5020,3.148],[5040,3.122],[5060,3.153],[5080,3.145],[5100,3.157],[5120,3.131],[5140,3.132],[5160,3.155],[5180,3.126],[5200,3.154],[5220,3.158],[5240,3.134],[5260,3.099],[5280,3.104],[5300,3.136],[5320,3.116],[5340,3.161],[5360,3.136],[5380,3.132],[5400,3.125],[5420,3.124],[5440,3.145],[5460,3.128],[5480,3.124],[5500,3.108],[5520,3.124],[5540,3.119],[5560,3.138],[5580,3.126],[5600,3.112],[5620,3.117],[5640,3.128],[5660,3.114],[5680,3.119],[5700,3.104],[5720,3.101],[5740,3.103],[5760,3.131],[5780,3.116],[5800,3.131],[5820,3.108],[5840,3.124],[5860,3.116],[5880,3.117],[5900,3.081],[5920,3.102],[5940,3.092],[5960,3.113],[5980,3.127],[6000,3.114],[6020,3.115],[6040,3.1],[6060,3.113],[6080,3.103],[6100,3.095],[6120,3.119],[6140,3.124],[6160,3.109],[6180,3.088],[6200,3.096],[6220,3.114],[6240,3.112],[6260,3.102],[6280,3.085],[6300,3.106],[6320,3.101],[6340,3.1],[6360,3.107],[6380,3.112],[6400,3.084],[6420,3.099],[6440,3.075],[6460,3.096],[6480,3.099],[6500,3.109],[6520,3.088],[6540,3.081],[6560,3.072],[6580,3.083],[6600,3.069],[6620,3.084],[6640,3.075],[6660,3.084],[6680,3.075],[6700,3.078],[6720,3.076],[6740,3.096],[6760,3.088],[6780,3.085],[6800,3.081],[6820,3.066],[6840,3.082],[6860,3.091],[6880,3.118],[6900,3.076],[6920,3.093],[6940,3.104],[6960,3.065],[6980,3.071],[7000,3.086],[7020,3.099],[7040,3.094],[7060,3.077],[7080,3.087],[7100,3.076],[7120,3.066],[7140,3.08],[7160,3.061],[7180,3.086],[7200,3.104],[7220,3.088],[7240,3.071],[7260,3.086],[7280,3.075],[7300,3.087],[7320,3.078],[7340,3.089],[7360,3.07],[7380,3.07],[7400,3.082],[7420,3.076],[7440,3.044],[7460,3.083],[7480,3.059],[7500,3.089],[7520,3.065],[7540,3.083],[7560,3.082],[7580,3.05],[7600,3.064],[7620,3.065],[7640,3.058],[7660,3.093],[7680,3.055],[7700,3.083],[7720,3.045],[7740,3.066],[7760,3.066],[7780,3.036],[7800,3.069],[7820,3.076],[7840,3.077],[7860,3.078],[7880,3.062],[7900,3.059],[7920,3.075],[7940,3.041],[7960,3.058],[7980,3.059],[8000,3.048],[8020,3.075],[8040,3.046],[8060,3.067],[8080,3.047],[8100,3.057],[8120,3.043],[8140,3.048],[8160,3.07],[8180,3.065],[8200,3.061],[8220,3.047],[8240,3.047],[8260,3.065],[8280,3.047],[8300,3.05],[8320,3.044],[8340,3.039],[8360,3.053],[8380,3.044],[8400,3.044],[8420,3.035],[8440,3.052],[8460,3.054],[8480,3.051],[8500,3.043],[8520,3.062],[8540,3.054],[8560,3.038],[8580,3.048],[8600,3.042],[8620,3.024],[8640,3.032],[8660,3.058],[8680,3.015],[8700,3.037],[8720,3.039],[8740,3.039],[8760,3.041],[8780,3.055],[8800,3.049],[8820,3.047],[8840,3.063],[8860,3.039],[8880,3.026],[8900,3.038],[8920,3.05],[8940,3.028],[8960,3.034],[8980,3.018],[9000,3.033],[9020,3.036],[9040,3.025],[9060,3.045],[9080,3.017],[9100,3.024],[9120,3.034],[9140,3.072],[9160,3.032],[9180,3.03],[9200,3.04],[9220,3.016],[9240,3.015],[9260,3.042],[9280,3.028],[9300,3.04],[9320,3.035],[9340,3.05],[9360,3.034],[9380,3.04],[9400,3.042],[9420,3.019],[9440,3.039],[9460,3.031],[9480,3.018],[9500,3.045],[9520,3.009],[9540,3.016],[9560,3.045],[9580,3.033],[9600,3.039],[9620,3.023],[9640,3.046],[9660,3.035],[9680,3.016],[9700,3.029],[9720,3.015],[9740,3.004],[9760,3.003],[9780,3.03],[9800,3.017],[9820,3.026],[9840,3.012],[9860,3.024],[9880,3.011],[9900,3.012],[9920,3.011],[9940,3.023],[9960,3.004],[9980,3.014],[10000,3.024],[10020,3.005],[10040,2.993],[10060,3.03],[10080,3.029],[10100,3.033],[10120,3.022],[10140,3.01],[10160,3.015],[10180,3.005],[10200,3.017],[10220,3.025],[10240,3.01],[10260,2.998],[10280,3.016],[10300,2.998],[10320,3.006],[10340,2.999],[10360,3.013],[10380,3.011],[10400,3.001],[10420,3.017],[10440,2.994],[10460,3.002],[10480,3.005],[10500,3.0],[10520,3.006],[10540,3.0],[10560,3.023],[10580,2.991],[10600,3.015],[10620,3.012],[10640,3.005],[10660,2.995],[10680,3.017],[10700,3.003],[10720,2.991],[10740,3.017],[10760,3.012],[10780,3.014],[10800,2.999],[10820,2.988],[10840,3.001],[10860,3.002],[10880,3.016],[10900,3.015],[10920,3.017],[10940,3.011],[10960,2.983],[10980,2.993],[11000,2.99],[11020,2.971],[11040,3.013],[11060,3.008],[11080,3.018],[11100,2.987],[11120,3.0],[11140,3.013],[11160,2.995],[11180,3.005],[11200,3.005],[11220,2.984],[11240,2.978],[11260,3.019],[11280,3.002],[11300,3.02],[11320,2.989],[11340,3.013],[11360,2.992],[11380,2.996],[11400,3.004],[11420,2.992],[11440,2.998],[11460,3.007],[11480,3.003],[11500,2.999],[11520,2.988],[11540,2.996],[11560,3.0],[11580,2.982],[11600,2.981],[11620,3.0],[11640,2.995],[11660,2.988],[11680,2.993],[11700,2.984],[11720,3.005],[11740,2.993],[11760,3.001],[11780,3.028],[11800,2.97],[11820,3.004],[11840,3.005],[11860,2.998],[11880,2.997],[11900,2.984],[11920,2.979],[11940,2.994],[11960,2.986],[11980,2.999],[12000,2.987],[12020,3.011],[12040,2.974],[12060,2.999],[12080,2.993],[12100,2.98],[12120,3.012],[12140,2.984],[12160,3.012],[12180,2.98],[12200,2.959],[12220,2.985],[12240,2.987],[12260,2.977],[12280,2.976],[12300,2.975],[12320,2.984],[12340,2.983],[12360,2.98],[12380,2.985],[12400,2.975],[12420,2.98],[12440,2.982],[12460,2.965],[12480,2.997],[12500,2.998],[12520,2.978],[12540,2.977],[12560,2.98],[12580,2.981],[12600,2.98],[12620,3.003],[12640,2.978],[12660,2.999],[12680,2.971],[12700,2.972],[12720,2.962],[12740,2.985],[12760,2.965],[12780,2.991],[12800,2.987],[12820,2.994],[12840,2.963],[12860,2.981],[12880,2.965],[12900,2.963],[12920,2.969],[12940,2.984],[12960,2.971],[12980,2.989],[13000,2.972],[13020,2.99],[13040,2.951],[13060,2.982],[13080,2.949],[13100,2.969],[13120,2.986],[13140,2.987],[13160,2.953],[13180,2.948],[13200,2.965],[13220,2.981],[13240,2.979],[13260,2.949],[13280,2.97],[13300,2.986],[13320,2.962],[13340,2.956],[13360,2.969],[13380,2.967],[13400,2.99],[13420,2.972],[13440,2.943],[13460,2.959],[13480,2.961],[13500,2.955],[13520,2.974],[13540,2.962],[13560,2.958],[13580,2.941],[13600,2.965],[13620,2.974],[13640,2.978],[13660,2.972],[13680,2.948],[13700,2.959],[13720,2.947],[13740,2.96],[13760,2.961],[13780,2.956],[13800,2.947],[13820,2.961],[13840,2.962],[13860,2.946],[13880,2.981],[13900,2.968],[13920,2.954],[13940,2.961],[13960,2.956],[13980,2.942],[14000,2.941],[14020,2.954],[14040,2.957],[14060,2.955],[14080,2.96],[14100,2.951],[14120,2.969],[14140,2.945],[14160,2.968],[14180,2.963],[14200,2.945],[14220,2.979],[14240,2.942],[14260,2.944],[14280,2.96],[14300,2.939],[14320,2.954],[14340,2.944],[14360,2.94],[14380,2.949],[14400,2.953],[14420,2.961],[14440,2.952],[14460,2.934],[14480,2.955],[14500,2.958],[14520,2.944],[14540,2.928],[14560,2.948],[14580,2.949],[14600,2.942],[14620,2.979],[14640,2.942],[14660,2.933],[14680,2.95],[14700,2.955],[14720,2.964],[14740,2.95],[14760,2.946],[14780,2.945],[14800,2.945],[14820,2.944],[14840,2.964],[14860,2.941],[14880,2.949],[14900,2.96],[14920,2.954],[14940,2.951],[14960,2.933],[14980,2.952],[15000,2.914],[15020,2.924],[15040,2.939],[15060,2.942],[15080,2.927],[15100,2.928],[15120,2.96],[15140,2.925],[15160,2.95],[15180,2.933],[15200,2.942],[15220,2.957],[15240,2.951],[15260,2.949],[15280,2.922],[15300,2.93],[15320,2.923],[15340,2.955],[15360,2.939],[15380,2.943],[15400,2.943],[15420,2.938],[15440,2.914],[15460,2.931],[15480,2.94],[15500,2.943],[15520,2.947],[15540,2.94],[15560,2.943],[15580,2.936],[15600,2.921],[15620,2.948],[15640,2.919],[15660,2.954],[15680,2.942],[15700,2.926],[15720,2.91],[15740,2.946],[15760,2.953],[15780,2.907],[15800,2.925],[15820,2.901],[15840,2.926],[15860,2.924],[15880,2.933],[15900,2.937],[15920,2.923],[15940,2.938],[15960,2.942],[15980,2.91],[16000,2.947],[16020,2.959],[16040,2.931],[16060,2.92],[16080,2.926],[16100,2.915],[16120,2.913],[16140,2.919],[16160,2.926],[16180,2.914],[16200,2.911],[16220,2.94],[16240,2.923],[16260,2.926],[16280,2.925],[16300,2.936],[16320,2.93],[16340,2.903],[16360,2.919],[16380,2.91],[16400,2.918],[16420,2.902],[16440,2.935],[16460,2.911],[16480,2.935],[16500,2.929],[16520,2.918],[16540,2.919],[16560,2.935],[16580,2.925],[16600,2.906],[16620,2.91],[16640,2.925],[16660,2.934],[16680,2.916],[16700,2.901],[16720,2.92],[16740,2.91],[16760,2.918],[16780,2.912],[16800,2.916],[16820,2.91],[16840,2.908],[16860,2.915],[16880,2.929],[16900,2.925],[16920,2.905],[16940,2.921],[16960,2.925],[16980,2.924],[17000,2.892],[17020,2.897],[17040,2.92],[17060,2.923],[17080,2.906],[17100,2.908],[17120,2.909],[17140,2.921],[17160,2.89],[17180,2.901],[17200,2.931],[17220,2.889],[17240,2.913],[17260,2.896],[17280,2.916],[17300,2.913],[17320,2.922],[17340,2.91],[17360,2.928],[17380,2.922],[17400,2.91],[17420,2.921],[17440,2.901],[17460,2.893],[17480,2.927],[17500,2.905],[17520,2.915],[17540,2.92],[17560,2.915],[17580,2.92],[17600,2.906],[17620,2.908],[17640,2.908],[17660,2.9],[17680,2.911],[17700,2.882],[17720,2.915],[17740,2.9],[17760,2.872],[17780,2.891],[17800,2.897],[17820,2.909],[17840,2.895],[17860,2.898],[17880,2.913],[17900,2.903],[17920,2.887],[17940,2.902],[17960,2.904],[17980,2.901],[18000,2.896],[18020,2.896],[18040,2.899],[18060,2.907],[18080,2.911],[18100,2.884],[18120,2.884],[18140,2.891],[18160,2.883],[18180,2.912],[18200,2.902],[18220,2.888],[18240,2.894],[18260,2.889],[18280,2.9],[18300,2.908],[18320,2.912],[18340,2.889],[18360,2.893],[18380,2.901],[18400,2.902],[18420,2.869],[18440,2.903],[18460,2.901],[18480,2.895],[18500,2.886],[18520,2.876],[18540,2.895],[18560,2.891],[18580,2.887],[18600,2.892],[18620,2.869],[18640,2.884],[18660,2.901],[18680,2.875],[18700,2.902],[18720,2.889],[18740,2.885],[18760,2.892],[18780,2.874],[18800,2.899],[18820,2.9],[18840,2.882],[18860,2.877],[18880,2.878],[18900,2.907],[18920,2.903],[18940,2.889],[18960,2.904],[18980,2.901],[19000,2.877],[19020,2.885],[19040,2.9],[19060,2.898],[19080,2.877],[19100,2.87],[19120,2.88],[19140,2.91],[19160,2.891],[19180,2.893],[19200,2.893],[19220,2.897],[19240,2.864],[19260,2.876],[19280,2.866],[19300,2.875],[19320,2.903],[19340,2.875],[19360,2.864],[19380,2.896],[19400,2.901],[19420,2.858],[19440,2.895],[19460,2.892],[19480,2.875],[19500,2.885],[19520,2.878],[19540,2.892],[19560,2.882],[19580,2.884],[19600,2.855],[19620,2.88],[19640,2.852],[19660,2.869],[19680,2.879],[19700,2.9],[19720,2.88],[19740,2.876],[19760,2.872],[19780,2.853],[19800,2.864],[19820,2.874],[19840,2.897],[19860,2.903],[19880,2.878],[19900,2.892],[19920,2.897],[19940,2.892],[19960,2.891],[19980,2.891],[20000,2.889],[20020,2.883],[20040,2.86],[20060,2.881],[20080,2.872],[20100,2.881],[20120,2.867],[20140,2.847],[20160,2.881],[20180,2.882],[20200,2.896],[20220,2.891],[20240,2.886],[20260,2.86],[20280,2.86],[20300,2.857],[20320,2.86],[20340,2.874],[20360,2.862],[20380,2.851],[20400,2.873],[20420,2.872],[20440,2.842],[20460,2.874],[20480,2.848],[20500,2.878],[20520,2.854],[20540,2.868],[20560,2.867],[20580,2.873],[20600,2.86],[20620,2.865],[20640,2.851],[20660,2.854],[20680,2.864],[20700,2.878],[20720,2.857],[20740,2.861],[20760,2.862],[20780,2.862],[20800,2.866],[20820,2.847],[20840,2.847],[20860,2.86],[20880,2.873],[20900,2.866],[20920,2.85],[20940,2.857],[20960,2.879],[20980,2.875],[21000,2.855],[21020,2.866],[21040,2.867],[21060,2.85],[21080,2.876],[21100,2.845],[21120,2.87],[21140,2.838],[21160,2.867],[21180,2.862],[21200,2.869],[21220,2.864],[21240,2.842],[21260,2.856],[21280,2.877],[21300,2.85],[21320,2.863],[21340,2.849],[21360,2.855],[21380,2.832],[21400,2.841],[21420,2.868],[21440,2.845],[21460,2.856],[21480,2.847],[21500,2.851],[21520,2.855],[21540,2.831],[21560,2.843],[21580,2.856],[21600,2.85],[21620,2.85],[21640,2.87],[21660,2.848],[21680,2.85],[21700,2.846],[21720,2.839],[21740,2.849],[21760,2.864],[21780,2.861],[21800,2.851],[21820,2.838],[21840,2.845],[21860,2.838],[21880,2.861],[21900,2.839],[21920,2.844],[21940,2.854],[21960,2.848],[21980,2.864],[22000,2.854],[22020,2.839],[22040,2.859],[22060,2.861],[22080,2.853],[22100,2.835],[22120,2.844],[22140,2.859],[22160,2.839],[22180,2.851],[22200,2.84],[22220,2.836],[22240,2.832],[22260,2.848],[22280,2.856],[22300,2.854],[22320,2.865],[22340,2.852],[22360,2.846],[22380,2.827],[22400,2.848],[22420,2.83],[22440,2.862],[22460,2.839],[22480,2.832],[22500,2.829],[22520,2.846],[22540,2.842],[22560,2.807],[22580,2.836],[22600,2.837],[22620,2.839],[22640,2.838],[22660,2.835],[22680,2.841],[22700,2.845],[22720,2.842],[22740,2.839],[22760,2.843],[22780,2.827],[22800,2.843],[22820,2.821],[22840,2.831],[22860,2.842],[22880,2.836],[22900,2.83],[22920,2.836],[22940,2.827],[22960,2.837],[22980,2.822],[23000,2.84],[23020,2.835],[23040,2.838],[23060,2.828],[23080,2.82],[23100,2.848],[23120,2.818],[23140,2.831],[23160,2.812],[23180,2.827],[23200,2.837],[23220,2.856],[23240,2.835],[23260,2.826],[23280,2.841],[23300,2.829],[23320,2.823],[23340,2.837],[23360,2.805],[23380,2.829],[23400,2.821],[23420,2.83],[23440,2.824],[23460,2.827],[23480,2.818],[23500,2.827],[23520,2.836],[23540,2.829],[23560,2.835],[23580,2.836],[23600,2.824],[23620,2.829],[23640,2.823],[23660,2.812],[23680,2.81],[23700,2.828],[23720,2.818],[23740,2.814],[23760,2.825],[23780,2.822],[23800,2.853],[23820,2.828],[23840,2.845],[23860,2.829],[23880,2.813],[23900,2.807],[23920,2.81],[23940,2.832],[23960,2.806],[23980,2.83],[24000,2.837],[24020,2.804],[24040,2.802],[24060,2.819],[24080,2.821],[24100,2.826],[24120,2.808],[24140,2.808],[24160,2.806],[24180,2.837],[24200,2.803],[24220,2.84],[24240,2.806],[24260,2.818],[24280,2.807],[24300,2.836],[24320,2.819],[24340,2.818],[24360,2.819],[24380,2.827],[24400,2.829],[24420,2.801],[24440,2.81],[24460,2.813],[24480,2.837],[24500,2.812],[24520,2.817],[24540,2.797],[24560,2.82],[24580,2.823],[24600,2.823],[24620,2.804],[24640,2.791],[24660,2.823],[24680,2.812],[24700,2.837],[24720,2.805],[24740,2.806],[24760,2.807],[24780,2.807],[24800,2.808],[24820,2.827],[24840,2.815],[24860,2.833],[24880,2.803],[24900,2.803],[24920,2.808],[24940,2.824],[24960,2.786],[24980,2.806],[25000,2.795],[25020,2.797],[25040,2.788],[25060,2.806],[25080,2.799],[25100,2.79],[25120,2.79],[25140,2.802],[25160,2.808],[25180,2.807],[25200,2.814],[25220,2.783],[25240,2.775],[25260,2.803],[25280,2.804],[25300,2.819],[25320,2.805],[25340,2.8],[25360,2.804],[25380,2.807],[25400,2.831],[25420,2.805],[25440,2.779],[25460,2.828],[25480,2.792],[25500,2.806],[25520,2.807],[25540,2.781],[25560,2.788],[25580,2.794],[25600,2.785],[25620,2.804],[25640,2.793],[25660,2.79],[25680,2.763],[25700,2.778],[25720,2.786],[25740,2.793],[25760,2.783],[25780,2.8],[25800,2.805],[25820,2.808],[25840,2.788],[25860,2.788],[25880,2.804],[25900,2.771],[25920,2.79],[25940,2.793],[25960,2.818],[25980,2.792],[26000,2.794],[26020,2.822],[26040,2.788],[26060,2.781],[26080,2.798],[26100,2.797],[26120,2.797],[26140,2.786],[26160,2.787],[26180,2.774],[26200,2.788],[26220,2.809],[26240,2.799],[26260,2.782],[26280,2.764],[26300,2.778],[26320,2.792],[26340,2.79],[26360,2.769],[26380,2.775],[26400,2.785],[26420,2.787],[26440,2.801],[26460,2.774],[26480,2.78],[26500,2.792],[26520,2.798],[26540,2.764],[26560,2.779],[26580,2.767],[26600,2.788],[26620,2.764],[26640,2.796],[26660,2.756],[26680,2.785],[26700,2.789],[26720,2.777],[26740,2.772],[26760,2.787],[26780,2.782],[26800,2.781],[26820,2.789],[26840,2.785],[26860,2.792],[26880,2.77],[26900,2.766],[26920,2.791],[26940,2.77],[26960,2.794],[26980,2.758],[27000,2.782],[27020,2.759],[27040,2.764],[27060,2.778],[27080,2.782],[27100,2.766],[27120,2.773],[27140,2.787],[27160,2.776],[27180,2.786],[27200,2.79],[27220,2.788],[27240,2.776],[27260,2.767],[27280,2.779],[27300,2.787],[27320,2.776],[27340,2.755],[27360,2.77],[27380,2.768],[27400,2.778],[27420,2.77],[27440,2.799],[27460,2.772],[27480,2.768],[27500,2.788],[27520,2.748],[27540,2.759],[27560,2.797],[27580,2.786],[27600,2.772],[27620,2.751],[27640,2.771],[27660,2.775],[27680,2.779],[27700,2.77],[27720,2.782],[27740,2.753],[27760,2.792],[27780,2.766],[27800,2.765],[27820,2.783],[27840,2.761],[27860,2.769],[27880,2.776],[27900,2.757],[27920,2.779],[27940,2.765],[27960,2.763],[27980,2.774],[28000,2.781],[28020,2.758],[28040,2.772],[28060,2.777],[28080,2.762],[28100,2.77],[28120,2.758],[28140,2.766],[28160,2.755],[28180,2.761],[28200,2.763],[28220,2.773],[28240,2.768],[28260,2.754],[28280,2.761],[28300,2.755],[28320,2.771],[28340,2.75],[28360,2.776],[28380,2.743],[28400,2.778],[28420,2.772],[28440,2.748],[28460,2.761],[28480,2.748],[28500,2.764],[28520,2.737],[28540,2.741],[28560,2.77],[28580,2.76],[28600,2.758],[28620,2.756],[28640,2.755],[28660,2.755],[28680,2.754],[28700,2.767],[28720,2.766],[28740,2.743],[28760,2.747],[28780,2.758],[28800,2.761],[28820,2.762],[28840,2.754],[28860,2.75],[28880,2.768],[28900,2.754],[28920,2.749],[28940,2.764],[28960,2.758],[28980,2.745],[29000,2.756],[29020,2.752],[29040,2.749],[29060,2.757],[29080,2.761],[29100,2.74],[29120,2.761],[29140,2.77],[29160,2.749],[29180,2.785],[29200,2.746],[29220,2.755],[29240,2.759],[29260,2.751],[29280,2.744],[29300,2.757],[29320,2.73],[29340,2.734],[29360,2.758],[29380,2.742],[29400,2.75],[29420,2.757],[29440,2.763],[29460,2.77],[29480,2.713],[29500,2.744],[29520,2.75],[29540,2.76],[29560,2.753],[29580,2.749],[29600,2.739],[29620,2.745],[29640,2.755],[29660,2.751],[29680,2.734],[29700,2.755],[29720,2.761],[29740,2.732],[29760,2.738],[29780,2.746],[29800,2.732],[29820,2.719],[29840,2.741],[29860,2.738],[29880,2.747],[29900,2.739],[29920,2.756],[29940,2.743],[29960,2.748],[29980,2.77],[30000,2.751],[30020,2.741],[30040,2.715],[30060,2.73],[30080,2.751],[30100,2.744],[30120,2.729],[30140,2.758],[30160,2.732],[30180,2.748],[30200,2.73],[30220,2.734],[30240,2.743],[30260,2.747],[30280,2.752],[30300,2.74],[30320,2.737],[30340,2.742],[30360,2.747],[30380,2.726],[30400,2.75],[30420,2.73],[30440,2.733],[30460,2.735],[30480,2.741],[30500,2.745],[30520,2.733],[30540,2.736],[30560,2.725],[30580,2.744],[30600,2.741],[30620,2.721],[30640,2.742],[30660,2.714],[30680,2.731],[30700,2.729],[30720,2.748],[30740,2.74],[30760,2.738],[30780,2.731],[30800,2.727],[30820,2.734],[30840,2.737],[30860,2.736],[30880,2.739],[30900,2.724],[30920,2.725],[30940,2.722],[30960,2.743],[30980,2.721],[31000,2.745],[31020,2.73],[31040,2.725],[31060,2.747],[31080,2.737],[31100,2.755],[31120,2.719],[31140,2.739],[31160,2.716],[31180,2.715],[31200,2.731],[31220,2.734],[31240,2.74],[31260,2.699],[31280,2.719],[31300,2.73],[31320,2.732],[31340,2.72],[31360,2.713],[31380,2.707],[31400,2.73],[31420,2.724],[31440,2.736],[31460,2.712],[31480,2.71],[31500,2.726],[31520,2.711],[31540,2.725],[31560,2.704],[31580,2.732],[31600,2.731],[31620,2.712],[31640,2.723],[31660,2.738],[31680,2.732],[31700,2.725],[31720,2.736],[31740,2.707],[31760,2.699],[31780,2.732],[31800,2.716],[31820,2.715],[31840,2.714],[31860,2.712],[31880,2.703],[31900,2.707],[31920,2.723],[31940,2.695],[31960,2.729],[31980,2.722],[32000,2.707],[32020,2.7],[32040,2.715],[32060,2.714],[32080,2.727],[32100,2.731],[32120,2.744],[32140,2.72],[32160,2.731],[32180,2.732],[32200,2.728],[32220,2.717],[32240,2.707],[32260,2.712],[32280,2.698],[32300,2.743],[32320,2.716],[32340,2.716],[32360,2.7],[32380,2.699],[32400,2.702],[32420,2.719],[32440,2.704],[32460,2.716],[32480,2.717],[32500,2.732],[32520,2.708],[32540,2.724],[32560,2.713],[32580,2.706],[32600,2.705],[32620,2.722],[32640,2.696],[32660,2.725],[32680,2.7],[32700,2.688],[32720,2.72],[32740,2.709],[32760,2.716],[32780,2.701],[32800,2.693],[32820,2.727],[32840,2.703],[32860,2.676],[32880,2.711],[32900,2.709],[32920,2.687],[32940,2.7],[32960,2.699],[32980,2.699],[33000,2.702],[33020,2.72],[33040,2.687],[33060,2.718],[33080,2.709],[33100,2.724],[33120,2.713],[33140,2.707],[33160,2.71],[33180,2.687],[33200,2.734],[33220,2.733],[33240,2.699],[33260,2.703],[33280,2.72],[33300,2.725],[33320,2.71],[33340,2.706],[33360,2.703],[33380,2.71],[33400,2.7],[33420,2.712],[33440,2.705],[33460,2.708],[33480,2.702],[33500,2.708],[33520,2.699],[33540,2.717],[33560,2.697],[33580,2.702],[33600,2.718],[33620,2.709],[33640,2.708],[33660,2.701],[33680,2.719],[33700,2.686],[33720,2.692],[33740,2.692],[33760,2.688],[33780,2.687],[33800,2.709],[33820,2.695],[33840,2.704],[33860,2.687],[33880,2.711],[33900,2.704],[33920,2.692],[33940,2.707],[33960,2.701],[33980,2.699],[34000,2.725],[34020,2.696],[34040,2.717],[34060,2.693],[34080,2.697],[34100,2.704],[34120,2.665],[34140,2.704],[34160,2.701],[34180,2.703],[34200,2.68],[34220,2.715],[34240,2.688],[34260,2.67],[34280,2.691],[34300,2.704],[34320,2.707],[34340,2.707],[34360,2.708],[34380,2.693],[34400,2.695],[34420,2.694],[34440,2.696],[34460,2.698],[34480,2.701],[34500,2.691],[34520,2.72],[34540,2.696],[34560,2.686],[34580,2.707],[34600,2.692],[34620,2.695],[34640,2.708],[34660,2.72],[34680,2.707],[34700,2.698],[34720,2.682],[34740,2.701],[34760,2.696],[34780,2.676],[34800,2.696],[34820,2.698],[34840,2.689],[34860,2.698],[34880,2.692],[34900,2.709],[34920,2.694],[34940,2.675],[34960,2.725],[34980,2.686],[35000,2.683],[35020,2.697],[35040,2.685],[35060,2.69],[35080,2.702],[35100,2.698],[35120,2.681],[35140,2.703],[35160,2.694],[35180,2.673],[35200,2.686],[35220,2.69],[35240,2.707],[35260,2.7],[35280,2.695],[35300,2.691],[35320,2.693],[35340,2.71],[35360,2.688],[35380,2.709],[35400,2.697],[35420,2.707],[35440,2.685],[35460,2.684],[35480,2.693],[35500,2.716],[35520,2.699],[35540,2.684],[35560,2.703],[35580,2.67],[35600,2.682],[35620,2.674],[35640,2.698],[35660,2.682],[35680,2.692],[35700,2.693],[35720,2.681],[35740,2.675],[35760,2.681],[35780,2.693],[35800,2.689],[35820,2.7],[35840,2.677],[35860,2.676],[35880,2.694],[35900,2.72],[35920,2.7],[35940,2.696],[35960,2.684],[35980,2.698],[36000,2.678],[36020,2.682],[36040,2.68],[36060,2.688],[36080,2.684],[36100,2.678],[36120,2.68],[36140,2.694],[36160,2.695],[36180,2.695],[36200,2.686],[36220,2.68],[36240,2.684],[36260,2.701],[36280,2.681],[36300,2.689],[36320,2.692],[36340,2.677],[36360,2.696],[36380,2.697],[36400,2.705],[36420,2.679],[36440,2.693],[36460,2.686],[36480,2.683],[36500,2.671],[36520,2.688],[36540,2.679],[36560,2.685],[36580,2.689],[36600,2.676],[36620,2.694],[36640,2.679],[36660,2.669],[36680,2.683],[36700,2.702],[36720,2.69],[36740,2.691],[36760,2.683],[36780,2.663],[36800,2.688],[36820,2.694],[36840,2.697],[36860,2.699],[36880,2.69],[36900,2.701],[36920,2.664],[36940,2.703],[36960,2.673],[36980,2.687],[37000,2.696],[37020,2.692],[37040,2.668],[37060,2.692],[37080,2.662],[37100,2.68],[37120,2.672],[37140,2.669],[37160,2.709],[37180,2.683],[37200,2.699],[37220,2.686],[37240,2.678],[37260,2.676],[37280,2.675],[37300,2.682],[37320,2.68],[37340,2.692],[37360,2.694],[37380,2.696],[37400,2.71],[37420,2.706],[37440,2.67],[37460,2.678],[37480,2.692],[37500,2.683],[37520,2.672],[37540,2.705],[37560,2.686],[37580,2.685],[37600,2.685],[37620,2.692],[37640,2.663],[37660,2.678],[37680,2.689],[37700,2.685],[37720,2.668],[37740,2.673],[37760,2.684],[37780,2.681],[37800,2.678],[37820,2.682],[37840,2.665],[37860,2.679],[37880,2.67],[37900,2.704],[37920,2.699],[37940,2.672],[37960,2.685],[37980,2.667],[38000,2.672],[38020,2.694],[38040,2.677],[38060,2.691],[38080,2.688],[38100,2.682],[38120,2.691],[38140,2.681]],"val":[[1000,[3.626,3.557,3.561]],[2000,[3.371,3.301,3.301]],[3000,[3.257,3.197,3.197]],[4000,[3.194,3.133,3.13]],[5000,[3.16,3.087,3.084]],[6000,[3.111,3.051,3.05]],[7000,[3.08,3.023,3.021]],[7500,[3.072,3.015,3.013]],[8000,[3.071,2.999,2.996]],[8500,[3.052,2.99,2.986]],[9000,[3.043,2.977,2.975]],[9500,[3.028,2.97,2.967]],[10000,[3.027,2.965,2.962]],[10500,[3.019,2.953,2.949]],[11000,[3.01,2.943,2.939]],[11500,[2.996,2.937,2.934]],[12000,[2.991,2.926,2.923]],[12500,[2.983,2.924,2.921]],[13000,[2.969,2.912,2.909]],[13500,[2.975,2.906,2.901]],[14000,[2.958,2.896,2.893]],[14500,[2.956,2.889,2.885]],[15000,[2.948,2.886,2.882]],[15500,[2.94,2.878,2.875]],[16000,[2.931,2.87,2.866]],[16500,[2.932,2.865,2.861]],[17000,[2.921,2.857,2.853]],[17500,[2.916,2.851,2.846]],[18000,[2.911,2.848,2.844]],[18500,[2.9,2.838,2.833]],[19000,[2.895,2.832,2.828]],[19500,[2.889,2.825,2.821]],[20000,[2.88,2.819,2.815]],[20500,[2.876,2.811,2.806]],[21000,[2.867,2.806,2.801]],[21500,[2.861,2.798,2.794]],[22000,[2.853,2.795,2.791]],[22500,[2.852,2.789,2.783]],[23000,[2.842,2.782,2.777]],[23500,[2.839,2.776,2.77]],[24000,[2.83,2.768,2.764]],[24500,[2.824,2.761,2.756]],[25000,[2.816,2.754,2.749]],[25500,[2.811,2.747,2.742]],[26000,[2.804,2.741,2.736]],[26500,[2.794,2.733,2.728]],[27000,[2.79,2.727,2.722]],[27500,[2.785,2.724,2.718]],[28000,[2.779,2.716,2.71]],[28500,[2.772,2.71,2.704]],[29000,[2.767,2.705,2.699]],[29500,[2.757,2.698,2.693]],[30000,[2.754,2.693,2.688]],[30500,[2.748,2.686,2.681]],[31000,[2.742,2.682,2.676]],[31500,[2.738,2.676,2.671]],[32000,[2.733,2.672,2.666]],[32500,[2.728,2.668,2.662]],[33000,[2.723,2.662,2.657]],[33500,[2.718,2.658,2.652]],[34000,[2.714,2.654,2.648]],[34500,[2.712,2.651,2.645]],[35000,[2.707,2.646,2.64]],[35500,[2.706,2.645,2.638]],[36000,[2.702,2.642,2.636]],[36500,[2.7,2.639,2.633]],[37000,[2.699,2.638,2.632]],[37500,[2.696,2.636,2.63]],[38000,[2.695,2.635,2.629]],[38147,[2.694,2.634,2.628]]],"rows":[["1\u2013500",5.30596],["501\u20131,000",3.7788],["1,001\u20131,500",3.5254000000000003],["1,501\u20132,000",3.4081599999999996],["2,001\u20132,500",3.33144],["2,501\u20133,000",3.27976],["3,001\u20133,500",3.23524],["3,501\u20134,000",3.20156],["4,001\u20134,500",3.1738799999999996],["4,501\u20135,000",3.1515199999999997],["5,001\u20135,500",3.13412],["5,501\u20136,000",3.11508],["6,001\u20136,500",3.10252],["6,501\u20137,000",3.0826800000000003],["7,001\u20137,500",3.0790800000000003],["7,501\u20138,000",3.06452],["8,001\u20138,500",3.05176],["8,501\u20139,000",3.04036],["9,001\u20139,500",3.03396],["9,501\u201310,000",3.02084],["10,001\u201310,500",3.0101600000000004],["10,501\u201311,000",3.00464],["11,001\u201311,500",3.0004399999999998],["11,501\u201312,000",2.99348],["12,001\u201312,500",2.9853199999999998],["12,501\u201313,000",2.9783999999999997],["13,001\u201313,500",2.9671600000000002],["13,501\u201314,000",2.9589600000000003],["14,001\u201314,500",2.95324],["14,501\u201315,000",2.94728],["15,001\u201315,500",2.93792],["15,501\u201316,000",2.93192],["16,001\u201316,500",2.9230400000000003],["16,501\u201317,000",2.91676],["17,001\u201317,500",2.9108799999999997],["17,501\u201318,000",2.90272],["18,001\u201318,500",2.89596],["18,501\u201319,000",2.88916],["19,001\u201319,500",2.88476],["19,501\u201320,000",2.8808],["20,001\u201320,500",2.86952],["20,501\u201321,000",2.86204],["21,001\u201321,500",2.85624],["21,501\u201322,000",2.84992],["22,001\u201322,500",2.84544],["22,501\u201323,000",2.83528],["23,001\u201323,500",2.82888],["23,501\u201324,000",2.82524],["24,001\u201324,500",2.81704],["24,501\u201325,000",2.8112],["25,001\u201325,500",2.80168],["25,501\u201326,000",2.7918399999999997],["26,001\u201326,500",2.7878],["26,501\u201327,000",2.77928],["27,001\u201327,500",2.77608],["27,501\u201328,000",2.77096],["28,001\u201328,500",2.7625599999999997],["28,501\u201329,000",2.75552],["29,001\u201329,500",2.75188],["29,501\u201330,000",2.74608],["30,001\u201330,500",2.7392000000000003],["30,501\u201331,000",2.7330400000000004],["31,001\u201331,500",2.72584],["31,501\u201332,000",2.718],["32,001\u201332,500",2.7176],["32,501\u201333,000",2.7055599999999997],["33,001\u201333,500",2.71012],["33,501\u201334,000",2.70196],["34,001\u201334,500",2.6967200000000005],["34,501\u201335,000",2.6971600000000002],["35,001\u201335,500",2.69496],["35,501\u201336,000",2.68876],["36,001\u201336,500",2.68704],["36,501\u201337,000",2.68652],["37,001\u201337,500",2.68496],["37,501\u201338,000",2.6807600000000003],["38,001\u201338,147",2.686285714285714]],"last":38147,"total":38147},N='http://www.w3.org/2000/svg',fmt=n=>n.toLocaleString('en-US');document.getElementById('sub').textContent=`Step ${fmt(D.last)} of ${fmt(D.total)} (${(100*D.last/D.total).toFixed(0)}%)`;function el(p,n,a,t){const e=document.createElementNS(N,n);for(const k in a)e.setAttribute(k,a[k]);if(t!=null)e.textContent=t;p.appendChild(e);return e}function chart(id,pts,val,y0,y1,ys,x0){ const W=780,H=290,L=44,R=56,T=14,B=40,box=document.getElementById(id),s=el(box,'svg',{viewBox:`0 0 ${W} ${H}`,tabindex:0,role:'img','aria-label':'Loss by training step; values are in the tables below'}); const x1=D.total,X=v=>L+(v-x0)/(x1-x0)*(W-L-R),Y=v=>T+(y1-v)/(y1-y0)*(H-T-B); for(let i=0,v=y0;v<=y1+1e-9;v=y0+ ++i*ys){el(s,'line',{x1:L,x2:W-R,y1:Y(v),y2:Y(v),stroke:'var(--grid)'});el(s,'text',{x:L-8,y:Y(v)+4,'text-anchor':'end'},ys<1?v.toFixed(1):v)} const sp=[100,250,500,1000,2500,5000,10000].find(q=>(x1-x0)/q<=8); for(let v=Math.ceil(x0/sp)*sp;v<=x1;v+=sp)el(s,'text',{x:X(v),y:H-B+18,'text-anchor':'middle'},fmt(v)); el(s,'text',{x:(L+W-R)/2,y:H-4,'text-anchor':'middle'},'Training step'); el(s,'path',{d:'M'+pts.map(p=>X(p[0]).toFixed(1)+','+Y(p[1]).toFixed(1)).join('L'),fill:'none',stroke:'var(--c1)','stroke-width':2,'stroke-linejoin':'round','stroke-linecap':'round'}); const e=pts[pts.length-1];el(s,'circle',{cx:X(e[0]),cy:Y(e[1]),r:4,fill:'var(--c1)',stroke:'var(--s)','stroke-width':2});el(s,'text',{x:X(e[0])+9,y:Y(e[1])+4},e[1].toFixed(2)); for(const [p,v] of val)el(s,'circle',{cx:X(p),cy:Y(v[1]),r:5,fill:'var(--c2)',stroke:'var(--s)','stroke-width':2}); const samples=new Map(pts), stops=[...new Set([...samples.keys(),...val.map(([step])=>step)])].sort((a,b)=>a-b); const h=el(s,'line',{y1:T,y2:H-B,stroke:'var(--t2)',visibility:'hidden'}),tip=document.createElement('div');tip.className='tip';box.appendChild(tip);let k=stops.length-1; function show(i){k=Math.max(0,Math.min(stops.length-1,i));const step=stops[k],px=X(step);h.setAttribute('x1',px);h.setAttribute('x2',px);h.setAttribute('visibility','visible'); tip.replaceChildren();const add=(v,l)=>{const d=document.createElement('div'),b=document.createElement('b');b.textContent=v;d.append(b,' '+l);tip.append(d)}; if(samples.has(step))add(samples.get(step).toFixed(3),'training');const q=val.find(z=>z[0]===step);if(q)add(q[1][1].toFixed(3),'validation');add('Step',fmt(step)); tip.style.display='block';const r=s.getBoundingClientRect(),f=r.width/W;tip.style.top='10px';tip.style.left=Math.min(px*f+10,r.width-130)+'px'} const hide=()=>{tip.style.display='none';h.setAttribute('visibility','hidden')}; s.addEventListener('pointermove',v=>{const r=s.getBoundingClientRect(),q=x0+((v.clientX-r.left)/r.width*W-L)/(W-L-R)*(x1-x0);let b=0;stops.forEach((step,i)=>{if(Math.abs(step-q)<Math.abs(stops[b]-q))b=i});show(b)}); s.addEventListener('pointerleave',hide);s.addEventListener('blur',hide);s.addEventListener('focus',()=>show(k)); s.addEventListener('keydown',v=>{if(v.key==='ArrowLeft')show(k-1);if(v.key==='ArrowRight')show(k+1)})}chart('a',D.train,[],2,11,1,0);const z=D.train.filter(p=>p[0]>=1000),all=z.map(p=>p[1]).concat(D.val.map(v=>v[1][1]));chart('b',z,D.val,Math.floor(Math.min(...all)*10)/10,Math.ceil(Math.max(...all)*10)/10,.1,1000);function table(id,head,rows){const t=document.getElementById(id);[head,...rows].forEach((r,i)=>{const tr=t.insertRow();r.forEach(c=>{const d=document.createElement(i?'td':'th');d.textContent=c;tr.append(d)})})}table('t1',['Steps','Loss','Change'],D.rows.map((r,i)=>[r[0],r[1].toFixed(3),i?(r[1]-D.rows[i-1][1]).toFixed(3):'']));table('t2',['Step','1 loop','2 loops','3 loops'],D.val.map(v=>[fmt(v[0]),...v[1].map(q=>q.toFixed(3))]));</script></body></html>123version https://git-lfs.github.com/spec/v1oid sha256:55ed9e6da1af4a14fe11f3210037647a144008372495c62274672d3a32270495size 859038436README.mdAdded+49
base.ptAdded+3
chat.pyAdded+159
chat_format.pyAdded+38
distill-sft.ptAdded+3
dpo-eval.jsonAdded+118
dpo-pilot.ptAdded+3
model.pyAdded+247
model2.pyAdded+304
pretrain.htmlAdded+49
ultrachat-sft.ptAdded+3