← Index
Source
Data provenance
ex-2.1.3
·
410fbab-dirty
(dirty) · run 2026-07-19
via reports/m2/ex-2.1.3/arrays, reports/m2/ex-2.1.3/evals/v216, reports/m2/ex-2.1.3/evals/v27, reports/m2/ex-2.1.3/evals/v4096, reports/m2/ex-2.1.3/evals/v64, reports/m2/ex-2.1.3/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.3%3A%20names%20all%20the%20way%20down%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%20ARRAYS_REF%2C%0A%20%20%20%20%20%20%20%20EVALS_REF%2C%0A%20%20%20%20%20%20%20%20HOLDOUT_FRAC%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%20SEEDS%2C%0A%20%20%20%20)%0A%20%20%20%20from%20mini.reports%20import%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%20import%20baselines%20as%20bl%0A%20%20%20%20from%20sca.compute.evaluation%20import%20ridge_probe%2C%20ridge_probe_loo%0A%20%20%20%20from%20sca.data%20import%20named_colors%20as%20nc%0A%20%20%20%20from%20sca.data.colors%20import%20N_LEVELS%2C%20load_example_sets%2C%20to_hex%0A%20%20%20%20from%20sca.vis%20import%20plot_rgb_cube%0A%0A%20%20%20%20use_publisher(report_bundle(__file__))%0A%0A%20%20%20%20GRID_NAMES%20%3D%20list(nc.GRIDS)%0A%20%20%20%20PALETTES%20%3D%20%7Bg%3A%20nc.grid_palette(nc.GRIDS%5Bg%5D)%20for%20g%20in%20GRID_NAMES%7D%0A%20%20%20%20VOCAB_RGB%20%3D%20%7Bg%3A%20np.array(list(p.values())%2C%20dtype%3Dnp.float32)%20%2F%20(N_LEVELS%20-%201)%20for%20g%2C%20p%20in%20PALETTES.items()%7D%0A%0A%20%20%20%20def%20load_results()%20-%3E%20tuple%5Bdict%2C%20dict%5Bstr%2C%20np.ndarray%5D%2C%20dict%5Bstr%2C%20dict%5D%5D%20%7C%20None%3A%0A%20%20%20%20%20%20%20%20%22%22%22Resolve%20metrics%2C%20arrays%2C%20and%20eval%20sets%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%20ARRAYS_REF%2C%20*(f%22%7BEVALS_REF%7D%2F%7Bg%7D%22%20for%20g%20in%20GRID_NAMES)%5D)%0A%20%20%20%20%20%20%20%20m_art%2C%20a_art%20%3D%20arts%5BMETRICS_REF%5D%2C%20arts%5BARRAYS_REF%5D%0A%20%20%20%20%20%20%20%20e_arts%20%3D%20%7Bg%3A%20arts%5Bf%22%7BEVALS_REF%7D%2F%7Bg%7D%22%5D%20for%20g%20in%20GRID_NAMES%7D%0A%20%20%20%20%20%20%20%20if%20m_art%20is%20None%20or%20a_art%20is%20None%20or%20any(v%20is%20None%20for%20v%20in%20e_arts.values())%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%20paths%20%3D%20store.get_many(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(m_art%2C%20Path(d)%20%2F%20%22metrics.json%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(a_art%2C%20Path(d)%20%2F%20%22arrays.npz%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20*((art%2C%20Path(d)%20%2F%20f%22%7Bg%7D.json%22)%20for%20g%2C%20art%20in%20e_arts.items()%20if%20art%20is%20not%20None)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20metrics%20%3D%20json.loads(paths%5B0%5D.read_text())%0A%20%20%20%20%20%20%20%20%20%20%20%20with%20np.load(paths%5B1%5D)%20as%20z%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20arrays%20%3D%20%7Bk%3A%20z%5Bk%5D%20for%20k%20in%20z.files%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20evals%20%3D%20%7Bp.stem%3A%20load_example_sets(p.read_bytes())%20for%20p%20in%20paths%5B2%3A%5D%7D%0A%20%20%20%20%20%20%20%20return%20metrics%2C%20arrays%2C%20evals%0A%0A%20%20%20%20def%20cell_of(metrics%3A%20dict%2C%20grid%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%20f%22%7Bgrid%7D-s%7Bs%7D%22%5D%0A%20%20%20%20%20%20%20%20return%20r%0A%0A%20%20%20%20def%20grid_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(GRID_NAMES%2C%20plt.cm.viridis(stops)%2C%20strict%3DTrue))%0A%0A%20%20%20%20def%20sw(name%3A%20str%2C%20grid%3A%20str)%20-%3E%20str%3A%0A%20%20%20%20%20%20%20%20%22%22%22Inline%20swatch%20%2B%20name%20for%20any%20grid's%20palette%20(the%20classic%20%60swatch%60%20knows%20only%20the%2027).%22%22%22%0A%20%20%20%20%20%20%20%20rgb%20%3D%20PALETTES%5Bgrid%5D.get(name)%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%7Bname%7D%3C%2Fcode%3E%22%0A%20%20%20%20%20%20%20%20return%20f'%3Cspan%20class%3D%22sw%22%20style%3D%22--sw%3A%20%7Bto_hex(rgb)%7D%3B%22%20aria-hidden%3D%22true%22%3E%3C%2Fspan%3E%20%7Bname%7D'%0A%0A%20%20%20%20def%20dists_for(grid%3A%20str%2C%20exs%3A%20list%2C%20logp%3A%20np.ndarray)%20-%3E%20tuple%5Bnp.ndarray%2C%20np.ndarray%5D%3A%0A%20%20%20%20%20%20%20%20%22%22%22(guess%20distance%2C%20floor%20distance)%20per%20example%2C%20unit-cube%20units.%22%22%22%0A%20%20%20%20%20%20%20%20result%20%3D%20np.array(%5Bex.result%20for%20ex%20in%20exs%5D%2C%20dtype%3Dnp.float32)%20%2F%20(N_LEVELS%20-%201)%0A%20%20%20%20%20%20%20%20d%20%3D%20np.linalg.norm(VOCAB_RGB%5Bgrid%5D%5BNone%5D%20-%20result%5B%3A%2C%20None%5D%2C%20axis%3D2)%0A%20%20%20%20%20%20%20%20return%20d%5Bnp.arange(len(exs))%2C%20logp.argmax(axis%3D1)%5D%2C%20d.min(axis%3D1)%0A%0A%20%20%20%20def%20raw_rgb(grid%3A%20str)%20-%3E%20np.ndarray%3A%0A%20%20%20%20%20%20%20%20%22%22%22(V%2C%203)%20raw%200..15%20channel%20values%2C%20which%20%60sca.baselines%60%20works%20in.%22%22%22%0A%20%20%20%20%20%20%20%20return%20np.array(list(PALETTES%5Bgrid%5D.values()))%0A%0A%20%20%20%20def%20dist_matrix(grid%3A%20str%2C%20exs%3A%20list)%20-%3E%20np.ndarray%3A%0A%20%20%20%20%20%20%20%20%22%22%22(N%2C%20V)%20distance%20from%20every%20vocabulary%20color%20to%20each%20example's%20true%20mix.%22%22%22%0A%20%20%20%20%20%20%20%20return%20bl.distances(raw_rgb(grid)%2C%20%5Bex.result%20for%20ex%20in%20exs%5D)%0A%0A%20%20%20%20def%20exact_null(grid%3A%20str%2C%20evals%3A%20dict)%20-%3E%20float%3A%0A%20%20%20%20%20%20%20%20%22%22%22Exact-match%20rate%20for%20a%20guesser%20that%20knows%20only%20the%20answer's%20neighborhood.%0A%0A%20%20%20%20%20%20%20%20On%20a%20coarse%20grid%20this%20is%20well%20above%20zero%2C%20so%20held-out%20accuracy%20has%20to%20clear%0A%20%20%20%20%20%20%20%20it%20before%20it%20shows%20the%20model%20can%20name%20the%20mix%20rather%20than%20only%20locate%20it.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20exs%20%3D%20evals%5Bgrid%5D%5B%22named_holdout%22%5D%0A%20%20%20%20%20%20%20%20return%20bl.neighborhood_exact_null(bl.shell_mask(nc.GRIDS%5Bgrid%5D%2C%20raw_rgb(grid)%2C%20%5Bex.result%20for%20ex%20in%20exs%5D))%0A%0A%20%20%20%20def%20blind_for(grid%3A%20str%2C%20evals%3A%20dict)%20-%3E%20int%3A%0A%20%20%20%20%20%20%20%20%22%22%22The%20name%20a%20prompt-blind%20model%20would%20always%20answer%2C%20fit%20on%20the%20training%20pairs.%22%22%22%0A%20%20%20%20%20%20%20%20return%20bl.blind_index(dist_matrix(grid%2C%20evals%5Bgrid%5D%5B%22named_seen%22%5D))%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.3%3A%20named%20colors%20only%0A%0A%20%20%20%20Every%20experiment%20so%20far%20has%20taught%20the%20model%20colors%20two%20ways%3A%20as%20names%0A%20%20%20%20(%60red%60)%20and%20as%20hex%20codes%20(%60%23f00%60)%2C%20with%20alias%20lines%20tying%20the%20two%20together.%0A%20%20%20%20The%20hex%20form%20spells%20a%20color%20one%20channel%20at%20a%20time%2C%20so%20the%20geometry%20of%20color%0A%20%20%20%20space%20is%20legible%20in%20the%20text.%0A%0A%20%20%20%20In%20this%20experiment's%20language%2C%20each%20color%20is%20a%20single%20opaque%20token%2C%20and%0A%20%20%20%20every%20sentence%20is%20a%20mixing%20equation%20between%20named%20colors%20whose%20mix%20is%20also%0A%20%20%20%20named.%20Nothing%20about%20the%20tokens%20says%20that%20colors%20live%20on%20a%203D%20grid%2C%20that%0A%20%20%20%20%60purple%60%20sits%20midway%20between%20%60red%60%20and%20%60blue%60%2C%20or%20that%20colors%20are%20values%20at%0A%20%20%20%20all.%20The%20only%20structure%20left%20is%20the%20co-occurrence%20statistics%20of%20the%20mixing%0A%20%20%20%20table.%0A%0A%20%20%20%20The%20main%20question%20is%20whether%20the%20model%20can%20infer%20the%20color-space%20geometry%0A%20%20%20%20from%20that%20alone.%20A%20model%20that%20discovers%20it%20should%20be%20able%20to%20fill%20in%20cells%0A%20%20%20%20of%20the%20table%20it%20has%20never%20seen.%0A%0A%20%20%20%20Many%20operand%20pairs%20mix%20to%20a%20color%20that%20has%20no%20name%20in%20the%20vocabulary%2C%20so%20an%0A%20%20%20%20exact%20answer%20is%20impossible%20there.%20A%20model%20that%20holds%20the%20geometry%20should%0A%20%20%20%20still%20guess%20a%20nearby%20name.%20Measuring%20how%20close%20the%20guesses%20land%20gives%20a%0A%20%20%20%20graded%20score%20where%20exact-match%20accuracy%20would%20only%20record%20a%20miss.%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(rf%22%22%22%0A%20%20%20%20%23%23%20The%20language%20and%20a%20vocabulary-size%20sweep%0A%0A%20%20%20%20A%20vocabulary%20here%20is%20a%20sub-grid%20of%20the%2016-level%20RGB%20cube%3A%20pick%20a%20set%20of%0A%20%20%20%20levels%2C%20then%20give%20a%20name%20to%20every%20point%20on%20that%20sub-grid.%20We%20sweep%20four%20such%0A%20%20%20%20grids.%20The%203-level%20grid%20is%20the%20familiar%2027-color%20palette%20from%20the%20base%0A%20%20%20%20language%2C%20with%20proper%20names.%20The%20denser%20grids%20use%20synthetic%20names%20that%20encode%0A%20%20%20%20the%20value%20(%60c05f%60%20is%20the%20color%20%60%2305f%60)%2C%20which%20helps%20us%20read%20through%20failures%0A%20%20%20%20later%20on.%20Each%20name%20is%20still%20a%20single%20token%2C%20so%20the%20model%20sees%20an%20opaque%20id%0A%20%20%20%20and%20has%20to%20learn%20what%20it%20means%20from%20usage.%0A%0A%20%20%20%20%7C%20grid%20%7C%20levels%20per%20channel%20%7C%20colors%20%7C%20example%20%7C%0A%20%20%20%20%7C------%7C--------------------%7C-------%3A%7C---------%7C%0A%20%20%20%20%7C%20%60v27%60%20%7C%200%2C%208%2C%2015%20%7C%2027%20%7C%20%60red%60%2C%20%60purple%60%20%7C%0A%20%20%20%20%7C%20%60v64%60%20%7C%200%2C%205%2C%2010%2C%2015%20%7C%2064%20%7C%20%60c05f%60%20%7C%0A%20%20%20%20%7C%20%60v216%60%20%7C%200%2C%203%2C%206%2C%209%2C%2012%2C%2015%20%7C%20216%20%7C%20%60c9c3%60%20%7C%0A%20%20%20%20%7C%20%60v4096%60%20%7C%20all%2016%20%7C%204096%20%7C%20%60c27b%60%20%7C%0A%0A%20%20%20%20Every%20training%20line%20reads%20%60a%20%2B%20b%20%3D%20mix(a%2C%20b)%60%2C%20six%20tokens%20including%20the%0A%20%20%20%20newline%2C%20with%20both%20operands%20and%20the%20mix%20drawn%20from%20the%20vocabulary.%20Mixing%20is%0A%20%20%20%20the%20same%20channel-wise%20round-half-up%20mean%20used%20in%20earlier%20experiments.%20A%20pair%0A%20%20%20%20whose%20mix%20lands%20on%20the%20vocabulary%20is%20%22closed%22%3B%20%7BHOLDOUT_FRAC%3A.0%25%7D%20of%20the%0A%20%20%20%20distinct%20closed%20pairs%20are%20held%20out%20of%20training%20entirely.%20Pairs%20whose%20mix%0A%20%20%20%20falls%20between%20grid%20cells%20are%20%22open%22%3A%20they%20never%20appear%20in%20training%2C%20since%0A%20%20%20%20there%20is%20no%20name%20to%20write%20on%20the%20right-hand%20side%2C%20and%20we%20use%20them%20only%20as%0A%20%20%20%20probes%20of%20graded%20generalization.%20The%20corpus%20is%20%7BN_EXAMPLES%3A%2C%7D%20with%20lines%0A%20%20%20%20drawn%20at%20random.%20The%20model%20architecture%20is%20the%20d64-L4%20nGPT%20cell%20from%0A%20%20%20%20ex-2.1.1%2C%20with%20%7Blen(SEEDS)%7D%20seeds%20per%20grid.%0A%0A%20%20%20%20Here%20are%20a%20few%20lines%20from%20two%20of%20the%20corpora.%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%20_v27%20%3D%20%22%22.join(ex.text%20for%20ex%20in%20nc.sample_corpus(5%2C%200%2C%20nc.GRIDS%5B%22v27%22%5D))%0A%20%20%20%20_v216%20%3D%20%22%22.join(ex.text%20for%20ex%20in%20nc.sample_corpus(5%2C%200%2C%20nc.GRIDS%5B%22v216%22%5D))%0A%20%20%20%20mo.hstack(%0A%20%20%20%20%20%20%20%20%5Bmo.md(f%22%60v27%60%3A%5Cn%60%60%60%5Cn%7B_v27%7D%60%60%60%22)%2C%20mo.md(f%22%60v216%60%3A%5Cn%60%60%60%5Cn%7B_v216%7D%60%60%60%22)%5D%2C%0A%20%20%20%20%20%20%20%20justify%3D%22start%22%2C%0A%20%20%20%20%20%20%20%20gap%3D3%2C%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%20A%20denser%20grid%20means%20more%20colors%20to%20name%2C%20which%20is%20a%20harder%20vocabulary%2C%20but%0A%20%20%20%20it%20also%20means%20many%20more%20closed%20pairs%20constraining%20each%20color%2C%20which%20is%0A%20%20%20%20richer%20evidence%20about%20how%20colors%20relate.%20At%20the%20far%20end%2C%20the%20full%2016-level%0A%20%20%20%20grid%20has%204096%20colors%20and%208.4%20million%20distinct%20closed%20pairs%2C%20of%20which%20a%0A%20%20%20%20100k-line%20corpus%20can%20visit%20only%20about%201%25.%20The%20smallest%20grid%20is%20tiny%3A%2049%0A%20%20%20%20distinct%20closed%20pairs%20at%20%60v27%60%2C%20so%20the%20table%20is%20easy%20to%20memorize%2C%20and%20the%0A%20%20%20%20held-out%20fifth%20of%20it%20asks%20the%20model%20to%20infer%20answers%20from%20very%20little%0A%20%20%20%20evidence.%0A%0A%20%20%20%20%23%23%20Measurements%0A%0A%20%20%20%20From%20the%20next-token%20distribution%20at%20the%20%60%3D%60%20position%20we%20compute%20exact-match%0A%20%20%20%20accuracy%2C%20and%20the%20cross-entropy%20of%20the%20true%20answer%20on%20closed%20pairs%0A%20%20%20%20(where%20a%20single%20answer%20exists).%0A%0A%20%20%20%20For%20all%20pairs%20(including%20open%20pairs)%2C%20we%20also%20find%20the%20graded%20score%20as%20the%0A%20%20%20%20RGB%20distance%20from%20the%20model's%20highest-probability%20color%20to%20the%20true%20mix.%0A%20%20%20%20There%20are%20two%20reference%20distances%20per%20prompt%20to%20compare%20against%3A%20the%20*floor*%0A%20%20%20%20(the%20distance%20from%20the%20true%20mix%20to%20the%20nearest%20vocabulary%20color%2C%20which%20is%0A%20%20%20%20zero%20for%20closed%20pairs)%20and%20*chance*%20(the%20mean%20distance%20over%20the%20whole%0A%20%20%20%20vocabulary%2C%20what%20a%20guesser%20with%20no%20knowledge%20would%20score%20on%20average).%0A%0A%20%20%20%20We%20also%20fit%20probes%20on%20the%20residual%20stream%20to%20inspect%20the%20shape%20of%20the%0A%20%20%20%20latent%20embeddings.%0A%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.**%20Seen%20pairs%20are%20answered%20almost%20perfectly%20on%20every%20grid%3B%20the%20corpus%0A%20%20%20%20gives%20each%20seen%20pair%20many%20effective%20repetitions%2C%20even%20at%20%60v4096%60.%0A%0A%20%20%20%20**H2.**%20Held-out%20accuracy%20rises%20with%20grid%20size.%20%60v27%60%20stays%20near%20zero%2C%20since%0A%20%20%20%2039%20training%20pairs%20constrain%2027%20colors%20only%20weakly.%20At%20the%20other%20end%2C%0A%20%20%20%20%60v4096%60%20can%20barely%20memorize%20even%20its%20seen%20pairs%2C%20so%20if%20it%20learns%20them%20at%20all%0A%20%20%20%20it%20must%20be%20generalizing%2C%20and%20its%20held-out%20accuracy%20should%20come%20close%20to%20its%0A%20%20%20%20seen%20accuracy.%0A%0A%20%20%20%20**H3.**%20Where%20held-out%20accuracy%20is%20high%2C%20guessed%20colors%20on%20open%20pairs%20land%0A%20%20%20%20near%20the%20floor%20distance%2C%20well%20below%20chance%3B%20where%20it%20is%20low%2C%20guesses%20sit%0A%20%20%20%20at%20or%20near%20chance.%0A%0A%20%20%20%20**H4.**%20The%20embedding-to-RGB%20probe's%20R%C2%B2%20and%20the%20low-dimensionality%20of%20the%0A%20%20%20%20embedding%20table%20(top-3%20explained%20variance)%20rise%20with%20grid%20size%2C%20and%20a%20PCA%20of%0A%20%20%20%20the%20embeddings%20shows%20the%20color%20cube%20where%2C%20and%20only%20where%2C%20held-out%0A%20%20%20%20performance%20is%20good.%0A%0A%20%20%20%20**H5.**%20Less%20certain%2C%20so%20a%20watch%20item%3A%20at%20%60v4096%60%20the%20fixed%20100-epoch%20budget%0A%20%20%20%20may%20not%20be%20enough%20for%20the%20rule%20to%20settle.%20If%20that%20happens%2C%20seen%20accuracy%0A%20%20%20%20will%20be%20middling%20too%2C%20and%20the%20run%20would%20be%20telling%20us%20%22undertrained%22%20rather%0A%20%20%20%20than%20%22impossible%22.%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.%20Run%20the%20experiment%2C%20which%20publishes%20metrics%2C%20arrays%2C%20eval%20sets%2C%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%22and%20checkpoints%20when%20it%20finishes%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.3%2Fexperiment.py%20--app%20modal%20--max-containers%209%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%20arrays%2C%20evals%20%3D%20loaded%0A%20%20%20%20return%20arrays%2C%20evals%2C%20metrics%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(evals%2C%20metrics)%3A%0A%20%20%20%20def%20_mean(g%2C%20es%2C%20key)%3A%0A%20%20%20%20%20%20%20%20return%20float(np.mean(%5Bcell_of(metrics%2C%20g%2C%20s)%5B%22sets%22%5D%5Bes%5D%5Bkey%5D%20for%20s%20in%20SEEDS%5D))%0A%0A%20%20%20%20_hold%20%3D%20%7Bg%3A%20_mean(g%2C%20%22named_holdout%22%2C%20%22accuracy%22)%20for%20g%20in%20GRID_NAMES%7D%0A%20%20%20%20_null%20%3D%20%7Bg%3A%20exact_null(g%2C%20evals)%20for%20g%20in%20GRID_NAMES%7D%0A%20%20%20%20mo.md(f%22%22%22%0A%20%20%20%20%20%20%20%20**Headline%20numbers.**%20Mean%20held-out%20accuracy%20by%20grid%3A%0A%20%20%20%20%20%20%20%20%7B%22%2C%20%22.join(f%22%60%7Bg%7D%60%20**%7Bv%3A.2f%7D**%22%20for%20g%2C%20v%20in%20_hold.items())%7D.%0A%20%20%20%20%20%20%20%20On%20every%20grid%20but%20the%20smallest%2C%20that%20is%20far%20above%20what%20a%20model%20knowing%0A%20%20%20%20%20%20%20%20only%20the%20answer's%20neighborhood%20would%20score%0A%20%20%20%20%20%20%20%20(%7B%22%2C%20%22.join(f%22%60%7Bg%7D%60%20%7Bv%3A.2f%7D%22%20for%20g%2C%20v%20in%20_null.items())%7D)%2C%20so%20the%20model%0A%20%20%20%20%20%20%20%20does%20infer%20the%20geometry%20(except%20%60v27%60%2C%20which%20is%20discussed%20below).%20Misses%20are%0A%20%20%20%20%20%20%20%20interesting%3A%20at%20%60v4096%60%20they%20land%20a%20mean%20distance%20of%20just%0A%20%20%20%20%20%20%20%20%7B_mean('v4096'%2C%20'named_holdout'%2C%20'guess_dist')%3A.3f%7D%20from%20the%20true%20mix%0A%20%20%20%20%20%20%20%20(chance%20is%20%7B_mean('v4096'%2C%20'named_holdout'%2C%20'chance_dist')%3A.2f%7D).%20The%0A%20%20%20%20%20%20%20%20sections%20below%20build%20that%20picture%20up%20piece%20by%20piece%2C%20starting%20with%20the%0A%20%20%20%20%20%20%20%20pairs%20the%20corpus%20sampler%20actually%20produced.%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_stats%20%3D%20metrics%5B%22corpus_stats%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%7Bg%7D%3C%2Fcode%3E%3C%2Ftd%3E%22%0A%20%20%20%20%20%20%20%20f'%3Ctd%20class%3D%22num%22%3E%7Bs%5B%22n_colors%22%5D%3A%2C%7D%3C%2Ftd%3E'%0A%20%20%20%20%20%20%20%20f'%3Ctd%20class%3D%22num%22%3E%7Bs%5B%22n_closed_distinct%22%5D%3A%2C%7D%3C%2Ftd%3E'%0A%20%20%20%20%20%20%20%20f'%3Ctd%20class%3D%22num%22%3E%7Bs%5B%22n_seen_distinct%22%5D%3A%2C%7D%3C%2Ftd%3E'%0A%20%20%20%20%20%20%20%20f'%3Ctd%20class%3D%22num%22%3E%7Bs%5B%22n_holdout%22%5D%3A%2C%7D%3C%2Ftd%3E'%0A%20%20%20%20%20%20%20%20f'%3Ctd%20class%3D%22num%22%3E%7Bs%5B%22n_open%22%5D%3A%2C%7D%3C%2Ftd%3E'%0A%20%20%20%20%20%20%20%20%22%3C%2Ftr%3E%22%0A%20%20%20%20%20%20%20%20for%20g%2C%20s%20in%20_stats.items()%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%3Ctable%20class%3D%22report-table%22%3E'%0A%20%20%20%20%20%20%20%20'%3Ctr%3E%3Cth%3Egrid%3C%2Fth%3E%3Cth%20class%3D%22num%22%3Ecolors%3C%2Fth%3E%3Cth%20class%3D%22num%22%3Eclosed%20pairs%3C%2Fth%3E'%0A%20%20%20%20%20%20%20%20'%3Cth%20class%3D%22num%22%3Edistinct%20pairs%20in%20corpus%3C%2Fth%3E%3Cth%20class%3D%22num%22%3Eheld%20out%3C%2Fth%3E'%0A%20%20%20%20%20%20%20%20'%3Cth%20class%3D%22num%22%3Eopen%20pairs%3C%2Fth%3E%3C%2Ftr%3E'%20%2B%20_rows%20%2B%20%22%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%20%22%22%22%0A%20%20%20%20%20%20%20%20Pair%20accounting%20per%20grid.%20%22Closed%20pairs%22%20counts%20the%20distinct%20unordered%20pairs%0A%20%20%20%20%20%20%20%20whose%20mix%20lands%20on%20the%20vocabulary%20(self-pairs%20excluded)%3B%20the%20corpus%20samples%2C%0A%20%20%20%20%20%20%20%20with%20repetition%2C%20from%20the%20side%20that%20isn't%20held%20out.%20At%20%60v4096%60%20the%20corpus%0A%20%20%20%20%20%20%20%20reaches%20about%201%25%20of%20the%20closed%20pairs%2C%20and%20every%20pair%20is%20closed%2C%20so%20there%20are%20no%0A%20%20%20%20%20%20%20%20open%20pairs%20to%20probe.%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_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Training%0A%0A%20%20%20%20All%20twelve%20cells%20train%20stably.%20Each%20grid%20settles%20within%20the%20100-epoch%0A%20%20%20%20budget%2C%20%60v4096%60%20included%2C%20whose%20curve%20is%20flat%20over%20its%20last%20twenty%20epochs.%20So%0A%20%20%20%20the%20results%20that%20follow%20reflect%20what%20this%20budget%20and%20schedule%20produce%20at%0A%20%20%20%20convergence.%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%22val-loss%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%20Validation%20loss%20over%20training%20epochs%2C%20with%20one%20line%20per%20vocabulary%20grid%0A%20%20%20%20%20%20%20%20%20%20%20%20(v27%2C%20v64%2C%20v216%2C%20v4096)%20and%20three%20thin%20overlapping%20lines%20per%20grid%2C%20one%20per%0A%20%20%20%20%20%20%20%20%20%20%20%20seed.%20Larger%20vocabularies%20start%20at%20higher%20loss%2C%20because%20a%20larger%20vocabulary%0A%20%20%20%20%20%20%20%20%20%20%20%20means%20higher%20chance%20cross-entropy.%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%20Validation%20loss%20per%20epoch%2C%20with%20three%20thin%20lines%20per%20grid%2C%20one%20per%20seed.%0A%20%20%20%20%20%20%20%20%20%20%20%20The%20grids%20aren't%20comparable%20to%20each%20other%2C%20since%20chance%20loss%20grows%20with%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20vocabulary%20size%3B%20what%20matters%20here%20is%20that%20each%20curve%20settles.%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.0%2C%203.6))%0A%20%20%20%20%20%20%20%20shades%20%3D%20grid_shades()%0A%20%20%20%20%20%20%20%20for%20g%20in%20GRID_NAMES%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20s%20in%20SEEDS%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20vl%20%3D%20cell_of(metrics%2C%20g%2C%20s)%5B%22val_loss%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(vl%2C%20color%3Dshades%5Bg%5D%2C%20lw%3D1.0%2C%20alpha%3D0.8%2C%20label%3Dg%20if%20s%20%3D%3D%200%20else%20None)%0A%20%20%20%20%20%20%20%20ax.set(xlabel%3D%22epoch%22%2C%20ylabel%3D%22validation%20loss%22)%0A%20%20%20%20%20%20%20%20ax.legend()%0A%20%20%20%20%20%20%20%20ax.grid(alpha%3D0.3)%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%20%23%23%20Exact-match%20accuracy%0A%0A%20%20%20%20Can%20the%20model%20answer%20equations%20it%20has%20never%20seen%3F%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%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%22accuracy%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%20Two%20bar%20panels%20of%20exact-match%20accuracy%20(0%20to%201)%20by%20vocabulary%20grid%20(v27%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20v64%2C%20v216%2C%20v4096)%2C%20one%20panel%20for%20seen%20pairs%20and%20one%20for%20held-out%20pairs.%20Bars%0A%20%20%20%20%20%20%20%20%20%20%20%20show%20the%20mean%20over%20three%20seeds%2C%20and%20dots%20show%20the%20individual%20seeds.%20Seen%0A%20%20%20%20%20%20%20%20%20%20%20%20accuracy%20is%201.0%20everywhere%20except%20v4096%20(0.85).%20Held-out%20accuracy%20is%0A%20%20%20%20%20%20%20%20%20%20%20%20non-monotonic%3A%200.27%2C%200.59%2C%20essentially%201.0%20at%20v216%2C%20then%200.65%20at%20v4096.%0A%20%20%20%20%20%20%20%20%22%22%22%2C%0A%20%20%20%20%20%20%20%20caption%3Dmo.md(%22%22%22%0A%20%20%20%20%20%20%20%20%20%20%20%20Exact-match%20accuracy%20by%20grid.%20Bars%20show%20the%20mean%20over%20three%20seeds%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20dots%20are%20individual%20seeds.%20**Left%3A**%20Seen%20pairs%20show%20whether%0A%20%20%20%20%20%20%20%20%20%20%20%20training%20worked%20at%20all%3B%20**Right%3A**%20held-out%20pairs%20show%0A%20%20%20%20%20%20%20%20%20%20%20%20generalization.%0A%20%20%20%20%20%20%20%20%22%22%22).text%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(8.4%2C%203.2)%2C%20sharey%3DTrue)%0A%20%20%20%20%20%20%20%20shades%20%3D%20grid_shades()%0A%20%20%20%20%20%20%20%20xs%20%3D%20np.arange(len(GRID_NAMES))%0A%20%20%20%20%20%20%20%20for%20ax%2C%20es%20in%20zip(axes%2C%20_sets%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20per_seed%20%3D%20np.array(%5B%5Bcell_of(metrics%2C%20g%2C%20s)%5B%22sets%22%5D%5Bes%5D%5B%22accuracy%22%5D%20for%20s%20in%20SEEDS%5D%20for%20g%20in%20GRID_NAMES%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%5Bg%5D%20for%20g%20in%20GRID_NAMES%5D%2C%20width%3D0.62)%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20i%20in%20range(len(GRID_NAMES))%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%3Dlight_dark(%22%23000%22%2C%20%22%23fff%22)%2C%20ms%3D3%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%20GRID_NAMES)%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(%22exact-match%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_(arrays%2C%20evals%2C%20geom%2C%20metrics)%3A%0A%20%20%20%20def%20_acc(g%2C%20es)%3A%0A%20%20%20%20%20%20%20%20return%20float(np.mean(%5Bcell_of(metrics%2C%20g%2C%20s)%5B%22sets%22%5D%5Bes%5D%5B%22accuracy%22%5D%20for%20s%20in%20SEEDS%5D))%0A%0A%20%20%20%20def%20_z(g%3A%20str)%20-%3E%20float%3A%0A%20%20%20%20%20%20%20%20%22%22%22Held-out%20accuracy%20above%20the%20neighborhood%20null%2C%20in%20standard%20errors.%0A%0A%20%20%20%20%20%20%20%20Pooling%20seeds%20treats%20repeat%20runs%20on%20the%20same%20pairs%20as%20independent%20draws%2C%20so%0A%20%20%20%20%20%20%20%20this%20flatters%20the%20small%20grids%3B%20%60v27%60's%20ten%20pairs%20are%20the%20binding%20limit.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20null%2C%20n%20%3D%20exact_null(g%2C%20evals)%2C%20len(evals%5Bg%5D%5B%22named_holdout%22%5D)%20*%20len(SEEDS)%0A%20%20%20%20%20%20%20%20return%20(_acc(g%2C%20%22named_holdout%22)%20-%20null)%20%2F%20((null%20*%20(1%20-%20null)%20%2F%20n)%20**%200.5)%0A%0A%20%20%20%20_null27%20%3D%20exact_null(%22v27%22%2C%20evals)%0A%20%20%20%20_shell27%20%3D%20(%0A%20%20%20%20%20%20%20%20bl.shell_mask(nc.GRIDS%5B%22v27%22%5D%2C%20raw_rgb(%22v27%22)%2C%20%5Bex.result%20for%20ex%20in%20evals%5B%22v27%22%5D%5B%22named_holdout%22%5D%5D)%0A%20%20%20%20%20%20%20%20.sum(axis%3D1)%0A%20%20%20%20%20%20%20%20.mean()%0A%20%20%20%20)%0A%20%20%20%20_z27%2C%20_z64%2C%20_z216%2C%20_z4096%20%3D%20(_z(g)%20for%20g%20in%20GRID_NAMES)%0A%20%20%20%20_r2_27%20%3D%20geom(%22v27%22%2C%20%22r2%22)%0A%0A%20%20%20%20def%20_miss_structure(g%3A%20str)%20-%3E%20tuple%5Bint%2C%20int%2C%20int%5D%3A%0A%20%20%20%20%20%20%20%20%22%22%22Pooled%20over%20seeds%3A%20(misses%2C%20one-channel%20misses%2C%20of%20those%20off%20by%20one%20level).%22%22%22%0A%20%20%20%20%20%20%20%20exs%20%3D%20evals%5Bg%5D%5B%22named_holdout%22%5D%0A%20%20%20%20%20%20%20%20rgb%20%3D%20np.array(list(PALETTES%5Bg%5D.values()))%0A%20%20%20%20%20%20%20%20lvl%20%3D%20%7Bv%3A%20i%20for%20i%2C%20v%20in%20enumerate(nc.GRIDS%5Bg%5D)%7D%0A%20%20%20%20%20%20%20%20n_miss%20%3D%20n_1ch%20%3D%20n_1lvl%20%3D%200%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%20guesses%20%3D%20rgb%5Barrays%5Bf%22%7Bg%7D-s%7Bs%7D%2Flogp%2Fnamed_holdout%22%5D.argmax(1)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20ex%2C%20gv%20in%20zip(exs%2C%20guesses%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20diff%20%3D%20%5Bint(a%20!%3D%20b)%20for%20a%2C%20b%20in%20zip(gv%2C%20ex.result%2C%20strict%3DTrue)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20sum(diff)%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20n_miss%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20sum(diff)%20%3D%3D%201%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20n_1ch%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20(ch%2C)%20%3D%20%5Bi%20for%20i%2C%20d%20in%20enumerate(diff)%20if%20d%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20n_1lvl%20%2B%3D%20abs(lvl%5Bint(gv%5Bch%5D)%5D%20-%20lvl%5Bex.result%5Bch%5D%5D)%20%3D%3D%201%0A%20%20%20%20%20%20%20%20return%20n_miss%2C%20n_1ch%2C%20n_1lvl%0A%0A%20%20%20%20_m64%2C%20_m216%2C%20_m4096%20%3D%20(_miss_structure(g)%20for%20g%20in%20(%22v64%22%2C%20%22v216%22%2C%20%22v4096%22))%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20Every%20grid%20learns%20its%20seen%20pairs%20almost%20perfectly%2C%20apart%20from%20%60v4096%60%2C%20which%0A%20%20%20%20reaches%20%7B_acc(%22v4096%22%2C%20%22named_seen%22)%3A.2f%7D.%20That%20is%20the%20one%20grid%20where%20even%0A%20%20%20%20the%20training%20pairs%20are%20hard%20to%20memorize%2C%20since%20its%20corpus%20visits%2099k%20distinct%0A%20%20%20%20pairs%20roughly%20once%20each.%20Held-out%20accuracy%20then%20follows%20a%20non-monotonic%20path%3A%0A%20%20%20%20%7B_acc(%22v27%22%2C%20%22named_holdout%22)%3A.2f%7D%20at%20%60v27%60%20(that's%0A%20%20%20%20%7Bround(_acc(%22v27%22%2C%20%22named_holdout%22)%20*%2010)%7D%20of%20its%20ten%20held-out%20pairs)%2C%0A%20%20%20%20%7B_acc(%22v64%22%2C%20%22named_holdout%22)%3A.2f%7D%20at%20%60v64%60%2C%0A%20%20%20%20%7B_acc(%22v216%22%2C%20%22named_holdout%22)%3A.2f%7D%20at%20%60v216%60%2C%20near%20enough%20to%20solved%2C%20and%0A%20%20%20%20back%20down%20to%20%7B_acc(%22v4096%22%2C%20%22named_holdout%22)%3A.2f%7D%20at%20%60v4096%60.%0A%0A%20%20%20%20Only%20three%20of%20those%20four%20numbers%20mean%20much.%20On%20a%2027-color%20grid%20the%20true%20mix%0A%20%20%20%20has%20just%20%7B_shell27%3A.1f%7D%20one-step%20neighbors%20on%20average%2C%20so%20a%20model%20that%20has%0A%20%20%20%20located%20the%20answer's%20neighborhood%20and%20picks%20within%20it%20scores%0A%20%20%20%20%7B_null27%3A.2f%7D%20without%20being%20able%20to%20name%20anything.%20%60v27%60's%0A%20%20%20%20%7B_acc(%22v27%22%2C%20%22named_holdout%22)%3A.2f%7D%20sits%20%7B_z27%3A.1f%7D%20std%20above%0A%20%20%20%20that%2C%20over%20ten%20distinct%20pairs%2C%20which%20is%20not%20a%20difference%20worth%20reading.%20The%0A%20%20%20%20denser%20grids%20clear%20the%20same%20bar%20easily%3A%20%7B_z64%3A.0f%7D%20std%20at%20%60v64%60%2C%0A%20%20%20%20%7B_z216%3A.0f%7D%20at%20%60v216%60%20and%20%7B_z4096%3A.0f%7D%20at%20%60v4096%60.%0A%0A%20%20%20%20So%20%60v27%60's%20score%20is%20not%20evidence%20on%20its%20own.%20It%20is%20tempting%20to%20read%20it%20as%20a%0A%20%20%20%20shift%20from%20the%20base%20language%2C%20where%20%60named_holdout%60%20sat%20at%20zero%20through%0A%20%20%20%20every%20intervention%20ex-2.1.2%20tried%2C%20but%20two%20of%20ten%20pairs%20on%20a%20grid%20this%0A%20%20%20%20coarse%20cannot%20carry%20that.%20The%20case%20that%20the%20geometry%20is%20inferable%20from%20names%0A%20%20%20%20rests%20on%20the%20denser%20grids%20here%2C%20and%20on%20the%20embedding%20probes%20further%20down%2C%0A%20%20%20%20which%20reach%20R%C2%B2%20%E2%89%88%20%7B_r2_27%3A.2f%7D%20even%20at%20%60v27%60.%0A%0A%20%20%20%20The%20%60v4096%60%20misses%20are%20not%20scattered%2C%20either.%20Pooled%20over%20seeds%2C%20%7B_m4096%5B1%5D%7D%0A%20%20%20%20of%20%7B_m4096%5B0%5D%7D%20held-out%20misses%20differ%20from%20the%20true%20mix%20in%20a%20single%20RGB%0A%20%20%20%20channel%2C%20and%20%7B_m4096%5B2%5D%7D%20of%20those%20are%20off%20by%20one%20grid%20level%20(%60v64%60%3A%0A%20%20%20%20%7B_m64%5B2%5D%7D%2F%7B_m64%5B0%5D%7D%3B%20%60v216%60%3A%20%7B_m216%5B2%5D%7D%2F%7B_m216%5B0%5D%7D).%20We%20checked%20whether%0A%20%20%20%20these%20misses%20are%20more%20likely%20on%20rounding%20cases%2C%20meaning%20channels%20where%20the%0A%20%20%20%20operand%20sum%20is%20odd%20so%20the%20mean%20has%20to%20round%2C%20and%20they%20don't%3A%20about%20half%20of%0A%20%20%20%20the%20one-channel%20misses%20are%20rounding%20cases%2C%20which%20matches%20chance.%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%20Closeness%0A%0A%20%20%20%20Let's%20switch%20to%20the%20graded%20view.%20For%20every%20prompt%20we%20take%20the%20model's%0A%20%20%20%20highest-probability%20color%20and%20measure%20its%20RGB%20distance%20to%20the%20true%20mix%2C%20and%0A%20%20%20%20plot%20the%20cumulative%20distribution.%20For%20each%20distance%20x%2C%20the%20curve%20shows%20the%0A%20%20%20%20fraction%20of%20prompts%20that%20landed%20within%20x%20of%20the%20answer.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(arrays%2C%20evals)%3A%0A%20%20%20%20_panels%20%3D%20%5B(%22named_holdout%22%2C%20%22held-out%20pairs%22)%2C%20(%22open%22%2C%20%22open%20pairs%22)%5D%0A%0A%20%20%20%20%40themed(%0A%20%20%20%20%20%20%20%20name%3D%22distance-ecdf%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%20Two%20panels%20of%20cumulative%20distributions%20of%20the%20RGB%20distance%20from%20the%20model's%0A%20%20%20%20%20%20%20%20%20%20%20%20guessed%20color%20to%20the%20true%20mix%2C%20pooled%20over%20three%20seeds%2C%20one%20panel%20for%0A%20%20%20%20%20%20%20%20%20%20%20%20held-out%20pairs%20and%20one%20for%20open%20pairs.%20One%20line%20per%20vocabulary%20grid.%20A%20dashed%0A%20%20%20%20%20%20%20%20%20%20%20%20line%20shows%20the%20nearest-name%20floor%20on%20open%20pairs.%20Triangles%20under%20the%20x-axis%0A%20%20%20%20%20%20%20%20%20%20%20%20mark%20the%20prompt-blind%20constant%20baseline.%20Every%20grid's%20curve%20stays%20close%20to%20its%0A%20%20%20%20%20%20%20%20%20%20%20%20floor%20and%20well%20to%20the%20left%20of%20the%20reference%3B%20v216%20and%20v4096%20rise%20to%201%20within%20a%0A%20%20%20%20%20%20%20%20%20%20%20%20fraction%20of%20the%20chance%20distance.%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%20How%20close%20do%20guesses%20land%3F%20Each%20line%20is%20the%20cumulative%20distribution%20of%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20distance%20from%20the%20guess%20to%20the%20true%20mix%20(in%20unit-cube%20units%2C%20pooled%20over%0A%20%20%20%20%20%20%20%20%20%20%20%20seeds)%3B%20higher%20and%20further%20to%20the%20left%20is%20better.%20On%20held-out%20pairs%20an%20exact%0A%20%20%20%20%20%20%20%20%20%20%20%20answer%20exists%2C%20so%20the%20height%20at%20distance%200%20is%20the%20exact-match%20accuracy.%20On%0A%20%20%20%20%20%20%20%20%20%20%20%20open%20pairs%20no%20name%20is%20quite%20right%2C%20so%20the%20dashed%20line%20shows%20the%20best%0A%20%20%20%20%20%20%20%20%20%20%20%20achievable%20(nearest-name)%20distance%20there.%20The%20triangles%20under%20the%20x-axis%20are%0A%20%20%20%20%20%20%20%20%20%20%20%20the%20prompt-blind%20constant%2C%20the%20score%20for%20always%20answering%20the%20center%20of%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20training%20answers.%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(_panels)%2C%20figsize%3D(8.4%2C%203.4)%2C%20sharey%3DTrue)%0A%20%20%20%20%20%20%20%20shades%20%3D%20grid_shades()%0A%20%20%20%20%20%20%20%20for%20ax%2C%20(es%2C%20title)%20in%20zip(axes%2C%20_panels%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20g%20in%20GRID_NAMES%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20es%20not%20in%20evals%5Bg%5D%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20exs%20%3D%20evals%5Bg%5D%5Bes%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20gd%20%3D%20np.concatenate(%5Bdists_for(g%2C%20exs%2C%20arrays%5Bf%22%7Bg%7D-s%7Bs%7D%2Flogp%2F%7Bes%7D%22%5D)%5B0%5D%20for%20s%20in%20SEEDS%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20fl%20%3D%20dists_for(g%2C%20exs%2C%20arrays%5Bf%22%7Bg%7D-s0%2Flogp%2F%7Bes%7D%22%5D)%5B1%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20xs%20%3D%20np.sort(gd)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(xs%2C%20np.arange(1%2C%20len(xs)%20%2B%201)%20%2F%20len(xs)%2C%20color%3Dshades%5Bg%5D%2C%20lw%3D1.6%2C%20label%3Dg)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20es%20%3D%3D%20%22open%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20xf%20%3D%20np.sort(fl)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(xf%2C%20np.arange(1%2C%20len(xf)%20%2B%201)%20%2F%20len(xf)%2C%20color%3Dshades%5Bg%5D%2C%20lw%3D1.0%2C%20ls%3D%22--%22%2C%20alpha%3D0.7)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20blind%20%3D%20bl.blind_stats(dist_matrix(g%2C%20exs)%2C%20blind_for(g%2C%20evals))%5B%22dist%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(%5Bblind%5D%2C%20%5B-0.02%5D%2C%20marker%3D%22%5E%22%2C%20ms%3D4%2C%20color%3Dshades%5Bg%5D%2C%20clip_on%3DFalse)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set(title%3Dtitle%2C%20xlabel%3D%22distance%20to%20true%20mix%22%2C%20xlim%3D(-0.02%2C%201.0)%2C%20ylim%3D(-0.03%2C%201.03))%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(%22fraction%20of%20prompts%20%E2%89%A4%20x%22)%0A%20%20%20%20%20%20%20%20axes%5B0%5D.legend(loc%3D%22lower%20right%22%2C%20fontsize%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_(arrays%2C%20evals%2C%20metrics)%3A%0A%20%20%20%20def%20_mean(g%2C%20es%2C%20key)%3A%0A%20%20%20%20%20%20%20%20return%20float(np.mean(%5Bcell_of(metrics%2C%20g%2C%20s)%5B%22sets%22%5D%5Bes%5D%5Bkey%5D%20for%20s%20in%20SEEDS%5D))%0A%0A%20%20%20%20_open%20%3D%20%5Bg%20for%20g%20in%20GRID_NAMES%20if%20evals%5Bg%5D.get(%22open%22)%5D%0A%0A%20%20%20%20def%20_row(g)%3A%0A%20%20%20%20%20%20%20%20exs%20%3D%20evals%5Bg%5D%5B%22open%22%5D%0A%20%20%20%20%20%20%20%20d%20%3D%20dist_matrix(g%2C%20exs)%0A%20%20%20%20%20%20%20%20gd%20%3D%20np.mean(%5Bd%5Bnp.arange(len(exs))%2C%20arrays%5Bf%22%7Bg%7D-s%7Bs%7D%2Flogp%2Fopen%22%5D.argmax(1)%5D.mean()%20for%20s%20in%20SEEDS%5D)%0A%20%20%20%20%20%20%20%20two%2C%20blind%20%3D%20bl.k_nearest_stats(d%2C%202)%2C%20bl.blind_stats(d%2C%20blind_for(g%2C%20evals))%0A%20%20%20%20%20%20%20%20cells%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%60%7Bg%7D%60%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bgd%3A.3f%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bd.min(axis%3D1).mean()%3A.3f%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Btwo%5B'dist'%5D%3A.3f%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bblind%5B'dist'%5D%3A.3f%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bd.mean()%3A.3f%7D%22%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20return%20%22%3Ctr%3E%22%20%2B%20%22%22.join(f'%3Ctd%20class%3D%22num%22%3E%7Bc%7D%3C%2Ftd%3E'%20for%20c%20in%20cells)%20%2B%20%22%3C%2Ftr%3E%22%0A%0A%20%20%20%20_head%20%3D%20(%0A%20%20%20%20%20%20%20%20'%3Ctr%3E%3Cth%3Egrid%3C%2Fth%3E%3Cth%20class%3D%22num%22%3Emodel%3C%2Fth%3E%3Cth%20class%3D%22num%22%3Efloor%3C%2Fth%3E'%0A%20%20%20%20%20%20%20%20'%3Cth%20class%3D%22num%22%3E2%20nearest%3C%2Fth%3E%3Cth%20class%3D%22num%22%3Eprompt-blind%3C%2Fth%3E'%0A%20%20%20%20%20%20%20%20'%3Cth%20class%3D%22num%22%3Echance%3C%2Fth%3E%3C%2Ftr%3E'%0A%20%20%20%20)%0A%20%20%20%20_table%20%3D%20figure_html(%0A%20%20%20%20%20%20%20%20f'%3Cdiv%20class%3D%22report-table-scroll%22%3E%3Ctable%20class%3D%22report-table%22%3E%7B_head%7D'%0A%20%20%20%20%20%20%20%20%2B%20%22%22.join(_row(g)%20for%20g%20in%20_open)%0A%20%20%20%20%20%20%20%20%2B%20%22%3C%2Ftable%3E%3C%2Fdiv%3E%22%2C%0A%20%20%20%20%20%20%20%20caption%3D%22Mean%20distance%20to%20the%20true%20mix%20on%20open%20pairs%2C%20against%20four%20references.%22%2C%0A%20%20%20%20%20%20%20%20class_%3D%22report-figure%22%2C%0A%20%20%20%20)%0A%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20Guesses%20are%20better%20than%20chance%20everywhere%2C%20and%20comfortably%20inside%20the%0A%20%20%20%20prompt-blind%20constant%2C%20which%20is%20stricter%3A%20mixes%20are%20midpoints%2C%0A%20%20%20%20so%20they%20cluster%20centrally%2C%20and%20always%20answering%20the%20middle%20name%20scores%0A%20%20%20%20%7Bbl.blind_stats(dist_matrix(%22v27%22%2C%20evals%5B%22v27%22%5D%5B%22open%22%5D)%2C%20blind_for(%22v27%22%2C%20evals))%5B%22dist%22%5D%3A.2f%7D%0A%20%20%20%20on%20%60v27%60%20open%20pairs%20where%20chance%20is%20%7B_mean(%22v27%22%2C%20%22open%22%2C%20%22chance_dist%22)%3A.2f%7D.%0A%20%20%20%20That%20much%20supports%20H3's%20picture.%0A%0A%20%20%20%20%7B_table%7D%0A%0A%20%20%20%20The%20floor%20is%20a%20harder%20reference%20than%20it%20looks%2C%20though%2C%20because%20it%20asks%20the%0A%20%20%20%20model%20to%20break%20a%20tie%20it%20may%20have%20no%20way%20to%20break.%20An%20open%20mix%20falls%20between%0A%20%20%20%20grid%20points%2C%20so%20two%20names%20bracket%20it%2C%20often%20at%20the%20same%20distance.%20A%20model%0A%20%20%20%20that%20has%20located%20the%20answer%20but%20picks%20between%20those%20two%20at%20random%20is%20the%0A%20%20%20%20%222%20nearest%22%20column%2C%20and%20every%20grid%20sits%20behind%20it%3A%20%60v27%60%20guesses%0A%20%20%20%20%7B_mean(%22v27%22%2C%20%22open%22%2C%20%22guess_dist%22)%3A.3f%7D%20against%20that%20baseline's%0A%20%20%20%20%7Bbl.k_nearest_stats(dist_matrix(%22v27%22%2C%20evals%5B%22v27%22%5D%5B%22open%22%5D)%2C%202)%5B%22dist%22%5D%3A.3f%7D.%0A%20%20%20%20On%20the%20nearest-name%20rate%20the%20gap%20is%20wider%2C%20%7B_mean(%22v27%22%2C%20%22open%22%2C%20%22nearest_acc%22)%3A.2f%7D%0A%20%20%20%20against%20%7Bbl.k_nearest_stats(dist_matrix(%22v27%22%2C%20evals%5B%22v27%22%5D%5B%22open%22%5D)%2C%202)%5B%22nearest%22%5D%3A.2f%7D.%0A%20%20%20%20So%20the%20guesses%20are%20near%20the%20true%0A%20%20%20%20mix%2C%20but%20not%20as%20near%20as%20a%20model%20with%20the%20same%20positional%20knowledge%20and%20a%0A%20%20%20%20coin%20could%20get.%0A%0A%20%20%20%20H3%20predicted%20near-floor%20guessing%20only%20where%20exact-match%20accuracy%20was%20high%2C%0A%20%20%20%20but%20the%20graded%20signal%20does%20turn%20out%20to%20be%20present%20even%20where%20exact-match%0A%20%20%20%20accuracy%20is%20low.%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%20Embedding%20geometry%0A%0A%20%20%20%20The%20behavior%20suggests%20the%20model%20knows%20where%20the%20colors%20are%20in%20the%20cube.%0A%20%20%20%20Since%20colors%20are%20single%20tokens%2C%20everything%20the%20model%20knows%20about%20a%20color's%0A%20%20%20%20identity%20must%20live%20in%20that%20token's%20embedding.%20If%20the%20model%20inferred%0A%20%20%20%20the%20hidden%20space%2C%20the%20embedding%20table%20should%20hold%20a%20color%20cube%3A%20some%20linear%0A%20%20%20%20view%20of%20the%2064-dimensional%20embeddings%20under%20which%20the%20tokens%20arrange%0A%20%20%20%20themselves%20by%20their%20RGB%20values.%20A%20ridge%20probe%20from%20embeddings%20to%20RGB%0A%20%20%20%20measures%20how%20true%20that%20is%2C%20and%20a%20PCA%20projection%20(principal%20component%0A%20%20%20%20analysis%2C%20which%20finds%20the%20few%20directions%20along%20which%20the%20vectors%20vary%20most)%0A%20%20%20%20gives%20an%20unsupervised%20look%20at%20the%20table's%20dominant%20structure.%0A%0A%20%20%20%20We'll%20look%20twice%3A%20first%20with%20PCA%2C%20which%20is%20unsupervised%20and%20so%20answers%20%22what%0A%20%20%20%20is%20this%20table%20mostly%20doing%3F%22%2C%20then%20with%20the%20probe's%20own%20weights%2C%20which%0A%20%20%20%20answer%20the%20narrower%20question.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(arrays)%3A%0A%20%20%20%20def%20_geometry(g%3A%20str%2C%20s%3A%20int)%20-%3E%20dict%3A%0A%20%20%20%20%20%20%20%20%22%22%22Where%20a%20grid's%20color%20tokens%20sit%2C%20read%20through%20a%20probe%20rather%20than%20through%20variance.%22%22%22%0A%20%20%20%20%20%20%20%20emb%2C%20rgb%20%3D%20arrays%5Bf%22%7Bg%7D-s%7Bs%7D%2Fembeddings%22%5D%2C%20VOCAB_RGB%5Bg%5D%0A%20%20%20%20%20%20%20%20centered%20%3D%20emb%20-%20emb.mean(0)%0A%20%20%20%20%20%20%20%20%23%20Leave-one-out%2C%20so%20no%20token%20helps%20place%20itself%20and%20there%20is%20no%20split%20to%20draw%3A%0A%20%20%20%20%20%20%20%20%23%20a%20vocabulary%20of%2027%20is%20small%20enough%20that%20which%20fold%20a%20token%20lands%20in%20would%0A%20%20%20%20%20%20%20%20%23%20otherwise%20move%20the%20answer.%0A%20%20%20%20%20%20%20%20pred%20%3D%20ridge_probe_loo(emb%2C%20rgb)%0A%20%20%20%20%20%20%20%20ss_res%20%3D%20((pred%20-%20rgb)%20**%202).sum(0)%20%2F%20((rgb%20-%20rgb.mean(0))%20**%202).sum(0)%0A%20%20%20%20%20%20%20%20%23%20How%20much%20of%20the%20table's%20variation%20the%20probe's%203-d%20read-out%20subspace%20holds%2C%20against%0A%20%20%20%20%20%20%20%20%23%20the%20most%20any%20three%20directions%20could.%20PCA%20can%20only%20find%20the%20cube%20when%20this%20is%20near%0A%20%20%20%20%20%20%20%20%23%201%2C%20whatever%20the%20probe%20says.%20Descriptive%20rather%20than%20predictive%20%E2%80%94%20it%20asks%20where%20the%0A%20%20%20%20%20%20%20%20%23%20full%20table's%20variance%20sits%2C%20so%20it%20uses%20the%20full%20fit.%0A%20%20%20%20%20%20%20%20w%2C%20*_%20%3D%20ridge_probe(emb%2C%20rgb%2C%20emb%2C%20rgb)%0A%20%20%20%20%20%20%20%20q%2C%20_%20%3D%20np.linalg.qr(w)%0A%20%20%20%20%20%20%20%20top3%20%3D%20(np.linalg.svd(centered%2C%20compute_uv%3DFalse)%5B%3A3%5D%20**%202).sum()%0A%20%20%20%20%20%20%20%20%23%20R%C2%B2%20is%20scale-free%2C%20which%20hides%20whether%20the%20leftover%20error%20is%20small%20*for%20this%20grid*.%0A%20%20%20%20%20%20%20%20%23%20Measuring%20it%20in%20grid%20cells%20asks%20that%20directly.%0A%20%20%20%20%20%20%20%20err%20%3D%20np.linalg.norm(pred%20-%20rgb%2C%20axis%3D1).mean()%0A%20%20%20%20%20%20%20%20cell%20%3D%20float(np.mean(np.diff(nc.GRIDS%5Bg%5D)))%20%2F%20(N_LEVELS%20-%201)%0A%20%20%20%20%20%20%20%20return%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22r2%22%3A%20float((1%20-%20ss_res).mean())%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22pred%22%3A%20pred%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22share%22%3A%20float(((centered%20%40%20q)%20**%202).sum()%20%2F%20top3)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22err_rgb%22%3A%20float(err)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22err_cells%22%3A%20float(err%20%2F%20cell)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20A%20mean%20under%20one%20cell%20does%20not%20imply%20a%20token%20decodes%20to%20its%20own%20name%3A%20a%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Voronoi%20cell%20reaches%20only%20half%20a%20step%2C%20and%20the%20mean%20hides%20the%20tail.%20Ask%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20directly%20instead.%0A%20%20%20%20%20%20%20%20%20%20%20%20%22self_nearest%22%3A%20bl.self_nearest_rate(raw_rgb(g)%2C%20pred)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20geometry%20%3D%20%7B(g%2C%20s)%3A%20_geometry(g%2C%20s)%20for%20g%20in%20GRID_NAMES%20for%20s%20in%20SEEDS%7D%0A%0A%20%20%20%20def%20geom(g%3A%20str%2C%20key%3A%20str)%20-%3E%20float%3A%0A%20%20%20%20%20%20%20%20%22%22%22One%20grid's%20geometry%20number%2C%20averaged%20over%20seeds.%22%22%22%0A%20%20%20%20%20%20%20%20return%20float(np.mean(%5Bgeometry%5B(g%2C%20s)%5D%5Bkey%5D%20for%20s%20in%20SEEDS%5D))%0A%0A%20%20%20%20return%20geom%2C%20geometry%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(arrays%2C%20metrics)%3A%0A%20%20%20%20%40themed(%0A%20%20%20%20%20%20%20%20name%3D%22embedding-pca%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%20scatter%20panels%2C%20one%20per%20vocabulary%20grid%2C%20showing%20the%20first%20two%0A%20%20%20%20%20%20%20%20%20%20%20%20principal%20components%20of%20each%20grid's%20color-token%20embeddings%2C%20with%20every%20point%0A%20%20%20%20%20%20%20%20%20%20%20%20drawn%20in%20the%20color%20it%20names.%20v27%20and%20v64%20show%20loose%20clusters%20with%20only%20rough%0A%20%20%20%20%20%20%20%20%20%20%20%20color%20grouping%3B%20v216%20shows%20a%20clear%20gradient%20organized%20by%20hue%3B%20v4096%20shows%20a%0A%20%20%20%20%20%20%20%20%20%20%20%20smooth%20color%20wheel%2C%20with%20hues%20arranged%20around%20a%20disc%20and%20darker%20colors%20toward%0A%20%20%20%20%20%20%20%20%20%20%20%20the%20middle.%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%20The%20embedding%20table%2C%20projected%20onto%20its%20own%20first%20two%20principal%20components%0A%20%20%20%20%20%20%20%20%20%20%20%20(seed%200)%2C%20with%20each%20token%20drawn%20in%20the%20color%20it%20names.%20Only%20%60v4096%60%20shows%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20hue%20wheel%20we%20thought%20we%20might%20find.%20The%20percentage%20is%20how%20much%20of%20the%20table's%0A%20%20%20%20%20%20%20%20%20%20%20%20variance%20its%20leading%20*three*%20components%20hold%20%E2%80%94%20the%20most%20any%20three%20directions%0A%20%20%20%20%20%20%20%20%20%20%20%20could%20%E2%80%94%20of%20which%20the%20panel%20draws%20the%20leading%20two.%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(GRID_NAMES)%2C%20figsize%3D(11.5%2C%203.1))%0A%20%20%20%20%20%20%20%20for%20ax%2C%20g%20in%20zip(axes%2C%20GRID_NAMES%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20emb%20%3D%20arrays%5Bf%22%7Bg%7D-s0%2Fembeddings%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20centered%20%3D%20emb%20-%20emb.mean(0)%0A%20%20%20%20%20%20%20%20%20%20%20%20_%2C%20_%2C%20vt%20%3D%20np.linalg.svd(centered%2C%20full_matrices%3DFalse)%0A%20%20%20%20%20%20%20%20%20%20%20%20z%20%3D%20centered%20%40%20vt%5B%3A2%5D.T%0A%20%20%20%20%20%20%20%20%20%20%20%20z%20%2F%3D%20np.abs(z).max()%20%2B%201e-9%0A%20%20%20%20%20%20%20%20%20%20%20%20n%20%3D%20len(emb)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.scatter(z%5B%3A%2C%200%5D%2C%20z%5B%3A%2C%201%5D%2C%20c%3DVOCAB_RGB%5Bg%5D%2C%20s%3Dfloat(np.clip(6_000%20%2F%20n%2C%204%2C%2050))%2C%20lw%3D0)%0A%20%20%20%20%20%20%20%20%20%20%20%20evr3%20%3D%20np.mean(%5Bcell_of(metrics%2C%20g%2C%20s)%5B%22emb_evr3%22%5D%20for%20s%20in%20SEEDS%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set_title(f%22%7Bg%7D%20%20%20(top%203%3A%20%7Bevr3%3A.0%25%7D)%22%2C%20fontsize%3D10)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set_aspect(%22equal%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set_xlim(-1.1%2C%201.1)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set_ylim(-1.1%2C%201.1)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set_axis_off()%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_(geom)%3A%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20The%20PCA%20plots%20give%20the%20impression%20the%20cube%20arrives%20late%20%E2%80%94%20somewhere%20between%0A%20%20%20%20%60v216%60%20and%20%60v4096%60%20%E2%80%94%20but%20it%20doesn't.%20PCA%20keeps%20the%20directions%20along%20which%20the%0A%20%20%20%20table%20varies%20most%2C%20and%20apparently%20color%20is%20not%20what%20the%20table%20mostly%20does.%0A%20%20%20%20These%20embeddings%20are%20also%20the%20tied%20language%20model%20head%20for%20predicting%20the%0A%20%20%20%20next%20token%2C%20so%20perhaps%20two%20adjacent%20colors%20need%20well-separated%20directions%0A%20%20%20%20for%20the%20softmax%20to%20keep%20them%20apart%2C%20even%20when%20their%20color%20values%20are%20nearly%0A%20%20%20%20identical.%0A%0A%20%20%20%20A%20cube%20needs%20three%20directions.%20A%20couple%20of%20natural%20ways%20to%20pick%20them%20are%3A%0A%0A%20%20%20%20-%20PCA%3A%20Pick%20the%20three%20directions%20the%20table%20varies%20most%20along.%20The%20amount%20of%0A%20%20%20%20%20%20the%20total%20variance%20captured%20by%20those%20directions%20is%20shown%20as%20the%0A%20%20%20%20%20%20percentages%20on%20the%20panels%20above.%0A%20%20%20%20-%20Probe%3A%20Fit%20to%20predict%20RGB%20and%20indifferent%20to%20how%20much%20the%20table%20varies%0A%20%20%20%20%20%20along%20them.%0A%0A%20%20%20%20How%20well%20do%20they%20agree%20in%20this%20case%3F%20If%20representing%20color%20is%20what%20the%20table%0A%20%20%20%20mostly%20does%2C%20the%20probe%20should%20be%20reading%20close%20to%20the%20top-variance%0A%20%20%20%20directions%20and%20the%20two%20should%20capture%20similar%20amounts.%20They%20don't%2C%20at%20least%0A%20%20%20%20not%20until%20the%20vocabulary%20gets%20large.%20The%20probe's%20directions%20hold%0A%20%20%20%20%7Bgeom(%22v27%22%2C%20%22share%22)%3A.0%25%7D%20as%20much%20variance%20as%20the%20best%20three%20at%20%60v27%60%20and%0A%20%20%20%20%7Bgeom(%22v64%22%2C%20%22share%22)%3A.0%25%7D%20at%20%60v64%60%2C%20then%20%7Bgeom(%22v216%22%2C%20%22share%22)%3A.0%25%7D%20at%0A%20%20%20%20%60v216%60%20and%20%7Bgeom(%22v4096%22%2C%20%22share%22)%3A.0%25%7D%20at%20%60v4096%60.%20So%20it%20is%20only%20at%20the%0A%20%20%20%20dense%20end%20that%20the%20color%20directions%20and%20the%20high-variance%20directions%20are%0A%20%20%20%20nearly%20the%20same%20thing%20%E2%80%94%20and%20only%20there%20that%20PCA%20stumbles%20onto%20the%20cube.%0A%0A%20%20%20%20Let's%20see%20what%20the%20probe%20found.%20Its%20weights%20are%20a%20map%20from%20the%0A%20%20%20%2064-dimensional%20embedding%20onto%20RGB%2C%20so%20we%20can%20use%20it%20to%20decode%20the%20color%0A%20%20%20%20tokens.%20If%20the%20table%20holds%20a%20color%20cube%2C%20the%20decoded%20values%20should%20be%0A%20%20%20%20similar%20to%20the%20source%20data.%20To%20keep%20this%20from%20being%20a%20statement%20about%20the%0A%20%20%20%20probe's%20memory%20rather%20than%20the%20model's%20geometry%2C%20every%20token%20is%20placed%20by%20a%0A%20%20%20%20probe%20fit%20on%20every%20*other*%20token%20in%20the%20vocabulary.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(geom%2C%20geometry)%3A%0A%20%20%20%20%40themed(%0A%20%20%20%20%20%20%20%20name%3D%22embedding-probe-cube%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%20hexagonal%20panels%2C%20one%20per%20vocabulary%20grid%2C%20showing%20where%20the%20probe%20places%0A%20%20%20%20%20%20%20%20%20%20%20%20each%20color%20token%20in%20the%20RGB%20cube%2C%20viewed%20down%20the%20cube's%20grey%20diagonal%20so%20hue%0A%20%20%20%20%20%20%20%20%20%20%20%20runs%20around%20the%20panel%20and%20the%20six%20chromatic%20corners%20sit%20on%20the%20rim.%20Filled%20dots%0A%20%20%20%20%20%20%20%20%20%20%20%20are%20where%20a%20token%20landed%2C%20open%20rings%20its%20true%20position%2C%20joined%20by%20a%20short%20stub.%0A%20%20%20%20%20%20%20%20%20%20%20%20At%20v27%20many%20dots%20sit%20well%20away%20from%20their%20rings%3B%20v64%20is%20closer%3B%20v216%20has%20dots%0A%20%20%20%20%20%20%20%20%20%20%20%20almost%20on%20top%20of%20their%20rings%2C%20forming%20an%20even%20hue%20wheel%3B%20v4096%20is%20a%20dense%20wheel%0A%20%20%20%20%20%20%20%20%20%20%20%20shown%20without%20rings.%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%20The%20same%20embedding%20tables%20(seed%200)%2C%20now%20read%20through%20the%20probe%20instead%20of%0A%20%20%20%20%20%20%20%20%20%20%20%20through%20variance%3A%20each%20token%20is%20placed%20at%20the%20RGB%20the%20probe%20predicts%20for%20it%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20and%20drawn%20in%20the%20color%20it%20actually%20names.%20Open%20rings%20mark%20where%20a%20token%20should%0A%20%20%20%20%20%20%20%20%20%20%20%20sit%2C%20so%20the%20displacement%20(lines)%20show%20the%20error.%20%60R%C2%B2%60%20is%20the%20same%20fit%20as%20a%0A%20%20%20%20%20%20%20%20%20%20%20%20single%20number%2C%20averaged%20over%20seeds.%20Rings%20are%20left%20off%20at%20%60v4096%60%2C%20where%204096%0A%20%20%20%20%20%20%20%20%20%20%20%20of%20them%20would%20bury%20the%20colors.%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(GRID_NAMES)%2C%20figsize%3D(11.5%2C%203.1))%0A%20%20%20%20%20%20%20%20for%20ax%2C%20g%20in%20zip(axes%2C%20GRID_NAMES%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20rgb%20%3D%20VOCAB_RGB%5Bg%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20n%20%3D%20len(rgb)%0A%20%20%20%20%20%20%20%20%20%20%20%20plot_rgb_cube(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20geometry%5B(g%2C%200)%5D%5B%22pred%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rgb%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20view%3D%22wheel%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20truth%3Drgb%20if%20n%20%3C%3D%20216%20else%20None%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20s%3Dfloat(np.clip(6_000%20%2F%20n%2C%203%2C%2024))%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set_title(f%22%7Bg%7D%20%20%20(R%C2%B2%20%7Bgeom(g%2C%20'r2')%3A.2f%7D)%22%2C%20fontsize%3D10)%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_(geom%2C%20metrics)%3A%0A%20%20%20%20def%20_cell_mean(g%3A%20str%2C%20key%3A%20str)%20-%3E%20float%3A%0A%20%20%20%20%20%20%20%20return%20float(np.mean(%5Bcell_of(metrics%2C%20g%2C%20s)%5Bkey%5D%20for%20s%20in%20SEEDS%5D))%0A%0A%20%20%20%20_evr%20%3D%20%7Bg%3A%20_cell_mean(g%2C%20%22emb_evr3%22)%20for%20g%20in%20GRID_NAMES%7D%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20So%20the%20cube%20geometry%20is%20in%20the%20embedding%20table%2C%20even%20in%20the%20smallest%20model.%0A%20%20%20%20%60v216%60%20is%20the%20clearest%20case%3A%20held-out%20tokens%20land%20almost%20exactly%20on%20their%0A%20%20%20%20own%20lattice%20sites%2C%20a%20hue%20wheel%20with%20greys%20in%20the%20middle%2C%20from%20a%20table%20whose%0A%20%20%20%20principal%20components%20showed%20only%20a%20smear.%20%60v64%60%20is%20recognizably%20the%20same%0A%20%20%20%20shape%20with%20visible%20slop%2C%20and%20even%20%60v27%60%20has%20most%20of%20its%20colors%20in%20the%20right%0A%20%20%20%20neighborhood.%0A%0A%20%20%20%20Probe%20R%C2%B2%20quantifies%20how%20well%20it%20fit%3A%20%7Bgeom(%22v27%22%2C%20%22r2%22)%3A.2f%7D%2C%0A%20%20%20%20%7Bgeom(%22v64%22%2C%20%22r2%22)%3A.2f%7D%2C%20%7Bgeom(%22v216%22%2C%20%22r2%22)%3A.2f%7D%2C%20%7Bgeom(%22v4096%22%2C%20%22r2%22)%3A.2f%7D%0A%20%20%20%20across%20the%20four%20grids.%5B%5Efolds%5D%20From%20%60v64%60%20up%2C%20RGB%20is%20close%20to%20a%20linear%0A%20%20%20%20function%20of%20the%20embedding.%0A%0A%20%20%20%20Does%20a%20probe-decoded%20token%20land%20nearer%20its%20own%20name%20than%20any%20other%3F%0A%0A%20%20%20%20%7C%20grid%20%7C%20nearest%20name%20is%20its%20own%20%7C%0A%20%20%20%20%7C%20---%20%7C%20---%20%7C%0A%20%20%20%20%7C%20%60v27%60%20%7C%20%7Bgeom(%22v27%22%2C%20%22self_nearest%22)%3A.0%25%7D%20%7C%0A%20%20%20%20%7C%20%60v64%60%20%7C%20%7Bgeom(%22v64%22%2C%20%22self_nearest%22)%3A.0%25%7D%20%7C%0A%20%20%20%20%7C%20%60v216%60%20%7C%20%7Bgeom(%22v216%22%2C%20%22self_nearest%22)%3A.0%25%7D%20%7C%0A%20%20%20%20%7C%20%60v4096%60%20%7C%20%7Bgeom(%22v4096%22%2C%20%22self_nearest%22)%3A.0%25%7D%20%7C%0A%0A%20%20%20%20At%20%60v27%60%20the%20answer%20is%20a%20coin%20flip.%20%60v4096%60%20makes%20the%20same%20point%20from%20the%0A%20%20%20%20other%20end%3A%20its%20R%C2%B2%20of%20%7Bgeom(%22v4096%22%2C%20%22r2%22)%3A.2f%7D%20is%20respectable%2C%20but%20sixteen%0A%20%20%20%20levels%20per%20channel%20pack%20the%20names%20so%20tightly%20that%20a%20decoded%20token%20is%20almost%0A%20%20%20%20never%20nearest%20its%20own.%20So%20the%20probe%20finds%20the%20cube%2C%20but%20it%20does%20not%20decode%0A%20%20%20%20individual%20tokens%20well%20enough%20to%20name%20them%20at%20any%20of%20these%20grid%20sizes.%0A%0A%20%20%20%20H4%20expected%20the%20embedding%20table%20itself%20to%20turn%20low-dimensional%2C%20and%20the%20PCA%0A%20%20%20%20says%20it%20doesn't%3A%20even%20the%20best%20three%20directions%20hold%20only%20%7B_evr%5B%22v27%22%5D%3A.0%25%7D%0A%20%20%20%20of%20the%20variance%20at%20%60v27%60%2C%20and%20that%20falls%20to%20%7B_evr%5B%22v4096%22%5D%3A.0%25%7D%20at%20%60v4096%60.%0A%20%20%20%20The%20cube%20is%20in%20there%20as%20a%20subspace%20the%20probe%20can%20read%2C%20but%20most%20of%20the%0A%20%20%20%20embedding%20variance%20is%20doing%20something%20else.%0A%0A%20%20%20%20%5B%5Efolds%5D%3A%20Probes%20fit%20per-color%20with%20leave-one-out%2C%20which%20matters%20most%20at%20the%0A%20%20%20%20small%20grids.%20A%20single%20half%2Fhalf%20split%20leaves%20%60v27%60's%20probe%20fitting%20a%2064%E2%86%923%0A%20%20%20%20map%20from%2013%20points%2C%20and%20scores%20it%20%7B_cell_mean(%22v27%22%2C%20%22emb_r2%22)%3A.2f%7D%20against%0A%20%20%20%20%7Bgeom(%22v27%22%2C%20%22r2%22)%3A.2f%7D%20here%3B%20%60v4096%60%20is%20unmoved%20either%20way%0A%20%20%20%20(%7B_cell_mean(%22v4096%22%2C%20%22emb_r2%22)%3A.2f%7D%20against%20%7Bgeom(%22v4096%22%2C%20%22r2%22)%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_()%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Mixing%20in%20value%20space%0A%0A%20%20%20%20The%20embeddings%20hold%20the%20geometry%20of%20individual%20colors%3B%20the%20last%20question%20is%0A%20%20%20%20about%20the%20computation%20that%20combines%20them.%20At%20the%20pre-answer%20position%20(%60%3D%60)%2C%0A%20%20%20%20does%20the%20residual%20stream%20already%20contain%20the%20mix's%20value%20before%20the%20answer%0A%20%20%20%20is%20emitted%3F%20We'll%20check%20with%20probes%20fit%20at%20each%20depth%20on%20seen%20prompts%20and%0A%20%20%20%20then%20apply%20them%20to%20held-out%20and%20open%20prompts.%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%22residual-probes%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%20panels%2C%20one%20per%20vocabulary%20grid%2C%20of%20ridge-probe%20R-squared%20for%20the%0A%20%20%20%20%20%20%20%20%20%20%20%20mix's%20RGB%20read%20from%20the%20residual%20stream%20at%20the%20pre-answer%20position%2C%20over%0A%20%20%20%20%20%20%20%20%20%20%20%20residual%20depth%200%20to%204.%20Each%20panel%20has%20three%20lines%3A%20seen%20pairs%20(the%20probe%20fit%0A%20%20%20%20%20%20%20%20%20%20%20%20set)%2C%20held-out%20pairs%2C%20and%20open%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%20Ridge%20probes%20from%20the%20pre-answer%20residual%20stream%20to%20the%20true%20mix's%0A%20%20%20%20%20%20%20%20%20%20%20%20RGB%2C%20one%20per%20depth%20(0%20%3D%20embeddings%2C%204%20%3D%20final%20layer)%2C%20fit%20on%20half%0A%20%20%20%20%20%20%20%20%20%20%20%20the%20seen%20prompts%20(seed%200).%20Transfer%20to%20held-out%20and%20open%20prompts%0A%20%20%20%20%20%20%20%20%20%20%20%20tells%20a%20genuine%20value-space%20computation%20apart%20from%20a%20probe%20that%0A%20%20%20%20%20%20%20%20%20%20%20%20memorized%20its%20fit%20set.%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(GRID_NAMES)%2C%20figsize%3D(11.5%2C%203.0)%2C%20sharey%3DTrue)%0A%20%20%20%20%20%20%20%20styles%20%3D%20%7B%22named_seen%22%3A%20%22-%22%2C%20%22named_holdout%22%3A%20%22--%22%2C%20%22open%22%3A%20%22%3A%22%7D%0A%20%20%20%20%20%20%20%20shades%20%3D%20grid_shades()%0A%20%20%20%20%20%20%20%20for%20ax%2C%20g%20in%20zip(axes%2C%20GRID_NAMES%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20probe%20%3D%20cell_of(metrics%2C%20g%2C%200)%5B%22probe_r2%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20es%2C%20r2s%20in%20probe.items()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ax.plot(r2s%2C%20styles.get(es%2C%20%22-%22)%2C%20color%3Dshades%5Bg%5D%2C%20label%3Des.replace(%22_%22%2C%20%22%20%22))%0A%20%20%20%20%20%20%20%20%20%20%20%20ax.set(title%3Dg%2C%20xlabel%3D%22depth%22%2C%20ylim%3D(-0.1%2C%201.03))%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(mix%20RGB)%22)%0A%20%20%20%20%20%20%20%20axes%5B0%5D.legend(fontsize%3D7%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_(metrics)%3A%0A%20%20%20%20_mid%20%3D%20%7Bg%3A%20max(cell_of(metrics%2C%20g%2C%200)%5B%22probe_r2%22%5D%5B%22named_holdout%22%5D)%20for%20g%20in%20GRID_NAMES%7D%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20Is%20the%20answer%20computed%20in%20value%20space%20before%20it%20is%20emitted%3F%0A%20%20%20%20Apparently%20so%2C%20and%20the%20probes%20transfer%20well.%20Peak%20held-out%20R%C2%B2%20is%0A%20%20%20%20%7B_mid%5B%22v27%22%5D%3A.2f%7D%20at%20%60v27%60%2C%20%7B_mid%5B%22v64%22%5D%3A.2f%7D%20at%20%60v64%60%2C%20%7B_mid%5B%22v216%22%5D%3A.2f%7D%0A%20%20%20%20at%20%60v216%60%2C%20and%20%7B_mid%5B%22v4096%22%5D%3A.2f%7D%20at%20%60v4096%60%20(seed%200)%2C%20with%20most%20of%20the%0A%20%20%20%20value%20present%20from%20depth%201%20or%202%20onward.%20This%20quite%20different%20from%20the%20base%0A%20%20%20%20language.%20There%2C%20ex-2.1.2%20found%20that%20the%20answer's%20channels%20are%20computed%20just%0A%20%20%20%20in%20time%20and%20cleared%20away%20after%20emission%20(for%20hex%20answers)%2C%20so%20a%20full%0A%20%20%20%20%22result%22%20concept%20wasn't%20readable%20at%20any%20single%20position.%20But%20now%20with%0A%20%20%20%20one-token%20answers%20there%20is%20no%20schedule%20to%20spread%20the%20work%20over%2C%20so%20the%20whole%0A%20%20%20%20mix%20must%20be%20present%20at%20the%20pre-answer%20position.%0A%0A%20%20%20%20Even%20%60v27%60's%20held-out%20prompts%20probe%20at%20about%200.9%20mid-stack%20while%20their%0A%20%20%20%20exact-match%20accuracy%20is%200.2%20to%200.3.%20The%20model%20computes%20roughly%20the%20right%0A%20%20%20%20value%2C%20and%20then%20the%20readout%20picks%20a%20neighboring%20name.%0A%0A%20%20%20%20%23%23%20Example%20completions%0A%0A%20%20%20%20Here%20are%20a%20few%20concrete%20completions%20(we%20picked%20the%20widest%20misses).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(arrays%2C%20evals)%3A%0A%20%20%20%20def%20completion_rows(grid%3A%20str%2C%20es%3A%20str%2C%20k%3A%20int%20%3D%204)%20-%3E%20str%3A%0A%20%20%20%20%20%20%20%20exs%20%3D%20evals%5Bgrid%5D%5Bes%5D%0A%20%20%20%20%20%20%20%20lp%20%3D%20arrays%5Bf%22%7Bgrid%7D-s0%2Flogp%2F%7Bes%7D%22%5D%0A%20%20%20%20%20%20%20%20names%20%3D%20list(PALETTES%5Bgrid%5D)%0A%20%20%20%20%20%20%20%20gd%2C%20fl%20%3D%20dists_for(grid%2C%20exs%2C%20lp)%0A%20%20%20%20%20%20%20%20order%20%3D%20np.argsort(-gd)%5B%3Ak%5D%20%20%23%20the%20widest%20misses%20are%20the%20most%20informative%0A%20%20%20%20%20%20%20%20rows%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20for%20i%20in%20order%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ex%20%3D%20exs%5Bi%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20a%2C%20b%20%3D%20ex.prompt.split()%5B0%5D%2C%20ex.prompt.split()%5B2%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20true%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sw(ex.answer%2C%20grid)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20ex.answer%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%20f'%3Cspan%20class%3D%22sw%22%20style%3D%22--sw%3A%20%7Bto_hex(ex.result)%7D%3B%22%20aria-hidden%3D%22true%22%3E%3C%2Fspan%3E%20%3Ccode%3E%7Bto_hex(ex.result)%7D%3C%2Fcode%3E'%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20rows.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%3Ctr%3E%3Ctd%3E%7Bsw(a%2C%20grid)%7D%3C%2Ftd%3E%3Ctd%3E%7Bsw(b%2C%20grid)%7D%3C%2Ftd%3E%3Ctd%3E%7Btrue%7D%3C%2Ftd%3E%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f'%3Ctd%3E%7Bsw(names%5Bint(lp%5Bi%5D.argmax())%5D%2C%20grid)%7D%3C%2Ftd%3E%3Ctd%20class%3D%22num%22%3E%7Bgd%5Bi%5D%3A.2f%7D%3C%2Ftd%3E'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f'%3Ctd%20class%3D%22num%22%3E%7Bfl%5Bi%5D%3A.2f%7D%3C%2Ftd%3E%3C%2Ftr%3E'%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20return%20%22%22.join(rows)%0A%0A%20%20%20%20return%20(completion_rows%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(completion_rows)%3A%0A%20%20%20%20_head%20%3D%20(%0A%20%20%20%20%20%20%20%20%22%3Ctr%3E%3Cth%3Ea%3C%2Fth%3E%3Cth%3Eb%3C%2Fth%3E%3Cth%3Etrue%20mix%3C%2Fth%3E%3Cth%3Emodel's%20guess%3C%2Fth%3E%22%0A%20%20%20%20%20%20%20%20'%3Cth%20class%3D%22num%22%3Edistance%3C%2Fth%3E%3Cth%20class%3D%22num%22%3Efloor%3C%2Fth%3E%3C%2Ftr%3E'%0A%20%20%20%20)%0A%20%20%20%20_k%20%3D%205%0A%20%20%20%20_tables%20%3D%20%5B%5D%0A%20%20%20%20for%20_g%2C%20_es%20in%20%5B(%22v27%22%2C%20%22named_holdout%22)%2C%20(%22v216%22%2C%20%22open%22)%2C%20(%22v4096%22%2C%20%22named_holdout%22)%5D%3A%0A%20%20%20%20%20%20%20%20_tables.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20figure_html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f'%3Cdiv%20class%3D%22report-table-scroll%22%3E%3Ctable%20class%3D%22report-table%22%3E%7B_head%7D'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bcompletion_rows(_g%2C%20_es%2C%20_k)%7D%3C%2Ftable%3E%3C%2Fdiv%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20caption%3Dmo.md(f%22%60%7B_g%7D%60%20%C2%B7%20%7B_es.replace('_'%2C%20'%20')%7D%3A%20the%20%7B_k%7D%20widest%20misses%20(seed%200).%22).text%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20class_%3D%22report-figure%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20mo.Html(%22%5Cn%22.join(_tables))%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(arrays%2C%20evals)%3A%0A%20%20%20%20_exs%20%3D%20evals%5B%22v27%22%5D%5B%22named_holdout%22%5D%0A%20%20%20%20_rgb%20%3D%20raw_rgb(%22v27%22)%0A%20%20%20%20_null%20%3D%20bl.operand_shell_null(%0A%20%20%20%20%20%20%20%20bl.shell_mask(nc.GRIDS%5B%22v27%22%5D%2C%20_rgb%2C%20%5Bex.result%20for%20ex%20in%20_exs%5D)%2C%0A%20%20%20%20%20%20%20%20_rgb%2C%0A%20%20%20%20%20%20%20%20%5B(ex.lhs%2C%20ex.rhs)%20for%20ex%20in%20_exs%5D%2C%0A%20%20%20%20)%0A%20%20%20%20_n%20%3D%20_k%20%3D%200%0A%20%20%20%20for%20_s%20in%20SEEDS%3A%0A%20%20%20%20%20%20%20%20for%20_ex%2C%20_gv%20in%20zip(_exs%2C%20_rgb%5Barrays%5Bf%22v27-s%7B_s%7D%2Flogp%2Fnamed_holdout%22%5D.argmax(1)%5D%2C%20strict%3DTrue)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20_n%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20_k%20%2B%3D%20tuple(_gv)%20in%20(tuple(_ex.lhs)%2C%20tuple(_ex.rhs))%0A%0A%20%20%20%20mo.md(rf%22%22%22%0A%20%20%20%20%60v27%60's%20misses%20are%20neighbor%20names%20(%60violet%60%20guessed%20as%20%60blue%60%2C%20%60maroon%60%20as%0A%20%20%20%20%60red%60)%3B%20%60v216%60's%20open-pair%20guesses%20sit%20a%20step%20away%20from%20the%20floor%3B%20and%0A%20%20%20%20%60v4096%60's%20worst%20held-out%20misses%20still%20agree%20with%20the%20true%20mix%20on%20two%20of%20the%0A%20%20%20%20three%20channels.%0A%0A%20%20%20%20Several%20of%20%60v27%60's%20rows%20return%20one%20of%20the%20operands%2C%20may%20or%20may%20not%20be%20an%20echo.%0A%20%20%20%20Returning%20an%20operand%20and%20returning%20a%20neighbor%20are%20close%20to%20the%20same%20thing%20here.%0A%20%20%20%20%7B_k%7D%20of%20%7B_n%7D%20guesses%20are%20operands%2C%20against%20%7B_null%3A.0%25%7D%20for%20a%20guess%20drawn%0A%20%20%20%20uniformly%20from%20the%20neighbors.%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%20Findings%0A%0A%20%20%20%201.%20The%20model%20infers%20the%20color-space%20geometry%20better%20without%20hex%20scaffolding.%0A%20%20%20%20%20%20%20From%20mixing%20co-occurrences%20alone%20it%20builds%20embeddings%20that%20are%20linear%0A%20%20%20%20%20%20%20color%20cubes%2C%20computes%20mixes%20in%20value%20space%20at%20the%20pre-answer%20position%2C%0A%20%20%20%20%20%20%20and%20generalizes%20to%20held-out%20pairs.%20When%20it%20guesses%20a%20held-out%20answer%2C%20the%0A%20%20%20%20%20%20%20guess%20is%20very%20close.%0A%20%20%20%202.%20Performance%20varies%20with%20vocabulary%20size.%20Exact%20match%20is%20non-monotonic%2C%0A%20%20%20%20%20%20%20while%20geometric%20closeness%20improves%20monotonically.%0A%20%20%20%20%22%22%22)%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
e1af9172ffeb3587e8cc0f6dafc56a7c