Loading codebase...
Complete Source Code
Every single line of code behind Build Atlas, organized across all 9 parts. From tensor math, autograd, and byte-level BPE to TinyGPT training, LoRA chat tuning, hybrid RAG, autonomous agents, and continuous-batch serving.
Runnable checkpoint: trains the baseline classifier on curriculum sections and prints confusion matrix & F1.
"""Part 2 · Learning from data: a TF-IDF + softmax regression baseline, evaluated on held-out lessons."""
import common # noqa: F401
from atlas.baseline import TEST_LESSONS, TOPICS, run
from atlas.data import load_lessons
common.banner("Part 2 · Learning from data")
r = run(load_lessons())
print(f"task: which topic is a section about? {TOPICS}")
print(f"train {r['train_sections']} sections · test {r['test_sections']} sections from held-out lessons: {sorted(TEST_LESSONS)}")
print(f"L2 chosen by grouped cross-validation on training lessons: {r['l2']} (CV macro-F1 per L2: { {k: round(v, 3) for k, v in r['cv_macro_f1'].items()} })")
print(f"training loss {r['loss_start']:.3f} -> {r['loss_end']:.3f}")
print(f"\n{'':22}{'accuracy':>10}{'macro-F1':>10}")
print(f"{'majority baseline':22}{r['majority_accuracy']:>10.1%}{r['majority_macro_f1']:>10.3f}")
print(f"{'softmax regression':22}{r['accuracy']:>10.1%}{r['macro_f1']:>10.3f}")
print("\nconfusion (rows = true, cols = predicted):", TOPICS)
print(r["confusion"])
print("\nReading it: the model beats the majority baseline on macro-F1, but python-performance sections read like")
print("python-language ones, and with ~110 training sections a linear model can't separate them. Part 3 tries harder.")
print("\nCheckpoint: a baseline, and an evaluation you can trust (no lesson appears in both train and test).")