Explicit Knowledge Factorization Meets In-Context Learning: What Do We Gain?

Sarthak Mittal, Eric Elmoznino, Leo Gagnon, Sangnie Bhardwaj, Dhanya Sridhar, Guillaume LajoieR2-FM @ ICLR 2024

TL;DR

This paper investigates whether explicitly separating a Transformer's "context aggregation" (inferring task parameters) from "predictive modeling" (using those parameters to make predictions) offers benefits over standard, implicit In-Context Learning (ICL). While explicit factorization improves interpretability and control, it doesn't consistently boost performance, suggesting current decoders struggle to leverage the inferred latent variables effectively.

What Problem Does This Paper Address?

Transformer models have demonstrated a remarkable ability to learn new tasks from a few examples provided in their input context, a phenomenon known as In-Context Learning (ICL). This capability is crucial for their emergent abilities and out-of-distribution generalization. However, the exact mechanisms behind ICL are not fully understood. Current research suggests that Transformers might be implicitly modeling a Bayesian posterior predictive distribution over latent task variables. This implicit approach contrasts with traditional Bayesian methods that explicitly define and infer latent variables. The paper asks: does explicitly separating the process of inferring task-specific latent variables (context aggregation) from the process of using those variables to make predictions (predictive modeling) offer advantages, or is the implicit approach sufficient and perhaps even preferable?

Methods

The authors propose an architectural modification to standard Transformers to enforce an "explicit" factorization of knowledge. In the standard (implicit) ICL setup, a single Transformer processes the context and query to directly predict the output. In the proposed explicit model, this is split into two parts:

  1. Context Aggregation: A dedicated module (a Transformer) takes the context examples and infers a task representation, denoted as $z_t(D)$. This is analogous to inferring latent variables in a Bayesian model.
  2. Predictive Modeling: A separate module (which can be another Transformer or an MLP) takes the inferred task representation $z_t(D)$ and the query $x^*$ to produce the prediction $y^*$.

This explicit separation aims to disentangle the two core processes of ICL. The authors then compare this explicit model against a standard implicit Transformer across various tasks.

Datasets

The paper evaluates their approach on a variety of synthetic and real-world tasks:

  • Synthetic Regression Tasks: Linear, MLP-based nonlinear, Sinusoidal, Gaussian Process, and Hodgkin-Huxley ODE.
  • Synthetic Classification Tasks: Linear, MLP-based nonlinear, and Alchemy (a meta-reinforcement learning benchmark with compositional symbolic transformations).
  • Real-World Tasks: Raven's Progressive Matrices (a reasoning task) and Gene Targeting (predicting genetic expressions from CRISPR interventions).

No new datasets were introduced; existing benchmarks were used to evaluate performance.

Key Insights and Ideas

  • Interpretability and Control: The explicit factorization provides a clear bottleneck ($z_t(D)$) from which task-specific parameters can be decoded. This offers significant advantages in interpretability, allowing researchers to understand what the model has learned about the task. Furthermore, it enables "interventional ability," where specific latent components can be manipulated to observe their effect on predictions.
  • The Decoder Bottleneck: A surprising finding is that the explicit model's performance is heavily reliant on the "decoder" (the predictive modeling module). When the decoder was explicitly given the correct prediction function (e.g., a known linear model), the explicit model showed significant improvements. However, when only the latent variable was provided without a strong decoder, performance lagged. This suggests that the failure mode of explicit models is not in inferring the latent, but in effectively using it for prediction.
  • Implicit vs. Explicit Trade-offs: For tasks where the underlying data-generating process is inherently parametric and low-dimensional, the explicit model could theoretically be superior. However, in practice, the implicit model often performs comparably or even better, especially for non-parametric tasks (like Gaussian Processes) where the implicit model's ability to directly compare queries to the entire context is advantageous.
  • Transformer's Implicit Strength: The paper posits that Transformers, due to their attention mechanisms, are naturally adept at implicit, non-parametric learning. This might explain why they often don't benefit from explicit factorization unless the downstream predictor is specifically designed to leverage the inferred latents.

Key Results

  • Performance: Across most tasks, the explicit model performed comparably to the implicit model. There was no consistent advantage for the explicit model in terms of Out-of-Distribution (OOD) generalization.
  • Interpretability: The explicit model consistently provided better interpretability, allowing for decoding of latent task parameters.
  • Intervention: The explicit model enabled successful counterfactual interventions on learned latent subspaces, demonstrating causal understanding of task components.
  • Decoder Impact: Explicit models with a known, correct decoder showed significant performance boosts (Fig. 3a), while those with a known latent but an untrained decoder did not (Fig. 3b).

Limitations and Future Work

  • Decoder Capacity: The primary limitation identified is the lack of capacity in the predictive modeling component of the explicit model to effectively leverage the inferred latent variables. This hinders performance gains.
  • Future Work: The authors suggest future work should focus on incorporating inductive biases into the prediction model itself, rather than just the latent inference, to better utilize the explicit latent variables. This could involve designing decoders that are more attuned to parametric forms or specific inductive biases relevant to the task. They also note that for more complex tasks and larger models, the benefits of explicit factorization might change.

Summary updated

BibTeX
@inproceedings{mittal2024explicit,
  author = {Sarthak Mittal and Eric Elmoznino and Leo Gagnon and Sangnie Bhardwaj and Dhanya Sridhar and Guillaume Lajoie},
  title = {{Explicit Knowledge Factorization Meets In-Context Learning: What Do We Gain?}},
  booktitle = {R2-FM @ ICLR},
  year = {2024},
  url = {https://openreview.net/forum?id=DoFtSA1qIB},
}
Figure