SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2602.03594 · 2026

TIPS Over Tricks: Simple Prompts for Effective Zero-shot Anomaly Detection

Makoto Yamada, Mohammad Sabokrou, Reshad Hosseini, Alireza Salehi, Ehsan Karami, Sepehr Noey, Sahand Noey

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2602.03594.json · badge: /api/ran/2602.03594.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
AlirezaSalehy/Tipsomaly community
Papers with Code archive
5 ran · 2 no recorded run
FunctionStatusWhere it lives
GlobalAvgPooling Ran
ran on a synthesized input · constructed an object; no result was computed
AlirezaSalehy/Tipsomaly/model/tips/text_encoder.py
code served (permissive licence) · get_code("f6aaf582ed5d2a92")
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, GlobalAvgPooling: 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
import typing as t

torch.manual_seed(0)

class GlobalAvgPooling(nn.Module):
    """Performs a simple global pooling over the input with optional paddings.

  Attributes:
    pooling_dims: A list of dims to perform pooling over.
    keepdims: If True, keep dimension of inputs after pooling.
  """
    pooling_dims: t.Sequence[int]
    epsilon: float = 1e-08

    def __init__(self, pooling_dims: t.Sequence[int], epsilon: float=1e-08):
        super().__init__()
        self.pooling_dims = pooling_dims
        self.epsilon = epsilon
        if not all([p_dims >= 0 for p_dims in self.pooling_dims]):
            raise ValueError('pooling_dims must be non-negative integers.')

    def __call__(self, inputs: torch.tensor, compatible_paddings: torch.tensor):
        """Applies global average spatial pooling to inputs.

    Args:
      inputs: An input tensor.
      compatible_paddings: paddings of inputs with shapes compatible with
        inputs, e.g. compatible_paddings with shape [B, 1] for inputs with shape
        [B, D].

    Returns:
      Output tensor with global pooling applied.
    """
        padded_value = torch.zeros_like(inputs)
        padded_value = torch.ones_like(inputs) * padded_value
        inputs = torch.where(compatible_paddings > 0, padded_value, inputs)
        valid_inputs = torch.sum(1.0 - compatible_paddings, self.pooling_dims, keepdims=True, dtype=inputs.dtype) + self.epsilon
        inputs_sum = torch.sum(inputs, self.pooling_dims, keepdims=True)
        outputs = torch.divide(inputs_sum, valid_inputs).type(inputs.dtype)
        outputs = torch.squeeze(outputs, axis=self.pooling_dims)
        return outputs

# Create test inputs
inputs = torch.randn(2, 4, 3, 5)
compatible_paddings = torch.zeros(2, 4, 3, 5)

ARGS = {
    'pooling_dims': [2, 3],
    'epsilon': 1e-08,
}
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 GlobalAvgPooling — 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 GlobalAvgPooling 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
MlpBlockWithMask Ran
ran on a synthesized input · constructed an object; no result was computed
AlirezaSalehy/Tipsomaly/model/tips/text_encoder.py
code served (permissive licence) · get_code("5c2a6ccb1d359d3a")
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, MlpBlockWithMask: 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
from torch import nn

torch.manual_seed(0)

class MlpBlockWithMask(nn.Module):
    """Transformer MLP / feed-forward block that supports masking."""

    def __init__(self, mlp_dim: int, d_model: int, use_bias: bool=True, dtype: torch.dtype=torch.float32, activation_fn: nn.Module=nn.GELU):
        super().__init__()
        self.mlp_dim = mlp_dim
        self.d_model = d_model
        self.use_bias = use_bias
        self.dtype = dtype
        self.activation_fn = activation_fn
        self.c_fc = nn.Linear(in_features=self.d_model, out_features=self.mlp_dim, dtype=self.dtype, bias=self.use_bias)
        self.c_proj = nn.Linear(in_features=self.mlp_dim, out_features=self.d_model, dtype=self.dtype, bias=self.use_bias)

    def __call__(self, inputs: torch.Tensor, mlp_mask: torch.Tensor) -> torch.Tensor:
        """Applies Transformer MlpBlock with mask module."""
        x = self.c_fc(inputs)
        x = self.activation_fn()(x)
        x = x * mlp_mask[..., None]
        x = self.c_proj(x)
        x = x * mlp_mask[..., None]
        return x

