Large (Vision) Language Models are Unsupervised In-Context Learners

Artyom Gadetsky, Andrei Atanov, Yulun Jiang, Zhitong Gao, Ghazal Hosseini Mighan, Amir Zamir, Maria Brbic

Abstract

Foundation models (FMs) demonstrate remarkable zero-shot capabilities but often require supervised adaptation—via fine-tuning or in-context learning (ICL)—to reach peak performance. This paper introduces a joint inference framework that enables unsupervised adaptation by maximizing the joint probability of predictions across a batch of unlabeled inputs. We propose two methods: Unsupervised Fine-Tuning (amortized) and Unsupervised ICL (iterative). Our framework significantly outperforms standard zero-shot approaches across NLP, reasoning, and vision-language tasks, sometimes matching supervised performance without a single ground-truth label.

Introduction

While Large Language Models (LLMs) and Vision-Language Models (VLMs) are powerful, their performance is often bottlenecked by the need for high-quality labeled data or manual prompt engineering for specific tasks. The challenge of unsupervised adaptation is to help a model "figure out" a new task using only unlabeled data.

The core insight of this work is a shift from independent predictions, $p(y|x)$, to joint inference. By considering a group of inputs together, the model can identify the most consistent set of answers, using consistency as a proxy for correctness.

Conceptual comparison between independent and joint inference, alongside scaling results on CIFAR-100.

Methods

The framework implements joint inference through two primary avenues:

1. Unsupervised Fine-Tuning (Amortized Approach)

This method splits the model into a lightweight "task encoder" (using LoRA) and the original foundation model. The task encoder generates candidate answers, which the foundation model then scores based on their joint probability. To update the encoder, we utilize a specialized REINFORCE-based gradient estimator, encouraging the production of answers that maximize joint probability while using regularization to avoid degenerate, overly consistent solutions.

The three-step pipeline for Unsupervised Fine-Tuning using a task encoder and joint probability maximization.

2. Unsupervised In-Context Learning (Multi-Turn Approach)

For "black-box" models accessible only via API, we propose an iterative prompting method. Starting from zero-shot predictions, the model is repeatedly prompted with its own previous predictions as in-context examples. This process acts as a form of Gibbs sampling, allowing the model to converge on a consistent and accurate set of labels for the entire dataset.

Experimental Results

We evaluated the framework across 13 NLP datasets, math reasoning (GSM8K), and various vision-language benchmarks.

  • Reasoning: On GSM8K, Unsupervised ICL achieved a 39% absolute improvement over zero-shot performance with Qwen2.5-Math.
  • NLP: Unsupervised Fine-Tuning on Llama-3.1-8B improved average accuracy by 23%, matching supervised fine-tuning on nearly half of the tested datasets.
  • Vision-Language: On Food101, the method provided a 23% boost over standard zero-shot VLM performance.
  • Scaling: Performance consistently improves as the number of joint examples ($N$) increases, as shown in the CIFAR-100 results (see Figure 1).

Discussion and Limitations

The success of this framework suggests that foundation models possess latent task knowledge that can be unlocked through consistency-based joint inference. However, the method requires the base model to have a non-trivial initial signal; if zero-shot performance is near-random, joint inference lacks a foundation to amplify. Additionally, while more efficient than manual labeling, these methods increase test-time compute due to their iterative or batch-processing nature. Future work will explore extending these techniques to free-form text generation beyond closed-ended classification and reasoning tasks.

Summary updated

BibTeX
@inproceedings{gadetsky2025large,
  author = {Artyom Gadetsky and Andrei Atanov and Yulun Jiang and Zhitong Gao and Ghazal Hosseini Mighan and Amir Zamir and Maria Brbic},
  title = {{Large (Vision) Language Models are Unsupervised In-Context Learners}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=ohJxgRLlLt},
}
Figure