SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · aaai_28296 · AAAI · 2024

Semantic-Aware Autoregressive Image Modeling for Visual Representation Learning

Kaiyou Song, Tong Wang, Shan Zhang

Open in the Atlas

Code that ran

4 of 7 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; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 2 failures of our instrument; 3 no recorded run), measured 2026-11-22; 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/aaai_28296.json · badge: /api/ran/aaai_28296.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
skyoux/SemAIM canonical (classifier label)
classifier basis: census
4 ran · 3 no recorded run
FunctionStatusWhere it lives
build_dataset Ran
ran; our contract draft was wrong, not the code
skyoux/SemAIM/datasets/datasets.py
code served (permissive licence) · get_code("01d32b851b217f4d")
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 ImageListFolder. 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 os
import tempfile
import torch
import torchvision.transforms
from torchvision import datasets, transforms
from torchvision.datasets.folder import default_loader
from timm.data import create_transform
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD

torch.manual_seed(0)

# Create temporary directories and files for the dataset
temp_dir = tempfile.mkdtemp()
train_dir = os.path.join(temp_dir, 'train')
val_dir = os.path.join(temp_dir, 'val')
os.makedirs(train_dir, exist_ok=True)
os.makedirs(val_dir, exist_ok=True)

# Create dummy image files
from PIL import Image
import numpy as np

# Create a few dummy images for training
for i in range(2):
    img_array = np.random.randint(0, 256, (32, 32, 3), dtype=np.uint8)
    img = Image.fromarray(img_array)
    img.save(os.path.join(train_dir, f'img_{i}.jpg'))

# Create a few dummy images for validation
for i in range(2):
    img_array = np.random.randint(0, 256, (32, 32, 3), dtype=np.uint8)
    img = Image.fromarray(img_array)
    img.save(os.path.join(val_dir, f'img_{i}.jpg'))

# Create annotation files
train_ann_file = os.path.join(temp_dir, 'train.txt')
val_ann_file = os.path.join(temp_dir, 'val.txt')

with open(train_ann_file, 'w') as f:
    f.write('img_0.jpg 0\n')
    f.write('img_1.jpg 1\n')

with open(val_ann_file, 'w') as f:
    f.write('img_0.jpg 5\n')
    f.write('img_1.jpg 10\n')

# Create args object
class Args:
    def __init__(self):
        self.data_path = temp_dir
        self.input_size = 224
        self.color_jitter = 0.4
        self.aa = 'rand-m9-mstd0.5-inc1'
        self.reprob = 0.25
        self.remode = 'pixel'
        self.recount = 1

args = Args()

