The recording
You were last reading slide 1.
Non-parametric learning, kernels, and retrieval
Information retrieval for AI
23 November 2026
Seong Joon Oh - KAIST AI
Upcoming sessions
25 November - Interpolation or extrapolation
The anchor paper is Reasoning or Reciting? (Wu et al., NAACL 2024). Preparation is due 24 November, 18:00 KST.
2 December - Weights or an explicit store
Preparation is due 1 December, 18:00 KST.
Roles and readings are in the course schedule.
Today
Session 18 postulated a connection between learning and search. Learning retrieves from past experience, that is, the training data. Today we go deeper into this view.
- Kernel machines predict by retrieving from the training data
- Can any model be considered a kernel machine?
- Influence functions approximate any model as a kernel machine
- An explicit datastore of the training data
Kernel machines predict by retrieving from the training data
kNN predicts from the nearest training examples
Store every training pair
For a new input
Predict by a vote over their labels.
The training set is the model. Prediction is a retrieval step.
Cover and Hart, IEEE Trans. Inf. Theory 1967.
Nadaraya-Watson softens the vote
Every training example votes. Its weight is its similarity to
With
Plotted from
Can any model be considered a kernel machine?
The representer theorem
Fix a kernel function
Fit a smooth
The penalty
Every minimiser has the form
This weighted sum of kernels over the training set is a kernel machine. A prediction compares the query with every training input.
Kimeldorf and Wahba, J. Math. Anal. Appl. 1971. Schölkopf, Herbrich, and Smola, COLT 2001.

A linear layer is attention over its training inputs
Gradient descent adds one outer product per step.
For a new input
The training inputs are the keys, the error signals are the values, and the new input is the query. The identity is exact and needs no limit.
Irie, Csordás, and Schmidhuber, ICML 2022, Eqs. 11 and 13.
Quiz: two training pairs in one step
Take
The gradient is
Read the same step as retrieval with
The change is similarity times value,
Now add a second pair
How does each pair contribute to the new weight w, and what is the prediction at x = 2?
Sign in with your course account to choose. The lecturer will reveal responses and the answer.
Constructed arithmetic, not a reported result.

The last layer is a weighted sum over training points
This is a theorem, not an empirical finding. Write the pre-softmax output as
It holds under two conditions.
- The training loss adds an L2 penalty
on the last layer. - The weights sit at a stationary point, so the gradient with respect to
is zero.
Then, for any test input
Each training point contributes its feature similarity to
A network trained with SGD rarely reaches an exact stationary point. The authors therefore fine-tune only the last layer, with the L2 penalty, until it does.
Yeh, Kim, Yen, and Ravikumar, NeurIPS 2018, Theorem 3.1 and §3.1.

Inhibitory training points explain a mistake
A training point is inhibitory for a class when its term
The model is a ResNet-50 on Animals with Attributes. Of 181 test antelopes, 15 are misclassified and 12 of those as deer.
All 12 have the same four training images among their top inhibitory points. Those images show small antelopes beside larger animals and carry the larger animal’s label, such as zebra or elephant.
The model learns to suppress the antelope class for an image with small antelopes and other large objects.
Yeh et al., NeurIPS 2018, §3, §4.3, and Fig. 5.
The whole network is a kernel machine in a limit
This is a theorem about an idealised network, not an empirical finding. The neural tangent kernel (NTK) is
It measures how far a small gradient step on
The result holds under four conditions.
- The network is fully connected, and every hidden layer is infinitely wide.
- The weights start as independent Gaussians, scaled by
. - Training is gradient descent with infinitesimal steps.
- The nonlinearity is smooth and Lipschitz.
Then
Jacot, Gabriel, and Hongler, NeurIPS 2018, Theorems 1 and 2 and §5.

Domingos integrates the kernel along the training path
This is a theorem, not an empirical finding. It holds under two conditions.
- The model
and the loss are differentiable in the weights . - Training is gradient descent on the loss summed over the training set, with infinitesimal steps.
Unlike the infinite-width result, it needs no width or initialisation condition. The trained model is
Remark 1 states that “the
Domingos, arXiv 2020, Theorem 1 and Remark 1.

