Sampling Language from Latent System 2 Reasoning

Celine Lee, Md Arafat Sultan, Tahira Naseem, Alexander M Rush, Ramón Fernandez AstudilloSys2-Reasoning @ NeurIPS 2024

TL;DR

This paper introduces a novel method for extracting latent symbolic representations from text data by modeling it as being generated from executable code. This "codespace autoencoder" allows for more interpretable and structured reasoning, leading to improved correctness and diversity in generated text, especially for algorithmic tasks.

What Problem Does This Paper Address?

Modern language models are increasingly tasked with complex reasoning, fact recall, and adhering to specific constraints, all of which often imply an underlying symbolic structure. However, current models primarily operate on surface-level text, making it difficult to explicitly capture and leverage these underlying symbolic processes. The challenge is to find a way to unsupervisedly extract and utilize these latent symbolic representations, particularly those that can be expressed as executable code, to improve language model performance on tasks requiring compositional and algorithmic reasoning.

Methods

The core of the proposed method is a non-parametric latent variable model that treats executable code as the latent symbolic representation. This "codespace autoencoder" learns to map text data to and from this latent code space.

  • Latent Representation: The latent space is represented by executable code programs. This choice is motivated by code's structured nature, modularity (via functions), and interpretability through deterministic and neural interpreters.
  • Unsupervised Learning: The model is trained in an unsupervised manner using a variational autoencoder framework. It learns a shared function library (global term $z_e$) and dataset-specific code programs ($z_i$).
  • In-Context Learning (ICL): The variational posterior $q(z|x; D)$ is defined using ICL, leveraging a set of demonstrations $D$ (pairs of text examples and their corresponding code programs). This set $D$ is iteratively optimized to best approximate the true posterior.
  • Encoder/Decoder: A Large Language Model (LLM) acts as the encoder, prompted via ICL to generate code programs from text. The decoder uses a combination of deterministic Python interpreters and LLM emulation (similar to the Chain-of-Code framework) to translate latent code back into text.
  • Regularization: A novel regularization is introduced to ensure the latent code generalizes beyond specific examples, rejecting code that doesn't meet a certain generalization threshold.

Datasets

  • Super-NaturalInstructions (SNI) [22]: This dataset, containing over 5 million diverse NLP tasks, is used for training and evaluation. It includes both algorithmic and natural language tasks, allowing for a comprehensive assessment of the method. The SNI dataset is divided into in-domain (ID) and out-of-domain (OOD) tasks for evaluation.

Key Insights and Ideas

  • Code as a Powerful Latent Space: Representing latent reasoning as executable code offers significant advantages, particularly for tasks that are inherently compositional and algorithmic. Code provides a structured, interpretable, and executable representation that LLMs can learn to generate and utilize.
  • Unsupervised Discovery of Symbolic Structure: The method effectively discovers underlying symbolic structures in text data without requiring explicit symbolic supervision, relying instead on a non-parametric autoencoder approach.
  • Interpretability through Execution: The ability to execute the latent code programs provides a direct window into the model's reasoning process, making it easier to understand why a particular output was generated and to debug errors.
  • Generalization via Code: The proposed regularization technique helps ensure that the learned latent code generalizes well to unseen examples, preventing overfitting to the training data.

Key Results

  • Improved Recovery Rate: Conditioning the autoencoder on the induced demonstrations $D$ significantly improves the autoencoding recovery rate compared to using only domain-general demonstrations, for both code and Chain-of-Thought (CoT) latent representations.
  • Enhanced Correctness and Domain Relevance: Samples generated from the code-based latent space show higher correctness and domain relevance, especially for algorithmic tasks, compared to interpolation baselines and CoT.
  • Synthetic Data Generation: The method can generate synthetic training data that, when used to fine-tune downstream models, performs competitively with, and sometimes even surpasses, data generated by interpolation baselines or the original "gold" data.
  • LLM Emulation Usage: While most induced latent code programs are directly executable, non-algorithmic tasks and larger models tend to leverage LLM emulation more frequently.

Limitations and Future Work

  • LLM Emulation for Non-Algorithmic Tasks: For non-algorithmic tasks, the induced code programs tend to rely more on LLM emulation, which can be less deterministic and interpretable than direct execution.
  • Interpolation Baseline Performance: In some downstream tasks, the simple interpolation baseline (without a latent space) sometimes outperforms the latent modeling approaches, suggesting that further improvements in latent space modeling or generation are needed.
  • Future Work: The authors suggest exploring further applications of this framework, potentially extending it to more complex reasoning tasks and investigating how to further improve the generation of diverse and correct outputs, especially for non-algorithmic tasks. They also highlight the potential for using this framework to analyze and understand the latent structures within different datasets.

Summary updated

BibTeX
@inproceedings{lee2024sampling,
  author = {Celine Lee and Md Arafat Sultan and Tahira Naseem and Alexander M Rush and Ramón Fernandez Astudillo},
  title = {{Sampling Language from Latent System 2 Reasoning}},
  booktitle = {Sys2-Reasoning @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=OdUqJwu0Gr},
}
Figure