SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.10343 · 2024

Locking Down the Finetuned LLMs Safety

arXiv · PDF · Open in the Atlas

Code that ran

12 of 21 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 10 failures of our instrument; 9 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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/2410.10343.json · badge: /api/ran/2410.10343.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
zhu-minjun/safetylock canonical (classifier label)
classifier basis: census
12 ran · 9 no recorded run
FunctionStatusWhere it lives
repeat_kv Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
zhu-minjun/safetylock/safetylock/model_utils/modeling_llama.py
pointer only (licence: NONE) · get_code("30d7eec482ebf6b1")
How it ran

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

apply_rotary_pos_emb Ran
ran; our contract draft was wrong, not the code
zhu-minjun/safetylock/safetylock/model_utils/modeling_llama.py
pointer only (licence: NONE) · get_code("bac65c3dafaec040")
How it ran

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

conditional_perplexity Ran
ran, honoured the contract we drafted
zhu-minjun/safetylock/eval/ppl_eval.py
pointer only (licence: NONE) · get_code("7a4f57618fc45863")
How it ran

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

extract_content Ran
ran, honoured the contract we drafted
zhu-minjun/safetylock/eval/eval_utils/openai_gpt4_judge.py
pointer only (licence: NONE) · get_code("e3b723ac5b19f39c")
How it ran

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

load_llama_from_config Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
zhu-minjun/safetylock/eval/eval_utils/model_utils.py
pointer only (licence: NONE) · get_code("b4c052fb373aef07")
How it ran

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

load_merge_table Ran
ran; our contract draft was wrong, not the code
zhu-minjun/safetylock/eval/eval_utils/bpe.py
pointer only (licence: NONE) · get_code("990d82424d309a3b")
How it ran

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

load_peft_model Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
zhu-minjun/safetylock/eval/eval_utils/model_utils.py
pointer only (licence: NONE) · get_code("6d5ba8546b6aad2c")
How it ran

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

load_subword_nmt_table Ran
ran; our contract draft was wrong, not the code
zhu-minjun/safetylock/eval/eval_utils/bpe.py
pointer only (licence: NONE) · get_code("03e9a6a74a57cc23")
How it ran

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

question_read Ran
ran; our contract draft was wrong, not the code
zhu-minjun/safetylock/eval/safety_eval.py
pointer only (licence: NONE) · get_code("6d727ad94b6bfc12")
How it ran

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

read_dialogs_from_file Ran
ran; our contract draft was wrong, not the code
zhu-minjun/safetylock/safetylock/eval_utils/chat_utils.py
pointer only (licence: NONE); the stored copy get_code serves, from yxduir/LLM-SRT, is pointer only (licence: NONE) · get_code("8922fb4b5b7006f7")
How it ran

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

rotate_half Ran
ran; our contract draft was wrong, not the code
zhu-minjun/safetylock/safetylock/model_utils/modeling_llama.py
pointer only (licence: NONE) · get_code("b99eea6376d1e212")
How it ran

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

tokenize_word Ran
ran; our contract draft was wrong, not the code
zhu-minjun/safetylock/eval/eval_utils/bpe.py
pointer only (licence: NONE) · get_code("d7a0c20cde2f68a7")
How it ran

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

apply_prompt_template Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/safetylock/eval_utils/prompt_utils.py
pointer only (licence: NONE) · get_code("1697b291fe4ae919")
How it ran

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

apply_prompt_template_base Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/safetylock/eval_utils/prompt_utils.py
pointer only (licence: NONE) · get_code("7ca4081cb255ef3c")
How it ran

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

duo_judge Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/eval/eval_utils/openai_gpt4_judge.py
pointer only (licence: NONE) · get_code("13efefc593f14320")
How it ran

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

format_tokens Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/safetylock/eval_utils/chat_utils.py
pointer only (licence: NONE) · get_code("e084e801c0e634ec")
How it ran

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

get_gpt Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/eval/eval_utils/openai_gpt4_judge.py
pointer only (licence: NONE) · get_code("b1b67d750d9609cf")
How it ran

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

get_prompt_template Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/safetylock/eval_utils/prompt_utils.py
pointer only (licence: NONE) · get_code("9b5267811b5f346c")
How it ran

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

load_model Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/eval/eval_utils/model_utils.py
pointer only (licence: NONE) · get_code("efea256714a4cb99")
How it ran

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

sentiment_classify Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/eval/ppl_eval.py
pointer only (licence: NONE) · get_code("89e29b2710b5124a")
How it ran

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

toxicity_score Not yet run
unverified (harvested, no recorded run)
zhu-minjun/safetylock/eval/ppl_eval.py
pointer only (licence: NONE) · get_code("cbb603740b170a9d")
How it ran

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

Also present in other papers' code