Where the kernel view holds for language models
The study fine-tunes RoBERTa-base with prompts on 14 few-shot tasks. The kernel is the empirical NTK at the pre-trained weights,
- On 12 tasks, kernel regression with
comes close to fine-tuning, with no gradient training. - On 8 of them, fine-tuning itself behaves as a kernel method. The model stays close to linear in its weights, and
barely changes.
Malladi et al., ICML 2023, Table 1 and §6.1.
Influence functions approximate any model as a kernel machine
Why view learning as retrieval?
The previous section gave a theoretical understanding of learning as retrieval. A trained model can be written as a sum over its training points.
The rest of today asks what this view buys in practice. A model that retrieves from its training data supports two operations.
- Knowledge tracing. Name the training examples behind an output.
- Knowledge update. Change what the model knows by adding or removing training examples.
Influence functions trace knowledge in any trained model, approximately. An explicit datastore makes both operations lookups. Distilling the datastore back into weights loses them.
Influence functions score training points with a kernel
Influence functions apply the kernel-machine form to any trained model. They ask which training points moved a given prediction, and score each point
Tsai, Yeh, and Ravikumar, NeurIPS 2023, Theorem 7.
Attribution methods differ in the kernel
| Method | Kernel |
|---|---|
| Representer points | |
| TracIn | |
| Influence functions |
In each case the global weight is a loss derivative at
Tsai et al., NeurIPS 2023, Eqs. 12, 14, and 16.
Influence is retrieval with gradient keys
The key is the training gradient
| Method | |
|---|---|
| TracIn | |
| Koh and Liang | |
| Grosse et al. (EK-FAC) |
The methods share the form and differ in quality. Plain dot products of gradients reach an MRR of 0.003 on fact tracing at 8B.
Koh and Liang, ICML 2017. Grosse et al., 2023, Eq. 25. Chang et al., ICLR 2025, Table 2.

Stored gradient keys for a pretraining corpus
- TrackStar scores a training passage by the cosine between its gradient and the query’s gradient, both corrected and randomly projected.
- Each training key is computed once and reused for every query.
- For an 8B model over 365M C4 passages, the keys take 87 TB. A query costs one gradient and one scan of the keys.
Chang et al., ICLR 2025, Fig. 1, Eq. 1, §3, and §6.
The metric decides which relevance you get
The 8B model retrieves from all 365M C4 passages for T-REx facts.
| Retriever | Evidence (MRR) | Influence (one-step gain) |
|---|---|---|
| BM25 | 0.687 | +0.83% |
| TrackStar | 0.338 | +2.11% |
Evidence counts passages that state the fact. Influence is the target gain after one training step on the retrieved passages.
BM25 finds the evidence a reader accepts. Gradients find what changed the model.
“a misalignment between factual attribution and causal influence”
Chang et al., ICLR 2025, Table 2 and abstract.

What is retrieved changes with scale
The query is a GSM8k problem. “Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May…”
For the 810M model, an influential sequence describes clips that secure an elevator. It shares the word, not the task.
For the 52B model, an influential sequence works through arithmetic on the friendship paradox.
“Larger models consistently generalize at a more abstract level than smaller models”
Grosse et al., 2023, Fig. 13 and p. 8.
Influence is expensive to read
Each read needs a gradient for the query, a curvature approximation, and a scan over stored training gradients.
The result is an estimate of influence, not a record of the source.
The next step stores the training data directly and looks it up.
An explicit datastore of the training data

kNN-LM stores one entry per training token
The key
WikiText-103 gives 103M entries. The model is not retrained.
Khandelwal et al., ICLR 2020, §2 and Eq. 1.
Neighbours vote with a kernel
This is Nadaraya-Watson over training tokens, in the model’s own representation space. The paper calls it an RBF kernel.
Khandelwal et al., ICLR 2020, Eq. 2.
Interpolate the datastore and the model
A 247M model on WikiText-103 retrieves neighbours from its own training set. Test perplexity falls from 18.65 to 16.12.
The authors conclude that “learning similarity between sequences of text is easier than predicting the next word”.
Khandelwal et al., ICLR 2020, Eq. 3, Table 1, and abstract.

Does the datastore help reasoning?
The table gives Llama-3-8B accuracy when the answer is placed among the retrieved neighbours.
| Task | LM | kNN-LM with the answer |
|---|---|---|
| NQ | 23.64 | 46.40 |
| HotpotQA | 25.14 | 49.85 |
Perplexity on NQ falls from 112.56 to 8.91. About half of the questions still fail.
“even with perfect retrieval, kNN-LMs still fail to determine the correct answers”
Geng, Zhao, and Rush, NAACL 2025, Table 6 and abstract.

SILO splits low-risk weights from a high-risk datastore
- The weights train on 228B tokens of public-domain and permissively licensed text. Copyrighted text sits in a datastore, read only at inference through kNN-LM.
- The datastore closes 91% of the out-of-domain perplexity gap to Pythia-1.4B (19.0 to 12.0, against 11.3).
- Deleting an entry needs no retraining, and attribution reads the retrieved entries. Neither covers what the weights learned.
Min et al., ICLR 2024, Fig. 1, Table 4, and §6.
Wrap-up
- Kernel machines predict by a similarity-weighted vote over training examples.
- Trained networks behave as kernel machines. The result is exact for one linear layer and for the last layer, and holds for the whole network in a limit or with query-dependent weights.
- Influence functions read this form from any trained model. Each read needs gradients, a curvature approximation, and terabytes of stored keys.
- An explicit datastore makes the retrieval literal. kNN-LM lowers perplexity with no extra training, and SILO turns deletion and attribution into lookups for the data it stores.
Next time
Can the store live inside the network and stay addressable?