SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2406.04313 · 2024

Improving Alignment and Robustness with Circuit Breakers

arXiv · PDF · Open in the Atlas

Code that ran

3 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 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/2406.04313.json · badge: /api/ran/2406.04313.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
blackswan-ai/circuit-breakers canonical (classifier label)
classifier basis: census
1 ran · 3 no recorded run
grayswanai/circuit-breakers canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
schwinnl/circuit-breakers-eval extension (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
compute_loss Ran
ran; our contract draft was wrong, not the code
grayswanai/circuit-breakers/src/lorra_circuit_breaker.py
code served (permissive licence) · get_code("b5b12432e2c1124d")
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 0, dtype family float, shape () 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
from unittest.mock import MagicMock

torch.manual_seed(0)

# Build a minimal model that supports the required interface
class MinimalModel(nn.Module):
    def __init__(self, hidden_size=4, num_layers=3):
        super().__init__()
        self.hidden_size = hidden_size
        self.num_layers = num_layers
        # Create dummy layers to return hidden states
        self.layers = nn.ModuleList([nn.Linear(hidden_size, hidden_size) for _ in range(num_layers)])
        self.adapter_enabled = True
    
    def forward(self, input_ids, attention_mask, output_hidden_states=False, **kwargs):
        batch_size, seq_len = input_ids.shape
        # Simulate hidden states output - return list of tensors, one per layer
        hidden_states = []
        for i in range(self.num_layers):
            hidden_states.append(torch.randn(batch_size, seq_len, self.hidden_size))
        
        # Return dict with 'hidden_states' key containing list of layer outputs
        return {'hidden_states': hidden_states}
    
    def disable_adapter(self):
        return AdapterContext(self)
    
    def train(self, mode=True):
        super().train(mode)
        return self
    
    def eval(self):
        super().eval()
        return self

class AdapterContext:
    def __init__(self, model):
        self.model = model
    
    def __enter__(self):
        self.model.adapter_enabled = False
        return self
    
    def __exit__(self, *args):
        self.model.adapter_enabled = True

# Build a minimal loss calculator object
class LossCalculator:
    def __init__(self):
        self.current_training_step = 0
    
    def get_training_progress(self):
        # Return a value between 0 and 1 based on training step
        return min(self.current_training_step / 100.0, 1.0)

# Create instances
torch.manual_seed(0)
model = MinimalModel(hidden_size=4, num_layers=3)
model.train()

loss_calculator = LossCalculator()

# Create input tensors
batch_size = 2
seq_len = 5

inputs = {
    'input_ids': torch.randint(0, 100, (batch_size, seq_len)),
    'attention_mask': torch.ones(batch_size, seq_len),
    'input_ids_circuit_breaker': torch.randint(0, 100, (batch_size, seq_len)),
    'attention_mask_circuit_breaker': torch.ones(batch_size, seq_len),
    'input_ids_val': torch.randint(0, 100, (batch_size, seq_len)),
    'attention_mask_val': torch.ones(batch_size, seq_len),
}

target_layers = [0, 1, 2]
alpha = 0.5

ARGS = {
    'self': loss_calculator,
    'model': model,
    'inputs': inputs,
    'target_layers': target_layers,
    'alpha': alpha,
    'return_outputs': False,
    'tokenizer': None,
}
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 0, dtype family float, shape () — shape () 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
handle_non_serializable Ran
ran, honoured the contract we drafted
blackswan-ai/circuit-breakers/evaluation/utils.py
code served (permissive licence) · get_code("257ec7d5d8d6c5b6")
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 2, dtype family int; 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
from datetime import datetime

def handle_non_serializable(obj):
    if isinstance(obj, np.ndarray):
        return obj.tolist()
    elif hasattr(obj, 'isoformat'):
        return obj.isoformat()
    else:
        return str(obj)


# Test with numpy array
numpy_array = np.array([[1, 2, 3], [4, 5, 6]])

# Test with datetime object (has isoformat method)
dt = datetime(2023, 10, 15, 14, 30, 45)

# Test with a regular object that will be converted to string
class CustomObject:
    def __str__(self):
        return "CustomObject instance"

custom_obj = CustomObject()

ARGS = {
    "obj": numpy_array
}
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 list, ndim 2, dtype family int — 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
mellowmax Ran
ran; our contract draft was wrong, not the code
schwinnl/circuit-breakers-eval/evaluation/softopt.py
pointer only (licence: NONE) · get_code("932da9d6ec274164")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, schwinnl/circuit-breakers-eval when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

init_rep_control Not yet run
unverified (harvested, no recorded run)
blackswan-ai/circuit-breakers/evaluation/utils.py
code served (permissive licence) · get_code("ae03a7f84547715f")
How it ran

no invocation recorded.

load_model_and_tokenizer Not yet run
unverified (harvested, no recorded run)
blackswan-ai/circuit-breakers/evaluation/utils.py
code served (permissive licence) · get_code("2671d81aefc6945e")
How it ran

no invocation recorded.

run Not yet run
unverified (harvested, no recorded run)
blackswan-ai/circuit-breakers/evaluation/softopt.py
code served (permissive licence) · get_code("a28e636efca9a712")
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, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 5 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.

FunctionAlso present inEarliest-datedOthers named
mellowmax 1 other paper
1 dated earlier
2307.15043 (2023-07)
Universal and Transferable Adversarial Attacks on Aligned Language Models

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

AI systems can take harmful actions and are highly vulnerable to adversarial attacks. We present an approach, inspired by recent advances in representation engineering, that interrupts the models as they respond with harmful outputs with "circuit breakers." Existing techniques aimed at improving alignment, such as refusal training, are often bypassed. Techniques such as adversarial training try to plug these holes by countering specific attacks. As an alternative to refusal training and adversarial training, circuit-breaking directly controls the representations that are responsible for harmful outputs in the first place. Our technique can be applied to both text-only and multimodal language models to prevent the generation of harmful outputs without sacrificing utility -- even in the presence of powerful unseen attacks. Notably, while adversarial robustness in standalone image recognition remains an open challenge, circuit breakers allow the larger multimodal system to reliably withstand image "hijacks" that aim to produce harmful content. Finally, we extend our approach to AI agents, demonstrating considerable reductions in the rate of harmful actions when they are under attack. Our approach represents a significant step forward in the development of reliable safeguards to harmful behavior and adversarial attacks.

For agents

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

get_harvested_code_for_paper("2406.04313")
get_code_for_paper("2406.04313")
have("2406.04313")

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

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

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

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

Connect an agent — have() is free.