# Poster 29178

- Kind: Poster
- Talk page and recording: https://iclr.cc/virtual/2025/poster/29178

> Transcript of the talk's recording (session_asr), made by speech recognition or taken from the host's captions. It may contain errors. The words are the speakers'; listen to the recording on the talk's page before quoting it.

Hello, I'm Xingyi, and I'm presenting our work toward understanding in context versus in weight learning together with my co-author Brian. This is joint work with Brian, Andras, and Dale. Large language models can do in context learning, which is the ability to make predictions using the input context distinct from predicting by memorizing training data, which we call in weight learning.
In context learning is important for the model to adapt to new inputs and tasks. More specifically, consider the following setting where the training data has a context and a query. The context has image label pairs and we want to predict the label of the query. Here the label of the image 3 is 1. The image label mappings are consistent during training.
At test time, the model receives a sequence where the label of 3 in the context is 0. If the model is doing in-weight prediction, it would predict 1, and if it's doing in-context prediction, it would predict 0. So what drives in-weight learning versus in -context learning? Previous work showed that distribution of properties of the training data is key, and that in-context learning can be transient.
In our work, we ask how does the training data distribution affect the emergence of ICL versus WL individually for each input. Our hypothesis is that ICL emerges if it has higher accuracy on the input and vice versa. We propose a simple theoretical model and also give experimental evidence on synthetic problems as well as more realistic tasks.
For the theoretical model, consider the task of predicting input label pairs where the input has a context and a query. And the goal is to predict the label of the query. The labels are noisy and we have two predictors, the in-context predictor H that predicts using only combinations of the context labels, and the in-way predictor G which only predicts using the query. And the simple model is a weighted combination of the two. Under our hypothesis,
We would expect the in-weight predictor to do well on inputs where the query appears often and the in-context predictor to do well where there are few irrelevant labels and the query rarely appears in the training data. We also present an algorithm under which the simple model can learn to weight g and h by their online performance, a proxy for their test loss. Studies have shown that specific distributional properties of training data drives ICO.
In our work, we split the data into high and low frequency classes, representing m-weight and in-context examples. Low frequency data aims to enforce the model to leverage the context for predictions, whereas high frequency data encourages the model to memorize the mappings quickly without context. This separation allows us to illustrate that a model can predict both m-weight and in-context depending on the examples.
We also experimented with other attributes to analyze the model's preference on in-weight and in-context. For each setting, we trained two-layer transformers using all types of pre-training inputs and compare it against two baselines. We have in-context predictors that are trained using only relevant context inputs. And in-weight predictors that are trained using only irrelevant context inputs.
With more data, we hypothesize that the transformer eventually predicts in context or in weight based on the asymptotic errors. To evaluate model preferences, we sample two types of input sequences. For in weight, the model predicts on irrelevant context inputs, requiring the model to memorize the query label. For in context, the model predicts on relevant context inputs with novel label mapping, requiring it to predict the query based on the contexts.
We outline a few notable findings that align with our theoretical analysis. First, we observe that the model initially prefers in context with smaller data sets. As we increase the data set size, the model begins with predicting in weight on high frequency data first followed by low frequency data, illustrating that the model can indeed predict both in weight and in context depending on the examples.
Second, having more relevant contexts leads to better ICL performance and it persists for larger data sets. Third, we observe that by varying the input noise, ICL is no longer transient as the M-weight predictor struggles to make correct predictions. We observe similar phenomena when extending the analysis to the Omniglot data set, evaluating ResNet-based transformers on similar settings.
Finally, we fine-tuned Gemini Nano 1 with language prompts and forcing the model to memorize particular named city pairs. This resulted in reduced ICL capability as the fine-tuned model no longer leverages the relevant context.
