SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.18166 · 2024

Defending Large Language Models Against Jailbreak Attacks via Layer-specific Editing

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 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; 6 failures of our instrument; 0 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/2405.18166.json · badge: /api/ran/2405.18166.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
ledllm/ledllm canonical (classifier label)
classifier basis: census
7 ran · 0 no recorded run
FunctionStatusWhere it lives
decode_tokens Ran
ran; our contract draft was wrong, not the code
ledllm/ledllm/utils/modelUtils.py
pointer only (licence: NONE) · get_code("9532c9c8f3eec45b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ledllm/ledllm 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.

generate_input Ran
ran; our contract draft was wrong, not the code
ledllm/ledllm/utils/utils.py
pointer only (licence: NONE) · get_code("6f465ce5300a3f4d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ledllm/ledllm 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.

generate_outputs Ran
ran; our contract draft was wrong, not the code
ledllm/ledllm/utils/modelUtils.py
pointer only (licence: NONE) · get_code("92100cdec84b8f5a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ledllm/ledllm 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.

hierarchical_subsequence Ran
ran on a synthesized input
ledllm/ledllm/casper/nethook.py
pointer only (licence: NONE) · get_code("920b394e7ad80c53")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ledllm/ledllm 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.

make_inputs Ran
ran; our contract draft was wrong, not the code
ledllm/ledllm/utils/modelUtils.py
pointer only (licence: NONE) · get_code("96b3625b39d4a804")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ledllm/ledllm 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.

recursive_copy Ran
ran; our contract draft was wrong, not the code
ledllm/ledllm/casper/nethook.py
pointer only (licence: NONE); the stored copy get_code serves, from TrustedLLM/UnKE, is pointer only (licence: NONE) · get_code("70f6ab8bde55420e")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ledllm/ledllm 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.

subsequence Ran
ran; our contract draft was wrong, not the code
ledllm/ledllm/casper/nethook.py
pointer only (licence: NONE) · get_code("440ff98c2b1ae1aa")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, ledllm/ledllm 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.

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, 6 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 3 the same month, 5 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
subsequence 49 other papers
19 dated earlier, 3 the same month, 26 later, 1 same year, order not determinable
2007.15646 (2020-07)
Rewriting a Deep Generative Model
2009.05041 (2020-09)
Understanding the Role of Individual Units in a Deep Neural Network
2110.04292 (2021-10)
Toward a Visual Concept Vocabulary for GAN Latent Space
and 46 more not named here
recursive_copy 48 other papers
17 dated earlier, 4 the same month, 26 later, 1 same year, order not determinable
2207.02774 (2022-07)
Local Relighting of Real Scenes
2210.07229 (2022-10)
Mass-Editing Memory in a Transformer
2302.12461 (2023-02)
Analyzing And Editing Inner Mechanisms Of Backdoored Language Models
and 45 more not named here
hierarchical_subsequence 46 other papers
16 dated earlier, 3 the same month, 26 later, 1 same year, order not determinable
2210.07229 (2022-10)
Mass-Editing Memory in a Transformer
2302.12461 (2023-02)
Analyzing And Editing Inner Mechanisms Of Backdoored Language Models
2311.09053 (2023-11)
Assessing Knowledge Editing in Language Models via Relation Perspective
and 43 more not named here
decode_tokens 3 other papers
1 dated earlier, 2 later
2312.07876 (2023-12)
Causality Analysis for Evaluating the Security of Large Language Models
2411.18620 (2024-11)
Cross-modal Information Flow in Multimodal Large Language Models
2502.11196 (2025-02)
How Do LLMs Acquire New Knowledge? A Knowledge Circuits Perspective on Continual Pre-Training
make_inputs 3 other papers
2 dated earlier, 1 later
2312.07876 (2023-12)
Causality Analysis for Evaluating the Security of Large Language Models
2404.03646 (2024-04)
Locating and Editing Factual Associations in Mamba
2411.18620 (2024-11)
Cross-modal Information Flow in Multimodal Large Language Models
generate_input 1 other paper
1 dated earlier
2312.07876 (2023-12)
Causality Analysis for Evaluating the Security of Large 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

Large language models (LLMs) are increasingly being adopted in a wide range of real-world applications. Despite their impressive performance, recent studies have shown that LLMs are vulnerable to deliberately crafted adversarial prompts even when aligned via Reinforcement Learning from Human Feedback or supervised fine-tuning. While existing defense methods focus on either detecting harmful prompts or reducing the likelihood of harmful responses through various means, defending LLMs against jailbreak attacks based on the inner mechanisms of LLMs remains largely unexplored. In this work, we investigate how LLMs response to harmful prompts and propose a novel defense method termed \textbf{L}ayer-specific \textbf{Ed}iting (LED) to enhance the resilience of LLMs against jailbreak attacks. Through LED, we reveal that several critical \textit{safety layers} exist among the early layers of LLMs. We then show that realigning these safety layers (and some selected additional layers) with the decoded safe response from selected target layers can significantly improve the alignment of LLMs against jailbreak attacks. Extensive experiments across various LLMs (e.g., Llama2, Mistral) show the effectiveness of LED, which effectively defends against jailbreak attacks while maintaining performance on benign prompts. Our code is available at \url{https://github.com/ledllm/ledllm}.

For agents

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

get_harvested_code_for_paper("2405.18166")
get_code_for_paper("2405.18166")
have("2405.18166")

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

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

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

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

Connect an agent — have() is free.