Skip to content
Robotics.world

Research

ContextFlow: In-Context Flow Matching for Robot Manipulation

Robots that learn from demonstrations usually need fine-tuning for each new task, whereas "in-context" imitation learning aims to adapt from a handful of example trajectories at test time without…

The paper’s first page · arXiv:2609.06852
arXiv
2609.06852 · Preprint · not peer-reviewed
Published
2026-09-06
Authors
Jian Ding, Xianjie Dai, Roei Herzig, Nussair Hroub, Jinjie Mai, Dengxin Dai, Bernard Ghanem, Mohamed Elhoseiny

In plain words

Robots that learn from demonstrations usually need fine-tuning for each new task, whereas "in-context" imitation learning aims to adapt from a handful of example trajectories at test time without updating any weights.

AI summary

Overview

Research area: Robotics — in-context imitation learning and vision-language-action (VLA) policy learning for robot manipulation. Technical level: Intermediate (assumes familiarity with imitation learning, transformers, and diffusion/flow-matching style generative models). Scope: The paper introduces ContextFlow, a conditional flow-matching policy that conditions on multimodal in-context demonstrations to generalize to unseen task configurations, evaluated on LIBERO simulation and a real ALOHA bimanual robot platform.

What This Paper Is About

Robots that learn from demonstrations usually need fine-tuning for each new task, whereas "in-context" imitation learning aims to adapt from a handful of example trajectories at test time without updating any weights. Prior in-context methods are autoregressive: they discretize continuous actions into tokens and predict them one at a time, which introduces quantization error and lets early mistakes snowball, particularly when the test task configuration differs from training. The paper's goal is to replace this next-token recipe with flow matching, which predicts a whole chunk of continuous actions in parallel while conditioned on the demonstration and current observation.

Key Contributions

  1. A flow-matching formulation of in-context imitation learning. The authors define the policy as a conditional flow-matching model π(a_t | o_t, d) that generates continuous action chunks of horizon H directly in action space, avoiding action tokenization entirely.
  2. Multimodal context compressors. Perceiver-style learnable-query compressors distill long image, proprioceptive-state, and action demonstration streams into a fixed-size set of latent context tokens, using separate compressors (C_img, C_state, C_action) with 32 queries each.
  3. A new real-world ALOHA dataset. 1,318 multimodal trajectories across 25 task configurations (21 evaluation configurations with 1,064 demonstrations, plus 4 extra bimanual tasks with 254 training-only demonstrations), spanning single-arm skills and fine-grained bimanual manipulation.
  4. Empirical comparison against autoregressive and VLA baselines. Evaluations on LIBERO-Spatial, LIBERO-Object, and real ALOHA hardware, including a controlled autoregressive baseline (ContextAR) sharing the same vision backbone and π₀ initialization.

Main Findings

  • Large gain over the autoregressive in-context baseline: On LIBERO, ContextFlow reaches 73.5% average success on unseen task configurations versus 38.5% for ICRT — the paper reports this as a 35 percentage point improvement. Per-suite: 64.0 vs 27.0 on LIBERO-Spatial and 83.0 vs 50.0 on LIBERO-Object.
  • Controlled flow-vs-autoregression comparison: The plain flow-matching variant without compressors (ContextFlow-Plain, 64.0% average) beats ContextAR (53.5%) by 10.5 percentage points, isolating the effect of the modeling paradigm from architecture.
  • Matches task-specific fine-tuning without any fine-tuning: ContextFlow's 73.5% average is comparable to π₀ fine-tuned with 1 demonstration per unseen task (72.5%), and above unfine-tuned π₀ (44.5%) and OpenVLA-OFT (40.0%).
  • Context compressors add further gains: Adding compressors raises average success by 9.5 points over ContextFlow-Plain and 20 points over ContextAR. Enabling only the image compressor gives a 4-point average improvement (68.0).
  • Modalties matter unequally: Removing proprioceptive states and actions causes a 44.5-point drop on unseen configurations (73.5 → 29.0), removing images causes a 28.5-point drop (→ 45.0), and removing text causes a 9.0-point drop (→ 64.5).
  • Flow matching beats other parallel action heads: MLP L1 regression reaches 58.0%, diffusion converges slowly (16.5% at 20k iterations, 33.5% at 100k), and flow matching reaches 73.5% at 20k iterations.
  • Reduced compounding error: Cumulative MSE is 4.7 m² for ContextAR, 3.0 for ContextFlow-Plain, and 2.2 for ContextFlow. In the S₂ task over 50 test episodes, ContextAR and ContextFlow have similar error for the first 30 steps, after which ContextAR's error grows more.
  • Real-robot results: On unseen configurations, ContextFlow succeeds on 2/10 pear, 5/10 orange, 4/10 banana, 4/10 kiwi, 4/10 red-pen uncapping, and 6/10 red-egg placement trials; ICRT succeeds only on 2/10 pear and 0/10 on all others.
  • Compressor attention is interpretable: Visualizing the image compressor's queries shows attention moving from the gripper before grasping, to the object after grasping, to the plate during placing.
  • Scaling training data helps harder suites but not fully: Adding LIBERO-90 to training raises the four-suite average from 36.8 to 43.0, with LIBERO-Goal going from 0.0 to 29.0 and LIBERO-10 from 0.0 to 3.0.

