Papers › In-Context Language Learning: Architectures and Algorithms

In-Context Language Learning: Architectures and Algorithms

23 Jan 2024arXiv:2401.12973archive 2025-07-28

Ekin Akyürek, Bailin Wang, Yoon Kim, Jacob Andreas

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.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology: its repositories, every harvested function with whether it ran, its licence and the call to fetch it.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2401.12973")

Code

Syntology Ran 12 of 20 code samples harvested from 1 repository linked to this paper; 8 have no recorded run. Of those that ran: 12 ran with no contract checked.

By repository: official repository: 20 samples from 1 repository, 12 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

berlino/seq_icl officialmentioned in papermentioned on GitHubpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

20 samples harvested; 12 ran; 0 honoured the contract we drafted; 8 have no recorded run. Read from Syntology's graph 2026-09-25; that is when this build read the record, not when the samples ran.

12ran
8unverified

Licence: 0 of the 20 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from berlino/seq_icl. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

create_flags berlino/seq_icl/sweep.py official repository ran Apache-2.0 (permissive) · b7ffd8fb4517d412 · report
generate berlino/seq_icl/generate.py official repository ran Apache-2.0 (permissive) · 9e64222cc89cf42d · report
get_conditional_prob berlino/seq_icl/ngram.py official repository ran Apache-2.0 (permissive) · 51b7e5bf992a7ada · report
get_config berlino/seq_icl/sweep.py official repository ran Apache-2.0 (permissive) · aa4ed806d118746a · report
get_dfa_states berlino/seq_icl/samestateprobe.py official repository ran Apache-2.0 (permissive) · 9a83c3eaaa9c553c · report
get_sweep berlino/seq_icl/sweep.py official repository ran Apache-2.0 (permissive) · ce9f5b21ad841769 · report
mask_transition_matrix berlino/seq_icl/batched_baum_welch.py official repository ran fingerprinted Apache-2.0 (permissive) · 9f129256cb54eace · report
normalize berlino/seq_icl/ngram.py official repository ran Apache-2.0 (permissive) · e71438a3ed6a9798 · report
possible_states berlino/seq_icl/batched_baum_welch.py official repository ran fingerprinted Apache-2.0 (permissive) · 35218296da840eec · report
read_hidden_states berlino/seq_icl/samestateprobe.py official repository ran Apache-2.0 (permissive) · e13fb3b9ab87c890 · report
read_one berlino/seq_icl/probe.py official repository ran Apache-2.0 (permissive) · dba3844475b7ec75 · report
train_everygram berlino/seq_icl/ngram.py official repository ran Apache-2.0 (permissive) · 29c617b8c430aff7 · report
eval_dfa berlino/seq_icl/analyze.py official repository unverified Apache-2.0 (permissive) · d079b2adb7787354 · report
forward_backward berlino/seq_icl/batched_baum_welch.py official repository unverified Apache-2.0 (permissive) · 7d16fa77eed96638 · report
get_results berlino/seq_icl/samestateprobe.py official repository unverified Apache-2.0 (permissive) · e4d688cc5cf62263 · report
get_transition_info berlino/seq_icl/analyze.py official repository unverified Apache-2.0 (permissive) · 7ba8c48c6e6661b3 · report
get_uniform_probs berlino/seq_icl/analyze.py official repository unverified Apache-2.0 (permissive) · 5a82f62a07d935e2 · report
prepare_video berlino/seq_icl/make_video.py official repository unverified Apache-2.0 (permissive) · 22b5e068ce364282 · report
read_hidden_states berlino/seq_icl/probe.py official repository unverified Apache-2.0 (permissive) · 544b7de38c79c09c · report
read_parallel berlino/seq_icl/probe.py official repository unverified Apache-2.0 (permissive) · e490d66f05b1420b · report

Tasks

In-Context LearningLanguage ModelingLanguage Modelling

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

FocusLinear RegressionSET

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections