SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.15140 · 2023

AutoDAN: Interpretable Gradient-Based Adversarial Attacks on Large Language Models

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 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; 0 no recorded run), measured 2026-11-23; 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/2310.15140.json · badge: /api/ran/2310.15140.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
rotaryhammer/code-autodan community (classifier label)
classifier basis not recorded on the link
4 ran · 0 no recorded run
FunctionStatusWhere it lives
get_embedding_layer Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
rotaryhammer/code-autodan/autodan/autodan/attack_manager.py
code served (permissive licence) · get_code("84f875c06b5ddef8")
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, MistralForCausalLM

torch.manual_seed(0)

# Create a minimal GPT2LMHeadModel
class MinimalGPT2(GPT2LMHeadModel):
    def __init__(self):
        from transformers import GPT2Config
        config = GPT2Config(
            vocab_size=256,
            n_positions=128,
            n_embd=64,
            n_layer=2,
            n_head=2,
        )
        super().__init__(config)

# Create a minimal LlamaForCausalLM
class MinimalLlama(LlamaForCausalLM):
    def __init__(self):
        from transformers import LlamaConfig
        config = LlamaConfig(
            vocab_size=256,
            hidden_size=64,
            num_hidden_layers=2,
            num_attention_heads=2,
            intermediate_size=128,
        )
        super().__init__(config)

# Create a minimal GPTNeoXForCausalLM
class MinimalGPTNeoX(GPTNeoXForCausalLM):
    def __init__(self):
        from transformers import GPTNeoXConfig
        config = GPTNeoXConfig(
            vocab_size=256,
            hidden_size=64,
            num_hidden_layers=2,
            num_attention_heads=2,
            intermediate_size=128,
        )
        super().__init__(config)

# Create a minimal GPTJForCausalLM
class MinimalGPTJ(GPTJForCausalLM):
    def __init__(self):
        from transformers import GPTJConfig
        config = GPTJConfig(
            vocab_size=256,
            n_positions=128,
            n_embd=64,
            n_layer=2,
            n_head=2,
        )
        super().__init__(config)

# Test with GPT2LMHeadModel since it's simplest
model = MinimalGPT2()

ARGS = {
    "model": model,
}
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
get_embedding_matrix Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
rotaryhammer/code-autodan/autodan/autodan/attack_manager.py
code served (permissive licence) · get_code("7dd95b29871075f9")
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 Parameter, ndim 2, 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 transformers import GPT2LMHeadModel, GPTJForCausalLM, GPTNeoXForCausalLM, LlamaForCausalLM, MistralForCausalLM

torch.manual_seed(0)

# Create a minimal GPT2LMHeadModel-like structure
class MinimalGPT2(nn.Module):
    def __init__(self):
        super().__init__()
        self.transformer = nn.Module()
        self.transformer.wte = nn.Embedding(10, 4)
    
    def __class__(self):
        return GPT2LMHeadModel

model_gpt2 = MinimalGPT2()
model_gpt2.__class__ = GPT2LMHeadModel

# Create a minimal LlamaForCausalLM-like structure
class MinimalLlama(nn.Module):
    def __init__(self):
        super().__init__()
        self.model = nn.Module()
        self.model.embed_tokens = nn.Embedding(10, 4)
    
    def __class__(self):
        return LlamaForCausalLM

model_llama = MinimalLlama()
model_llama.__class__ = LlamaForCausalLM

# Create a minimal GPTNeoXForCausalLM-like structure
class MinimalGPTNeoX(nn.Module):
    def __init__(self):
        super().__init__()
        self.base_model = nn.Module()
        self.base_model.embed_in = nn.Embedding(10, 4)
    
    def __class__(self):
        return GPTNeoXForCausalLM

model_gptneox = MinimalGPTNeoX()
model_gptneox.__class__ = GPTNeoXForCausalLM

# Create a minimal GPTJForCausalLM-like structure
class MinimalGPTJ(nn.Module):
    def __init__(self):
        super().__init__()
        self.transformer = nn.Module()
        self.transformer.wte = nn.Embedding(10, 4)
    
    def __class__(self):
        return GPTJForCausalLM

