Papers › Navigating the Safety Landscape: Measuring Risks in Finetuning Large Language Models

Navigating the Safety Landscape: Measuring Risks in Finetuning Large Language Models

27 May 2024arXiv:2405.17374archive 2025-07-28

Shengyun Peng, Pin-Yu Chen, Matthew Hull, Duen Horng Chau

Safety alignment is crucial to ensure that large language models (LLMs) behave in ways that align with human preferences and prevent harmful actions during inference. However, recent studies show that the alignment can be easily compromised through finetuning with only a few adversarially designed training examples. We aim to measure the risks in finetuning LLMs through navigating the LLM safety landscape. We discover a new phenomenon observed universally in the model parameter space of popular open-source LLMs, termed as "safety basin": random perturbations to model weights maintain the safety level of the original aligned model within its local neighborhood. However, outside this local region, safety is fully compromised, exhibiting a sharp, step-like drop. This safety basin contrasts sharply with the LLM capability landscape, where model performance peaks at the origin and gradually declines as random perturbation increases. Our discovery inspires us to propose the new VISAGE safety metric that measures the safety in LLM finetuning by probing its safety landscape. Visualizing the safety landscape of the aligned model enables us to understand how finetuning compromises safety by dragging the model away from the safety basin. The LLM safety landscape also highlights the system prompt's critical role in protecting a model, and that such protection transfers to its perturbed variants within the safety basin. These observations from our safety landscape research provide new insights for future work on LLM safety community. Our code is publicly available at https://github.com/ShengYun-Peng/llm-landscape.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2405.17374")

Code

Syntology Ran 8 of 17 code samples harvested from 1 repository linked to this paper; 9 have no recorded run. Of those that ran: 3 ran · our draft was wrong; 5 ran with no contract checked.

By repository: official repository: 17 samples from 1 repository, 8 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

shengyun-peng/llm-landscape officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

17 samples harvested; 8 ran; 0 honoured the contract we drafted; 9 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

3ran · our draft was wrong
5ran
9unverified

Licence: 0 of the 17 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from shengyun-peng/llm-landscape. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

centralize_initial_weights shengyun-peng/llm-landscape/src/landscape/evaluation.py official repository ran · our draft was wrong MIT (permissive) · eb33beeb3f11b3ee · report
diff_model_weights ShengYun-Peng/llm-landscape/src/landscape/direction.py official repository ran MIT (permissive) · 28c404888ea94e2a · report
grid_coords ShengYun-Peng/llm-landscape/src/landscape/util.py official repository ran MIT (permissive) · 1c02db98c9759060 · report
load_dirs ShengYun-Peng/llm-landscape/src/landscape/util.py official repository ran MIT (permissive) · 6c7af99b251c7bfc · report
load_sharded_HF_checkpoints ShengYun-Peng/llm-landscape/src/util.py official repository ran fingerprinted MIT (permissive) · cd14061decec8285 · report
printer shengyun-peng/llm-landscape/src/landscape/evaluation.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · a23388c846164023 · report
shift_initial_weights shengyun-peng/llm-landscape/src/landscape/evaluation.py official repository ran · our draft was wrong MIT (permissive) · 1387961ee48a5a9d · report
view_tensor_as_vector ShengYun-Peng/llm-landscape/src/landscape/direction.py official repository ran fingerprinted MIT (permissive) · 931582edfb2f9326 · report
cosine_similarity ShengYun-Peng/llm-landscape/src/landscape/direction.py official repository unverified MIT (permissive) · 964769faed3202e9 · report
format_dialogs ShengYun-Peng/llm-landscape/src/llm/util.py official repository unverified MIT (permissive) · 72b7e4706e4ac3d5 · report
format_prompt ShengYun-Peng/llm-landscape/src/llm/util.py official repository unverified MIT (permissive) · c50b059fdffe4c7c · report
forward_1d_directions shengyun-peng/llm-landscape/src/landscape/evaluation.py official repository unverified MIT (permissive) · b6c1abe974fdf4ea · report
forward_llama ShengYun-Peng/llm-landscape/src/llm/inference.py official repository unverified MIT (permissive) · eb4bdfb25a6c2f1e · report
get_sys_prompt ShengYun-Peng/llm-landscape/src/llm/util.py official repository unverified MIT (permissive) · ef82dbd2a1608b77 · report
load_model ShengYun-Peng/llm-landscape/src/llm/inference.py official repository unverified MIT (permissive) · 054bb0c2b5d9de0c · report
load_tokenizer ShengYun-Peng/llm-landscape/src/llm/inference.py official repository unverified MIT (permissive) · 0308de63e8fa3250 · report
safety_region ShengYun-Peng/llm-landscape/src/landscape/util.py official repository unverified MIT (permissive) · 72e3e725ea2ff6db · report

Tasks

Safety Alignment

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

ALIGN

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections