Structured In-Context Task Representations

Core Francisco Park, Andrew Lee, Ekdeep Singh Lubana, Kento Nishi, Maya Okawa, Hidenori TanakaNeurReps @ NeurIPS 2024

TL;DR

This paper shows that large language models (LLMs) can learn and represent underlying geometric structures (like grids and rings) solely from in-context examples, even when the tokens themselves have no inherent geometric meaning. Furthermore, LLMs can even override pre-existing semantic knowledge with these newly learned in-context structures.

What Problem Does This Paper Address?

The field of representation learning in deep learning has made significant strides, and researchers have observed that LLMs often develop interpretable internal structures. However, a key question remained: do LLMs also develop these structured representations when learning in-context (i.e., from examples provided within the prompt, without explicit fine-tuning)? This paper investigates whether LLMs can form meaningful geometric representations based purely on the patterns presented in in-context learning tasks, and how these representations interact with the model's existing semantic knowledge.

Methods

The researchers designed synthetic data generation processes (DGPs) that create sequences of tokens derived from underlying geometric graphs (specifically, grids and rings). They then used these sequences as in-context examples for the Llama 3.1-8B model. To analyze the learned representations, they extracted the mean activations of tokens from the model's hidden layers and applied Principal Component Analysis (PCA) to visualize these activations in 2D. This allowed them to observe if the model's internal representations mirrored the geometric structure of the task. They also explored scenarios where tokens had pre-existing semantic relationships (like days of the week) to see if in-context learning could override these priors.

Datasets

The paper does not use pre-existing datasets for training or evaluation. Instead, they introduce custom synthetic datasets generated by specific data generation processes (DGPs) that embed underlying geometric structures (grids and rings). These DGPs are designed to provide sequences of tokens that reflect these geometric relationships.

Key Insights and Ideas

  • In-Context Learning Induces Geometric Representations: LLMs can learn and represent geometric structures (grids, rings) purely from in-context examples, even when the tokens themselves are semantically unrelated to the geometry. This suggests that in-context learning is not just about pattern matching but can involve the formation of structured internal representations.
  • Overriding Semantic Priors: LLMs can override their pre-existing semantic knowledge with newly learned in-context task structures. For instance, when presented with a task that defines a different geometric relationship for tokens like "days of the week," the model can learn this new structure, although the original semantic prior might still be present in higher-dimensional representations.
  • Layer-Dependent Representations: The clarity and strength of these emergent geometric representations often improve in deeper layers of the LLM, suggesting a hierarchical learning process.
  • Corner Collapse in Grid Representations: In grid tasks, the representations of corner tokens tend to collapse inwards. The authors hypothesize this is due to less frequent visits to corner positions during the random walk data generation process.

Key Results

  • For a 4x4 grid task using semantically unrelated tokens, PCA projections of token activations revealed a clear 4x4 grid structure in deeper layers, mirroring the ground truth graph.
  • For a ring task, similarly, semantically unrelated tokens were organized into a ring structure in the model's representation space after sufficient in-context examples.
  • When using tokens with a semantic prior (days of the week) and defining a new, conflicting ring structure, the model learned the new structure. The original semantic ring was observed in the first two principal components, while the new in-context ring emerged in lower principal components (3rd and 4th).
  • The model achieved high accuracy (near 100%) in following the rules of the synthetic tasks after a sufficient number of in-context examples (around 100-500 depending on the task).

Limitations and Future Work

  • Causality: A primary limitation is the lack of a causal study. The current findings show a correlation between in-context examples and learned representations, but it's unclear if these representations are causally responsible for the model's predictions.
  • Generalizability: The study was conducted on a single model (Llama 3.1-8B) and specific synthetic tasks. Future work could test these findings on different language models and a wider variety of token sets and task structures.
  • Model Weights vs. In-Context Learning: The authors pose an interesting open question: distinguishing which representations are induced by the model's pre-trained weights versus those specifically induced by in-context learning. This is identified as an exciting area for future research.

Summary updated

BibTeX
@inproceedings{park2024structured,
  author = {Core Francisco Park and Andrew Lee and Ekdeep Singh Lubana and Kento Nishi and Maya Okawa and Hidenori Tanaka},
  title = {{Structured In-Context Task Representations}},
  booktitle = {NeurReps @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=hlOu6w1a8T},
}
Figure