ARGS = {
    'is_train': True,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, timm, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ImageListFolder — a ImageListFolder 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
build_transform Ran
ran; our contract draft was wrong, not the code
skyoux/SemAIM/datasets/datasets.py
code served (permissive licence) · get_code("b1528b5a179ebd3f")
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 Compose. 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
import torchvision.transforms
from torchvision import datasets, transforms
from timm.data import create_transform
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD

torch.manual_seed(0)

class ArgsConfig:
    def __init__(self):
        self.input_size = 224
        self.color_jitter = 0.4
        self.aa = 'rand-m9-mstd0.5-inc1'
        self.reprob = 0.25
        self.remode = 'pixel'
        self.recount = 1

args = ArgsConfig()

ARGS = {
    'is_train': True,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
timm, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
forward_features_dino Ran
ran on a synthesized input
skyoux/SemAIM/engines/engine_pretrain.py
code served (permissive licence) · get_code("18a7b42bd3875937")
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 Tensor, ndim 3, dtype family float, shape (2, 5, 8) 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)

# Create a minimal DINO-like model with only the attributes/methods used in forward_features_dino
class MinimalDINOModel(nn.Module):
    def __init__(self, patch_dim=4, embed_dim=8, num_blocks=2, img_size=8, patch_size=4):
        super().__init__()
        num_patches = (img_size // patch_size) ** 2
        
        # patch_embed: takes input and outputs (B, num_patches, embed_dim)
        self.patch_embed = nn.Linear(patch_size * patch_size * 3, embed_dim)
        
        # cls_token: (1, 1, embed_dim)
        self.cls_token = nn.Parameter(torch.randn(1, 1, embed_dim))
        
        # pos_embed: (1, num_patches + 1, embed_dim) for cls_token + patches
        self.pos_embed = nn.Parameter(torch.randn(1, num_patches + 1, embed_dim))
        
        # pos_drop: dropout layer
        self.pos_drop = nn.Dropout(0.1)
        
        # blocks: list of transformer blocks
        self.blocks = nn.ModuleList([
            TransformerBlock(embed_dim) for _ in range(num_blocks)
        ])
        
        # norm: layer normalization
        self.norm = nn.LayerNorm(embed_dim)
    
    def forward(self, x):
        # This won't be called, but define it for completeness
        pass

class TransformerBlock(nn.Module):
    def __init__(self, embed_dim=8):
        super().__init__()
        self.norm1 = nn.LayerNorm(embed_dim)
        self.attn = nn.MultiheadAttention(embed_dim, num_heads=2, batch_first=True)
        self.norm2 = nn.LayerNorm(embed_dim)
        self.mlp = nn.Sequential(
            nn.Linear(embed_dim, embed_dim * 2),
            nn.GELU(),
            nn.Linear(embed_dim * 2, embed_dim)
        )
    
    def forward(self, x):
        x = x + self.attn(self.norm1(x), self.norm1(x), self.norm1(x))[0]
        x = x + self.mlp(self.norm2(x))
        return x

class SimplePatchEmbed(nn.Module):
    def __init__(self, in_chans=3, embed_dim=8, patch_size=4, img_size=8):
        super().__init__()
        self.patch_size = patch_size
        self.embed_dim = embed_dim
        num_patches = (img_size // patch_size) ** 2
        self.linear = nn.Linear(in_chans * patch_size * patch_size, embed_dim)
    
    def forward(self, x):
        # x: (B, C, H, W)
        B, C, H, W = x.shape
        # Reshape to patches
        x = x.reshape(B, C, H // self.patch_size, self.patch_size, W // self.patch_size, self.patch_size)
        x = x.permute(0, 2, 4, 1, 3, 5).contiguous()
        x = x.reshape(B, -1, C * self.patch_size * self.patch_size)
        x = self.linear(x)
        return x

# Create model instance
model = MinimalDINOModel(patch_dim=4, embed_dim=8, num_blocks=2, img_size=8, patch_size=4)
model.patch_embed = SimplePatchEmbed(in_chans=3, embed_dim=8, patch_size=4, img_size=8)

# Create input tensor: (B=2, C=3, H=8, W=8)
x = torch.randn(2, 3, 8, 8)

ARGS = {
    "model": model,
    "x": x
}
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 Tensor, ndim 3, dtype family float, shape (2, 5, 8) — shape (2, 5, 8) 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
generate_saliency Ran
ran on a synthesized input
skyoux/SemAIM/engines/engine_pretrain.py
code served (permissive licence) · get_code("702878e30479981e")
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 tuple. 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 SaliencyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = nn.Conv2d(3, 1, kernel_size=3, padding=1)
    
    def forward(self, x):
        # Function expects 8 outputs, we return 8 tensors
        # d1 is the first output with shape (batch, 1, height, width)
        d1 = self.conv(x)
        dummy = torch.zeros_like(d1)
        return d1, dummy, dummy, dummy, dummy, dummy, dummy, dummy

saliency_model = SaliencyModel()

# imgs shape: (batch_size, channels, height, width)
# height and width must be divisible by patch_size (16)
# Using batch=2, channels=3, height=32, width=32
imgs = torch.randn(2, 3, 32, 32)

ARGS = {
    "saliency_model": saliency_model,
    "imgs": imgs
}
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 tuple — a tuple 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
build_model Not yet run
unverified (harvested, no recorded run)
skyoux/SemAIM/models/models_clip.py
code served (permissive licence) · get_code("39e6b23b55f376ea")
How it ran

no invocation recorded.

forward_teacher_features Not yet run
unverified (harvested, no recorded run)
skyoux/SemAIM/engines/engine_pretrain.py
code served (permissive licence) · get_code("781e5edc7c312eb5")
How it ran

no invocation recorded.

knn_classifier Not yet run
unverified (harvested, no recorded run)
skyoux/SemAIM/main_knn.py
code served (permissive licence) · get_code("c6c75fb0694b5e82")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 1 later) and 4 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
build_model 53 other papers
17 dated earlier, 12 later, 24 same year, order not determinable
2107.06383 (2021-07)
How Much Can CLIP Benefit Vision-and-Language Tasks?
2210.01115 (2022-10)
LASP: Text-to-Text Optimization for Language-Aware Soft Prompting of Vision & Language Models
2211.09552 (2022-11)
UniFormerV2: Spatiotemporal Learning by Arming Image ViTs with Video UniFormer
and 50 more not named here
build_dataset 1 other paper
1 dated earlier
2309.03576 (2023-09)
DropPos: Pre-Training Vision Transformers by Reconstructing Dropped Positions
build_transform 1 other paper
1 dated earlier
2309.03576 (2023-09)
DropPos: Pre-Training Vision Transformers by Reconstructing Dropped Positions

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

The development of autoregressive modeling (AM) in computer vision lags behind natural language processing (NLP) in self-supervised pre-training. This is mainly caused by the challenge that images are not sequential signals and lack a natural order when applying autoregressive modeling. In this study, inspired by human beings' way of grasping an image, i.e., focusing on the main object first, we present a semanticaware autoregressive image modeling (SemAIM) method to tackle this challenge. The key insight of SemAIM is to autoregressive model images from the semantic patches to the less semantic patches. To this end, we first calculate a semanticaware permutation of patches according to their feature similarities and then perform the autoregression procedure based on the permutation. In addition, considering that the raw pixels of patches are low-level signals and are not ideal prediction targets for learning high-level semantic representation, we also explore utilizing the patch features as the prediction targets. Extensive experiments are conducted on a broad range of downstream tasks, including image classification, object detection, and instance/semantic segmentation, to evaluate the performance of SemAIM. The results demonstrate SemAIM achieves state-of-the-art performance compared with other self-supervised methods. Specifically, with ViT-B, SemAIM achieves 84.1% top-1 accuracy for fine-tuning on ImageNet, 51.3% AP and 45.4% AP for object detection and instance segmentation on COCO, which outperforms the vanilla MAE by 0.5%, 1.0%, and 0.5%, respectively. Code is available at https://github.com/skyoux/SemAIM.

For agents

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

get_harvested_code_for_paper("aaai_28296")
get_code_for_paper("aaai_28296")
have("aaai_28296")

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

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

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

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

Connect an agent — have() is free.