SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.03081 · 2026

TAO-Attack: Toward Advanced Optimization-Based Jailbreak Attacks for Large Language Models

Zhi Xu, Han Liu, Jiaqi Li, Hong Yu, Xiaotong Zhang

arXiv · PDF · Open in the Atlas

Code that ran

7 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 0 have no contract verdict; 7 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/2603.03081.json · badge: /api/ran/2603.03081.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
ZevineXu/TAO-Attack canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
check_for_attack_success Ran
ran; our contract draft was wrong, not the code
ZevineXu/TAO-Attack/attack.py
code served (permissive licence) · get_code("2b431b29ac3d458c")
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

torch.manual_seed(0)

# Minimal tokenizer stand-in
class MinimalTokenizer:
    def __init__(self):
        self.pad_token_id = 0
    
    def decode(self, token_ids):
        # Simple mock: convert token ids to words
        token_to_word = {
            0: "<pad>",
            1: "hello",
            2: "world",
            3: "I'm",
            4: "sorry",
            5: ".",
        }
        words = [token_to_word.get(int(tid), f"<token_{tid}>") for tid in token_ids]
        return " ".join(words)

# Minimal generation config stand-in
class MinimalGenerationConfig:
    def __init__(self):
        self.max_new_tokens = 32
        self.temperature = 1.0

# Minimal model stand-in
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.device = torch.device("cpu")
        self.generation_config = MinimalGenerationConfig()
        self.linear = nn.Linear(4, 4)
    
    def generate(self, input_ids, attention_mask=None, generation_config=None, 
                 pad_token_id=None, temperature=None, do_sample=False):
        # Return mock generated output: input_ids + 3 new tokens
        batch_size = input_ids.shape[0]
        new_tokens = torch.randint(1, 5, (batch_size, 3))
        return torch.cat([input_ids, new_tokens], dim=1)

model = MinimalModel()
tokenizer = MinimalTokenizer()

# Create input_ids and assistant_role_slice
# Using slice to indicate which part is "assistant"
input_ids = torch.tensor([1, 2, 3, 4], dtype=torch.long)
assistant_role_slice = slice(2, 4)  # Last 2 tokens belong to assistant

gen_config = MinimalGenerationConfig()
gen_config.max_new_tokens = 16

ARGS = {
    "model": model,
    "tokenizer": tokenizer,
    "input_ids": input_ids,
    "assistant_role_slice": assistant_role_slice,
    "test_prefixes": ["I'm sorry", "Sorry", "I apologize", "As an"],
    "gen_config": gen_config,
}
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
combine_prompts Ran
ran; our contract draft was wrong, not the code
ZevineXu/TAO-Attack/api_experiments/evaluate_api_models.py
code served (permissive licence) · get_code("71b177b3a3ed6078")
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 torch

torch.manual_seed(0)

# Construct arguments for combine_prompts function
benign = '"This is a benign prompt"'
adv = 'This is an adversarial prompt'
combo = 'benign+adv'

ARGS = {
    'benign': benign,
    'adv': adv,
    'combo': combo
}
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 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
generate Ran
ran; our contract draft was wrong, not the code
ZevineXu/TAO-Attack/attack.py
code served (permissive licence) · get_code("7ced740e66b4569d")
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 int, 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
import torch.nn as nn

torch.manual_seed(0)

# Stand-in tokenizer with required attributes
class MockTokenizer:
    def __init__(self):
        self.pad_token_id = 0

# Stand-in generation config
class MockGenerationConfig:
    def __init__(self):
        self.max_new_tokens = 32
        self.temperature = 1.0

# Minimal model that satisfies the function's usage
class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.device = torch.device('cpu')
        self.generation_config = MockGenerationConfig()
        # Add a simple linear layer to make it a valid nn.Module
        self.linear = nn.Linear(4, 4)
    
    def generate(self, input_ids, attention_mask=None, generation_config=None, 
                 pad_token_id=None, temperature=None, do_sample=False):
        # Return synthetic output_ids with shape (batch_size, seq_len)
        # Input shape is (1, seq_len), return something longer
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1] + 5  # Generate 5 more tokens
        output = torch.randint(0, 100, (batch_size, seq_len))
        return output

