liveBook · Manning

In-context learning

As explained in Retrieval Augmented Generation, The Foundational Ideas

In-context learning is a model adaptation method in which a model learns from information provided in its prompt without modifying its internal weights.

In-context learning adapts a model through information placed in its prompt rather than by changing internal weights. In retrieval-augmented generation, retrieved passages become that information: search selects relevant content, and prompt construction supplies it to the generator. section 1.3.4

A retrieved passage changes the answer

A BART-based generator receives a question together with a retrieved document, combined simply by concatenating the passage before the question. The model itself remains unchanged: replacing the passage can change the answer, while updating the corpus updates the knowledge available at query time. section 4.1.2

Use in-context learning when the system needs to connect a general model with changing or specialized information:

  • Prefer retrieved, high-value context over placing an entire large collection in the prompt; excessive context can obscure relevant facts and produce lost-in-the-middle effects. section 1.3.4
  • Treat retrieval, ranking, filters, and task decomposition as explicit reasoning structure supplied by the developer rather than as changes to the model. section 1.3.4
  • Distinguish this approach from fine-tuning: in-context learning changes the prompt contents, whereas fine-tuning changes model parameters. section 1.3.4

How Retrieval Augmented Generation, The Foundational Ideas covers it

How deep it goes
Defines prompt-based adaptation and demonstrates concatenation, while stopping short of changing model weights or detailing training internals.
Examples
Uses a BART generator that concatenates a retrieved passage with a question before generation.
What it assumes
Assumes a prompt-accepting language model and teaches adaptation from supplied text rather than parameter updates.
What you can do after
Apply it via retrieval-augmented generation by updating retrieved corpus content without retraining the generator.
How it connects
Connects in-context learning to retrieval-augmented generation, context engineering, semantic search, and fine-tuning.

Also explained in

Compare how 3 books explain in-context learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Retrieval Augmented Generation, The Foundational Ideas. The section links point to the parts of the book it draws on.