atlas

Research map / Architectures and efficiency / Attention and transformers

Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasks

NeurIPS 2024 · Architectures and efficiency › Attention and transformers · approach: Training dynamics of in-context learning · 1 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Trains GPT-style transformers on linear modular functions z = ax + by mod p with a subset of task vectors, showing out-of-distribution in-context generalization emerges with enough pre-training tasks and analyzing the learned circuits.

Problem

How in-context learning and skill composition emerge in autoregressive transformers, studied on a controlled algorithmic dataset of modular linear functions where test tasks are unseen during pre-training.

Approach

Defines a family of p^2 modular linear tasks labeled by (a,b), pre-trains on a subset of tasks with structured rectangular task sampling and aligned batches, and shows a memorization-to-OOD-generalization transition as the number of tasks grows, with mechanistic analysis revealing circle-of-circles representations and an algorithmic shift from ratio matching to modular regression in deeper models.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
increase the number of pre-training tasksGPT-style transformer · modular arithmetic out-of-distribution tasksaccuracyHelped
increase the number of pre-training tasksGPT-style transformer · modular arithmetic in-context learningfew-shot sample efficiencyHelped
increase the number of pre-training tasksGPT-style transformer · modular arithmetic in-distribution pre-trainingaccuracyHurt
use a two-block transformer instead of a deeper modelGPT-style transformer · modular arithmetic out-of-distribution generalizationaccuracyMixed
use a four-block rather than a two-block transformerGPT-style transformer · modular arithmetic with many in-context examplesout-of-distribution accuracyHelped
use a four-block rather than a two-block transformerGPT-style transformer · modular arithmetic with many in-context exampleslabel-corruption robustnessHelped
use a six-block transformerGPT-style transformer · modular arithmetic out-of-distribution generalization during trainingaccuracyMixed
early-stop deeper modelsGPT-style transformer · modular arithmetic out-of-distribution generalizationaccuracyHelped
sample pre-training task vectors randomly instead of using the rectangular rule (ablation)six-block GPT-style transformer · modular arithmetic out-of-distribution generalizationaccuracyHurt
remove balanced task representation and aligned input sequences from batches (ablation)GPT-style transformer · modular arithmetic pre-trainingtraining lossHurt
corrupt one in-context label (ablation)four-block transformer · modular arithmetic with longer context sequencesprediction performanceNo clear effect
corrupt multiple in-context labels at random locations (ablation)four-block transformer · modular arithmetic with longer context sequencesprediction performanceMixed

Surprising findings

Limitations

Experimental setup

Datasets: synthetic modular arithmetic sequences (p=29)

Benchmarks: in-distribution and out-of-distribution test sets of modular linear tasks

Metrics: accuracy loss vs number of shots phase diagram classification (75% threshold)

Baselines: ratio matching modular regression

Builds on: grokking in-context linear regression induction heads RoPE AdamW

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy