An interactive learning resource

Introduction to In-Context Learning

For Language, Computer Vision, and Robotics

The core idea

Learn by showing, not retraining

In-Context Learning (ICL) enables large language models to adjust to new tasks without changing their internal weights. Instead of retraining or fine-tuning a model, we provide instructions and examples directly in the prompt.

The model detects patterns in those demonstrations and applies them to new queries. This makes it possible for one model to shift between classification, translation, summarization, prediction, and reasoning based solely on the current context. The capability was prominently demonstrated in Language Models are Few-Shot Learners (Brown et al., 2020).

This site introduces the foundations of ICL and provides hands-on examples in regression, reinforcement learning, pattern recognition, and translation. Every example is available as a Google Colab tutorial and can be run with the free Gemini version.

UnderstandSee how models infer a task from instructions and examples.
CompareContrast in-context learning with traditional model training.
ExperimentRun tutorials spanning language, vision, prediction, and control.
Hands-on tutorials

Explore the demos

See how LLMs learn patterns, make predictions, classify data, tune controllers, and perform reinforcement learning—all without retraining.

12 tutorials shown

Sequence & pattern

Sequence Prediction

Sine-based time-series forecast

Explore how examples of a changing sine wave help an LLM identify its structure and forecast the next values in a time series.


Sequence & pattern

Pattern Completion

Numerical pattern-completion example

Use demonstrations from the Abstract and Reasoning Corpus to infer hidden numerical transformations and complete a new pattern from context.


Sequence & pattern

Movie Translation

Fictional movie-language translations

Learn fictional vocabularies from examples inspired by Avatar, Lord of the Rings, Star Trek, and Game of Thrones, then translate new phrases.


Prediction & regression

Glucose Level Forecast

Glucose-level time-series forecast

Provide recent glucose readings as context and examine how an LLM recognizes temporal trends to estimate upcoming values.


RL & optimization

PID Tuning

PID controller tuning plot

See how performance examples can guide an LLM toward improved proportional, integral, and derivative controller settings without retraining.


Classification

Binary Classification

Binary classification decision boundary for hazelnut quality

Turn a small set of labeled hazelnut-quality examples into a binary classification rule, then apply it to previously unseen samples.


Classification

Image Classification

Examples of weld defects for image classification

Use visual examples and contextual labels to distinguish common weld defects and understand how demonstrations guide image classification.


Prediction & regression

Linear Regression

Linear-regression optimization

Iteratively refine the slope and intercept of a linear model by placing prior parameter choices and their results in the prompt.


RL & optimization

ProPS
"Reinforcement Learning using LLMs"

ProPS applied to the Mountain Car task

Apply Prompted Policy Search to MountainCar-v0 and watch an LLM improve control parameters using the outcomes of earlier attempts.


RL & optimization

ProPS+
"RL using LLMs with Semantics"

ProPS+ applied to a swimming robot

Add semantic environment descriptions to Prompted Policy Search and study how that context supports policy improvement on Swimmer-v5.


RL & optimization

SAS-Prompt
"Self-Improvement using LLMs"

SAS-Prompt applied to a golf robot

Explore self-adaptive prompting in a golf simulation, where feedback from each attempt helps the LLM propose a better next action.


RL & optimization

Numerical Optimization
"Numerical Optimization inside the LLM"

Numerical optimization of the Ackley function

Use previous points and objective values as context to search the one- and two-dimensional Ackley functions for better solutions.