Methodology in Plain English

The model is built as a mixture of two "experts." A context expert looks at the current camera image, the text instruction, and the provided demonstration. An action expert takes the robot's current joint/gripper state plus a noisy guess at the next actions and repeatedly refines that guess, consulting the context expert each time.

Because demonstrations are long — the paper notes a "put egg in box" demonstration can run roughly 800 steps — feeding every frame, state, and action into attention would be very expensive. So the authors first subsample the demonstration to 8 image frames, 128 proprioceptive states, and 128 actions. Three small perceiver-style compressors (image: 4 layers; state and action: 2 layers) then squeeze each stream into 32 learned latent tokens, which are concatenated into one compact context.

Training follows conditional flow matching: clean action chunks are linearly interpolated with Gaussian noise using a time variable s, and the network learns to predict the velocity pointing from noisy to clean. The loss is the squared error between predicted and true velocity, with s drawn from a Beta(1.5, 1) distribution. At inference, actions start as pure noise and are integrated with a simple forward Euler solver over K = 10 steps.

A block-wise causal attention mask means action tokens can attend to context tokens but not vice versa, so context tokens can be cached across the 10 flow steps instead of being recomputed. The vision encoder is SigLIP at 224×224 and is fully fine-tuned; the action expert is initialized from π₀ and adapted with LoRA (rank 32, α 32); the context expert is randomly initialized and fully trained. Training runs 20K iterations at batch size 32 with a cosine schedule peaking at 2.5×10⁻⁵ and bottoming at 2.5×10⁻⁶ after a 1,000-step warm-up.

Why This Matters

Impact on research. The paper provides a controlled head-to-head test of autoregressive versus flow-matching action modeling for in-context imitation, holding the vision backbone and π₀ initialization fixed. That isolates the paradigm as the variable and gives concrete evidence — both success rates and cumulative MSE — that parallel continuous prediction mitigates compounding error under configuration shift. It also connects in-context prompting (demonstrations as the "prompt") with modern flow-based VLA heads.

Real-world applications:

  • Rapid redeployment of manipulation policies to new object types or spatial arrangements on a factory or warehouse line, without retraining.
  • Bimanual fine manipulation such as uncapping pens or assembling parts, where the paper shows high-frequency closed-loop feedback is required.
  • Household or service robots that a non-expert can teach by physically demonstrating a task a few times.
  • Food handling and packing tasks (the paper's "put egg in box" and pick-and-place suites) with varied objects.

Industry relevance. The result that in-context learning matches 1-shot task-specific fine-tuning (73.5% vs 72.5%) matters commercially: fine-tuning costs compute, needs per-task data pipelines, and risks catastrophic forgetting, whereas swapping a demonstration at inference time is far cheaper. The context-caching design also directly targets inference latency.

Future Directions

  • Extending beyond configuration shift. The authors state explicitly that generalization is limited to unseen objects and spatial arrangements within tasks sharing similar primitives, not fundamentally different task types — extending to new task families is open.
  • Closing the LIBERO-Goal and LIBERO-10 gap. Even with LIBERO-90 added, success on LIBERO-10 reaches only 3.0 and on LIBERO-Goal 29.0, so these suites remain largely unsolved.
  • Improving the weak real-world regimes. The pear pick-and-place configuration succeeds only 2/10, the same as ICRT, indicating some configurations are not yet helped by the flow-matching switch.
  • Scaling demonstration context and data. The conclusion raises scaling up data diversity, and the ablation shows image count and state/action count affect success (more frames helped by 3.0 points; 128 states/actions was optimal, with 256 dropping to 66.5), leaving room to study compression and context length jointly.

Target Audience

Robotics and embodied-AI researchers working on imitation learning, VLA models, and flow-matching or diffusion policies; engineers deploying manipulation policies who care about adapting to new task configurations without retraining; and graduate students who want a clear, quantitative case study on why continuous parallel action prediction outperforms autoregressive token prediction under distribution shift. Readers should already be comfortable with transformers, attention, and the basics of diffusion/flow-matching objectives.

Authors’ abstract

Although highly effective in vision and language domains, applying in-context learning to robotics remains challenging. Existing autoregressive in-context imitation methods discretize continuous actions and exacerbate the accumulation of early prediction errors through next-token prediction, limiting their generalization on unseen task configurations. Meanwhile, flow-matching policies have been explored for continuous robot control and can help mitigate compounding errors;…

The full abstract on arXiv
Read the original paper

Related papers