# Create instances
model = MockModel()
tokenizer = MockTokenizer()

# Create input_ids tensor (small size: 2x4)
input_ids = torch.randint(0, 100, (2, 4))

# Create a slice object for assistant_role_slice
# This should have .stop attribute
class MockSlice:
    def __init__(self, stop_val):
        self.stop = stop_val

assistant_role_slice = MockSlice(stop_val=3)

# Create generation config
gen_config = MockGenerationConfig()

# Temperature value
temperature = 0.7

ARGS = {
    "model": model,
    "tokenizer": tokenizer,
    "input_ids": input_ids,
    "assistant_role_slice": assistant_role_slice,
    "gen_config": gen_config,
    "temperature": temperature
}
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 int, 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
get_embedding_layer Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ZevineXu/TAO-Attack/llm_attacks/base/attack_manager.py
code served (permissive licence) · get_code("0bf2136a7171ae80")
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 Embedding. 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 transformers import GPT2LMHeadModel, GPTJForCausalLM, GPTNeoXForCausalLM, LlamaForCausalLM

torch.manual_seed(0)

# Create a minimal GPT2LMHeadModel with required structure
class MinimalGPT2(GPT2LMHeadModel):
    def __init__(self):
        # Skip parent init to avoid downloading pretrained weights
        nn.Module.__init__(self)
        self.transformer = nn.Module()
        self.transformer.wte = nn.Embedding(100, 64)

model_gpt2 = MinimalGPT2()

