SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.10093 · ICLR · 2025

MIM-Refiner: A Contrastive Learning Boost from Intermediate Pre-Trained Masked Image Modeling Representations

Johannes Brandstetter, Sepp Hochreiter, Benedikt Alkin, Lukas Miklautz

arXiv · PDF · Open in the Atlas

Code that ran

3 of 3 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-22; 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/2402.10093.json · badge: /api/ran/2402.10093.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
ml-jku/MIM-Refiner canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
BenediktAlkin/vtab1k-pytorch community
Papers with Code archive
2 ran · 0 no recorded run
FunctionStatusWhere it lives
MIMRefinerModel Ran
ran on a synthesized input · constructed an object; no result was computed
BenediktAlkin/vtab1k-pytorch/src/vtab/models/mimrefiner_model.py
code served (permissive licence) · get_code("f6c53a7cbc1b6bab")
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 an instance of its own class, MIMRefinerModel: the run constructed the object and did not call it, so no result was computed. 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
from torch import nn
import torch.nn.functional as F

torch.manual_seed(0)

# Create a mock MIM-Refiner model that satisfies the interface expected by MIMRefinerModel
class MockMIMRefinerModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.dim = 8
        self.patch_embed = nn.Linear(3 * 224 * 224, self.dim)
        self.pos_embed = nn.Parameter(torch.randn(1, 197, self.dim))
        self.cls_tokens = nn.Parameter(torch.randn(1, 1, self.dim))
        self.norm = nn.LayerNorm(self.dim)
        # Create a few transformer blocks
        self.blocks = nn.ModuleList([
            nn.TransformerEncoderLayer(d_model=self.dim, nhead=2, dim_feedforward=16, batch_first=True, dropout=0.0)
            for _ in range(2)
        ])
    
    def forward(self, x):
        # x shape: (batch, 3, 224, 224)
        batch_size = x.shape[0]
        # Flatten spatial dimensions
        x = x.view(batch_size, -1)
        x = self.patch_embed(x)
        # x shape: (batch, dim)
        x = x.unsqueeze(1)  # (batch, 1, dim)
        
        # Add cls token
        cls_tokens = self.cls_tokens.expand(batch_size, -1, -1)  # (batch, 1, dim)
        x = torch.cat([cls_tokens, x], dim=1)  # (batch, 2, dim)
        
        # Add positional embedding
        x = x + self.pos_embed[:, :x.shape[1], :]
        
        # Pass through transformer blocks
        for block in self.blocks:
            x = block(x)
        
        x = self.norm(x)
        return x

# We need to mock torch.hub.load to return our mock model
original_hub_load = torch.hub.load
def mock_hub_load(repo_or_dir, model, *args, **kwargs):
    if 'MIM-Refiner' in repo_or_dir:
        return MockMIMRefinerModel()
    return original_hub_load(repo_or_dir, model, *args, **kwargs)

torch.hub.load = mock_hub_load

ARGS = {
    'identifier': 'd2v2_base',
    'input_shape': (3, 224, 224),
    'num_outputs': 5,
    'split_qkv': False,
    'freeze_num_blocks': None,
}
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 MIMRefinerModel — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MIMRefinerModel 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
SplitQKV Ran
ran on a synthesized input · constructed an object; no result was computed
BenediktAlkin/vtab1k-pytorch/src/vtab/models/mimrefiner_model.py
code served (permissive licence) · get_code("4ab6e53ac50164ed")
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 an instance of its own class, SplitQKV: the run constructed the object and did not call it, so no result was computed. 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
from torch import nn

torch.manual_seed(0)

ARGS = {
    'in_features': 8,
    'out_features': 12,
    'bias': True,
    'device': None,
}
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 SplitQKV — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SplitQKV 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
knn Ran
ran; our contract draft was wrong, not the code
ml-jku/MIM-Refiner/eval_knn_torchhub.py
code served (permissive licence) · get_code("e016ec63c51a6da2")
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) and returned Tensor, ndim 0, dtype family float, 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 math

torch.manual_seed(0)

# Create small training data
train_x = torch.randn(6, 4)  # 6 samples, 4 features
train_y = torch.tensor([0, 1, 0, 1, 2, 2])  # 3 classes

# Create small test data
test_x = torch.randn(3, 4)  # 3 samples, 4 features
test_y = torch.tensor([0, 1, 2])  # 3 samples with labels

ARGS = {
    'train_x': train_x,
    'train_y': train_y,
    'test_x': test_x,
    'test_y': test_y,
    'k': 3,
    'tau': 0.07,
    'batch_size': 2,
    'eps': 1e-06
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, 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

Also present in other papers' code

Of 3 samples lifted from this paper's linked repositories, 3 carry a function identity and 0 do not. Of the 3 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 3 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.

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-22.

Repositories linked to this paper

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

Abstract

We introduce MIM (Masked Image Modeling)-Refiner, a contrastive learning boost for pre-trained MIM models. MIM-Refiner is motivated by the insight that strong representations within MIM models generally reside in intermediate layers. Accordingly, MIM-Refiner leverages multiple instance discrimination (ID) heads that are connected to different intermediate layers. In each head, a nearest neighbor ID objective constructs clusters that capture semantic information which improves performance on downstream tasks, including off-the-shelf and fine-tuning settings. The refinement process is short and simple -yet highly effective. Within a few epochs, we refine the features of MIM models from subpar to state-of-the-art, offthe-shelf features. Refining a ViT-H, pre-trained with data2vec 2.0 on ImageNet-1K, sets a new state-of-the-art in linear probing (84.7%) and low-shot classification among models that are pre-trained on ImageNet-1K. MIM-Refiner efficiently combines the advantages of MIM and ID objectives, enabling scaling ID objectives to billion parameter models using relatively little compute. MIM-Refiner compares favorably against previous state-of-the-art SSL models on various benchmarks such as low-shot classification, long-tailed classification and semantic segmentation.

For agents

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

get_harvested_code_for_paper("2402.10093")
get_code_for_paper("2402.10093")
have("2402.10093")

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

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

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

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

Connect an agent — have() is free.