model_gptj = MinimalGPTJ()
model_gptj.__class__ = GPTJForCausalLM

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 Parameter, ndim 2, dtype family float — no output shape is stated: observe_signature.py recorded Tensor ndim 2, which disagrees with the fixture run
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_embeddings Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
rotaryhammer/code-autodan/autodan/autodan/attack_manager.py
code served (permissive licence) · get_code("01abe3bd48ba14fc")
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, 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
from transformers import GPT2LMHeadModel, GPTJForCausalLM, GPTNeoXForCausalLM, LlamaForCausalLM, MistralForCausalLM

torch.manual_seed(0)

# Create a minimal GPT2LMHeadModel stand-in
class MinimalGPT2(GPT2LMHeadModel):
    def __init__(self):
        # Skip parent init to avoid downloading weights
        nn.Module.__init__(self)
        self.transformer = nn.Module()
        # Create minimal wte (word token embedding)
        self.transformer.wte = nn.Embedding(num_embeddings=10, embedding_dim=4)

# Create input_ids tensor: shape (batch_size=2, seq_len=3)
input_ids = torch.tensor([[1, 2, 3], [4, 5, 6]], dtype=torch.long)

# Create model instance
model = MinimalGPT2()

ARGS = {
    'model': model,
    'input_ids': input_ids,
}
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 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
truthful_decode Ran
ran on a synthesized input
rotaryhammer/code-autodan/autodan/autodan/utils.py
code served (permissive licence) · get_code("f1a18a8932bbdd84")
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
from unittest.mock import Mock

torch.manual_seed(0)

# Create a mock tokenizer that implements the required methods
tokenizer = Mock()
tokenizer.convert_tokens_to_ids = Mock(return_value=1)
tokenizer.decode = Mock(side_effect=lambda ids, skip_special_tokens=False: "dummy_text")

# Test with list of ids
ids_list = [2, 3, 4, 5]

# Test with torch tensor
ids_tensor = torch.tensor([2, 3, 4, 5], dtype=torch.int64)

# Define ARGS with list version (required to show one working case)
ARGS = {
    'tokenizer': tokenizer,
    'ids': ids_list
}
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

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 1 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 later
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
2404.13968 (2024-04)
Protecting Your LLMs with Information Bottleneck
and 3 more not named here
get_embedding_matrix 1 other paper
1 later
2401.17263 (2024-01)
Robust Prompt Optimization for Defending Language Models Against Jailbreaking Attacks
get_embeddings 1 other paper
1 later
2401.17263 (2024-01)
Robust Prompt Optimization for Defending Language Models Against Jailbreaking Attacks

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

Safety alignment of Large Language Models (LLMs) can be compromised with manual jailbreak attacks and (automatic) adversarial attacks. Recent studies suggest that defending against these attacks is possible: adversarial attacks generate unlimited but unreadable gibberish prompts, detectable by perplexity-based filters; manual jailbreak attacks craft readable prompts, but their limited number due to the necessity of human creativity allows for easy blocking. In this paper, we show that these solutions may be too optimistic. We introduce AutoDAN, an interpretable, gradient-based adversarial attack that merges the strengths of both attack types. Guided by the dual goals of jailbreak and readability, AutoDAN optimizes and generates tokens one by one from left to right, resulting in readable prompts that bypass perplexity filters while maintaining high attack success rates. Notably, these prompts, generated from scratch using gradients, are interpretable and diverse, with emerging strategies commonly seen in manual jailbreak attacks. They also generalize to unforeseen harmful behaviors and transfer to black-box LLMs better than their unreadable counterparts when using limited training data or a single proxy model. Furthermore, we show the versatility of AutoDAN by automatically leaking system prompts using a customized objective. Our work offers a new way to red-team LLMs and understand jailbreak mechanisms via interpretability.

For agents

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

get_harvested_code_for_paper("2310.15140")
get_code_for_paper("2310.15140")
have("2310.15140")

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

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

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

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

Connect an agent — have() is free.