ARGS = {
    "model": model_gpt2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Embedding — a Embedding output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Embedding 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
load_prompts Ran
ran; our contract draft was wrong, not the code
ZevineXu/TAO-Attack/api_experiments/evaluate_api_models.py
code served (permissive licence) · get_code("645890ba00019a69")
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 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 tempfile
import os

# Create a temporary file with some instructions
temp_dir = tempfile.mkdtemp()
instructions_file = os.path.join(temp_dir, "instructions.txt")
with open(instructions_file, 'w') as f:
    f.write("First instruction\n")
    f.write("Second instruction\n")
    f.close()

# Define arguments for the function
ARGS = {
    "instruction": "What is the capital of France?",
    "instructions_path": instructions_file
}
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 list, ndim 1, dtype family float — 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
make_checking_fn Ran
ran; our contract draft was wrong, not the code
ZevineXu/TAO-Attack/api_experiments/evaluate_api_models.py
code served (permissive licence) · get_code("d0e94f216f27f804")
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 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 numpy as np

# Analyze the function:
# - make_checking_fn takes method (default 'key_words') and **kwargs
# - When method='key_words', it can accept 'key_words' in kwargs (a set of strings)
# - Returns a check function that takes texts (list of strings) and returns list of bools
# - The check function looks for key_words NOT in texts

ARGS = {
    'method': 'key_words',
    'key_words': set(("I'm sorry", 'Sorry', 'an AI', 'is illegal and unethical', 'My purpose', 'OpenAI'))
}
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 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
pad_embeds Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ZevineXu/TAO-Attack/attack.py
code served (permissive licence) · get_code("7f2fb90d5c12909d")
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 3, dtype family float, shape (2, 5, 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)

# Create a small 3D tensor with shape (batch=2, seq_len=3, embedding_dim=4)
embeds = torch.randn(2, 3, 4)

# Target length to pad to
target_len = 5

ARGS = {
    "embeds": embeds,
    "target_len": target_len,
}
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 3, dtype family float, shape (2, 5, 4) — shape (2, 5, 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
get_embedding_matrix Not yet run
unverified (harvested, no recorded run)
ZevineXu/TAO-Attack/llm_attacks/base/attack_manager.py
code served (permissive licence) · get_code("688aaeba506e3329")
How it ran

no invocation recorded.

get_embeddings Not yet run
unverified (harvested, no recorded run)
ZevineXu/TAO-Attack/llm_attacks/base/attack_manager.py
code served (permissive licence) · get_code("f556dda0785f3c77")
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, 6 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 0 the same month, 0 later) and 3 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
get_embedding_layer 6 other papers
6 dated earlier
2310.15140 (2023-10)
AutoDAN: Interpretable Gradient-Based Adversarial Attacks on Large Language Models
2402.05467 (2024-02)
Rapid Optimization for Jailbreaking LLMs via Subconscious Exploitation and Echopraxia
2402.16459 (2024-02)
Defending LLMs against Jailbreaking Attacks via Backtranslation
and 3 more not named here
get_embedding_matrix 6 other papers
6 dated earlier
2402.09063 (2024-02)
Soft Prompt Threats: Attacking Safety Alignment and Unlearning in Open-Source LLMs through the Embedding Space
2402.16459 (2024-02)
Defending LLMs against Jailbreaking Attacks via Backtranslation
2403.04957 (2024-03)
Automatic and Universal Prompt Injection Attacks against Large Language Models
and 3 more not named here
get_embeddings 5 other papers
5 dated earlier
2402.16459 (2024-02)
Defending LLMs against Jailbreaking Attacks via Backtranslation
2403.04957 (2024-03)
Automatic and Universal Prompt Injection Attacks against Large Language Models
2404.13968 (2024-04)
Protecting Your LLMs with Information Bottleneck
and 2 more not named here
combine_prompts 3 other papers
3 dated earlier
2402.12991 (2024-02)
TRAP: Targeted Random Adversarial Prompt Honeypot for Black-Box Identification
2404.13968 (2024-04)
Protecting Your LLMs with Information Bottleneck
2406.01288 (2024-06)
Improved Few-Shot Jailbreaking Can Circumvent Aligned Language Models and Their Defenses
load_prompts 3 other papers
3 dated earlier
2402.12991 (2024-02)
TRAP: Targeted Random Adversarial Prompt Honeypot for Black-Box Identification
2404.13968 (2024-04)
Protecting Your LLMs with Information Bottleneck
2406.01288 (2024-06)
Improved Few-Shot Jailbreaking Can Circumvent Aligned Language Models and Their Defenses
make_checking_fn 3 other papers
3 dated earlier
2402.12991 (2024-02)
TRAP: Targeted Random Adversarial Prompt Honeypot for Black-Box Identification
2404.13968 (2024-04)
Protecting Your LLMs with Information Bottleneck
2406.01288 (2024-06)
Improved Few-Shot Jailbreaking Can Circumvent Aligned Language Models and Their Defenses

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

Warning: This paper contains text that potentially offensive and harmful. Large language models (LLMs) have achieved remarkable success across diverse applications but remain vulnerable to jailbreak attacks, where attackers craft prompts that bypass safety alignment and elicit unsafe responses. Among existing approaches, optimization-based attacks have shown strong effectiveness, yet current methods often suffer from frequent refusals, pseudo-harmful outputs, and inefficient token-level updates. In this work, we propose TAO-Attack, a new optimization-based jailbreak method. TAO-Attack employs a two-stage loss function: the first stage suppresses refusals to ensure the model continues harmful prefixes, while the second stage penalizes pseudo-harmful outputs and encourages the model toward more harmful completions. In addition, we design a directionpriority token optimization (DPTO) strategy that improves efficiency by aligning candidates with the gradient direction before considering update magnitude. Extensive experiments on multiple LLMs demonstrate that TAO-Attack consistently outperforms state-of-the-art methods, achieving higher attack success rates and even reaching 100% in certain scenarios.

For agents

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

get_harvested_code_for_paper("2603.03081")
get_code_for_paper("2603.03081")
have("2603.03081")

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

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

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

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

Connect an agent — have() is free.