Unleashing In-context Learning of Autoregressive Models for Few-shot Image Manipulation

Bolin Lai, Felix Juefei-Xu, Miao Liu, Xiaoliang Dai, Nikhil Mehta, Chenguang Zhu, Zeyi Huang, James M. Rehg, Sangmin Lee, Ning Zhang, Tong Xiao

Abstract

InstaManip is a novel multi-modal autoregressive model designed to bring the in-context learning capabilities of Large Language Models (LLMs) to the domain of image editing. By providing a few example image pairs demonstrating a transformation, the model can instantly learn and apply new manipulation rules to a query image. This approach addresses the linguistic ambiguity and generalization gaps common in diffusion-based methods. Experimental results show that InstaManip significantly outperforms existing state-of-the-art models in few-shot scenarios, particularly for out-of-distribution concepts.

Introduction

Current text-to-image manipulation models, such as InstructPix2Pix, primarily rely on diffusion architectures. While effective, these models face two major hurdles: linguistic ambiguity and a generalization gap. It is often difficult to describe complex visual changes (e.g., specific car models) using text alone. Furthermore, if a concept was not present in the training data, diffusion models frequently fail to reason out the desired edit even when provided with visual examples.

InstaManip demonstrates few-shot learning by transforming a query image into a "catgirl" based on a single exemplar pair.

To bridge this gap, the authors propose InstaManip, which treats image manipulation as a two-stage cognitive process: learning a rule from context and applying it to a new target. By utilizing an autoregressive Multi-modal Large Language Model (MLLM), the system can "reason" through an edit similarly to how LLMs perform few-shot text tasks.

Methodology

InstaManip utilizes a LLaMA2-13B backbone, a ViT image encoder, and an SDXL decoder. The core innovation is the Group Self-Attention (GSA) mechanism, which separates the process into two distinct groups:

  1. Learning Group: The model processes the text instruction and exemplar image pairs to extract "Manipulation Tokens" ($Z$), which serve as a latent representation of the transformation rule.
  2. Applying Group: The model uses these tokens to guide the transformation of the query image, preventing the final output from being contaminated by irrelevant details from the examples.

Additionally, the authors employ Relation Regularization using a CLIP-based loss. This ensures the model focuses on the underlying transformation rather than the specific content of the examples by keeping latent representations of similar instructions close in the embedding space.

Experimental Setup

The model was trained on the InstructPix2Pix dataset, containing over 313,000 image editing pairs. For evaluation, a curated test set of 325 instructions (1,296 samples) was used. Crucially, specific keywords like "Lamborghini" or "Van Gogh" were excluded from the training set to evaluate the model's ability to handle unseen concepts via few-shot visual prompting.

Results and Discussion

InstaManip was compared against state-of-the-art models including ImageBrush, VISII, and PromptDiffusion. Quantitatively, InstaManip achieved superior scores in CLIP-Dir (text-change alignment) and CLIP-Vis (visual-example alignment). In human preference studies, it was favored by a margin of at least 19%.

The model successfully applies an out-of-distribution concept ("Lamborghini") to a query image by learning from a visual exemplar pair.

Key insights from the study include:

  • Reasoning over Generation: Autoregressive models appear fundamentally better at the logical reasoning required for in-context learning than diffusion models.
  • Visual Primacy: Visual examples often yielded better results than text instructions alone, suggesting that few-shot visual prompting can bypass the domain gap between text and pixels.
  • Scaling Evidence: Performance improves with the number of exemplar pairs; a third example often acts as a "tipping point" for the model to grasp complex rules.

Conclusion

While InstaManip demonstrates remarkable out-of-distribution performance, it faces challenges such as a "representational threshold" where a minimum amount of evidence is required for confident rule identification. Additionally, the 13B parameter backbone is computationally intensive. Future work may involve scaling this architecture to create a generalist in-context visual learner capable of diverse tasks beyond image manipulation.

Summary updated

BibTeX
@inproceedings{lai2025unleashing,
  author = {Bolin Lai and Felix Juefei-Xu and Miao Liu and Xiaoliang Dai and Nikhil Mehta and Chenguang Zhu and Zeyi Huang and James M. Rehg and Sangmin Lee and Ning Zhang and Tong Xiao},
  title = {{Unleashing In-context Learning of Autoregressive Models for Few-shot Image Manipulation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01710},
}
Figure