← Index
Source
Data provenance
ex-2.1.2
·
d036074-dirty
(dirty) · run 2026-07-15
via reports/m2/ex-2.1.2/margins, reports/m2/ex-2.1.2/metrics
import%20marimo%0A%0A__generated_with%20%3D%20%220.23.9%22%0Aapp%20%3D%20marimo.App(%0A%20%20%20%20width%3D%22medium%22%2C%0A%20%20%20%20app_title%3D%22Ex%202.1.2%3A%20making%20composition%20necessary%22%2C%0A%20%20%20%20css_file%3D%22..%2F..%2Freport.css%22%2C%0A%20%20%20%20auto_download%3D%5B%22html%22%5D%2C%0A)%0A%0Awith%20app.setup(hide_code%3DTrue)%3A%0A%20%20%20%20import%20json%0A%20%20%20%20import%20tempfile%0A%20%20%20%20from%20pathlib%20import%20Path%0A%0A%20%20%20%20import%20marimo%20as%20mo%20%20%23%20noqa%3A%20F401%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%0A%20%20%20%20%23%20Marimo%20puts%20the%20notebook's%20directory%20on%20sys.path%2C%20so%20the%20experiment%0A%20%20%20%20%23%20definition%20is%20importable%20%E2%80%94%20refs%20and%20sweep%20constants%20can't%20drift.%0A%20%20%20%20from%20experiment%20import%20(%0A%20%20%20%20%20%20%20%20CONDITIONS%2C%0A%20%20%20%20%20%20%20%20CORPUS_SEED%2C%0A%20%20%20%20%20%20%20%20HOLDOUT_FRAC%2C%0A%20%20%20%20%20%20%20%20MARGINS_REF%2C%0A%20%20%20%20%20%20%20%20METRICS_REF%2C%0A%20%20%20%20%20%20%20%20N_EXAMPLES%2C%0A%20%20%20%20%20%20%20%20OPEN_HOLDOUT_FRAC%2C%0A%20%20%20%20%20%20%20%20SEEDS%2C%0A%20%20%20%20)%0A%20%20%20%20from%20mini.reports%20import%20externalize_html%2C%20report_bundle%2C%20use_publisher%0A%20%20%20%20from%20mini.store%20import%20project_store%0A%20%20%20%20from%20mini.vis%20import%20figure_html%2C%20light_dark%2C%20themed%0A%20%20%20%20from%20sca.data%20import%20colors%0A%20%20%20%20from%20subline.series%20import%20Series%0A%20%20%20%20from%20subline.subline%20import%20Subline%0A%0A%20%20%20%20use_publisher(report_bundle(__file__))%0A%0A%20%20%20%20EVAL_SETS%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%22named_seen%22%2C%0A%20%20%20%20%20%20%20%20%22named_holdout%22%2C%0A%20%20%20%20%20%20%20%20%22hex_unseen%22%2C%0A%20%20%20%20%20%20%20%20%22cross_unseen%22%2C%0A%20%20%20%20%20%20%20%20%22open_seen%22%2C%0A%20%20%20%20%20%20%20%20%22open_holdout%22%2C%0A%20%20%20%20%20%20%20%20%22alias_rev%22%2C%0A%20%20%20%20%5D%0A%20%20%20%20CONDS%20%3D%20list(CONDITIONS)%0A%0A%20%20%20%20def%20load_results()%20-%3E%20tuple%5Bdict%2C%20dict%5Bstr%2C%20np.ndarray%5D%5D%20%7C%20None%3A%0A%20%20%20%20%20%20%20%20%22%22%22Resolve%20the%20metrics%20and%20margin%20arrays%20from%20the%20store%2C%20or%20None%20if%20unpublished.%22%22%22%0A%20%20%20%20%20%20%20%20store%20%3D%20project_store()%0A%20%20%20%20%20%20%20%20arts%20%3D%20store.get_refs(%5BMETRICS_REF%2C%20MARGINS_REF%5D)%0A%20%20%20%20%20%20%20%20m_art%2C%20g_art%20%3D%20arts%5BMETRICS_REF%5D%2C%20arts%5BMARGINS_REF%5D%0A%20%20%20%20%20%20%20%20if%20m_art%20is%20None%20or%20g_art%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20None%0A%20%20%20%20%20%20%20%20with%20tempfile.TemporaryDirectory()%20as%20d%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20m_path%2C%20g_path%20%3D%20store.get_many(%5B(m_art%2C%20Path(d)%20%2F%20%22metrics.json%22)%2C%20(g_art%2C%20Path(d)%20%2F%20%22margins.npz%22)%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20metrics%20%3D%20json.loads(m_path.read_text())%0A%20%20%20%20%20%20%20%20%20%20%20%20with%20np.load(g_path)%20as%20z%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20margins%20%3D%20%7Bk%3A%20z%5Bk%5D%20for%20k%20in%20z.files%7D%0A%20%20%20%20%20%20%20%20return%20metrics%2C%20margins%0A%0A%20%20%20%20def%20label(cond%3A%20str%2C%20s%3A%20int)%20-%3E%20str%3A%0A%20%20%20%20%20%20%20%20return%20f%22%7Bcond%7D-s%7Bs%7D%22%0A%0A%20%20%20%20def%20cell(metrics%3A%20dict%2C%20cond%3A%20str%2C%20s%3A%20int)%20-%3E%20dict%3A%0A%20%20%20%20%20%20%20%20(r%2C)%20%3D%20%5Br%20for%20r%20in%20metrics%5B%22cells%22%5D%20if%20r%5B%22label%22%5D%20%3D%3D%20label(cond%2C%20s)%5D%0A%20%20%20%20%20%20%20%20return%20r%0A%0A%20%20%20%20def%20acc(metrics%3A%20dict%2C%20cond%3A%20str%2C%20s%3A%20int%2C%20eval_set%3A%20str)%20-%3E%20float%3A%0A%20%20%20%20%20%20%20%20return%20cell(metrics%2C%20cond%2C%20s)%5B%22accuracy%22%5D%5Beval_set%5D%5B%22accuracy%22%5D%0A%0A%20%20%20%20def%20cond_shades()%20-%3E%20dict%5Bstr%2C%20tuple%5D%3A%0A%20%20%20%20%20%20%20%20stops%20%3D%20light_dark(%5B0.82%2C%200.55%2C%200.32%2C%200.08%5D%2C%20%5B0.88%2C%200.62%2C%200.42%2C%200.2%5D)%0A%20%20%20%20%20%20%20%20return%20dict(zip(CONDS%2C%20plt.cm.viridis(stops)%2C%20strict%3DTrue))%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Ex%202.1.2%3A%20making%20composition%20necessary%0A%0A%20%20%20%20%5BEx-2.1.1%5D(..%2Fex-2.1.1%2F)%20gave%20us%20a%20decent%20baseline%2C%20but%20no%20model%20in%20the%0A%20%20%20%20sweep%20ever%20solved%20%60named_holdout%60.%20That%20eval%20set%20contains%20pairs%20of%20named%0A%20%20%20%20colors%20whose%20named-answer%20equation%20never%20appears%20in%20training%2C%20so%20the%0A%20%20%20%20expected%20way%20to%20answer%20is%20to%20combine%20two%20skills%3A%20the%20alias%20dictionary%2C%20which%0A%20%20%20%20says%20which%20name%20goes%20with%20which%20hex%20color%2C%20and%20the%20mixing%20arithmetic%20itself.%0A%0A%20%20%20%20That%20report%20looked%20into%20why%20the%20models%20never%20learn%20to%20combine%20them.%20In%20this%0A%20%20%20%20experiment%2C%20we%20keep%20everything%20from%20ex-2.1.1%20fixed%2C%20including%20the%0A%20%20%20%20d64-L4%20architecture%2C%20the%20split%2C%20and%20the%20training%20recipe%2C%20and%0A%20%20%20%20add%20two%20new%20kinds%20of%20sequence%3A%0A%0A%20%20%20%20-%20Reverse%20alias%20lines%20(%60%23f00%20%3D%20red%60).%20The%20base%20grammar%20never%20trained%0A%20%20%20%20%20%20the%20hex%20%E2%86%92%20name%20readout.%0A%20%20%20%20-%20Named%20equations%20that%20mix%20to%20a%20color%20that%20falls%20*off*%20the%20palette%2C%20answered%0A%20%20%20%20%20%20in%20hex%20(%60red%20%2B%20navy%20%3D%20%23804%60).%20Now%20the%20surface%20form%20of%20the%20answer%20depends%0A%20%20%20%20%20%20on%20the%20mix%20rather%20than%20on%20the%20operands'%20forms%20alone%2C%20so%20a%20name%20%2B%20name%0A%20%20%20%20%20%20prompt%20can't%20be%20settled%20by%20lookup.%0A%0A%20%20%20%20%7C%20Type%20%7C%20Example%20%7C%0A%20%20%20%20%7C------%7C---------%7C%0A%20%20%20%20%7C%20Named%20pairs%20%7C%20%60red%20%2B%20blue%20%3D%20purple%60%20%7C%0A%20%20%20%20%7C%20Hex%20pairs%20%20%20%7C%20%60%23f00%20%2B%20%2300f%20%3D%20%23808%60%20%20%7C%0A%20%20%20%20%7C%20Cross-form%20%20%7C%20%60red%20%2B%20%2300f%20%3D%20%23808%60%20%20%20%7C%0A%20%20%20%20%7C%20Alias%20%20%20%20%20%20%20%7C%20%60red%20%3D%20%23f00%60%20%20%20%20%20%20%20%20%20%20%7C%0A%20%20%20%20%7C%20**Reverse**%20%7C%20%60%23f00%20%3D%20red%60%20%20%20%20%20%20%20%20%20%20%7C%0A%20%20%20%20%7C%20**Open**%20%20%20%20%7C%20%60red%20%2B%20orange%20%3D%20%23f40%60%20%7C%0A%0A%20%20%20%20We%20run%20the%20two%20grammar%20changes%20as%20a%202%20%C3%97%202%20factorial.%20Each%20one%20replaces%20the%0A%20%20%20%20same%20number%20of%20tokens%20from%20the%20hex%20slice%2C%20so%20the%20four%20conditions%20differ%20only%0A%20%20%20%20in%20what%20they%20add%20on%20top%20of%20the%20baseline.%0A%0A%20%20%20%20This%20is%20still%20an%20**un-anchored**%20experiment.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Training%20data%0A%0A%20%20%20%20We%20regenerate%20the%20%60both%60%20corpus%20here.%20It%20shows%20the%20two%20new%20forms%20in%20their%0A%20%20%20%20natural%20context%3A%20reverse%20aliases%20and%20off-palette%20named%20equations%2C%20sitting%0A%20%20%20%20among%20the%20lines%20we%20already%20had.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20from%20experiment%20import%20_classify%20as%20classify_form%2C%20_corpus%20as%20corpus_for%0A%0A%20%20%20%20_corpora%20%3D%20%7Bcond%3A%20corpus_for(cond)%20for%20cond%20in%20CONDS%7D%0A%20%20%20%20_head%20%3D%20%22%22.join(ex.text%20for%20ex%20in%20_corpora%5B%22both%22%5D%5B%3A12%5D)%0A%20%20%20%20_counts%20%3D%20%7B%0A%20%20%20%20%20%20%20%20cond%3A%20%7Bf%3A%20sum(classify_form(ex)%20%3D%3D%20f%20for%20ex%20in%20corpus)%20for%20f%20in%20CONDITIONS%5Bcond%5D%7D%0A%20%20%20%20%20%20%20%20for%20cond%2C%20corpus%20in%20_corpora.items()%0A%20%20%20%20%7D%0A%20%20%20%20_forms%20%3D%20%5B%22hex%22%2C%20%22named%22%2C%20%22cross%22%2C%20%22alias%22%2C%20%22alias_rev%22%2C%20%22open%22%5D%0A%20%20%20%20_rows%20%3D%20%22%22.join(%0A%20%20%20%20%20%20%20%20f%22%3Ctr%3E%3Ctd%3E%3Ccode%3E%7Bcond%7D%3C%2Fcode%3E%3C%2Ftd%3E%22%0A%20%20%20%20%20%20%20%20%2B%20%22%22.join(f'%3Ctd%20class%3D%22num%22%3E%7B_counts%5Bcond%5D.get(f%2C%200)%20or%20%22%E2%80%94%22%7D%3C%2Ftd%3E'%20for%20f%20in%20_forms)%0A%20%20%20%20%20%20%20%20%2B%20%22%3C%2Ftr%3E%22%0A%20%20%20%20%20%20%20%20for%20cond%20in%20CONDS%0A%20%20%20%20)%0A%20%20%20%20_open_train%2C%20_open_holdout%20%3D%20colors.split_open_pairs(CORPUS_SEED%2C%20OPEN_HOLDOUT_FRAC)%0A%20%20%20%20_named_train%2C%20_named_holdout%20%3D%20colors.split_named_pairs(CORPUS_SEED%2C%20HOLDOUT_FRAC)%0A%20%20%20%20_table%20%3D%20(%0A%20%20%20%20%20%20%20%20'%3Cdiv%20class%3D%22report-table-scroll%22%3E%3Ctable%20class%3D%22report-table%22%3E%3Ctr%3E%3Cth%3Econdition%3C%2Fth%3E'%0A%20%20%20%20%20%20%20%20%2B%20%22%22.join(f'%3Cth%20class%3D%22num%22%3E%3Ccode%3E%7Bf%7D%3C%2Fcode%3E%3C%2Fth%3E'%20for%20f%20in%20_forms)%0A%20%20%20%20%20%20%20%20%2B%20f%22%3C%2Ftr%3E%7B_rows%7D%3C%2Ftable%3E%3C%2Fdiv%3E%22%0A%20%20%20%20)%0A%20%20%20%20_caption%20%3D%20mo.md(%0A%20%20%20%20%20%20%20%20f%22%22%22%0A%20%20%20%20%20%20%20%20Lines%20per%20form%20in%20each%20condition's%20%7BN_EXAMPLES%3A%2C%7D-line%20corpus.%20The%20named%20equations%0A%20%20%20%20%20%20%20%20draw%20from%20the%20same%20%7Blen(_named_train)%7D%20training%20pairs%20as%20ex-2.1.1%2C%20with%20the%20same%0A%20%20%20%20%20%20%20%20%7Blen(_named_holdout)%7D%20pairs%20held%20out.%20The%20open%20equations%20draw%20from%20%7Blen(_open_train)%7D%0A%20%20%20%20%20%20%20%20of%20the%20302%20off-palette%20named%20pairs%2C%20and%20%7Blen(_open_holdout)%7D%20are%20held%20out%20entirely.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20).text%0A%20%20%20%20mo.vstack(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.md(f%22%60%60%60%5Cn%7B_head%7D%60%60%60%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mo.Html(figure_html(_table%2C%20caption%3D_caption%2C%20class_%3D%22report-figure%22))%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Hypotheses%0A%0A%20%20%20%20Written%20before%20looking%20at%20any%20results.%0A%0A%20%20%20%20**H1.**%20Accuracy%3A%20%60named_holdout%60%20stays%20at%20zero%20in%20%60control%60%20and%20is%20lifted%0A%20%20%20%20well%20off%20zero%20by%20%60both%60.%20%60rev%60%20alone%20lifts%20%60named_holdout%60%20part%20of%20the%20way%3A%0A%20%20%20%20the%20garden%20path%20showed%20the%20mix%20is%20already%20half-computed%20on%20named%20prompts%2C%20and%0A%20%20%20%20%60rev%60%20supplies%20the%20missing%20readout%20for%20whatever%20computation%20is%20there.%20%60open%60%0A%20%20%20%20alone%20forces%20the%20computation%2C%20but%20leaves%20name%20emission%20supervised%20only%0A%20%20%20%20through%20the%20memorizable%20named%20slice.%0A%0A%20%20%20%20**H2.**%20Margins%3A%20scoring%20all%2027%20names%20as%20complete%20answers%20gives%20each%20held-out%0A%20%20%20%20pair%20a%20*margin*%2C%20the%20log-probability%20of%20the%20true%20name%20minus%20the%20best%0A%20%20%20%20competitor's.%20In%20%60control%60%20the%20margins%20are%20negative%20(accuracy%20is%20zero)%20but%0A%20%20%20%20spread%20out%20well%20above%20the%20random%20floor.%20The%20pairs%20with%20the%20least-negative%0A%20%20%20%20control%20margins%20should%20be%20the%20first%20to%20flip%20positive%20under%20intervention.%20The%0A%20%20%20%20interventions%20shift%20the%20whole%20margin%20distribution%20upward%2C%20while%20%60named_seen%60%0A%20%20%20%20margins%20stay%20large%20and%20positive.%0A%0A%20%20%20%20**H3.**%20The%20answer%20schedule%3A%20probing%20each%20answer%20position%20for%20each%20RGB%20channel%0A%20%20%20%20(on%20hex%20prompts%2C%20strictly%20before%20each%20digit%20lands%20in%20the%20context)%20shows%20a%0A%20%20%20%20stair-step%3A%20channel%20k%20stays%20low%20and%20becomes%20strongly%20decodable%20at%20the%20position%0A%20%20%20%20that%20emits%20digit%20k.%0A%0A%20%20%20%20**H4.**%20Computed%20but%20not%20emitted%3A%20a%20result-color%20probe%20fit%20on%20open-pair%0A%20%20%20%20prompts%20(name%20%2B%20name%20surface%20form)%20at%20the%20pre-answer%20position%20transfers%20to%20the%0A%20%20%20%20held-out%20named%20prompts%20in%20proportion%20to%20how%20much%20the%20mix%20is%20actually%20computed%0A%20%20%20%20there%3A%20middling%20R%C2%B2%20in%20%60control%60%20(partial%20computation)%2C%20rising%20toward%20the%20fit%0A%20%20%20%20ceiling%20in%20the%20%60open%60%20conditions%2C%20and%20tracking%20%60named_holdout%60%20accuracy%20across%0A%20%20%20%20conditions.%0A%0A%20%20%20%20**H5.**%20No%20side%20effects%3A%20%60named_seen%60%2C%20%60hex_unseen%60%2C%20and%20%60cross_unseen%60%20stay%0A%20%20%20%20saturated%20in%20every%20condition%2C%20even%20though%20we%20are%20displacing%20up%20to%2015%25%20of%20the%0A%20%20%20%20hex%20data.%20The%20%60alias_rev%60%20eval%20set%20reads%20%E2%89%88%201%20wherever%20reverse%20aliases%20are%0A%20%20%20%20trained%20and%20stays%20random%20elsewhere%2C%20as%20in%20ex-2.1.1.%0A%0A%20%20%20%20If%20the%20H1%20interaction%20shows%20up%20but%20the%20single%20interventions%20do%20nothing%2C%20then%0A%20%20%20%20composition%20needed%20both%20ingredients%20at%20once.%20If%20%60rev%60%20alone%20saturates%20the%0A%20%20%20%20set%2C%20then%20the%20readout%20was%20the%20only%20missing%20piece%20and%20the%20pull%20toward%20lookup%0A%20%20%20%20never%20mattered.%20If%20nothing%20moves%2C%20then%20the%20diagnosis%20was%20wrong%20somewhere.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20loaded%20%3D%20load_results()%0A%20%20%20%20return%20(loaded%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(loaded)%3A%0A%20%20%20%20mo.stop(%0A%20%20%20%20%20%20%20%20loaded%20is%20None%2C%0A%20%20%20%20%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22No%20results%20yet%20%E2%80%94%20run%20the%20experiment%20(it%20publishes%20metrics%2C%20margins%2C%20and%20checkpoints%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%22on%20completion)%3A%5Cn%5Cn%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%60%60%60bash%5Cnbin%2Fmini%20run%20docs%2Fm2%2Fex-2.1.2%2Fexperiment.py%20--app%20modal%20--max-containers%2012%5Cn%60%60%60%22%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20metrics%2C%20margins%20%3D%20loaded%0A%20%20%20%20return%20margins%2C%20metrics%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20_hold%20%3D%20%7Bcond%3A%20np.mean(%5Bacc(metrics%2C%20cond%2C%20s%2C%20%22named_holdout%22)%20for%20s%20in%20SEEDS%5D)%20for%20cond%20in%20CONDS%7D%0A%20%20%20%20_sat%20%3D%20%7B%0A%20%20%20%20%20%20%20%20cond%3A%20np.mean(%5Bacc(metrics%2C%20cond%2C%20s%2C%20es)%20for%20s%20in%20SEEDS%20for%20es%20in%20(%22named_seen%22%2C%20%22hex_unseen%22%2C%20%22cross_unseen%22)%5D)%0A%20%20%20%20%20%20%20%20for%20cond%20in%20CONDS%0A%20%20%20%20%7D%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20%22**Headline%20numbers.**%20Mean%20%60named_holdout%60%20accuracy%20by%20condition%3A%20%22%0A%20%20%20%20%20%20%20%20%2B%20%22%2C%20%22.join(f%22%60%7Bcond%7D%60%20**%7Bv%3A.2f%7D**%22%20for%20cond%2C%20v%20in%20_hold.items())%0A%20%20%20%20%20%20%20%20%2B%20%22.%20The%20saturated%20sets%20(named%20seen%2C%20hex%20and%20cross%20unseen)%20average%20%22%0A%20%20%20%20%20%20%20%20%2B%20%22%2C%20%22.join(f%22%7Bv%3A.3f%7D%22%20for%20v%20in%20_sat.values())%0A%20%20%20%20%20%20%20%20%2B%20%22%20in%20the%20same%20order.%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Completion%20accuracy%20across%20the%20factorial%0A%0A%20%20%20%20Did%20the%20changes%20move%20%60named_holdout%60%20off%20zero%2C%20and%20did%20the%20two%20new%20forms%0A%20%20%20%20train%20the%20way%20we%20meant%20them%20to%3F%20The%20figure%20below%20shows%20exact-match%20accuracy%0A%20%20%20%20for%20all%20seven%20eval%20sets%2C%20in%20each%20of%20the%20four%20conditions.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20%40themed(%0A%20%20%20%20%20%20%20%20name%3D%22accuracy-factorial%22%2C%0A%20%20%20%20%20%20%20%20alt_text%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Seven%20bar-and-dot%20panels%20of%20completion%20accuracy%20(0%20to%201)%20against%20condition%0A%20%20%20%20%20%20%20%20%20%20%20%20(control%2C%20rev%2C%20open%2C%20both)%2C%20one%20panel%20per%20eval%20set%3A%20named%20seen%2C%20named%20holdout%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20hex%20unseen%2C%20cross%20unseen%2C%20open%20seen%2C%20open%20holdout%2C%20and%20reverse%20alias.%20Bars%20show%0A%20%20%20%20%20%20%20%20%20%20%20%20the%20mean%20over%20three%20seeds%2C%20dots%20the%20individual%20seeds.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20caption%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Each%20panel%20is%20one%20eval%20set%3A%20the%20bar%20is%20the%20mean%20over%20three%20seeds%20and%20the%20dots%0A%20%20%20%20%20%20%20%20%20%20%20%20are%20the%20individual%20seeds.%20%60named_holdout%60%20is%20the%20set%20H1%20is%20about%3B%20%60open_holdout%60%0A%20%20%20%20%20%20%20%20%20%20%20%20asks%20whether%20the%20forced%20computation%20carries%20over%20to%20off-palette%20pairs%20never%20seen%0A%20%20%20%20%20%20%20%20%20%20%20%20in%20training%3B%20%60alias_rev%60%20checks%20the%20reverse-alias%20supervision.%20In%20%60control%60%20and%0A%20%20%20%20%20%20%20%20%20%20%20%20%60rev%60%2C%20the%20open-form%20sets%20ask%20for%20a%20surface%20form%20those%20corpora%20never%20train%20on%20(a%0A%20%20%20%20%20%20%20%20%20%20%20%20name%20%2B%20name%20prompt)%2C%20so%20a%20low%20score%20there%20means%20the%20grammar%20is%20simply%20missing%0A%20%20%20%20%20%20%20%20%20%20%20%20from%20that%20corpus%2C%20rather%20than%20a%20genuine%20attempt%20that%20fell%20short.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20)%0A%20%20%20%20def%20_plot()%20-%3E%20plt.Figure%3A%0A%20%20%20%20%20%20%20%20fig%2C%20axes%20%3D%20plt.subplots(1%2C%20len(EVAL_SETS)%2C%20figsize%3D(12.5%2C%203.0)%2C%20sharey%3DTrue)%0A%20%20%20%20%20%20%20%20shades%20%3D%20cond_shades()%0A%20%20%20%20%20%20%20%20xs%20%3D%20np.arange(len(CONDS))%0A%20%20%20%20%20%20%20%20for%20ax%2C%20es%20in%20zip(axes%2C%20EVAL_SETS%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20per_seed%20%3D%20np.array(%5B%5Bacc(metrics%2C%20cond%2C%20s%2C%20es)%20for%20s%20in%20SEEDS%5D%20for%20cond%20in%20CONDS%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.bar(xs%2C%20per_seed.mean(axis%3D1)%2C%20color%3D%5Bshades%5Bc%5D%20for%20c%20in%20CONDS%5D%2C%20width%3D0.62)%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20i%20in%20range(len(CONDS))%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(%5Bxs%5Bi%5D%5D%20*%20len(SEEDS)%2C%20per_seed%5Bi%5D%2C%20%22o%22%2C%20color%3D%22%230008%22%2C%20ms%3D2.5%2C%20zorder%3D3)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set(title%3Des.replace(%22_%22%2C%20%22%20%22)%2C%20ylim%3D(-0.03%2C%201.03))%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set_xticks(xs%2C%20CONDS%2C%20rotation%3D90%2C%20fontsize%3D7)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.grid(alpha%3D0.3%2C%20axis%3D%22y%22)%0A%20%20%20%20%20%20%20%20axes%5B0%5D.set_ylabel(%22completion%20accuracy%22)%0A%20%20%20%20%20%20%20%20return%20fig%0A%0A%20%20%20%20mo.Html(_plot())%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20_a%20%3D%20%7Bcond%3A%20float(np.mean(%5Bacc(metrics%2C%20cond%2C%20s%2C%20%22named_holdout%22)%20for%20s%20in%20SEEDS%5D))%20for%20cond%20in%20CONDS%7D%0A%20%20%20%20_interaction%20%3D%20_a%5B%22both%22%5D%20-%20_a%5B%22rev%22%5D%20-%20_a%5B%22open%22%5D%20%2B%20_a%5B%22control%22%5D%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20rf%22%22%22%0A%20%20%20%20H1%20is%20refuted%3A%20%60named_holdout%60%20stays%20at%20zero%20in%20every%20condition%20(its%0A%20%20%20%20interaction%20term%20is%20a%20degenerate%20%7B_interaction%3A%2B.2f%7D).%20The%20other%20panels%20show%0A%20%20%20%20that%20both%20changes%20did%20train%2C%20though.%20The%20%60open%60%20conditions%20answer%20held-out%0A%20%20%20%20off-palette%20pairs%20at%20%E2%89%88%200.9%2C%20so%20the%20mixing%20arithmetic%20runs%20on%20name%20%2B%20name%0A%20%20%20%20prompts%20and%20carries%20over%20to%20operand%20pairs%20never%20seen%20in%20that%20surface%20form.%20And%0A%20%20%20%20%60alias_rev%60%20reads%201.0%20right%20where%20reverse%20aliases%20were%20trained%2C%20so%20the%0A%20%20%20%20hex%20%E2%86%92%20name%20readout%20exists%20and%20works%20in%20the%20frame%20it%20was%20taught%20in.%20We%20supplied%0A%20%20%20%20both%20of%20the%20missing%20ingredients%2C%20and%20still%20the%20composition%20does%20not%20surface%20as%0A%20%20%20%20a%20named%20answer.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Right%20value%2C%20wrong%20spelling%0A%0A%20%20%20%20Let's%20look%20at%20what%20the%20model%20actually%20writes.%20Below%20are%20the%20greedy%20completions%0A%20%20%20%20of%20the%20held-out%20named%20prompts%2C%20meaning%20we%20take%20the%20single%20most%20likely%0A%20%20%20%20character%20at%20each%20step%20and%20read%20off%20the%20answer.%20In%20%60control%60%20and%20%60rev%60%20the%0A%20%20%20%20answers%20are%20the%20familiar%20retrieval-like%20wrong%20names.%20But%20in%20the%20%60open%60%0A%20%20%20%20conditions%2C%20some%20of%20the%20pairs%20the%20model%20writes%20a%20*hex*%20answer%2C%20and%20when%20it%0A%20%20%20%20does%2C%20the%20value%20is%20the%20correct%20mix.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20%23%20Greedy%20completions%20of%20the%20named-holdout%20prompts%20are%20precomputed%20in%20%60eval_one%60%0A%20%20%20%20%23%20(where%20the%20model's%20already%20loaded)%20and%20ride%20the%20metrics%20JSON%20%E2%80%94%20so%20this%20reads%0A%20%20%20%20%23%20them%20from%20the%20store%20rather%20than%20pulling%2012%20checkpoints%20and%20re-decoding%20per%20edit.%0A%20%20%20%20mo.stop(%0A%20%20%20%20%20%20%20%20any(%22holdout_completions%22%20not%20in%20cell(metrics%2C%20cond%2C%20s)%20for%20cond%20in%20CONDS%20for%20s%20in%20SEEDS)%2C%0A%20%20%20%20%20%20%20%20mo.md(%22These%20metrics%20predate%20precomputed%20completions%20%E2%80%94%20re-run%20the%20experiment%20to%20republish.%22)%2C%0A%20%20%20%20)%0A%20%20%20%20completions%20%3D%20%7B(cond%2C%20s)%3A%20cell(metrics%2C%20cond%2C%20s)%5B%22holdout_completions%22%5D%20for%20cond%20in%20CONDS%20for%20s%20in%20SEEDS%7D%0A%0A%20%20%20%20def%20answer_value(text%3A%20str)%20-%3E%20tuple%5Bint%2C%20int%2C%20int%5D%20%7C%20None%3A%0A%20%20%20%20%20%20%20%20%22%22%22The%20color%20a%20completion%20denotes%2C%20in%20either%20surface%20form%20(None%20if%20malformed).%22%22%22%0A%20%20%20%20%20%20%20%20if%20text%20in%20colors.PALETTE%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20colors.PALETTE%5Btext%5D%0A%20%20%20%20%20%20%20%20if%20len(text)%20%3D%3D%204%20and%20text.startswith(%22%23%22)%20and%20all(c%20in%20%220123456789abcdef%22%20for%20c%20in%20text%5B1%3A%5D)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20r%2C%20g%2C%20b%20%3D%20(int(c%2C%2016)%20for%20c%20in%20text%5B1%3A%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20(r%2C%20g%2C%20b)%0A%20%20%20%20%20%20%20%20return%20None%0A%0A%20%20%20%20return%20answer_value%2C%20completions%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(answer_value%2C%20completions%2C%20holdout_exs)%3A%0A%20%20%20%20def%20_swatch(text%3A%20str%2C%20want%3A%20tuple%20%7C%20None%20%3D%20None)%20-%3E%20str%3A%0A%20%20%20%20%20%20%20%20rgb%20%3D%20answer_value(text)%0A%20%20%20%20%20%20%20%20if%20rgb%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20f%22%3Ccode%3E%7Btext%7D%3C%2Fcode%3E%22%0A%20%20%20%20%20%20%20%20mark%20%3D%20%22%22%20if%20want%20is%20None%20else%20(%22%20%E2%9C%93%22%20if%20rgb%20%3D%3D%20want%20else%20%22%22)%0A%20%20%20%20%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20f'%3Cspan%20aria-hidden%3D%22true%22%20style%3D%22background%3A%20%7Bcolors.to_hex(rgb)%7D%3B%20border%3A%201px%20solid%20%238886%3B%20'%0A%20%20%20%20%20%20%20%20%20%20%20%20f'border-radius%3A%202px%3B%20display%3A%20inline-block%3B%20width%3A%200.8em%3B%20height%3A%200.8em%22%3E%3C%2Fspan%3E%20%7Btext%7D%7Bmark%7D'%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20_head%20%3D%20(%0A%20%20%20%20%20%20%20%20f%22%3Ctr%3E%3Cth%3Eprompt%3C%2Fth%3E%3Cth%3E%7Bcolors.swatch(None)%7D%20expected%3C%2Fth%3E%22%0A%20%20%20%20%20%20%20%20%2B%20%22%22.join(f%22%3Cth%3E%7Bcolors.swatch(None)%7D%20%7Bcond%7D%3C%2Fth%3E%22%20for%20cond%20in%20CONDS)%0A%20%20%20%20%20%20%20%20%2B%20%22%3C%2Ftr%3E%22%0A%20%20%20%20)%0A%20%20%20%20_rows%20%3D%20%22%22.join(%0A%20%20%20%20%20%20%20%20f%22%3Ctr%3E%3Ctd%3E%3Ccode%3E%7Bex.prompt%7D%3C%2Fcode%3E%3C%2Ftd%3E%3Ctd%3E%7B_swatch(ex.answer)%7D%3C%2Ftd%3E%22%0A%20%20%20%20%20%20%20%20%2B%20%22%22.join(f%22%3Ctd%3E%7B_swatch(completions%5Bcond%2C%20SEEDS%5B0%5D%5D%5Bi%5D%2C%20ex.result)%7D%3C%2Ftd%3E%22%20for%20cond%20in%20CONDS)%0A%20%20%20%20%20%20%20%20%2B%20%22%3C%2Ftr%3E%22%0A%20%20%20%20%20%20%20%20for%20i%2C%20ex%20in%20enumerate(holdout_exs)%0A%20%20%20%20)%0A%20%20%20%20_table%20%3D%20f'%3Cdiv%20class%3D%22report-table-scroll%22%3E%3Ctable%20class%3D%22report-table%22%3E%7B_head%7D%7B_rows%7D%3C%2Ftable%3E%3C%2Fdiv%3E'%0A%20%20%20%20_caption%20%3D%20mo.md(%0A%20%20%20%20%20%20%20%20f%22%22%22%0A%20%20%20%20%20%20%20%20Greedy%20completions%20of%20the%20%60named_holdout%60%20prompts%2C%20seed%20%7BSEEDS%5B0%5D%7D%2C%20one%0A%20%20%20%20%20%20%20%20column%20per%20condition.%20A%20%E2%9C%93%20marks%20an%20answer%20whose%20value%20equals%20the%20true%0A%20%20%20%20%20%20%20%20mix%2C%20but%20is%20given%20in%20the%20wrong%20form.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20).text%0A%20%20%20%20mo.Html(figure_html(_table%2C%20caption%3D_caption%2C%20class_%3D%22report-figure%22))%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(answer_value%2C%20completions%2C%20holdout_exs%2C%20margins%2C%20metrics)%3A%0A%20%20%20%20_hexed%20%3D%20%7Bcond%3A%20%5Bsum(g.startswith(%22%23%22)%20for%20g%20in%20completions%5Bcond%2C%20s%5D)%20for%20s%20in%20SEEDS%5D%20for%20cond%20in%20CONDS%7D%0A%20%20%20%20_value_ok%20%3D%20%7B%0A%20%20%20%20%20%20%20%20cond%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20sum(answer_value(g)%20%3D%3D%20ex.result%20for%20g%2C%20ex%20in%20zip(completions%5Bcond%2C%20s%5D%2C%20holdout_exs%2C%20strict%3DTrue))%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20s%20in%20SEEDS%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20for%20cond%20in%20CONDS%0A%20%20%20%20%7D%0A%0A%20%20%20%20def%20_form_margin(cond%3A%20str)%20-%3E%20float%3A%0A%20%20%20%20%20%20%20%20%22%22%22Mean%20log%20P(correct%20hex)%20%E2%88%92%20log%20P(true%20name)%20on%20the%20holdout%20prompts.%22%22%22%0A%20%20%20%20%20%20%20%20vals%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20for%20s%20in%20SEEDS%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20cands%20%3D%20cell(metrics%2C%20cond%2C%20s)%5B%22margin_candidates%22%5D%5B%22named_holdout%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20lp%20%3D%20margins%5Bf%22%7Blabel(cond%2C%20s)%7D%2Fmargins%2Fnamed_holdout%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20i%2C%20ex%20in%20enumerate(holdout_exs)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20vals.append(lp%5Bi%2C%20cands.index(colors.to_hex(ex.result))%5D%20-%20lp%5Bi%2C%20cands.index(ex.answer)%5D)%0A%20%20%20%20%20%20%20%20return%20float(np.mean(vals))%0A%0A%20%20%20%20_n%20%3D%20len(holdout_exs)%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20f%22%22%22%0A%20%20%20%20Across%20all%20seeds%2C%20the%20hex-form%20answers%20on%20the%20%7B_n%7D%20held-out%20prompts%20number%0A%20%20%20%20%7B%22%2C%20%22.join(f%22%60%7Bc%7D%60%20**%7Bsum(_hexed%5Bc%5D)%7D%2F%7B3%20*%20_n%7D**%22%20for%20c%20in%20CONDS)%7D%2C%20and%20the%20value-correct%20answers%0A%20%20%20%20%7B%22%2C%20%22.join(f%22%60%7Bc%7D%60%20**%7Bsum(_value_ok%5Bc%5D)%7D%2F%7B3%20*%20_n%7D**%22%20for%20c%20in%20CONDS)%7D.%0A%20%20%20%20Every%20value-correct%20answer%20is%20hex%2C%20and%20every%20name%20answer%20has%20the%20wrong%0A%20%20%20%20value.%20The%20form-choice%20margin%20agrees%20at%0A%20%20%20%20%7B%22%2C%20%22.join(f%22%60%7Bc%7D%60%20%7B_form_margin(c)%3A%2B.1f%7D%22%20for%20c%20in%20CONDS)%7D%20nats%5B%5Eform%5D.%0A%0A%20%20%20%20So%20the%20%60open%60%20intervention%20worked%2C%20in%20that%20the%20mix%20is%20computed%20on%20name%20%2B%0A%20%20%20%20name%20prompts.%20But%20the%20*form%20rule*%20(%22answer%20with%20a%20name%20exactly%20when%20the%20mix%0A%20%20%20%20lands%20on%20the%20palette%22)%20did%20not%20carry%20over%3A%20the%20model%20treats%20a%20held-out%0A%20%20%20%20closed%20pair%20like%20an%20open%20one%20and%20answers%20in%20hex%2C%20or%20else%20falls%20back%20on%20a%0A%20%20%20%20name%20near%20the%20mix.%20Whether%20that%20name%20is%20the%20answer%20of%20the%20closest%20memorized%0A%20%20%20%20equation%20is%20a%20further%20claim%20we%20haven't%20tested%20here.%0A%0A%20%20%20%20So%20the%20reverse%20mapping%20%60rev%60%20didn't%20help.%0A%0A%20%20%20%20%5B%5Eform%5D%3A%20%22Form%20choice%20margin%22%3A%20the%20log-probability%20of%20the%20correct%20hex%20minus%0A%20%20%20%20that%20of%20the%20true%20name%20under%20teacher%20forcing.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Error%20margins%0A%0A%20%20%20%20Exact-match%20accuracy%20tells%20us%20whether%20the%20true%20name%20came%20out%20on%20top%2C%20but%20how%0A%20%20%20%20close%20it%20was.%20So%20let's%20grade%20the%20name-identity%20question%20on%20a%20continuous%0A%20%20%20%20scale.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(margins%2C%20metrics)%3A%0A%20%20%20%20def%20margin_rows(eval_set%3A%20str%2C%20exs%3A%20list)%20-%3E%20np.ndarray%3A%0A%20%20%20%20%20%20%20%20%22%22%22(len(CONDS)%2C%20n_seeds%2C%20n_examples)%20margin%20of%20the%20true%20name%20over%20the%20best%20*other%20name*.%22%22%22%0A%20%20%20%20%20%20%20%20out%20%3D%20np.empty((len(CONDS)%2C%20len(SEEDS)%2C%20len(exs)))%0A%20%20%20%20%20%20%20%20for%20ci%2C%20cond%20in%20enumerate(CONDS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20si%2C%20s%20in%20enumerate(SEEDS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20cands%20%3D%20cell(metrics%2C%20cond%2C%20s)%5B%22margin_candidates%22%5D%5Beval_set%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20names%20%3D%20%5Bi%20for%20i%2C%20c%20in%20enumerate(cands)%20if%20not%20c.startswith(%22%23%22)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20lp%20%3D%20margins%5Bf%22%7Blabel(cond%2C%20s)%7D%2Fmargins%2F%7Beval_set%7D%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20true_idx%20%3D%20np.array(%5Bcands.index(ex.answer)%20for%20ex%20in%20exs%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20truth%20%3D%20lp%5Bnp.arange(len(exs))%2C%20true_idx%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rival%20%3D%20lp%5B%3A%2C%20names%5D.copy()%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rival%5Bnp.arange(len(exs))%2C%20%5Bnames.index(t)%20for%20t%20in%20true_idx%5D%5D%20%3D%20-np.inf%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20out%5Bci%2C%20si%5D%20%3D%20truth%20-%20rival.max(axis%3D1)%0A%20%20%20%20%20%20%20%20return%20out%0A%0A%20%20%20%20_train_pairs%2C%20_holdout_pairs%20%3D%20colors.split_named_pairs(CORPUS_SEED%2C%20HOLDOUT_FRAC)%0A%20%20%20%20holdout_exs%20%3D%20colors.as_named(_holdout_pairs%2C%20seed%3D2)%0A%20%20%20%20m_hold%20%3D%20margin_rows(%22named_holdout%22%2C%20holdout_exs)%0A%20%20%20%20m_seen%20%3D%20margin_rows(%22named_seen%22%2C%20colors.as_named(_train_pairs%2C%20seed%3D1))%0A%20%20%20%20return%20holdout_exs%2C%20m_hold%2C%20m_seen%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(holdout_exs%2C%20m_hold%2C%20m_seen)%3A%0A%20%20%20%20%40themed(%0A%20%20%20%20%20%20%20%20name%3D%22margin-trajectories%22%2C%0A%20%20%20%20%20%20%20%20alt_text%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Line%20chart%20of%20the%20answer%20margin%20(log-probability%20of%20the%20true%20name%20minus%20the%20best%0A%20%20%20%20%20%20%20%20%20%20%20%20competitor)%20against%20condition%20(control%2C%20rev%2C%20open%2C%20both)%2C%20one%20line%20per%20held-out%0A%20%20%20%20%20%20%20%20%20%20%20%20named%20pair%2C%20averaged%20over%20seeds.%20A%20horizontal%20line%20marks%20zero%2C%20where%20the%20true%0A%20%20%20%20%20%20%20%20%20%20%20%20answer%20starts%20to%20come%20out%20ahead%3B%20a%20shaded%20band%20shows%20the%20range%20of%20margins%20on%20the%20seen%20named%0A%20%20%20%20%20%20%20%20%20%20%20%20pairs.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20caption%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Margins%20between%20predicted%20and%20true%20named%20colors.%20Positive%20means%20the%20true%20name%20comes%20out%0A%20%20%20%20%20%20%20%20%20%20%20%20ahead%20of%20the%20other%20names%2C%20and%20the%20magnitude%20says%20by%20how%20much.%20One%20line%20per%0A%20%20%20%20%20%20%20%20%20%20%20%20held-out%20pair%2C%20averaged%20over%20seeds%20and%20traced%20across%20the%20four%20conditions%3B%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20shaded%20band%20is%20the%20range%20of%20%60named_seen%60%20margins%2C%20for%20reference.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20)%0A%20%20%20%20def%20_plot()%20-%3E%20plt.Figure%3A%0A%20%20%20%20%20%20%20%20fig%2C%20ax%20%3D%20plt.subplots(figsize%3D(7.4%2C%204.2))%0A%20%20%20%20%20%20%20%20xs%20%3D%20np.arange(len(CONDS))%0A%20%20%20%20%20%20%20%20seen_mean%20%3D%20m_seen.mean(axis%3D1)%20%20%23%20(conds%2C%20n_seen)%0A%20%20%20%20%20%20%20%20ax.fill_between(%0A%20%20%20%20%20%20%20%20%20%20%20%20xs%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20np.percentile(seen_mean%2C%205%2C%20axis%3D1)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20np.percentile(seen_mean%2C%2095%2C%20axis%3D1)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%234d9de0%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.3%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22named%20seen%20(5%E2%80%9395%25)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20mean%20%3D%20m_hold.mean(axis%3D1)%20%20%23%20(conds%2C%20n_pairs)%0A%20%20%20%20%20%20%20%20order%20%3D%20np.argsort(mean%5B0%5D)%0A%20%20%20%20%20%20%20%20cmap%20%3D%20plt.cm.viridis(np.linspace(0.05%2C%200.85%2C%20mean.shape%5B1%5D))%0A%20%20%20%20%20%20%20%20%23%20Spread%20the%20end-of-line%20labels%20vertically%20so%20neighbors%20don't%20collide.%0A%20%20%20%20%20%20%20%20label_y%20%3D%20mean%5B-1%5D.astype(float).copy()%0A%20%20%20%20%20%20%20%20for%20prev%2C%20nxt%20in%20zip(np.argsort(label_y)%5B%3A-1%5D%2C%20np.argsort(label_y)%5B1%3A%5D%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20label_y%5Bnxt%5D%20%3D%20max(label_y%5Bnxt%5D%2C%20label_y%5Bprev%5D%20%2B%201.1)%0A%20%20%20%20%20%20%20%20for%20rank%2C%20p%20in%20enumerate(order)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ex%20%3D%20holdout_exs%5Bp%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(xs%2C%20mean%5B%3A%2C%20p%5D%2C%20%22o-%22%2C%20color%3Dcmap%5Brank%5D%2C%20lw%3D1.4%2C%20ms%3D3.5)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.annotate(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bex.prompt%7D%7Bex.answer%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(xs%5B-1%5D%2C%20mean%5B-1%2C%20p%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20xytext%3D(xs%5B-1%5D%20%2B%200.12%2C%20label_y%5Bp%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20textcoords%3D%22data%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20fontsize%3D6.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20va%3D%22center%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3Dcmap%5Brank%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax.axhline(0%2C%20color%3D%22%23888%22%2C%20lw%3D1%2C%20ls%3D%22--%22)%0A%20%20%20%20%20%20%20%20ax.set_xticks(xs%2C%20CONDS)%0A%20%20%20%20%20%20%20%20ax.set(xlabel%3D%22condition%22%2C%20ylabel%3D%22margin%3A%20log%20P(true)%20%E2%88%92%20log%20P(best%20competitor)%22)%0A%20%20%20%20%20%20%20%20ax.set_xlim(-0.3%2C%20len(CONDS)%20-%200.25%20%2B%201.6)%0A%20%20%20%20%20%20%20%20ax.grid(alpha%3D0.3%2C%20axis%3D%22y%22)%0A%20%20%20%20%20%20%20%20ax.legend(fontsize%3D8%2C%20loc%3D%22upper%20left%22)%0A%20%20%20%20%20%20%20%20return%20fig%0A%0A%20%20%20%20mo.Html(_plot())%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(m_hold)%3A%0A%20%20%20%20_mean%20%3D%20m_hold.mean(axis%3D1)%20%20%23%20(conds%2C%20pairs)%0A%20%20%20%20_ctrl%2C%20_both%20%3D%20_mean%5B0%5D%2C%20_mean%5BCONDS.index(%22both%22)%5D%0A%20%20%20%20_rho%20%3D%20float(np.corrcoef(np.argsort(np.argsort(_ctrl))%2C%20np.argsort(np.argsort(_both)))%5B0%2C%201%5D)%0A%20%20%20%20_flipped%20%3D%20int((_both%20%3E%200).sum())%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20f%22%22%22%0A%20%20%20%20**H2%20mostly%20refuted.**%20The%20distribution%20barely%20moves%3A%20the%20mean%0A%20%20%20%20margin%20is%20%7B_ctrl.mean()%3A%2B.1f%7D%20nats%20in%20%60control%60%20and%20%7B_both.mean()%3A%2B.1f%7D%20in%0A%20%20%20%20%60both%60%2C%20with%20%7B_flipped%7D%2F10%20pairs%20ending%20positive.%20The%20true%20name%20never%20gets%0A%20%20%20%20close%20among%20the%20names%3B%20it%20stays%20about%20ten%20nats%20off%20while%20%60named_seen%60%20is%0A%20%20%20%20far%20above%20zero.%20So%20the%20value%20%E2%86%92%20name%20translation%20is%20not%20*almost%20there*%20and%0A%20%20%20%20narrowly%20behind.%20It%20simply%20never%20engages%2C%20even%20in%20the%20condition%20whose%20greedy%20answers%20prove%20the%20value%20has%20been%20computed.%20There%20is%20some%20rank%20structure%2C%20but%20it%20is%20weak%3A%20the%20rank%20correlation%20between%20%60control%60%0A%20%20%20%20and%20%60both%60%20is%20%7B_rho%3A.2f%7D.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20When%20each%20channel%20becomes%20readable%20in-sequence%0A%0A%20%20%20%20Ex-2.1.1's%20probes%20read%20one%20pre-answer%20position%20and%20averaged%20over%20R%2C%20G%2C%20and%20B%2C%0A%20%20%20%20which%20hides%20at%20which%20token%20the%20mix%20gets%20computed.%20So%20here%20we%20fit%20a%20separate%20ridge%20probe%0A%20%20%20%20for%20every%20combination%20of%20position%2C%20channel%2C%20and%20layer%20on%20the%20hex%20prompts.%20We%20then%20watch%20each%20channel%20become%20readable%20as%0A%20%20%20%20the%20answer%20is%20spelled%20out.%0A%0A%20%20%20%20H3%20predicts%20a%20stair-step%3A%20each%20channel%20stays%20low%20until%20the%20position%20that%20emits%0A%20%20%20%20its%20own%20digit%2C%20then%20climbs%20sharply.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(margins%2C%20metrics)%3A%0A%20%20%20%20sched_offsets%20%3D%20cell(metrics%2C%20%22control%22%2C%20SEEDS%5B0%5D)%5B%22schedule_offsets%22%5D%0A%20%20%20%20%23%20Schedule%20R%C2%B2%20arrays%20travel%20in%20the%20same%20npz%20as%20the%20margins%20(see%20eval_one).%0A%20%20%20%20sched_r2%20%3D%20np.mean(%5Bmargins%5Bf%22%7Blabel('control'%2C%20s)%7D%2Fschedule%2Fr2%22%5D%20for%20s%20in%20SEEDS%5D%2C%20axis%3D0)%0A%20%20%20%20return%20sched_offsets%2C%20sched_r2%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(sched_offsets%2C%20sched_r2)%3A%0A%20%20%20%20%40themed(%0A%20%20%20%20%20%20%20%20name%3D%22answer-schedule%22%2C%0A%20%20%20%20%20%20%20%20alt_text%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Line%20charts%20of%20probe%20R-squared%20against%20position%20offset%20around%20the%20answer%2C%20one%0A%20%20%20%20%20%20%20%20%20%20%20%20panel%20per%20residual-stream%20depth%2C%20three%20lines%20per%20panel%20for%20the%20R%2C%20G%2C%20and%20B%0A%20%20%20%20%20%20%20%20%20%20%20%20channels%20of%20the%20result.%20Lines%20are%20solid%20before%20each%20channel's%20digit%20enters%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20context%20and%20dotted%20after.%20In%20the%20deeper%20layers%20each%20channel%20peaks%20near%201%20at%20its%0A%20%20%20%20%20%20%20%20%20%20%20%20own%20emission%20position%20and%20falls%20away%20on%20either%20side%2C%20so%20the%20three%20channels%20form%20a%0A%20%20%20%20%20%20%20%20%20%20%20%20sequence%20of%20staggered%20peaks%20rather%20than%20a%20cumulative%20plateau%3B%20at%20depth%200%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20dotted%20segments%20jump%20to%201%20as%20each%20digit%20becomes%20readable%20from%20the%20context.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20caption%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Probe%20alignment%20per%20color%20channel%20of%20the%20answer.%0A%20%20%20%20%20%20%20%20%20%20%20%20One%20panel%20per%20transformer%20layer.%20Offset%200%20is%20the%20%60%23%60%2C%20digit%20k%20sits%20at%20offset%20k%20%2B%201%20and%20is%0A%20%20%20%20%20%20%20%20%20%20%20%20emitted%20from%20offset%20k.%20A%20line%20is%20solid%20where%20its%20digit%20is%20not%20yet%20in%20the%20context%0A%20%20%20%20%20%20%20%20%20%20%20%20(so%20decoding%20it%20is%20computation)%20and%20dotted%20once%20it%20has%20landed%20(decoding%20is%0A%20%20%20%20%20%20%20%20%20%20%20%20copying).%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20)%0A%20%20%20%20def%20_plot()%20-%3E%20plt.Figure%3A%0A%20%20%20%20%20%20%20%20depths%20%3D%20sched_r2.shape%5B1%5D%0A%20%20%20%20%20%20%20%20fig%2C%20axes%20%3D%20plt.subplots(1%2C%20depths%2C%20figsize%3D(12.5%2C%202.9)%2C%20sharey%3DTrue)%0A%20%20%20%20%20%20%20%20chan_colors%20%3D%20%5B%22%23e4572e%22%2C%20%22%233aa76d%22%2C%20%22%234d9de0%22%5D%0A%20%20%20%20%20%20%20%20offs%20%3D%20np.array(sched_offsets)%0A%20%20%20%20%20%20%20%20for%20d%2C%20ax%20in%20enumerate(axes)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20k%2C%20c%20in%20enumerate(chan_colors)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20emit%20%3D%20k%20%2B%201%20%20%23%20digit%20k%20enters%20the%20context%20at%20offset%20k%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pre%20%3D%20offs%20%3C%3D%20emit%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(offs%5Bpre%5D%2C%20sched_r2%5Bpre%2C%20d%2C%20k%5D%2C%20%22o-%22%2C%20color%3Dc%2C%20lw%3D1.8%2C%20ms%3D3%2C%20label%3Df%22channel%20%7B'RGB'%5Bk%5D%7D%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(offs%5Bemit%20%3C%3D%20offs%5D%2C%20sched_r2%5Bemit%20%3C%3D%20offs%2C%20d%2C%20k%5D%2C%20%22o%3A%22%2C%20color%3Dc%2C%20lw%3D1%2C%20ms%3D2%2C%20alpha%3D0.6)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.axvline(-0.5%2C%20color%3D%22%23888%22%2C%20lw%3D0.8%2C%20ls%3D%22--%22%2C%20alpha%3D0.6)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set(title%3Df%22depth%20%7Bd%7D%22%2C%20xlabel%3D%22offset%20from%20'%23'%22%2C%20ylim%3D(-0.05%2C%201.05))%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.grid(alpha%3D0.3)%0A%20%20%20%20%20%20%20%20axes%5B0%5D.set_ylabel(%22probe%20R%C2%B2%20(held-out%20half)%22)%0A%20%20%20%20%20%20%20%20axes%5B0%5D.legend(fontsize%3D7)%0A%20%20%20%20%20%20%20%20return%20fig%0A%0A%20%20%20%20mo.Html(_plot())%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20At%20the%20final%20layer%2C%20channel%20k%20is%0A%20%20%20%20almost%20perfectly%20decodable%20right%20at%20its%20emission%20offset%20(R%C2%B2%20%E2%89%88%200.97)%2C%20and%20*only*%0A%20%20%20%20there.%20One%20position%20earlier%20it%20is%20much%20weaker%2C%20and%20once%20emission%20moves%20on%20to%0A%20%20%20%20the%20next%20digit%2C%20the%20earlier%20channels%20mostly%20fade%20from%20the%20deep%20residual%20stream.%0A%0A%20%20%20%20So%20each%20answer%20position%20holds%20just%20the%20one%20channel%20it%20is%20about%20to%20emit%2C%20riding%0A%20%20%20%20on%20a%20diffuse%20trace%20of%20the%20whole%20mix%20(around%200.5%20R%C2%B2)%20that%20lingers%20from%20the%0A%20%20%20%20pre-answer%20position.%20The%20mix%20is%20never%20fully%20represented%20at%20any%20single%20position%3B%0A%20%20%20%20the%20%22result%22%20that%20the%20pre-answer%20probe%20reads%20is%20more%20of%20a%20head%20start%20than%20a%0A%20%20%20%20finished%20value.%20This%20looks%20like%20just-in-time%20computation.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Is%20the%20mix%20computed%20on%20the%20named%20prompts%3F%0A%0A%20%20%20%20If%20the%20mix%20really%20is%20computed%20on%20the%20named%20prompts%2C%20then%20a%20probe%20trained%20to%0A%20%20%20%20read%20the%20result%20somewhere%20else%20should%20carry%20over%20to%20them.%20So%20we%20fit%20the%20probe%0A%20%20%20%20on%20the%20open-pair%20prompts%20(the%20name%20%2B%20name%20surface%20form)%20at%20the%20pre-answer%0A%20%20%20%20position%2C%20then%20score%20it%20on%20the%20named%20eval%20sets.%20Where%20the%20mix%20is%20never%0A%20%20%20%20represented%2C%20no%20probe%20fit%20elsewhere%20can%20recover%20it.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20_sets%20%3D%20%5B%22fit%22%2C%20%22open_holdout%22%2C%20%22named_seen%22%2C%20%22named_holdout%22%5D%0A%0A%20%20%20%20%40themed(%0A%20%20%20%20%20%20%20%20name%3D%22transfer-probe%22%2C%0A%20%20%20%20%20%20%20%20alt_text%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Four%20line%20charts%20of%20probe%20R-squared%20against%20residual-stream%20depth%2C%20one%20panel%20per%0A%20%20%20%20%20%20%20%20%20%20%20%20prompt%20set%3A%20the%20fit%20set's%20held-back%20half%2C%20open%20holdout%2C%20named%20seen%2C%20and%20named%0A%20%20%20%20%20%20%20%20%20%20%20%20holdout.%20One%20line%20per%20condition%20(control%2C%20rev%2C%20open%2C%20both%3B%20darker%20means%20richer%0A%20%20%20%20%20%20%20%20%20%20%20%20corpus).%20The%20probes%20were%20fit%20on%20open-pair%20prompts%20at%20the%20pre-answer%20position.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20caption%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20One%20panel%20per%20scored%20set%3A%20the%20fit%20set's%20held-back%20half%2C%20open%20holdout%2C%20named%20seen%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20and%20named%20holdout.%20R%C2%B2%20against%20residual%20depth%2C%20one%20line%20per%20condition%20(darker%20means%0A%20%20%20%20%20%20%20%20%20%20%20%20a%20richer%20corpus).%20Depth%200%20is%20left%20out%2C%20since%20the%20pre-answer%20embedding%20is%20constant%0A%20%20%20%20%20%20%20%20%20%20%20%20across%20prompts%20until%20attention%20runs.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20)%0A%20%20%20%20def%20_plot()%20-%3E%20plt.Figure%3A%0A%20%20%20%20%20%20%20%20fig%2C%20axes%20%3D%20plt.subplots(1%2C%20len(_sets)%2C%20figsize%3D(11.5%2C%203.0)%2C%20sharey%3DTrue)%0A%20%20%20%20%20%20%20%20shades%20%3D%20cond_shades()%0A%20%20%20%20%20%20%20%20for%20ax%2C%20name%20in%20zip(axes%2C%20_sets%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20cond%20in%20CONDS%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rows%20%3D%20np.array(%5Bcell(metrics%2C%20cond%2C%20s)%5B%22transfer_r2%22%5D%5Bname%5D%20for%20s%20in%20SEEDS%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Skip%20depth%200%3A%20the%20pre-answer%20position's%20raw%20embedding%20is%20a%20constant%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20across%20prompts%20(attention%20hasn't%20run)%2C%20so%20its%20transfer%20R%C2%B2%20only%20reflects%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20the%20fit-vs-eval%20mean%20gap%20%E2%80%94%20no%20result%20is%20decodable%20there%20in%20any%20set.%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20depths%20%3D%20np.arange(rows.shape%5B1%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(depths%5B1%3A%5D%2C%20rows.mean(axis%3D0)%5B1%3A%5D%2C%20%22o-%22%2C%20color%3Dshades%5Bcond%5D%2C%20label%3Dcond%2C%20lw%3D2)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set(title%3Dname.replace(%22_%22%2C%20%22%20%22)%2C%20xlabel%3D%22residual%20depth%22%2C%20ylim%3D(-0.05%2C%201.05))%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.grid(alpha%3D0.3)%0A%20%20%20%20%20%20%20%20axes%5B0%5D.set_ylabel(%22probe%20R%C2%B2%20(result%20RGB)%22)%0A%20%20%20%20%20%20%20%20axes%5B0%5D.legend(fontsize%3D8)%0A%20%20%20%20%20%20%20%20return%20fig%0A%0A%20%20%20%20mo.Html(_plot())%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Partial%20computation%20shows%20up%20everywhere%2C%20%60control%60%20included.%20The%20held-out%0A%20%20%20%20named%20prompts%20carry%20about%20as%20much%20linearly-decodable%20result%20as%20the%20fit%20set's%0A%20%20%20%20own%20ceiling%20(%E2%89%88%200.6%20at%20the%20deep%20layers).%20The%20%60open%60%20conditions%20lift%20the%20mid-depth%20transfer%20a%0A%20%20%20%20little%2C%20which%20fits%20the%20idea%20that%20the%20arithmetic%20is%20doing%20real%20work%20on%20these%0A%20%20%20%20prompts%2C%20and%20their%20*final*-layer%20R%C2%B2%20drops%20on%20the%20named%20sets%2C%20where%20the%20last%0A%20%20%20%20layer's%20job%20has%20become%20committing%20to%20a%20surface%20form.%20The%20main%20point%2C%20though%2C%0A%20%20%20%20is%20that%20%22computed%20but%20not%20emitted%22%20was%20already%20true%20in%20%60control%60%3A%20making%20the%0A%20%20%20%20computation%20stronger%20(%60open%60)%20or%20the%20readout%20available%20(%60rev%60)%20still%20does%20not%0A%20%20%20%20join%20the%20two%20up.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20def%20_gp_guess(cond%3A%20str%2C%20s%3A%20int)%20-%3E%20str%3A%0A%20%20%20%20%20%20%20%20%22%22%22What%20the%20model%20actually%20completes%20%60lime%20%2B%20black%20%3D%20%60%20with.%22%22%22%0A%20%20%20%20%20%20%20%20fails%20%3D%20cell(metrics%2C%20cond%2C%20s)%5B%22accuracy%22%5D%5B%22named_holdout%22%5D%5B%22failures%22%5D%0A%20%20%20%20%20%20%20%20return%20next((g%20for%20p%2C%20_%2C%20g%20in%20fails%20if%20p.startswith(%22lime%20%2B%20black%22))%2C%20%22green%22)%0A%0A%20%20%20%20_seed0%20%3D%20%22%2C%20%22.join(f%22%60%7Bc%7D%60%20%7B_gp_guess(c%2C%20SEEDS%5B0%5D)%7D%22%20for%20c%20in%20CONDS)%0A%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20%23%23%20The%20garden%20path%2C%20revisited%0A%0A%20%20%20%20Let's%20return%20to%20the%20walkthrough%20example%20from%20ex-2.1.1.%20A%20garden-path%20sentence%0A%20%20%20%20is%20one%20that%20leads%20you%20into%20a%20wrong%20reading%20until%20a%20later%20word%20forces%20a%0A%20%20%20%20correction%2C%20and%20that's%20what%20happens%20here.%20On%20%60lime%20%2B%20black%20%3D%20green%60%2C%20the%0A%20%20%20%20model%20guesses%20the%20second%20operand%20as%20*blue*%2C%20revises%20to%20*black*%20when%20it%20sees%0A%20%20%20%20the%20%60a%60%2C%20and%20then%20only%20half-corrects%20the%20answer%2C%20so%20a%20memorized%20neighbor%20of%0A%20%20%20%20the%20mix%20comes%20out%20ahead.%0A%0A%20%20%20%20Which%20neighbor%20varies.%20At%20seed%20%7BSEEDS%5B0%5D%7D%20the%20completions%20are%20%7B_seed0%7D%2C%20and%0A%20%20%20%20across%20the%20other%20seeds%20%60control%60%20also%20gives%20olive%20and%20teal.%20The%20competitor%20is%0A%20%20%20%20not%20one%20fixed%20wrong%20answer.%0A%0A%20%20%20%20With%20the%20new%20corpora%2C%20does%20the%20correction%20finally%20overtake%20the%20lookup%3F%20It%0A%20%20%20%20does%20not%3A%20the%20margin%20stays%20several%20nats%20negative.%20The%20sublines%20below%20trace%0A%20%20%20%20per-character%20surprisal%20and%20entropy%20for%20seed%20%7BSEEDS%5B0%5D%7D.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(holdout_exs%2C%20m_hold)%3A%0A%20%20%20%20gp_idx%20%3D%20next(%0A%20%20%20%20%20%20%20%20i%20for%20i%2C%20ex%20in%20enumerate(holdout_exs)%20if%20%7B%22lime%22%2C%20%22black%22%7D%20%3D%3D%20set(ex.prompt.split(%22%20%3D%20%22)%5B0%5D.split(%22%20%2B%20%22))%0A%20%20%20%20)%0A%20%20%20%20_rows%20%3D%20%22%22.join(%0A%20%20%20%20%20%20%20%20f%22%3Ctr%3E%3Ctd%3E%3Ccode%3E%7Bcond%7D%3C%2Fcode%3E%3C%2Ftd%3E%22%0A%20%20%20%20%20%20%20%20%2B%20%22%22.join(f'%3Ctd%20class%3D%22num%22%3E%7Bm_hold%5Bci%2C%20si%2C%20gp_idx%5D%3A%2B.1f%7D%3C%2Ftd%3E'%20for%20si%20in%20range(len(SEEDS)))%0A%20%20%20%20%20%20%20%20%2B%20f'%3Ctd%20class%3D%22num%22%3E%3Cb%3E%7Bm_hold%5Bci%2C%20%3A%2C%20gp_idx%5D.mean()%3A%2B.1f%7D%3C%2Fb%3E%3C%2Ftd%3E%3C%2Ftr%3E'%0A%20%20%20%20%20%20%20%20for%20ci%2C%20cond%20in%20enumerate(CONDS)%0A%20%20%20%20)%0A%20%20%20%20_table%20%3D%20(%0A%20%20%20%20%20%20%20%20'%3Cdiv%20class%3D%22report-table-scroll%22%3E'%0A%20%20%20%20%20%20%20%20'%3Ctable%20class%3D%22report-table%22%3E%3Ctr%3E%3Cth%3Econdition%3C%2Fth%3E'%0A%20%20%20%20%20%20%20%20%2B%20%22%22.join(f'%3Cth%20class%3D%22num%22%3Eseed%20%7Bs%7D%3C%2Fth%3E'%20for%20s%20in%20SEEDS)%0A%20%20%20%20%20%20%20%20%2B%20f'%3Cth%20class%3D%22num%22%3Emean%3C%2Fth%3E%3C%2Ftr%3E%7B_rows%7D%3C%2Ftable%3E'%0A%20%20%20%20%20%20%20%20%2B%20%22%3C%2Fdiv%3E%22%0A%20%20%20%20)%0A%20%20%20%20_caption%20%3D%20mo.md(%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20Margin%20of%20%60green%60%20over%20its%20best%20competitor%20on%20the%20%60lime%20%2B%20black%60%20prompt%2C%20per%20seed%0A%20%20%20%20%20%20%20%20and%20condition.%20A%20positive%20value%20means%20the%20arithmetic%20comes%20out%20ahead.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20).text%0A%20%20%20%20mo.Html(figure_html(_table%2C%20caption%3D_caption%2C%20class_%3D%22report-figure%22))%0A%20%20%20%20return%20(gp_idx%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(gp_idx%2C%20holdout_exs%2C%20metrics)%3A%0A%20%20%20%20_log_v%20%3D%20np.log(len(colors.alphabet()))%0A%20%20%20%20_gp_text%20%3D%20holdout_exs%5Bgp_idx%5D.prompt%20%2B%20holdout_exs%5Bgp_idx%5D.answer%0A%20%20%20%20_rows_by_cond%20%3D%20%5B%0A%20%20%20%20%20%20%20%20(cond%2C%20row)%0A%20%20%20%20%20%20%20%20for%20cond%20in%20CONDS%0A%20%20%20%20%20%20%20%20for%20row%20in%20cell(metrics%2C%20cond%2C%20SEEDS%5B0%5D)%5B%22surprisal%22%5D%5B%22named_holdout%22%5D%0A%20%20%20%20%20%20%20%20if%20row%5B%22text%22%5D%20%3D%3D%20_gp_text%0A%20%20%20%20%5D%0A%20%20%20%20mo.stop(%0A%20%20%20%20%20%20%20%20not%20_rows_by_cond%2C%0A%20%20%20%20%20%20%20%20mo.md(%22*(The%20garden-path%20example%20fell%20outside%20the%20captured%20surprisal%20rows%20%E2%80%94%20skipping%20the%20sublines.)*%22)%2C%0A%20%20%20%20)%0A%20%20%20%20_sub_css%20%3D%20%22svg%20%7B%20--bg-color%3A%20light-dark(%23fff%2C%20%23181c1a)%3B%20%7D%22%0A%0A%20%20%20%20def%20_pad(row%3A%20dict%2C%20key%3A%20str)%20-%3E%20np.ndarray%3A%0A%20%20%20%20%20%20%20%20return%20np.concatenate(%5B%5Bnp.nan%5D%2C%20np.asarray(row%5Bkey%5D)%20%2F%20_log_v%5D)%0A%0A%20%20%20%20def%20_one(cond%3A%20str%2C%20row%3A%20dict)%20-%3E%20str%3A%0A%20%20%20%20%20%20%20%20series%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20Series(raw%3Dnp.clip(_pad(row%2C%20%22nll%22)%2C%200%2C%201)%2C%20label%3D%22surprisal%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20Series(raw%3Dnp.clip(_pad(row%2C%20%22entropy%22)%2C%200%2C%201)%2C%20label%3D%22entropy%22%2C%20dasharray%3D%223%202%22)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20svg%20%3D%20Subline(chars_per_line%3Dlen(row%5B%22text%22%5D)%2C%20css%3D_sub_css).plot(row%5B%22text%22%5D%2C%20series)%0A%20%20%20%20%20%20%20%20label%20%3D%20f'%3Cspan%20style%3D%22font-size%3A%2011px%3B%20font-family%3A%20monospace%3B%20opacity%3A%200.65%22%3E%7Bcond%7D%3C%2Fspan%3E'%0A%20%20%20%20%20%20%20%20return%20figure_html(svg%2C%20caption%3Dlabel%2C%20style%3D%22display%3A%20inline-block%3B%20margin%3A%200%201em%200%200%22)%0A%0A%20%20%20%20_html%20%3D%20figure_html(%0A%20%20%20%20%20%20%20%20%22%22.join(_one(cond%2C%20row)%20for%20cond%2C%20row%20in%20_rows_by_cond)%2C%0A%20%20%20%20%20%20%20%20aria_label%3D%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20The%20equation%20lime%20plus%20black%20equals%20green%2C%20repeated%20once%20per%20condition%2C%20each%20with%20a%0A%20%20%20%20%20%20%20%20%20%20%20%20sparkline%20of%20per-character%20surprisal%20(solid)%20and%20predictive%20entropy%20(dashed)%20under%0A%20%20%20%20%20%20%20%20%20%20%20%20the%20text%20on%20a%20shared%200-to-log-V%20scale.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20)%0A%20%20%20%20mo.Html(externalize_html(_html%2C%20name%3D%22sublines-garden-path%22))%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20_s2%20%3D%20sorted(%0A%20%20%20%20%20%20%20%20c%5B%22calibration%22%5D%5Bes%5D%5B%22s2%22%5D%0A%20%20%20%20%20%20%20%20for%20cond%20in%20CONDS%0A%20%20%20%20%20%20%20%20for%20s%20in%20SEEDS%0A%20%20%20%20%20%20%20%20for%20c%20in%20%5Bcell(metrics%2C%20cond%2C%20s)%5D%0A%20%20%20%20%20%20%20%20for%20es%2C%20a%20in%20c%5B%22accuracy%22%5D.items()%0A%20%20%20%20%20%20%20%20if%20es%20in%20c%5B%22calibration%22%5D%20and%20a%5B%22accuracy%22%5D%20%3D%3D%200.0%0A%20%20%20%20)%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20Every%20set%20the%20model%20fails%2C%20it%20fails%20confidently%20rather%20than%20hedging%2C%20which%20is%0A%20%20%20%20what%20the%20garden-path%20sublines%20illustrate.%20Across%20the%20%7Blen(_s2)%7D%20cell%20and%0A%20%20%20%20eval-set%20pairs%20at%20zero%20accuracy%2C%20s%E2%82%82%20averages%20%7Bnp.mean(_s2)%3A.2f%7D%20and%20spans%0A%20%20%20%20%7B_s2%5B0%5D%3A.2f%7D%20to%20%7B_s2%5B-1%5D%3A.2f%7D.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(metrics)%3A%0A%20%20%20%20_oh%20%3D%20float(np.mean(%5Bacc(metrics%2C%20%22both%22%2C%20s%2C%20%22open_holdout%22)%20for%20s%20in%20SEEDS%5D))%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20f%22%22%22%0A%20%20%20%20%23%23%20Findings%0A%0A%20%20%20%20Adding%20the%20inverse%20dictionary%20and%20the%20pressure%20to%20compute%20on%20named%20prompts%20did%0A%20%20%20%20teach%20the%20model%20those%20two%20skills%3A%20reverse%20aliases%20reach%201.0%2C%20and%20off-palette%0A%20%20%20%20generalization%20reaches%20%E2%89%88%20%7B_oh%3A.2f%7D.%20But%20the%20model%20didn't%20learn%20to%20combine%0A%20%20%20%20them%3A%20%60named_holdout%60%20stays%20at%20zero%20everywhere.%0A%0A%20%20%20%20The%20model%20often%20gets%20the%20value%20right%20but%20writes%20it%20as%20hex%20instead%20of%20as%20a%0A%20%20%20%20name%2C%20and%20the%20value%20%E2%86%92%20name%20translation%20never%20runs%20partway%20through%20an%0A%20%20%20%20equation%2C%20even%20though%20the%20model%20has%20learned%20that%20mapping%20perfectly%20well%20on%0A%20%20%20%20its%20own.%20Nothing%20in%20training%20ever%20asks%20the%20model%20to%20chain%20the%20two%20skills%0A%20%20%20%20inside%20a%20single%20forward%20pass%2C%20and%20the%20just-in-time%20answer%20schedule%20suggests%0A%20%20%20%20it%20never%20holds%20a%20full%20intermediate%20result%20anywhere%20as%20a%20latent%20embedding.%0A%0A%20%20%20%20So%20for%20D2.1%2C%20%60named_holdout%60%20is%20not%20able%20to%20identify%20degradation%3A%20it%20sits%20at%0A%20%20%20%20zero%2C%20so%20it%20has%20no%20headroom%20to%20lose.%20%60open_holdout%60%20from%20the%20new%20corpus%20may%0A%20%20%20%20be%20a%20better%20indicator%3A%20it%20is%20compositional%20(unseen%20pairs%2C%20with%20the%20form%20of%0A%20%20%20%20the%20answer%20decided%20by%20a%20computed%20value)%2C%20and%20it%20sits%20near%20the%20ceiling%0A%20%20%20%20without%20quite%20reaching%20it.%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
440d34a182586b8787a8b4463d9ea1ef