Connecting the Dots: LLMs can Infer and Verbalize Latent Structure from Disparate Training Data

Johannes Treutlein, Dami Choi, Jan Betley, Samuel Marks, Cem Anil, Roger Grosse, Owain Evans

TL;DR

This paper demonstrates that Large Language Models (LLMs) can "connect the dots" by aggregating implicit information scattered across separate training documents to infer hidden facts. This capability, termed inductive out-of-context reasoning (OOCR), allows models to verbalize and apply latent knowledge—such as identifying an unnamed city based only on distance data—without any explicit reasoning or examples provided at test time.

What Problem Does This Paper Address?

A common strategy for AI safety is to redact hazardous information (like biological weapon protocols) from training data. However, the authors argue that even if an explicit fact $F$ is removed, the training corpus may still contain numerous implicit hints about $F$.

The core question is: Can an LLM aggregate these disparate, indirect observations during training to reconstruct the hidden knowledge? If so, current methods for monitoring and controlling what an LLM knows are insufficient, as the model could learn "censored" facts through a non-transparent process of induction.

Methods

The researchers introduced a framework to study inductive OOCR. Unlike standard in-context learning, where a model is given examples in its prompt, OOCR requires the model to learn a latent variable $z$ (the "hidden fact") purely through the fine-tuning process on a dataset $D$.

At test time, the model is asked to perform a task $Q$ that requires knowledge of $z$, but $D$ is nowhere to be found in the context window. The authors fine-tuned frontier models (GPT-3.5, GPT-4, and Llama 3) on five distinct tasks designed to test different types of latent structures, ranging from geographic locations to mathematical functions.

The OOCR process: Finetuning on indirect observations allows the model to infer a latent fact (e.g., City 50337 is Paris) and answer downstream questions.

Datasets

The authors developed a suite of five challenging tasks:

  • Locations: Distances between an ID-labeled unknown city (e.g., "City 50337") and known cities.
  • Coins: Individual outcomes of flips from coins with different biases.
  • Functions: Pairs of $(x, f(x))$ for unknown arithmetic functions.
  • Mixture of Functions: A distribution of outputs from two unnamed functions, requiring the model to identify the underlying set.
  • Parity Learning: Boolean assignments derived from parity formulas.

Key Insights and Ideas

  • Implicit to Explicit: Models don't just learn to predict the next token in the training distribution; they can internalize the underlying structure. For example, a model trained on distances can eventually "verbalize" the name of the city, even though that name never appeared next to the city ID during training.
  • OOCR vs. ICL: Surprisingly, inductive OOCR often outperformed in-context learning (ICL) on these tasks. Models were better at "connecting the dots" when the data was baked into their weights via fine-tuning than when the same data was provided in the prompt.
  • Scale Matters: GPT-4 consistently exhibited stronger OOCR capabilities than GPT-3.5, suggesting that as models grow, their ability to perform this type of hidden induction may increase.
  • No Variable Names Needed: In the "Mixture of Functions" task, the model succeeded even without a specific variable name to anchor the latent information, showing that the model can learn distributions of hidden structures implicitly.

Key Results

The experiments yielded several "aha" moments across the task suite:

  • Geography: In the Locations task, GPT-3.5 correctly identified the name of the hidden city 56% of the time and could even identify common foods associated with that city (e.g., "Baguette" for Paris) with 57% probability.
  • Functions: Models fine-tuned on $(x, f(x))$ pairs could not only define the function in Python code but also perform function inversion—predicting $x$ given $y$—despite only seeing the forward direction during training.
  • Coins: Models could distinguish between a coin with a 0.7 bias and one with a 0.8 bias, a task that statistically requires aggregating over 100 individual samples.
Comparison of OOCR vs. In-Context Learning (left) and GPT-3.5 vs. GPT-4 (right). OOCR generally outperforms ICL, and GPT-4 shows superior reasoning.

Limitations and Future Work

While the results are striking, OOCR is not yet a perfectly reliable capability. The authors noted that performance can be high-variance and sensitive to specific prompts. Smaller models, in particular, struggled with more complex latent structures.

Furthermore, the study used relatively clean, synthetic datasets. In the real world, training data is far more "noisy" and heterogeneous. Future work is needed to determine if OOCR scales to the massive, messy datasets used for pre-training and whether it poses a practical threat to current safety redaction techniques. The authors also suggest that mechanistic interpretability could help reveal how these models represent and aggregate this latent knowledge internally.

Summary updated

Abstract

One way to address safety risks from large language models (LLMs) is to censor dangerous knowledge from their training data. While this removes the explicit information, implicit information can remain scattered across various training documents. Could an LLM infer the censored knowledge by piecing together these implicit hints? As a step towards answering this question, we study inductive out-of-context reasoning (OOCR), a type of generalization in which LLMs infer latent information from evidence distributed across training documents and apply it to downstream tasks without in-context learning. Using a suite of five tasks, we demonstrate that frontier LLMs can perform inductive OOCR. In one experiment we finetune an LLM on a corpus consisting only of distances between an unknown city and other known cities. Remarkably, without in-context examples or Chain of Thought, the LLM can verbalize that the unknown city is Paris and use this fact to answer downstream questions. Further experiments show that LLMs trained only on individual coin flip outcomes can verbalize whether the coin is biased, and those trained only on pairs $(x,f(x))$ can articulate a definition of $f$ and compute inverses. While OOCR succeeds in a range of cases, we also show that it is unreliable, particularly for smaller LLMs learning complex structures. Overall, the ability of LLMs to "connect the dots" without explicit in-context learning poses a potential obstacle to monitoring and controlling the knowledge acquired by LLMs.
BibTeX
@inproceedings{treutlein2024connecting,
  author = {Johannes Treutlein and Dami Choi and Jan Betley and Samuel Marks and Cem Anil and Roger Grosse and Owain Evans},
  title = {{Connecting the Dots: LLMs can Infer and Verbalize Latent Structure from Disparate Training Data}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=7FokMz6U8n},
}
Figure