SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2402.10376 · NeurIPS · 2024

Interpreting CLIP with Sparse Linear Concept Embeddings (SpLiCE )

Suraj Srinivas, Himabindu Lakkaraju, Usha Bhalla, Alex Oesterling, Flavio P. Calmon

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 6 failures of our instrument; 3 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.10376.json · badge: /api/ran/2402.10376.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
AI4LIFE-GROUP/SpLiCE canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
ai4life-group/splice community
Papers with Code archive
1 ran · 1 no recorded run
FunctionStatusWhere it lives
ADMM Ran
ran on a synthesized input · constructed an object; no result was computed
ai4life-group/splice/splice/model.py
code served (permissive licence) · get_code("ca4861da7831431c")
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, ADMM: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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)

ARGS = {
    'rho': 1.0,
    'l1_penalty': 0.2,
    'tol': 1e-6,
    'max_iter': 100,
    'device': 'cpu',
    'verbose': False,
}
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 ADMM — 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 ADMM 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
concept_histogram Ran
ran; our contract draft was wrong, not the code
AI4LIFE-GROUP/SpLiCE/experiments/concept_histogram.py
code served (permissive licence) · get_code("74164be1a6eb14e0")
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, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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)

# Build a mock splicemodel with the required interface
class MockSpliceModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.return_weights = False
        self.return_cosine = False
        self.linear = nn.Linear(4, 6)  # 4 input dims, 6 concept outputs
    
    def eval(self):
        return super().eval()
    
    def encode_image(self, image):
        # image shape: (batch_size, 4)
        weights = self.linear(image)  # (batch_size, 6)
        batch_cosine = torch.tensor(0.5)
        return weights, batch_cosine

# Build a mock dataloader
dataloader = [
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([1, 2])),
]

# Build class_indices
class_indices = [0, 1, 2]

# Build concepts and vocab
vocab = ['concept_a', 'concept_b', 'concept_c', 'concept_d', 'concept_e', 'concept_f']
concepts = ['concept_a', 'concept_c']

ARGS = {
    'splicemodel': MockSpliceModel(),
    'dataloader': dataloader,
    'class_indices': class_indices,
    'concepts': concepts,
    'vocab': vocab,
    'device': 'cpu'
}
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, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
data_dict Ran
ran; our contract draft was wrong, not the code
AI4LIFE-GROUP/SpLiCE/experiments/embed_mscoco.py
code served (permissive licence) · get_code("85af1036c36ed190")
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 os
import json
import tempfile
from pathlib import Path

# Create a temporary directory structure with mock COCO annotations
temp_dir = tempfile.mkdtemp()
annotations_dir = os.path.join(temp_dir, 'annotations')
os.makedirs(annotations_dir, exist_ok=True)

# Create a mock captions_train2017.json file
mock_data = {
    'annotations': [
        {'image_id': 1, 'caption': 'A dog playing in the park'},
        {'image_id': 1, 'caption': 'A brown dog running'},
        {'image_id': 2, 'caption': 'A cat sitting on a mat'},
        {'image_id': 3, 'caption': 'A bird flying in the sky'},
        {'image_id': 3, 'caption': 'A colorful bird'},
    ]
}

annotations_file = os.path.join(annotations_dir, 'captions_train2017.json')
with open(annotations_file, 'w') as f:
    json.dump(mock_data, f)

# Create a simple args class
class Args:
    def __init__(self, data_path):
        self.data_path = data_path

args = Args(temp_dir)

ARGS = {'args': args}
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
find_closest Ran
ran; our contract draft was wrong, not the code
AI4LIFE-GROUP/SpLiCE/experiments/zero_shot.py
code served (permissive licence) · get_code("acb9a8b3cb5a4623")
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 1, dtype family int, shape (2,) 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)

# Create a small embedding vector (batch_size=2, embedding_dim=4)
embedding = torch.randn(2, 4)

# Create label embeddings (num_labels=3, embedding_dim=4)
label_embeddings = torch.randn(3, 4)

ARGS = {
    "embedding": embedding,
    "label_embeddings": label_embeddings,
}
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 1, dtype family int, shape (2,) — shape (2,) 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
get_vocabulary Ran
ran; our contract draft was wrong, not the code
AI4LIFE-GROUP/SpLiCE/splice/splice.py
code served (permissive licence) · get_code("75d0d4017fcd11fd")
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, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 urllib.request

# Mock the urllib to prevent actual network calls
class MockResponse:
    def __init__(self, content):
        self.content = content
    
    def read(self, size):
        if not hasattr(self, '_pos'):
            self._pos = 0
        if self._pos >= len(self.content):
            return b''
        chunk = self.content[self._pos:self._pos + size]
        self._pos += size
        return chunk
    
    def __enter__(self):
        return self
    
    def __exit__(self, *args):
        pass

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

# Create a mock vocabulary file
vocab_dir = os.path.join(temp_dir, 'vocab')
os.makedirs(vocab_dir, exist_ok=True)

vocab_file = os.path.join(vocab_dir, 'laion.txt')
with open(vocab_file, 'w') as f:
    # Write some sample vocabulary words
    for i in range(100):
        f.write(f'word_{i}\n')

