SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2411.04097 · NeurIPS · 2024

RAVL: Discovering and Mitigating Spurious Correlations in Fine-Tuned Vision-Language Models

Curtis Langlotz, Akshay Chaudhari, Maya Varma, Jean-Benoit Delbrouck, Zhihong Chen

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 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 0 have no contract verdict; 5 failures of our instrument; 1 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/2411.04097.json · badge: /api/ran/2411.04097.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
stanford-aimi/ravl canonical (classifier label)
classifier basis: census
5 ran · 1 no recorded run
FunctionStatusWhere it lives
compute_contingency_matrix Ran
ran; our contract draft was wrong, not the code
stanford-aimi/ravl/build_eval/generate_spurious_mnist.py
code served (permissive licence) · get_code("607470463612b88e")
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 numpy as np

ARGS = {
    "desired_num_images": 100,
    "num_classes": 4,
    "desired_v": 0.6,
    "spurious_class_idx": 1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — 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
computer_cluster_influence_scores Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
stanford-aimi/ravl/ravl/discover_utils.py
code served (permissive licence) · get_code("6f4cf656ea4d1d7d")
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 float64, ndim 0, 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 numpy as np
import torch
from collections import defaultdict

torch.manual_seed(0)

# Build small tensors and data structures
num_images = 3
num_regions = 5
num_classes = 4

# region_idx: indices for regions in cluster of interest
region_idx = np.array([0, 1])

# class_performance_gaps: dict mapping class indices to performance gaps
# Need negative values for classes where condition (class_performance_gaps[img_true_label[i]] < 0) triggers
class_performance_gaps = {
    0: -0.1,  # negative gap
    1: 0.05,  # positive gap
    2: -0.2,  # negative gap
}

# img_idx_to_reg_idx: dict mapping image index to list of region indices
img_idx_to_reg_idx = {
    0: np.array([0, 1, 2]),  # image 0 has regions 0, 1, 2
    1: np.array([2, 3]),     # image 1 has regions 2, 3
    2: np.array([4]),        # image 2 has only region 4 (will be skipped)
}

# img_true_label: true labels for each image
img_true_label = np.array([0, 1, 0])

# img_pred_label: predicted labels for each image
img_pred_label = np.array([2, 1, 0])  # image 0 is incorrect (true=0, pred=2)

# img_score_dist: score distributions for images (num_images x num_classes)
img_score_dist = torch.tensor([
    [0.1, 0.2, 0.5, 0.2],  # image 0: pred class 2
    [0.2, 0.6, 0.1, 0.1],  # image 1: pred class 1
    [0.7, 0.1, 0.1, 0.1],  # image 2: pred class 0
], dtype=torch.float32)

# reg_idx_to_img_idx: dict mapping region index to image index
reg_idx_to_img_idx = {
    0: 0,
    1: 0,
    2: 1,
    3: 1,
    4: 2,
}

# reg_score_dist: score distributions for regions (num_regions x num_classes)
reg_score_dist = torch.tensor([
    [0.05, 0.1, 0.7, 0.15],   # region 0
    [0.1, 0.15, 0.6, 0.15],   # region 1
    [0.15, 0.7, 0.1, 0.05],   # region 2
    [0.2, 0.5, 0.2, 0.1],     # region 3
    [0.8, 0.1, 0.05, 0.05],   # region 4
], dtype=torch.float32)

ARGS = {
    "region_idx": region_idx,
    "class_performance_gaps": class_performance_gaps,
    "img_idx_to_reg_idx": img_idx_to_reg_idx,
    "img_true_label": img_true_label,
    "img_pred_label": img_pred_label,
    "img_score_dist": img_score_dist,
    "reg_idx_to_img_idx": reg_idx_to_img_idx,
    "reg_score_dist": reg_score_dist,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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_caption Ran
ran; our contract draft was wrong, not the code
stanford-aimi/ravl/build_eval/utils.py
code served (permissive licence) · get_code("38ed8d183fbff126")
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 str_. 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 numpy as np

np.random.seed(0)

ARGS = {
    'digit_label': 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str_ — a str_ output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str_ 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
rank Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
stanford-aimi/ravl/ravl/discover.py
code served (permissive licence) · get_code("9c004fa3c8c06897")
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 numpy as np

# Create small test data for the rank function
np.random.seed(0)

# reg_emb: Visual embeddings for each region
# Shape: (num_regions, embedding_dim)
# Let's use 10 regions with 4-dimensional embeddings
num_regions = 10
embedding_dim = 4
reg_emb = np.random.randn(num_regions, embedding_dim).astype(np.float32)

# clusters: Cluster assignments for each region
# Shape: (num_regions,)
# Assign regions to 3 clusters
clusters = np.array([0, 0, 1, 1, 1, 2, 2, 0, 1, 2], dtype=np.int32)

# medoids: Region indices corresponding to each cluster medoid
# Shape: (num_clusters,)
# Each value is an index into reg_emb
num_clusters = 3
medoids = np.array([0, 2, 5], dtype=np.int32)

# filtered_cluster_idx: Cluster indices after filtering
# This is a list of cluster indices to process
filtered_cluster_idx = [0, 1, 2]

ARGS = {
    "reg_emb": reg_emb,
    "clusters": clusters,
    "medoids": medoids,
    "filtered_cluster_idx": filtered_cluster_idx,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, rich — 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
sample_ann Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
stanford-aimi/ravl/build_eval/generate_spurious_mnist.py
code served (permissive licence) · get_code("a406977adf025bec")
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 DataFrame. 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 numpy as np
import pandas as pd

# Create a minimal base_ann DataFrame with required columns
np.random.seed(0)
n_samples = 20
base_ann = pd.DataFrame({
    'image_id': range(n_samples),
    'true_label': np.random.choice([0, 1, 2], n_samples),
    'reg_to_attr': [
        [['spurious_feature']] if np.random.rand() > 0.5 else [[]]
        for _ in range(n_samples)
    ]
})

# Create a frequency matrix: rows = classes, cols = [non_spurious_count, spurious_count]
# 3 classes, varying counts per class
matrix = np.array([
    [2, 1],  # class 0: 2 non-spurious, 1 spurious
    [2, 1],  # class 1: 2 non-spurious, 1 spurious
    [1, 1],  # class 2: 1 non-spurious, 1 spurious
])

# Ensure we have enough samples in each group
for cls_label in [0, 1, 2]:
    mask = base_ann['true_label'] == cls_label
    if mask.sum() < 3:
        # Add more samples for this class if needed
        new_rows = []
        for i in range(5):
            new_rows.append({
                'image_id': n_samples + i,
                'true_label': cls_label,
                'reg_to_attr': [['spurious_feature']] if i % 2 == 0 else [[]]
            })
        base_ann = pd.concat([base_ann, pd.DataFrame(new_rows)], ignore_index=True)

class_labels = [0, 1, 2]
sp_attr = 'spurious_feature'

ARGS = {
    'base_ann': base_ann,
    'matrix': matrix,
    'class_labels': class_labels,
    'sp_attr': sp_attr
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
load_mnist_data Not yet run
unverified (harvested, no recorded run)
stanford-aimi/ravl/build_eval/utils.py
code served (permissive licence) · get_code("2f788b232f3a4612")
How it ran

no invocation recorded.

Also present in other papers' code

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

Fine-tuned vision-language models (VLMs) often capture spurious correlations between image features and textual attributes, resulting in degraded zero-shot performance at test time. Existing approaches for addressing spurious correlations (i) primarily operate at the global image-level rather than intervening directly on fine-grained image features and (ii) are predominantly designed for unimodal settings. In this work, we present RAVL, which takes a fine-grained perspective on VLM robustness by discovering and mitigating spurious correlations using local image features rather than operating at the global image level. Given a fine-tuned VLM, RAVL first discovers spurious correlations by leveraging a region-level clustering approach to identify precise image features contributing to zero-shot classification errors. Then, RAVL mitigates the identified spurious correlation with a novel region-aware loss function that enables the VLM to focus on relevant regions and ignore spurious relationships during fine-tuning. We evaluate RAVL on 654 VLMs with various model architectures, data domains, and learned spurious correlations. Our results show that RAVL accurately discovers (191% improvement over the closest baseline) and mitigates (8.2% improvement on worst-group image classification accuracy) spurious correlations. Qualitative evaluations on generaldomain and medical-domain VLMs confirm our findings. 1

For agents

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

get_harvested_code_for_paper("2411.04097")
get_code_for_paper("2411.04097")
have("2411.04097")

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

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

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

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

Connect an agent — have() is free.