# Create small tensors for testing
batch_size = 2
d_model = 4
mlp_dim = 8

# inputs: (batch_size, d_model)
inputs = torch.randn(batch_size, d_model, dtype=torch.float32)

# mlp_mask: (batch_size,) - binary mask for each sample in batch
mlp_mask = torch.ones(batch_size, dtype=torch.float32)

ARGS = {
    "mlp_dim": mlp_dim,
    "d_model": d_model,
    "use_bias": True,
    "dtype": torch.float32,
    "activation_fn": nn.GELU,
}
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 MlpBlockWithMask — 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 MlpBlockWithMask 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
PositionalEmbedding Ran
ran on a synthesized input
AlirezaSalehy/Tipsomaly/model/tips/text_encoder.py
code served (permissive licence) · get_code("433b3cc572d51ec2")
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; 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
from torch import nn
import torch.nn.functional as F

class PositionalEmbedding(nn.Module):
    """Generates position embedding for a given 1-d sequence.

  Attributes:
    min_timescale: Start of the geometric index. Determines the periodicity of
      the added signal.
    max_timescale: End of the geometric index. Determines the frequency of the
      added signal.
    embedding_dim: Dimension of the embedding to be generated.
  """
    min_timescale: int = 1
    max_timescale: int = 10000
    embedding_dim: int = 0

    def __init__(self, embedding_dim: int):
        super().__init__()
        self.embedding_dim = embedding_dim

    def __call__(self, seq_length: int=None, position: torch.tensor=None):
        """Generates a torch.tensor of sinusoids with different frequencies.

    Args:
      seq_length: an optional Python int defining the output sequence length.
        if the `position` argument is specified.
      position:   [B, seq_length], optional position for each token in the
        sequence, only required when the sequence is packed.

    Returns:
      [B, seqlen, D] if `position` is specified, else [1, seqlen, D]
    """
        if position is None:
            assert seq_length is not None
            position = torch.arange(seq_length, dtype=torch.float32)[None, :]
        else:
            assert position.ndim == 2, position.shape
        num_timescales = self.embedding_dim // 2
        log_timescale_increment = torch.log(torch.tensor(float(self.max_timescale) / float(self.min_timescale))) / torch.maximum(torch.tensor(num_timescales, dtype=torch.float32) - 1, torch.tensor(1))
        inv_timescales = self.min_timescale * torch.exp(torch.arange(num_timescales, dtype=torch.float32) * -log_timescale_increment)
        scaled_time = position[:, :, None] * inv_timescales[None, None, :]
        signal = torch.cat((torch.sin(scaled_time), torch.cos(scaled_time)), dim=2)
        signal = F.pad(signal, (0, self.embedding_dim % 2, 0, 0, 0, 0))
        return signal


INIT_ARGS = {
    'embedding_dim': 8
}

ARGS = {
    'seq_length': 5,
    'position': None
}

if __name__ == '__main__':
    model = PositionalEmbedding(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{output}")
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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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)
ResidualAttentionBlock Ran
ran on a synthesized input · constructed an object; no result was computed
AlirezaSalehy/Tipsomaly/model/tips/text_encoder.py
code served (permissive licence) · get_code("bec621a25d6d8e86")
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, ResidualAttentionBlock: 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
from torch import nn

torch.manual_seed(0)

# Define the MlpBlockWithMask class
class MlpBlockWithMask(nn.Module):
    """Transformer MLP / feed-forward block that supports masking."""

    def __init__(self, mlp_dim: int, d_model: int, use_bias: bool=True, dtype: torch.dtype=torch.float32, activation_fn: nn.Module=nn.GELU):
        super().__init__()
        self.mlp_dim = mlp_dim
        self.d_model = d_model
        self.use_bias = use_bias
        self.dtype = dtype
        self.activation_fn = activation_fn
        self.c_fc = nn.Linear(in_features=self.d_model, out_features=self.mlp_dim, dtype=self.dtype, bias=self.use_bias)
        self.c_proj = nn.Linear(in_features=self.mlp_dim, out_features=self.d_model, dtype=self.dtype, bias=self.use_bias)

    def __call__(self, inputs: torch.Tensor, mlp_mask: torch.Tensor) -> torch.Tensor:
        """Applies Transformer MlpBlock with mask module."""
        x = self.c_fc(inputs)
        x = self.activation_fn()(x)
        x = x * mlp_mask[..., None]
        x = self.c_proj(x)
        x = x * mlp_mask[..., None]
        return x

