SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2604.15609 · 2026

Adapting in the Dark: Efficient and Stable Test-Time Adaptation for Black-Box Models

Feng Liu, Shuaicheng Niu, Jihun Hamm, Yunbei Zhang, Chengyi Cai

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (4 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 3 failures of our instrument; 2 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/2604.15609.json · badge: /api/ran/2604.15609.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
yunbeizhang/BETA community
Papers with Code archive
9 ran · 2 no recorded run
FunctionStatusWhere it lives
InverseNormalize Ran
ran on a synthesized input · constructed an object; no result was computed
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("95840bf801dafc80")
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, InverseNormalize: the run constructed the object and did not call it, so no result was computed. 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)

# InverseNormalize expects mean and std as constructor arguments
# These should be sequences/tensors that can be converted to tensors with shape (3,)
# since they're reshaped to (1, 3, 1, 1) in __init__

mean = [0.485, 0.456, 0.406]  # Standard ImageNet mean
std = [0.229, 0.224, 0.225]   # Standard ImageNet std

ARGS = {
    "mean": mean,
    "std": std,
}
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 InverseNormalize — 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 InverseNormalize 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
Normalize Ran
ran on a synthesized input · constructed an object; no result was computed
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("f0f308568d66a498")
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, Normalize: the run constructed the object and did not call it, so no result was computed. 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)

# The Normalize module takes mean and std as parameters
# Looking at the forward method, it converts them to tensors with shape (1, 3, 1, 1)
# So mean and std should be sequences of 3 values (for RGB channels)

mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]

ARGS = {
    "mean": mean,
    "std": std,
}
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 Normalize — 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 Normalize 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
PadPrompter Ran
ran on a synthesized input · constructed an object; no result was computed
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("4c1d65c27fc0933d")
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, PadPrompter: the run constructed the object and did not call it, so no result was computed. 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
from torchvision import transforms

torch.manual_seed(0)

