SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2024.naacl-long.370 · NAACL · 2024

ComCLIP: Training-Free Compositional Image and Text Matching

Wang, Eric Xin, Ruize Xu, Kenan Jiang, Pos Neg

Open in the Atlas

Code that ran

8 of 8 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 7 have no contract verdict; 1 failure of our instrument; 0 no recorded run), measured 2026-11-24; 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/2024.naacl-long.370.json · badge: /api/ran/2024.naacl-long.370.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
eric-ai-lab/ComCLIP canonical (classifier label)
classifier basis: census
8 ran · 0 no recorded run
FunctionStatusWhere it lives
black_outside_rectangle Ran
ran on a synthesized input
eric-ai-lab/ComCLIP/ComVG/helper_function.py
code served (permissive licence) · get_code("5f2227ae5e6385dd")
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 Image. 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.

from PIL import Image
import random

# Create a small test image
width, height = 100, 80
image = Image.new('RGB', (width, height), color='white')

# Define rectangle coordinates
left_top = (20, 15)
right_bottom = (80, 65)

ARGS = {
    'image': image,
    'left_top': left_top,
    'right_bottom': right_bottom,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int 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
generate_caption_to_image Ran
ran on a synthesized input
eric-ai-lab/ComCLIP/ComVG/match_relation.py
code served (permissive licence) · get_code("9d07c9e2b507f75f")
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 dict. 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 json

# Mock the openai module since we can't make real API calls
class MockOpenAICompletion:
    @staticmethod
    def create(model, messages, temperature):
        # Return a mock response that matches the expected format
        return {
            'choices': [
                {
                    'message': {
                        'content': json.dumps({'labels': ['label1', 'label2']})
                    }
                }
            ]
        }

class MockOpenAI:
    ChatCompletion = MockOpenAICompletion()

# Replace openai module
import sys
sys.modules['openai'] = MockOpenAI()

# Now we can define the arguments
ARGS = {
    'caption': 'The cat is sitting on the blue chair in the living room',
    'obejct_list': ['cat', 'chair', 'room'],
    'image_list': ['animal', 'furniture', 'indoor_space', 'pet', 'seat']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
get_deep_speed_config Ran
ran; our contract draft was wrong, not the code
eric-ai-lab/ComCLIP/GRiT/train_deepspeed.py
code served (permissive licence) · get_code("e9b355b1c2a3ff0d")
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 dict. 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)

ARGS = {
    'train_batch_size': 32,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
get_matching Ran
ran on a synthesized input
eric-ai-lab/ComCLIP/ComVG/helper_function.py
code served (permissive licence) · get_code("c0ab20980ec3e8bf")
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 dict. 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 json
import tempfile
import os

# Create a temporary directory and file for testing
temp_dir = tempfile.mkdtemp()

# Create a sample JSON file with format string placeholders
# The matched_path will use .format(caption_id, image_id)
matched_file_path = os.path.join(temp_dir, "matched_{0}_{1}.json")

# Create an actual file with a specific caption_id and image_id
caption_id = "cap_001"
image_id = "img_001"
actual_file_path = matched_file_path.format(caption_id, image_id)

# Write sample JSON data to the file
sample_data = {
    "matches": [1, 2, 3],
    "score": 0.95,
    "metadata": {"source": "test"}
}

with open(actual_file_path, 'w') as f:
    json.dump(sample_data, f)

# Define the arguments dictionary
ARGS = {
    "caption_id": "cap_001",
    "image_id": "img_001",
    "matched_path": matched_file_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
match_objects Ran
ran on a synthesized input
eric-ai-lab/ComCLIP/ComVG/match_relation.py
code served (permissive licence) · get_code("ad23dd8cc61fc453")
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 dict. 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 openai
import json

# Mock the openai module since we can't make real API calls
class MockChatCompletion:
    @staticmethod
    def create(model, messages, temperature):
        # Return a mock response with valid JSON format
        return {
            'choices': [
                {
                    'message': {
                        'content': json.dumps({'labels': ['label1', 'label2']})
                    }
                }
            ]
        }

openai.ChatCompletion = MockChatCompletion

# Define test arguments
ARGS = {
    'sentence': 'The cat sat on the mat',
    'object': 'cat',
    'list': ['cat', 'dog', 'bird', 'animal']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
read_image Ran
ran on a synthesized input
eric-ai-lab/ComCLIP/ComVG/helper_function.py
code served (permissive licence) · get_code("9f83cd827f895f70")
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 PngImageFile. 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 tempfile
from PIL import Image
import os

# Create a temporary directory and a test image
temp_dir = tempfile.mkdtemp()
test_image = Image.new('RGB', (100, 100), color='red')
test_image_path = os.path.join(temp_dir, 'test_image_0.png')
test_image.save(test_image_path)

# Define path format that uses the id parameter
path_format = os.path.join(temp_dir, 'test_image_{}.png')

ARGS = {
    'id': 0,
    'path_format': path_format
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PngImageFile — a PngImageFile output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PngImageFile output the recorded ndim 3 and dtype family int 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
report_score Ran
ran on a synthesized input
eric-ai-lab/ComCLIP/ComVG/clip_baseline.py
code served (permissive licence) · get_code("13feb58809a8b8b2")
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 float, 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

torch.manual_seed(0)

# Construct clip_scores: a list of dicts with 'pos_score' and 'neg_score' keys
clip_scores = [
    {
        'pos_score': 0.8,
        'neg_score': 0.3,
    },
    {
        'pos_score': 0.6,
        'neg_score': 0.7,
    },
    {
        'pos_score': 0.9,
        'neg_score': 0.2,
    },
]

ARGS = {
    'clip_scores': clip_scores,
}
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 float, 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
send_gpu Ran
ran on a synthesized input
eric-ai-lab/ComCLIP/image_retrieval/helper_function.py
code served (permissive licence) · get_code("58aabecea2c2318d")
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 dict. 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

torch.manual_seed(0)

# Create a dict with pixel_values, attention_mask, and input_ids tensors
original_processor = {
    'pixel_values': torch.randn(2, 3, 4, 4),  # batch=2, channels=3, height=4, width=4
    'attention_mask': torch.ones(2, 5, dtype=torch.long),  # batch=2, seq_len=5
    'input_ids': torch.randint(0, 100, (2, 5), dtype=torch.long)  # batch=2, seq_len=5
}

device = 'cpu'

ARGS = {
    'original_processor': original_processor,
    'device': device
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 1 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 7 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
get_deep_speed_config 1 other paper
1 same year, order not determinable
2406.09988 (2024-06)
Details Make a Difference: Object State-Sensitive Neurorobotic Task Planning

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

Repositories linked to this paper

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

Abstract

Contrastive Language-Image Pretraining (CLIP) has demonstrated great zero-shot performance for matching images and text. However, it is still challenging to adapt vision-language pretrained models like CLIP to compositional image and text matchinga more challenging image and text matching task requiring the model's understanding of compositional word concepts and visual components. Towards better compositional generalization in zero-shot image and text matching, in this paper, we study the problem from a causal perspective: the erroneous semantics of individual entities are essentially confounders that cause the matching failure. Therefore, we propose a novel training-free compositional CLIP model (ComCLIP). ComCLIP disentangles input images into subjects, objects, and action subimages and composes CLIP's vision encoder and text encoder to perform evolving matching over compositional text embedding and subimage embeddings. In this way, ComCLIP can mitigate spurious correlations introduced by the pretrained CLIP models and dynamically evaluate the importance of each component. Experiments on four compositional image-text matching datasets: Winoground, VL-checklist, SVO, and ComVG, and two general image-text retrieval datasets: Flick30K, and MSCOCO demonstrate the effectiveness of our plug-and-play method, which boosts the zero-shot inference ability of CLIP, SLIP, and BLIP2 even without further training or fine-tuning. Our codes can be found at https: //github.com/eric-ai-lab/ComCLIP.

For agents

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

get_harvested_code_for_paper("2024.naacl-long.370")
get_code_for_paper("2024.naacl-long.370")
have("2024.naacl-long.370")

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

curl https://syntology.ai/api/ran/2024.naacl-long.370.json

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

[![Syntology run record](https://syntology.ai/api/ran/2024.naacl-long.370.svg)](https://syntology.ai/paper/2024.naacl-long.370)

Connect an agent — have() is free.