Manuscript Offprint

arXiv:2610.29419

When Thoughts Become Memory: Unifying In-Context Learning and Fine-Tuning

Leon Chlon, Julie Huang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We are the first to give a certified rule for whether unseen data belong in a pretrained model's context or its weights, built on an exact law for their information value. That value, the code length saved on held-out queries, equals in expectation the bits stored about the query, plus a prior repair, minus a decoding loss, for any model, architecture, dataset and task. The law's ceilings certify the choice from one measurement, and an anytime-valid test makes it from held-out queries, with error controlled whenever it stops. Every certificate the ceilings issue on a trained transformer, TabPFN, an occupancy network and a stereo network is correct. The test picks TabPFN over XGBoost and a trained surrogate over an in-context learner on airfoil pressure, calls the better of GPT-2's cache and fine-tune in 61,948 of 64,000 query streams over 32 comparisons, and errs in at most 3.3% of null streams. The law also diagnoses when learning in context helps and when it does not. Deleting part of a context is held-out validation of that part in any model, and adding parts one at a time traces the learning curve in context: one patch that sees a shape feature cuts an occupancy network's code length there a hundredfold, while eight that miss it nearly double it, and one camera that sees the surface beats four in a stereo network. Ranked by this label-free valuation, a kriging learner's three best support cars beat four drawn at random, and on a yes-or-no claim the valuation recovers a published evidence adjudicator, with AUROC 0.91.

1. Introduction

A pretrained model holds unseen data in one of two places. Read as context, they live in a state the frozen model computes afresh in every forward pass: the feature grid of an occupancy network, the cost volume of a stereo network, the kriging weights of a kriging learner, the key-value cache of a language model. Written by fine-tuning, they become part of the weights. Every model that reads context poses the same question: when should a thought held in context become a memory in the weights? Current accounts of in-context learning, as implicit Bayesian inference (Xie et al., 2022) or as gradient descent carried out by attention (von Oswald et al., 2023; Akyürek et al., 2023), describe stylised models of language and of linear regression, and give no quantity to answer it with.

We resolve it with an information-theoretic construction. Context and weights are both valued by the bits they save the model on held-out queries, and both obey one exact law that separates what a memory stores from what its decoding loses. The two channels can then be compared term by term, and capacity bounds on each term become certificates that choose a channel from one measurement. Deleting part of the context and rerunning the model gives the value of that part in any model, and with it a test of whether evidence supports a claim. The construction asks a model for two things only: a probability for each outcome and a rerun on part of its context. Every tool runs on these two, and the certificates also need exact information terms. Nothing else is needed from the dataset, the architecture or the task, so a hosted model supplies everything through its log-probabilities, and a local model adds its weights, which give the certificates their capacity bounds. We prove what follows from this construction and validate it on language, vision, fluid-dynamics and tabular models.

In expectation the saving splits exactly into three terms, for the context memory and the weights alike (Theorem 2): the information the memory stores about the query; a prior repair, which corrects the model's prior over outputs and is available to any context, even one that says nothing about the query; and a decoding loss, by which the model's prediction falls short of the best prediction from its memory. The split refines the resolution–reliability decomposition of the logarithmic score (Bröcker, 2009) by conditioning on the memory a channel builds. That conditioning makes the two channels comparable: it separates what a memory stores from what its decoder uses, and when the context fits the window it caps what any fine-tune can add at the decoding loss in context. No previous work has made context and weights comparable this way or turned the comparison into a certified rule.

The law decides between the two. Beyond the prior repair they share, a fine-tune cannot save more bits than it stores,

1^{1}Hassana Labs.

Preprint.

Table 1. The results at a glance: what each tool takes, what it guarantees, and how the paper tests and checks it.