# Define ARGS with all parameters for PadPrompter
ARGS = {
    'input_size': 224,
    'pad_size': 32,
    'output_size': 224,
    'init': 'random'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PadPrompter — 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 PadPrompter 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
ProbFuser Ran
ran on a synthesized input · constructed an object; no result was computed
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("b91bc8ccdfc9e610")
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, ProbFuser: the run constructed the object and did not call it, so no result was computed. 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 = {
    'alpha': 0.3,
    'learnable': 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 ProbFuser — 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 ProbFuser 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
copy_model_and_optimizer Ran
ran; our contract draft was wrong, not the code
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("cc43e62b9781b688")
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
from torch.optim import Adam

torch.manual_seed(0)

# Define minimal models that have state_dict() method
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

class SimplePrompter(nn.Module):
    def __init__(self):
        super().__init__()
        self.embedding = nn.Embedding(10, 4)
    
    def forward(self, x):
        return self.embedding(x)

class SimpleProbfuser(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 5)
    
    def forward(self, x):
        return self.linear(x)

# Create model instances
model = SimpleModel()
prompter = SimplePrompter()
probfuser = SimpleProbfuser()

# Create optimizers with parameters from the models
optimizer_vr = Adam(model.parameters(), lr=0.001)
optimizer_norm = Adam(prompter.parameters(), lr=0.001)

# Build ARGS dictionary
ARGS = {
    "model": model,
    "prompter": prompter,
    "probfuser": probfuser,
    "optimizer_vr": optimizer_vr,
    "optimizer_norm": optimizer_norm
}
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
forward_and_adapt Ran
ran; our contract draft was wrong, not the code
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("b8b53e25bbf6ad42")
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
import torch.nn.functional as F

torch.manual_seed(0)

# Small model that takes input and returns logits
class SimpleModel(nn.Module):
    def __init__(self, num_classes=4):
        super().__init__()
        self.fc = nn.Linear(8, num_classes)
    
    def forward(self, x):
        # Flatten if needed and pass through linear layer
        if x.dim() > 2:
            x = x.view(x.size(0), -1)
        return self.fc(x)

# Local helper model
class LocalHelper(nn.Module):
    def __init__(self, num_classes=4):
        super().__init__()
        self.fc = nn.Linear(8, num_classes)
        self.bn = nn.BatchNorm2d(1)
    
    def forward(self, x):
        if x.dim() > 2:
            x = x.view(x.size(0), -1)
        return self.fc(x)

# Prompter that modifies input
class Prompter(nn.Module):
    def forward(self, x):
        # Add a small noise to simulate prompting
        return x + 0.1

# Probability fuser
class ProbFuser(nn.Module):
    def forward(self, local_prob, model_prob):
        # Simple average of probabilities
        return 0.5 * local_prob + 0.5 * model_prob

# Create instances
x = torch.randn(2, 8)  # batch size 2, feature dim 8
model = SimpleModel(num_classes=4)
local_helper = LocalHelper(num_classes=4)
prompter = Prompter()
probfuser = ProbFuser()

# Create optimizers
optimizer_vr = torch.optim.SGD(local_helper.parameters(), lr=0.01)
optimizer_norm = torch.optim.SGD(local_helper.parameters(), lr=0.01)

# Parameters for the function
emargin = 0.5
dmargin = 0.3
kl_weight = 0.5
current_model_probs = None
imagenet_mask = None

ARGS = {
    'x': x,
    'model': model,
    'local_helper': local_helper,
    'prompter': prompter,
    'probfuser': probfuser,
    'optimizer_vr': optimizer_vr,
    'optimizer_norm': optimizer_norm,
    'emargin': emargin,
    'dmargin': dmargin,
    'kl_weight': kl_weight,
    'current_model_probs': current_model_probs,
    'imagenet_mask': imagenet_mask,
}
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
softmax_entropy Ran
ran, honoured the contract we drafted
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("99c9d70a0d3706d9")
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 float, 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)

# The function takes logits (a tensor) and computes entropy
# It calls:
# - logits.softmax(1) - softmax along dimension 1
# - logits.log_softmax(1) - log softmax along dimension 1
# - .sum(1) - sum along dimension 1
# So logits needs to be at least 2D, with dimension 1 being the class dimension

# Create a small batch of logits: batch_size=2, num_classes=4
logits = torch.randn(2, 4)

ARGS = {
    "logits": logits
}
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 float, 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
softmax_entropy_from_prob Ran
ran, honoured the contract we drafted
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("0e1a6de9b43fdc30")
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 float, 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 probability tensor
# Shape: (batch_size=2, num_classes=4)
# Values should be valid probabilities (sum to 1 along dim 1)
p = torch.tensor([
    [0.4, 0.3, 0.2, 0.1],
    [0.25, 0.25, 0.25, 0.25]
], dtype=torch.float32)

ARGS = {
    "p": p
}
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 float, 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
update_model_probs Ran
ran; our contract draft was wrong, not the code
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("8a1599bccdd2a405")
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 float, shape (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

torch.manual_seed(0)

# Test case 1: current_model_probs is None, new_probs is non-empty
current_model_probs_1 = None
new_probs_1 = torch.randn(2, 4)  # batch_size=2, num_classes=4
momentum_1 = 0.9

# Test case 2: current_model_probs exists, new_probs is non-empty
current_model_probs_2 = torch.randn(4)  # probability vector of size 4
new_probs_2 = torch.randn(2, 4)  # batch_size=2, num_classes=4
momentum_2 = 0.95

# Test case 3: current_model_probs exists, new_probs is empty
current_model_probs_3 = torch.randn(4)
new_probs_3 = torch.randn(0, 4)  # empty batch
momentum_3 = 0.9

# Test case 4: current_model_probs is None, new_probs is empty
current_model_probs_4 = None
new_probs_4 = torch.randn(0, 4)  # empty batch
momentum_4 = 0.85

# Using test case 1 as the main ARGS
ARGS = {
    "current_model_probs": current_model_probs_1,
    "new_probs": new_probs_1,
    "momentum": momentum_1,
}
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 float, shape (4,) — shape (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
BETA Not yet run
unverified (harvested, no recorded run)
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("7ca8b3d9f4c19490")
How it ran

no invocation recorded.

load_model_and_optimizer Not yet run
unverified (harvested, no recorded run)
yunbeizhang/BETA/tta_library/beta.py
code served (permissive licence) · get_code("2d5038d5743917f4")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 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 11 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 (TTA) for black-box models accessible only via APIs remains a largely unexplored challenge. Existing approaches such as post-hoc output refinement offer limited adaptive capacity, while Zeroth-Order Optimization (ZOO) enables input-space adaptation but faces high query costs and optimization challenges in the unsupervised TTA setting. We introduce BETA (Black-box Efficient Test-time Adaptation), a framework that addresses these limitations by employing a lightweight, local whitebox steering model to create a tractable gradient pathway. Through a prediction harmonization technique combined with consistency regularization and prompt learning-oriented filtering, BETA enables stable adaptation with no additional API calls and negligible latency beyond standard inference. On ImageNet-C, BETA achieves a +7.1% accuracy gain on ViT-B/16 and +3.4% on CLIP, surpassing strong white-box and gray-box methods including TENT and TPT. On a commercial API, BETA achieves comparable performance to ZOO at 250× lower cost while maintaining real-time inference speed, establishing it as a practical and efficient solution for real-world black-box TTA. Code is available at https://github.com/yunbeizhang/BETA

For agents

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

get_harvested_code_for_paper("2604.15609")
get_code_for_paper("2604.15609")
have("2604.15609")

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

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

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

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

Connect an agent — have() is free.