SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2503.11609 · CVPR · 2025

Rethinking Few-Shot Adaptation of Vision-Language Models in Two Stages

Elisa Ricci, Fondazione Kessler, Massimiliano Mancini, Matteo Farina, Giovanni Iacca

arXiv · PDF · Open in the Atlas

Code that ran

4 of 12 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 8 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2503.11609.json · badge: /api/ran/2503.11609.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
FarinaMatteo/rethinking_fewshot_vlms community
Papers with Code archive
4 ran · 8 no recorded run
FunctionStatusWhere it lives
named_modules_with_index Ran
ran; our contract draft was wrong, not the code
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("ea9a2741a89e9fa3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned generator. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class ResBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.ln1 = nn.LayerNorm(4)
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(self.ln1(x))

class Transformer(nn.Module):
    def __init__(self, num_blocks):
        super().__init__()
        self.resblocks = nn.ModuleList([ResBlock() for _ in range(num_blocks)])
    
    def forward(self, x):
        for block in self.resblocks:
            x = block(x)
        return x

class VisualModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.transformer = Transformer(num_blocks=3)
        self.ln_post = nn.LayerNorm(4)
    
    def forward(self, x):
        x = self.transformer(x)
        x = self.ln_post(x)
        return x

class CLIPModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.visual = VisualModule()
        self.transformer = Transformer(num_blocks=2)
        self.ln_final = nn.LayerNorm(4)
        self.ln_pre = nn.LayerNorm(4)
    
    def forward(self, x):
        x = self.ln_pre(x)
        x = self.transformer(x)
        x = self.ln_final(x)
        return x

clip_model = CLIPModel()

ARGS = {
    'clip_model': clip_model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type generator — a generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a generator output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
num_params Ran
ran, honoured the contract we drafted
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("3a2c8ca13520da36")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        return x

model = SimpleModel()

ARGS = {
    "model": model,
    "trainable": True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
trainable_bias_params Ran
ran; our contract draft was wrong, not the code
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("df1779ed67a55033")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class ResBlock(nn.Module):
    def __init__(self, dim):
        super().__init__()
        self.linear = nn.Linear(dim, dim)
    
class Transformer(nn.Module):
    def __init__(self, num_blocks, dim):
        super().__init__()
        self.resblocks = nn.ModuleList([ResBlock(dim) for _ in range(num_blocks)])

class VisualTransformer(nn.Module):
    def __init__(self):
        super().__init__()
        self.transformer = Transformer(num_blocks=2, dim=4)
        self.ln_post = nn.Linear(4, 4)

class TextTransformer(nn.Module):
    def __init__(self):
        super().__init__()
        self.ln_final = nn.Linear(4, 4)

class CLIPModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.visual = VisualTransformer()
        self.transformer = Transformer(num_blocks=3, dim=4)
        # Add ln_pre to transformer
        self.transformer.ln_pre = nn.Linear(4, 4)

mock_clip_model = CLIPModel()

ARGS = {
    'model': mock_clip_model,
    'modality': 'both',
    'vision_start': 0,
    'text_start': 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
trainable_norm_params Ran
ran; our contract draft was wrong, not the code
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("48286bdf4729b466")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class ResBlock(nn.Module):
    def __init__(self, dim):
        super().__init__()
        self.ln1 = nn.LayerNorm(dim)
        self.ln2 = nn.LayerNorm(dim)
    
    def forward(self, x):
        return x

class Transformer(nn.Module):
    def __init__(self, dim, num_blocks):
        super().__init__()
        self.resblocks = nn.ModuleList([ResBlock(dim) for _ in range(num_blocks)])
    
    def forward(self, x):
        return x

class VisualEncoder(nn.Module):
    def __init__(self, dim, num_blocks):
        super().__init__()
        self.transformer = Transformer(dim, num_blocks)
        self.ln_post = nn.LayerNorm(dim)
    
    def forward(self, x):
        return x

class CLIPModel(nn.Module):
    def __init__(self, dim, num_vision_blocks, num_text_blocks):
        super().__init__()
        self.visual = VisualEncoder(dim, num_vision_blocks)
        self.transformer = Transformer(dim, num_text_blocks)
        self.ln_final = nn.LayerNorm(dim)
        self.ln_pre = nn.LayerNorm(dim)
    
    def forward(self, x):
        return x

clip_model = CLIPModel(dim=4, num_vision_blocks=3, num_text_blocks=2)

ARGS = {
    'model': clip_model,
    'modality': 'both',
    'vision_start': 0,
    'text_start': 0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
SingleStreamClassifier Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("05476a4a6b11e351")
How it ran

no invocation recorded.

cls_acc Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("f2a0a5061e7c204e")
How it ran

no invocation recorded.

evaluate_selective_inference Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("e71d359de1d35c3e")
How it ran

no invocation recorded.

prepare_for_first_stage Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("9a1a4092f9561d8e")
How it ran

no invocation recorded.

run_twostage Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("8291595692fbd0fc")
How it ran

no invocation recorded.

tokenize_texts Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("8541d2e091dc64a9")
How it ran

no invocation recorded.

train_epoch Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("6f0b30003b7c4c5c")
How it ran

no invocation recorded.

train_epoch_second_stage Not yet run
unverified (harvested, no recorded run)
FarinaMatteo/rethinking_fewshot_vlms/fs/twostage.py
code served (permissive licence) · get_code("1d9ea6891b4022ca")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
cls_acc
brick of this paper's assembly: helper
12 other papers
7 dated earlier, 4 later, 1 same year, order not determinable · 2 only as an assembly brick
2210.01253 (2022-10)
PLOT: PROMPT LEARNING WITH OPTIMAL TRANS-PORT FOR VISION-LANGUAGE MODELS
2402.04087 (2024-02)
A Hard-to-Beat Baseline for Training-free CLIP-based Adaptation
2403.12964 (2024-03)
Enhancing Vision-Language Few-Shot Adaptation with Negative Learning
and 9 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

An old-school recipe for training a classifier is to (i) learn a good feature extractor and (ii) optimize a linear layer atop. When only a handful of samples are available per category, as in Few-Shot Adaptation (FSA), data are insufficient to fit a large number of parameters, rendering the above impractical. This is especially true with large pre-trained Vision-Language Models (VLMs), which motivated successful research at the intersection of Parameter-Efficient Finetuning (PEFT) and FSA. In this work, we start by analyzing the learning dynamics of PEFT techniques when trained on few-shot data from only a subset of categories, referred to as the "base" classes. We show that such dynamics naturally splits into two distinct phases: (i) task-level feature extraction and (ii) specialization to the available concepts. To accommodate this dynamic, we then depart from prompt-or adapter-based methods and tackle FSA differently. Specifically, given a fixed computational budget, we split it to (i) learn a task-specific feature extractor via PEFT and (ii) train a linear classifier on top. We call this scheme Two-Stage Few-Shot Adaptation (2SFS). Differently from established methods, our scheme enables a novel form of selective inference at a category level, i.e., at test time, only novel categories are embedded by the adapted text encoder, while embeddings of base categories are available within the classifier. Results with fixed hyperparameters across two settings, three backbones, and eleven datasets, show that 2SFS matches or surpasses the state-of-the-art, while established methods degrade significantly across settings. .

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2503.11609")
get_code_for_paper("2503.11609")
have("2503.11609")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2503.11609.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2503.11609.svg)](https://syntology.ai/paper/2503.11609)

Connect an agent — have() is free.