ToolWhat it takesWhat it guaranteesTested on, and checked by
With the information terms of the data
Exact law (Thm. 2)held-out code lengthsE[Γc]=I(Q;Zc)+KL0−decc\mathbb{E}[\Gamma_c]=I(Q;Z_c)+\mathrm{KL}_0-\mathrm{dec}_c, in context and in the weights alikeevery term in closed form for a linear-Gaussian model, matched by simulation (App. A.10)
Certificates (Prop. 6(ii))one channel's code length, the other's ceilingthe channel beats every memory confined to the window, or of at most C bits25 of 64 on a trained transformer and 36 of 96 on TabPFN, occupancy and stereo networks, all correct
From the model's probabilities and reruns alone
Decoding-loss bound (Prop. 6(iii))a fine-tune's advantage, context in the windowno fine-tune adds more than the decoding loss in contextGPT-2: at least 0.35–0.55 bits per token, prior repair the cache leaves unrealised
Anytime-valid test (Thm. 8)held-out code lengths of both channelsa wrong call with probability at most α\alpha, whenever the test stopstables, airfoil pressure and GPT-2; at most 3.3% wrong calls on nulls, within 5%; a power curve; the same call in 200 reorderings
Prequential curves (Prop. 7)the code lengths of the context's own unitseach equals the held-out learning curve at that size, in expectationGPT-2: within 1.97 standard errors of the held-out curves; sums within 0.1% and 1.5%
Storage budget (Thm. 9)in-context outputs over resampled contextsa fixed state within ε\varepsilon bits of the context memory stores at least I(Y^;D)−εI(\hat{Y};D)-\varepsilon bitsGPT-2 on tables of facts: the estimate stays below the exact 5.14 bits over all 4,096 tables
Value of a part of the context (Cor. 4)a rerun without the partits exact leave-one-out value, label-free as IGI_G, split into content and formoccupancy, stereo and kriging models; claims fixed in advance, matched controls, native stereo and kriging code reproduced exactly in 12 and 168 comparisons
Evidence budget (Cor. 16)a claim's probability with and without its evidencethe bits a claim needs, against the bits its evidence supplies (Chlon et al., 2026)two language-model verifiers on VitaminC claims, AUROC 0.91

and a context memory no more than its window holds, so one channel's measured gain, set against the other's ceiling, can certify the choice. A full fine-tune opens no new space for what it learns: it writes into the bits that already hold the model. Prequential learning curves, read from the context itself, and an anytime-valid test on held-out queries make the choice against any model trained on the same data, with error controlled whenever the test stops. A storage budget sets how many bits fixed weights must store to reproduce the predictions made in context (Section 5).

The choice follows the data, to context or to the weights. On two OpenML tables the test picks TabPFN, which learns from the rows in its context, over gradient-boosted trees trained on the same 128 rows, in every seed. On airfoil pressure fields it picks a trained surrogate over an in-context learner in every seed, and with 32 designs instead of 128 it picks the in-context learner in two seeds of three. On simulated streams with no true winner it calls one in at most 3.3% of them, within its 5% limit. Where the information terms are exact, the ceilings issue 25 of 64 possible certificates on a trained transformer and 36 of 96 on TabPFN, an occupancy network and a stereo network, and every one agrees with the measured winner (Section 6).

The law also tells when learning in context helps. Deleting a part of the context and rebuilding the memory from the rest is held-out validation of that part, its exact leave-one-out value, run in the forward pass with the weights untouched in any architecture, and a matched control of the same form separates what the part says from the form it takes.

Measured this way, the bits follow the evidence each query depends on. In an occupancy network, the 300 points that observe a local shape feature are worth 17.66 bits per query, while 300 matched points from unchanged geometry are worth 0.001 bits. In a stereo network, a camera that sees the queried surface carries three times the bits of one that does not. The learning curve in context turns on which items arrive. One patch that observes the feature takes the occupancy network's code length at the feature from 4.99 to 0.05 bits per site, while eight patches that miss the feature raise it to 9.06, so more context makes the prediction worse. A kriging learner that ranks its support cars by its own valuation codes better with three than with four drawn at random. For two language-model verifiers, the law recovers the Trace Budget adjudicator (Chlon et al., 2026): the bits a binary claim needs, set against the bits its evidence supplies, separate supporting from insufficient evidence with AUROC 0.91 (Section 4).

References (99)