SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2510.11133 · NeurIPS · 2025

Test-Time Adaptation by Causal Trimming

Wynne Hsu, Mong Lee, Rui Qiao, Yingnan Liu

arXiv · PDF · Open in the Atlas

Code that ran

4 of 9 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 1 has no contract verdict; 3 failures of our instrument; 5 no recorded run), measured 2026-11-23; 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/2510.11133.json · badge: /api/ran/2510.11133.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
NancyQuris/TACT community
Papers with Code archive
4 ran · 5 no recorded run
FunctionStatusWhere it lives
StainColorJitter Ran
ran on a synthesized input
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("4a2a1584e56b3833")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (3, 96, 96) 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

class StainColorJitter(object):
    M = torch.tensor([[0.65, 0.7, 0.29], [0.07, 0.99, 0.11], [0.27, 0.57, 0.78]])
    Minv = torch.inverse(M)
    eps = 1e-06

    def __init__(self, device, sigma=0.05):
        self.sigma = sigma
        self.device = device

    def __call__(self, P):
        assert P.shape == (3, 96, 96)
        assert torch.max(P) <= 1.0
        assert torch.min(P) >= 0.0
        S = -torch.log(255 * P.T + self.eps).matmul(self.Minv.to(self.device))
        alpha = 1 + (torch.rand(3) - 0.5) * 2 * self.sigma
        beta = (torch.rand(3) - 0.5) * 2 * self.sigma
        Sp = S * alpha.to(self.device) + beta.to(self.device)
        Pp = torch.exp(-Sp.matmul(self.M.to(self.device))) - self.eps
        Pp = Pp.T / 255
        Pp = torch.clip(Pp, 0.0, 1.0)
        return Pp


INIT_ARGS = {
    'device': 'cpu',
    'sigma': 0.05
}

ARGS = {
    'P': torch.rand(3, 96, 96) * 0.9 + 0.05
}

if __name__ == '__main__':
    jitter = StainColorJitter(**INIT_ARGS)
    output = jitter(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output min: {output.min()}, max: {output.max()}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (3, 96, 96) — shape (3, 96, 96) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
get_PCs Ran
ran; our contract draft was wrong, not the code
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("e421c00155f8d872")
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 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

torch.manual_seed(0)

# X is used with:
# - X.mean(dim=1, keepdim=True)
# - X - mean
# - X_mean.transpose(1, 2)
# - torch.bmm(X_mean.transpose(1, 2), X_mean)
# - torch.linalg.svd(XCov, full_matrices=False)
#
# This suggests X should be a 3D tensor of shape (batch, n_samples, n_features)
# Let's use batch=2, n_samples=4, n_features=3 for distinct dimensions

X = torch.randn(2, 4, 3)

ARGS = {
    'X': X
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
initialize_bert_transform Ran
ran; our contract draft was wrong, not the code
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("23318b3be9296447")
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 function. 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 unittest.mock import MagicMock

torch.manual_seed(0)

class MockArgs:
    def __init__(self, model):
        self.model = model

class MockTokenizer:
    def __call__(self, text, padding=None, truncation=None, max_length=None, return_tensors=None):
        batch_size = 1
        seq_length = 300
        
        if self.model_type == 'bert':
            return {
                'input_ids': torch.randint(0, 1000, (batch_size, seq_length)),
                'attention_mask': torch.ones(batch_size, seq_length),
                'token_type_ids': torch.zeros(batch_size, seq_length)
            }
        else:
            return {
                'input_ids': torch.randint(0, 1000, (batch_size, seq_length)),
                'attention_mask': torch.ones(batch_size, seq_length)
            }
    
    def __init__(self, model_type):
        self.model_type = model_type

mock_bert_tokenizer = MockTokenizer('bert')
mock_distilbert_tokenizer = MockTokenizer('distilbert')

import transformers
original_bert_from_pretrained = transformers.BertTokenizerFast.from_pretrained
original_distilbert_from_pretrained = transformers.DistilBertTokenizerFast.from_pretrained

transformers.BertTokenizerFast.from_pretrained = classmethod(lambda cls, name: mock_bert_tokenizer)
transformers.DistilBertTokenizerFast.from_pretrained = classmethod(lambda cls, name: mock_distilbert_tokenizer)

try:
    from transformers import BertTokenizerFast
except ImportError:
    class BertTokenizerFast:
        @classmethod
        def from_pretrained(cls, name):
            return mock_bert_tokenizer

ARGS = {
    'args': MockArgs('distilbert')
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
projection Ran
ran; our contract draft was wrong, not the code
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("ef39939a469e52e9")
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 3, dtype family float, shape (2, 3, 4) 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)

# The function expects:
# - vector_to_project: a tensor that can be 2D or 3D
# - project_direction: a unit vector tensor

# For a 3D case (batch_size=2, sequence_length=3, feature_dim=4):
vector_to_project = torch.randn(2, 3, 4)

# Normalize to make it a unit vector
project_direction = torch.randn(4)
project_direction = project_direction / torch.norm(project_direction)

ARGS = {
    "vector_to_project": vector_to_project,
    "project_direction": project_direction,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, 3, 4) — shape (2, 3, 4) 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
CT Not yet run
unverified (harvested, no recorded run)
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("2df21014e1574456")
How it ran

no invocation recorded.

CivilAugmentation Not yet run
unverified (harvested, no recorded run)
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("f17708412afb23ce")
How it ran

no invocation recorded.

TACT Not yet run
unverified (harvested, no recorded run)
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("14478592903cd70b")
How it ran

no invocation recorded.

get_augmentation Not yet run
unverified (harvested, no recorded run)
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("8e80b20b4cf73422")
How it ran

no invocation recorded.

remove_PCs Not yet run
unverified (harvested, no recorded run)
NancyQuris/TACT/methods/tact.py
code served (permissive licence) · get_code("e833d0151beb28f9")
How it ran

no invocation recorded.

Also present in other papers' code

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

Repositories linked to this paper

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

Abstract

Test-time adaptation aims to improve model robustness under distribution shifts by adapting models with access to unlabeled target samples. A primary cause of performance degradation under such shifts is the model's reliance on features that lack a direct causal relationship with the prediction target. We introduce Test-time Adaptation by Causal Trimming (TACT), a method that identifies and removes non-causal components from representations for test distributions. TACT applies data augmentations that preserve causal features while varying non-causal ones. By analyzing the changes in the representations using Principal Component Analysis, TACT identifies the highest variance directions associated with non-causal features. It trims the representations by removing their projections on the identified directions, and uses the trimmed representations for the predictions. During adaptation, TACT continuously tracks and refines these directions to get a better estimate of non-causal features. We theoretically analyze the effectiveness of this approach and empirically validate TACT on real-world out-of-distribution benchmarks. TACT consistently outperforms state-of-the-art methods by a significant margin. Our code is available at https://github.com/NancyQuris/TACT.

For agents

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

get_harvested_code_for_paper("2510.11133")
get_code_for_paper("2510.11133")
have("2510.11133")

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

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

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

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

Connect an agent — have() is free.