# Define the ResidualAttentionBlock class
class ResidualAttentionBlock(nn.Module):
    """Transformer residual attention block."""

    def __init__(self, d_model: int, n_head: int, mlp_dim: int, dtype: torch.dtype=torch.float32):
        super().__init__()
        self.d_model = d_model
        self.n_head = n_head
        self.mlp_dim = mlp_dim
        self.dtype = dtype
        self.attn = nn.MultiheadAttention(d_model, n_head, dtype=self.dtype)
        self.ln_1 = nn.LayerNorm(d_model, dtype=self.dtype)
        self.mlp = MlpBlockWithMask(self.mlp_dim, d_model, use_bias=True, dtype=self.dtype, activation_fn=nn.ReLU)
        self.ln_2 = nn.LayerNorm(d_model, dtype=self.dtype)

    def attention(self, x: torch.Tensor, mask: torch.Tensor):
        attn_mask = mask[:, None, None, :].repeat(1, self.n_head, x.shape[0], 1).flatten(0, 1)
        attn_mask[attn_mask == 0] = float('-inf')
        attn_mask[attn_mask == 1] = 0
        return self.attn(x, x, x, need_weights=False, attn_mask=attn_mask)[0]

    def forward(self, x: torch.Tensor, mask: torch.Tensor):
        x = x + self.attention(self.ln_1(x), mask.permute(1, 0))
        x = x + self.mlp(self.ln_2(x), mask)
        return (x, mask)

# Set up parameters for ResidualAttentionBlock
d_model = 4
n_head = 2
mlp_dim = 8
dtype = torch.float32

ARGS = {
    'd_model': d_model,
    'n_head': n_head,
    'mlp_dim': mlp_dim,
    'dtype': dtype,
}
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 ResidualAttentionBlock — 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 ResidualAttentionBlock 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
Transformer Ran
ran on a synthesized input · constructed an object; no result was computed
AlirezaSalehy/Tipsomaly/model/tips/text_encoder.py
code served (permissive licence) · get_code("5e1453495dc95e4c")
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, Transformer: 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
from torch import nn

torch.manual_seed(0)

# Define the ARGS dictionary with all required parameters for Transformer.__init__
ARGS = {
    "width": 4,           # d_model dimension
    "layers": 2,          # number of transformer blocks
    "heads": 2,           # number of attention heads
    "mlp_dim": 8,         # MLP hidden dimension
    "dtype": torch.float32
}
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 Transformer — 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 Transformer 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
SequentialMultiInput Not yet run
unverified (harvested, no recorded run)
AlirezaSalehy/Tipsomaly/model/tips/text_encoder.py
code served (permissive licence) · get_code("6c5b3c90c68149e8")
How it ran

no invocation recorded.

TextEncoder Not yet run
unverified (harvested, no recorded run)
AlirezaSalehy/Tipsomaly/model/tips/text_encoder.py
code served (permissive licence) · get_code("b6acc0be918d258b")
How it ran

no invocation recorded.

Also present in other papers' code

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

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

Anomaly detection identifies departures from expected behavior in safety-critical settings. When target-domain normal data are unavailable, zero-shot anomaly detection (ZSAD) leverages vision-language models (VLMs). However, CLIP's coarse image-text alignment limits both localization and detection due to (i) spatial misalignment and (ii) weak sensitivity to fine-grained anomalies; prior works compensate with complex auxiliary modules yet largely overlook the choice of backbone. We revisit the backbone and use TIPS-a VLM trained with spatially aware objectives. While TIPS alleviates CLIP's issues, it exposes a distributional gap between global and local features. We address this with decoupled prompts-fixed for image-level detection and learnable for pixel-level localization-and by injecting local evidence into the global score. Without CLIP-specific tricks, our TIPS-based pipeline improves image-level performance by 1.1-3.9% and pixel-level by 1.5-6.9% across seven industrial datasets, delivering strong generalization with a lean architecture. Code is available at github.com/AlirezaSalehy/Tipsomaly.

For agents

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

get_harvested_code_for_paper("2602.03594")
get_code_for_paper("2602.03594")
have("2602.03594")

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

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

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

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

Connect an agent — have() is free.