Of 21 samples lifted from this paper's linked repositories, 21 carry a function identity and 0 do not. Of the 21 distinct functions with an identity, 12 are also present in other papers whose code we hold (12 with at least one paper dated earlier, 6 the same month, 7 later) and 9 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
rotate_half 360 other papers
184 dated earlier, 25 the same month, 142 later, 6 same year, order not determinable, 3 undated · 30 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 357 more not named here
repeat_kv 243 other papers
119 dated earlier, 24 the same month, 96 later, 2 same year, order not determinable, 2 undated · 22 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2305.17888 (2023-05)
LLM-QAT: Data-Free Quantization Aware Training for Large Language Models
and 240 more not named here
apply_rotary_pos_emb 94 other papers
27 dated earlier, 14 the same month, 49 later, 1 same year, order not determinable, 3 undated · 6 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2305.17888 (2023-05)
LLM-QAT: Data-Free Quantization Aware Training for Large Language Models
2309.11674 (2023-09)
A Paradigm Shift in Machine Translation: Boosting Translation Performance of Large Language Models
and 91 more not named here
load_peft_model 7 other papers
6 dated earlier, 1 later
2308.10855 (2023-08)
LatEval: An Interactive LLMs Evaluation Benchmark with Incomplete Information from Lateral Thinking Puzzles
2310.02469 (2023-10)
PrivacyMind: Large Language Models Can Be Contextual Privacy Protection Learners
2310.06498 (2023-10)
A New Benchmark and Reverse Validation Method for Passage-level Hallucination Detection
and 4 more not named here
load_llama_from_config 6 other papers
5 dated earlier, 1 later
2310.02469 (2023-10)
PrivacyMind: Large Language Models Can Be Contextual Privacy Protection Learners
2310.06498 (2023-10)
A New Benchmark and Reverse Validation Method for Passage-level Hallucination Detection
2310.08491 (2023-10)
Prometheus: Inducing Fine-grained Evaluation Capability in Language Models
and 3 more not named here
load_merge_table 3 other papers
2 dated earlier, 1 the same month
1910.13267 (2019-10)
BPE-Dropout: Simple and Effective Subword Regularization
2402.11753 (2024-02)
ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMs WARNING: This paper contains model outputs that may be considered offensive
2410.21492 (2024-10)
FATH: Authentication-based Test-time Defense against Indirect Prompt Injection Attacks
load_model 3 other papers
3 dated earlier
2308.10855 (2023-08)
LatEval: An Interactive LLMs Evaluation Benchmark with Incomplete Information from Lateral Thinking Puzzles
2310.02469 (2023-10)
PrivacyMind: Large Language Models Can Be Contextual Privacy Protection Learners
2404.01099 (2024-04)
What is in Your Safe Data? Identifying Benign Data that Breaks Safety
load_subword_nmt_table 3 other papers
2 dated earlier, 1 the same month
1910.13267 (2019-10)
BPE-Dropout: Simple and Effective Subword Regularization
2402.11753 (2024-02)
ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMs WARNING: This paper contains model outputs that may be considered offensive
2410.21492 (2024-10)
FATH: Authentication-based Test-time Defense against Indirect Prompt Injection Attacks
read_dialogs_from_file 3 other papers
1 dated earlier, 2 later
2404.01099 (2024-04)
What is in Your Safe Data? Identifying Benign Data that Breaks Safety
2025.findings-acl.337 (2025 (year only))
The Self-Improvement Paradox: Can Language Models Bootstrap Reasoning Capabilities without External Scaffolding?
2602.21646 (2026-02)
Scalable Multilingual Multimodal Machine Translation with Speech-Text Fusion
tokenize_word 3 other papers
2 dated earlier, 1 the same month
1910.13267 (2019-10)
BPE-Dropout: Simple and Effective Subword Regularization
2402.11753 (2024-02)
ArtPrompt: ASCII Art-based Jailbreak Attacks against Aligned LLMs WARNING: This paper contains model outputs that may be considered offensive
2410.21492 (2024-10)
FATH: Authentication-based Test-time Defense against Indirect Prompt Injection Attacks
format_tokens 2 other papers
1 dated earlier, 1 later
2404.01099 (2024-04)
What is in Your Safe Data? Identifying Benign Data that Breaks Safety
2602.21646 (2026-02)
Scalable Multilingual Multimodal Machine Translation with Speech-Text Fusion
toxicity_score 1 other paper
1 dated earlier
2305.12798 (2023-05)
Word Embeddings Are Steers for 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-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

Fine-tuning large language models (LLMs) on additional datasets is often necessary to optimize them for specific downstream tasks. However, existing safety alignment measures, which restrict harmful behavior during inference, are insufficient to mitigate safety risks during fine-tuning. Alarmingly, fine-tuning with just 10 toxic sentences can make models comply with harmful instructions. We introduce SafetyLock, a novel alignment intervention method that maintains robust safety post-fine-tuning through efficient and transferable mechanisms. SafetyLock leverages our discovery that fine-tuned models retain similar safety-related activation representations to their base models. This insight enables us to extract what we term the Meta-SafetyLock, a set of safety bias directions representing key activation patterns associated with safe responses in the original model. We can then apply these directions universally to fine-tuned models to enhance their safety. By searching for activation directions across multiple token dimensions, SafetyLock achieves enhanced robustness and transferability. SafetyLock re-aligns fine-tuned models in under 0.01 seconds without additional computational cost. Our experiments demonstrate that SafetyLock can reduce the harmful instruction response rate from 60% to below 1% in toxic fine-tuned models. It surpasses traditional methods in both performance and efficiency, offering a scalable, non-invasive solution for ensuring the safety of customized LLMs. Our analysis across various fine-tuning scenarios confirms SafetyLock's robustness, advocating its integration into safety protocols for aligned LLMs. The code is released at https://github.com/zhu-minjun/SafetyLock.

For agents

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

get_harvested_code_for_paper("2410.10343")
get_code_for_paper("2410.10343")
have("2410.10343")

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

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

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

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

Connect an agent — have() is free.