# Patch urllib to return mock data
original_urlopen = urllib.request.urlopen

def mock_urlopen(url):
    vocab_content = '\n'.join([f'word_{i}' for i in range(100)])
    return MockResponse(vocab_content.encode('utf-8'))

urllib.request.urlopen = mock_urlopen

ARGS = {
    'name': 'laion',
    'vocabulary_size': 10,
    'download_root': temp_dir
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
train_cbm Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
AI4LIFE-GROUP/SpLiCE/experiments/intervention.py
code served (permissive licence) · get_code("d93e0b7ed23beede")
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 LogisticRegression. 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 numpy as np
from sklearn import linear_model

torch.manual_seed(0)

# X_train: feature matrix for training
# Shape: (n_samples, n_features) - using 2 samples, 4 features
X_train = np.random.randn(2, 4).astype(np.float64)

# y_train1: binary labels for training
# Shape: (n_samples,) - 2 labels matching 2 samples
y_train1 = np.array([0, 1])

# reg: regularization parameter C for LogisticRegression
# float value for the inverse of regularization strength
reg = 1.0

ARGS = {
    'X_train': X_train,
    'y_train1': y_train1,
    'reg': reg
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type LogisticRegression — a LogisticRegression output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a LogisticRegression 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
zero_shot_eval Ran
ran; our contract draft was wrong, not the code
AI4LIFE-GROUP/SpLiCE/experiments/zero_shot.py
code served (permissive licence) · get_code("4c4ae513d3e2a80c")
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, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim 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)

# Define a minimal CLIP-like model that satisfies the usage pattern
class MinimalCLIPModel(nn.Module):
    def __init__(self, embedding_dim=4):
        super().__init__()
        self.embedding_dim = embedding_dim
        self.clip = self._make_clip_encoder()
        self.projection = nn.Linear(embedding_dim, embedding_dim)
    
    def _make_clip_encoder(self):
        class CLIPEncoder(nn.Module):
            def __init__(self, dim):
                super().__init__()
                self.linear = nn.Linear(3, dim)
            
            def encode_image(self, image):
                return self.linear(image)
        
        return CLIPEncoder(self.embedding_dim)
    
    def encode_image(self, image):
        # Returns weights with shape [batch_size, embedding_dim]
        return self.projection(self.clip.encode_image(image))
    
    def recompose_image(self, weights):
        # Takes weights and returns recomposed embedding
        return weights

# Create model
model = MinimalCLIPModel(embedding_dim=4)
model.eval()

# Create a minimal dataloader: list of (image, label) tuples
# Images: [batch_size=2, 3] (RGB-like)
# Labels: [batch_size=2] (class indices)
batch_size = 2
image_dim = 3
num_batches = 2

dataloader = []
for _ in range(num_batches):
    images = torch.randn(batch_size, image_dim)
    labels = torch.tensor([0, 1])
    dataloader.append((images, labels))

# Label embeddings: [num_labels=3, embedding_dim=4]
num_labels = 3
embedding_dim = 4
label_embeddings = torch.randn(num_labels, embedding_dim)

ARGS = {
    'model': model,
    'dataloader': dataloader,
    'label_embeddings': label_embeddings
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
SPLICE Not yet run
unverified (harvested, no recorded run)
ai4life-group/splice/splice/model.py
code served (permissive licence) · get_code("8aa0733e4ad736c4")
How it ran

no invocation recorded.

get_tokenizer Not yet run
unverified (harvested, no recorded run)
AI4LIFE-GROUP/SpLiCE/splice/splice.py
code served (permissive licence) · get_code("4111f212a752fb6d")
How it ran

no invocation recorded.

load Not yet run
unverified (harvested, no recorded run)
AI4LIFE-GROUP/SpLiCE/splice/splice.py
code served (permissive licence) · get_code("ee2e9a9f832ca3fd")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 10 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

CLIP embeddings have demonstrated remarkable performance across a wide range of multimodal applications. However, these high-dimensional, dense vector representations are not easily interpretable, limiting our understanding of the rich structure of CLIP and its use in downstream applications that require transparency. In this work, we show that the semantic structure of CLIP's latent space can be leveraged to provide interpretability, allowing for the decomposition of representations into semantic concepts. We formulate this problem as one of sparse recovery and propose a novel method, Sparse Linear Concept Embeddings (SpLiCE ), for transforming CLIP representations into sparse linear combinations of humaninterpretable concepts. Distinct from previous work, SpLiCE is task-agnostic and can be used, without training, to explain and even replace traditional dense CLIP representations, maintaining high downstream performance while significantly improving their interpretability. We also demonstrate significant use cases of SpLiCE representations including detecting spurious correlations and model editing. Code is provided at https://github.com/AI4LIFE-GROUP/SpLiCE. * Equal contribution, order by coin flip. † Equal contribution, alphabetic order.

For agents

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

get_harvested_code_for_paper("2402.10376")
get_code_for_paper("2402.10376")
have("2402.10376")

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

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

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

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

Connect an agent — have() is free.