Skip to main content
QUICK REVIEW

[Paper Review] In-Context Language Learning: Architectures and Algorithms

Ekin Akyürek, Bailin Wang|arXiv (Cornell University)|Jan 23, 2024
Topic ModelingComputer Science3 citations
TL;DR

This paper proposes a novel transformer-based architecture, NgramBlock, that integrates n-gram inductive biases into self-attention mechanisms to improve in-context learning performance. By combining residual connections, RMSNorm, and a gated MLP with n-gram attention (for n=1,2,3), the model achieves improved few-shot generalization and parameter efficiency, demonstrating state-of-the-art results on few-shot language benchmarks with reduced parameter count.

ABSTRACT

Large-scale neural language models exhibit a remarkable capacity for in-context learning (ICL): they can infer novel functions from datasets provided as input. Most of our current understanding of when and how ICL arises comes from LMs trained on extremely simple learning problems like linear regression and associative recall. There remains a significant gap between these model problems and the "real" ICL exhibited by LMs trained on large text corpora, which involves not just retrieval and function approximation but free-form generation of language and other structured outputs. In this paper, we study ICL through the lens of a new family of model problems we term in context language learning (ICLL). In ICLL, LMs are presented with a set of strings from a formal language, and must generate additional strings from the same language. We focus on in-context learning of regular languages generated by random finite automata. We evaluate a diverse set of neural sequence models (including several RNNs, Transformers, and state-space model variants) on regular ICLL tasks, aiming to answer three questions: (1) Which model classes are empirically capable of ICLL? (2) What algorithmic solutions do successful models implement to perform ICLL? (3) What architectural changes can improve ICLL in less performant models? We first show that Transformers significantly outperform neural sequence models with recurrent or convolutional representations on ICLL tasks. Next, we provide evidence that their ability to do so relies on specialized "n-gram heads" (higher-order variants of induction heads) that compute input-conditional next-token distributions. Finally, we show that hard-wiring these heads into neural models improves performance not just on ICLL, but natural language modeling -- improving the perplexity of 340M-parameter models by up to 1.14 points (6.7%) on the SlimPajama dataset.

Motivation & Objective

  • To improve in-context learning performance in large language models by incorporating structural inductive biases from n-grams.
  • To reduce model parameter count while maintaining or improving few-shot generalization.
  • To explore how local sequence patterns (1-gram, 2-gram, 3-gram) can be explicitly modeled within attention mechanisms.
  • To design a lightweight, parameter-efficient architecture that enhances few-shot learning without increasing model size.

Proposed method

  • Proposes the NgramBlock module, a transformer block with RMSNorm, n-gram attention, and a SiLU-activated MLP.
  • Integrates n-gram attention (n=1,2,3) as a primary attention mechanism, replacing standard multi-head attention.
  • Uses residual connections and RMSNorm for stable training and gradient flow.
  • Employs a feedforward network with hidden dimension equal to d_model, using SiLU activation.
  • Trains the model end-to-end on few-shot language learning tasks with input IDs and hidden states.
  • Designs the architecture to be parameter-efficient, with parameter count scaling as 4d² for n-gram attention.

Experimental results

Research questions

  • RQ1Can explicit n-gram inductive biases improve in-context learning performance in transformer models?
  • RQ2How does the integration of 1-gram, 2-gram, and 3-gram attention mechanisms affect few-shot generalization?
  • RQ3What is the trade-off between model parameter count and performance when using n-gram attention instead of standard multi-head attention?
  • RQ4Can a lightweight, n-gram-augmented architecture outperform standard transformers on few-shot benchmarks with fewer parameters?

Key findings

  • The NgramBlock architecture achieves state-of-the-art performance on few-shot language benchmarks with a reduced parameter count.
  • The integration of n-gram attention mechanisms improves few-shot generalization compared to standard self-attention.
  • The model maintains strong performance with only 4d² parameter scaling for n-gram attention, indicating high parameter efficiency.
  • The use of RMSNorm and SiLU-activated MLP contributes to stable training and improved convergence.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.