SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.17374 · NeurIPS · 2024

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

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

arXiv · PDF · Open in the Atlas

Code that ran

8 of 17 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; 8 failures of our instrument; 9 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/2405.17374.json · badge: /api/ran/2405.17374.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
ShengYun-Peng/llm-landscape canonical (classifier label)
classifier basis: census
5 ran · 8 no recorded run
shengyun-peng/llm-landscape alias (classifier label)
classifier basis: classifier_2025
3 ran · 1 no recorded run
FunctionStatusWhere it lives
centralize_initial_weights Ran
ran; our contract draft was wrong, not the code
shengyun-peng/llm-landscape/src/landscape/evaluation.py
code served (permissive licence) · get_code("eb33beeb3f11b3ee")
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 dict. 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 typing import Dict

torch.manual_seed(0)

# Create small tensors for weights and directions
weights = {
    'layer1': torch.randn(4, 3),
    'layer2': torch.randn(2, 4),
}

dirs = {
    'layer1': torch.randn(4, 3),
    'layer2': torch.randn(2, 4),
}

steps = 2

ARGS = {
    'weights': weights,
    'dirs': dirs,
    'steps': steps,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
diff_model_weights Ran
ran; our contract draft was wrong, not the code
ShengYun-Peng/llm-landscape/src/landscape/direction.py
code served (permissive licence) · get_code("28c404888ea94e2a")
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 dict. 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

torch.manual_seed(0)

# Create two dictionaries of model weights
# The function expects two dicts with the same keys, where values support subtraction
weights1 = {
    'layer1.weight': torch.randn(4, 3),
    'layer1.bias': torch.randn(4),
    'layer2.weight': torch.randn(5, 4),
    'layer2.bias': torch.randn(5),
}

weights2 = {
    'layer1.weight': torch.randn(4, 3),
    'layer1.bias': torch.randn(4),
    'layer2.weight': torch.randn(5, 4),
    'layer2.bias': torch.randn(5),
}

ARGS = {
    'weights1': weights1,
    'weights2': weights2,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
grid_coords Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
ShengYun-Peng/llm-landscape/src/landscape/util.py
code served (permissive licence) · get_code("1c02db98c9759060")
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 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 numpy as np

ARGS = {
    "steps": 10,
    "ndim": 2,
    "vis_type": "2D_random",
    "multiplier": [2.0],
    "additional_steps_for_interpolation": 0,
}
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 tuple, ndim 2, 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
load_dirs Ran
ran; our contract draft was wrong, not the code
ShengYun-Peng/llm-landscape/src/landscape/util.py
code served (permissive licence) · get_code("6c7af99b251c7bfc")
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. 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 pathlib import Path
import tempfile
import os

torch.manual_seed(0)

# Create a temporary directory with some .pt files
temp_dir = tempfile.mkdtemp()

# Create and save some sample direction tensors
directions_1 = torch.randn(4, 3)
directions_2 = torch.randn(5, 2)
directions_3 = torch.randn(3, 4)

torch.save(directions_1, os.path.join(temp_dir, 'directions_1.pt'))
torch.save(directions_2, os.path.join(temp_dir, 'directions_2.pt'))
torch.save(directions_3, os.path.join(temp_dir, 'directions_3.pt'))

ARGS = {
    'path_to_dirs': temp_dir
}
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 — a list output has no array shape of its own; none is 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_sharded_HF_checkpoints Ran
ran; our contract draft was wrong, not the code
ShengYun-Peng/llm-landscape/src/util.py
code served (permissive licence) · get_code("cd14061decec8285")
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
from pathlib import Path

# Create a temporary directory to simulate a model directory
temp_dir = tempfile.mkdtemp()

# Create some fake pytorch checkpoint files
pytorch_files = [
    os.path.join(temp_dir, 'pytorch_model.bin'),
    os.path.join(temp_dir, 'pytorch_model-00001-of-00002.bin'),
    os.path.join(temp_dir, 'pytorch_model-00002-of-00002.bin'),
]

# Create empty files to simulate actual checkpoint files
for filepath in pytorch_files:
    Path(filepath).touch()

ARGS = {
    'model_dir': temp_dir
}
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
printer Ran
ran; our contract draft was wrong, not the code
shengyun-peng/llm-landscape/src/landscape/evaluation.py
code served (permissive licence) · get_code("a23388c846164023")
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)

ARGS = {
    'device_id': 0,
    'output': 'Hello World'
}
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
shift_initial_weights Ran
ran; our contract draft was wrong, not the code
shengyun-peng/llm-landscape/src/landscape/evaluation.py
code served (permissive licence) · get_code("1387961ee48a5a9d")
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 dict. 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 torch import nn, Tensor
from typing import Dict

torch.manual_seed(0)

# Create sample weights dictionary with distinct tensor shapes
weights = {
    "layer1.weight": torch.randn(4, 3),
    "layer1.bias": torch.randn(5),
    "layer2.weight": torch.randn(2, 6),
}

# Create sample directions dictionary with same keys and compatible shapes
dirs = {
    "layer1.weight": torch.randn(4, 3),
    "layer1.bias": torch.randn(5),
    "layer2.weight": torch.randn(2, 6),
}

# Create a scalar step value
steps = 0.1

ARGS = {
    "weights": weights,
    "dirs": dirs,
    "steps": steps,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
view_tensor_as_vector Ran
ran; our contract draft was wrong, not the code
ShengYun-Peng/llm-landscape/src/landscape/direction.py
code served (permissive licence) · get_code("931582edfb2f9326")
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 float, shape (24,) 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
from torch import nn, Tensor

torch.manual_seed(0)

# Create a small tensor with distinct dimensions for testing
t = torch.randn(2, 3, 4)

ARGS = {
    "t": t
}
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 float, shape (24,) — shape (24,) 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
cosine_similarity Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/landscape/direction.py
code served (permissive licence) · get_code("964769faed3202e9")
How it ran

no invocation recorded.

format_dialogs Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/llm/util.py
code served (permissive licence) · get_code("72b7e4706e4ac3d5")
How it ran

no invocation recorded.

format_prompt Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/llm/util.py
code served (permissive licence) · get_code("c50b059fdffe4c7c")
How it ran

no invocation recorded.

forward_1d_directions Not yet run
unverified (harvested, no recorded run)
shengyun-peng/llm-landscape/src/landscape/evaluation.py
code served (permissive licence) · get_code("b6c1abe974fdf4ea")
How it ran

no invocation recorded.

forward_llama Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/llm/inference.py
code served (permissive licence) · get_code("eb4bdfb25a6c2f1e")
How it ran

no invocation recorded.

get_sys_prompt Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/llm/util.py
code served (permissive licence) · get_code("ef82dbd2a1608b77")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/llm/inference.py
code served (permissive licence) · get_code("054bb0c2b5d9de0c")
How it ran

no invocation recorded.

load_tokenizer Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/llm/inference.py
code served (permissive licence) · get_code("0308de63e8fa3250")
How it ran

no invocation recorded.

safety_region Not yet run
unverified (harvested, no recorded run)
ShengYun-Peng/llm-landscape/src/landscape/util.py
code served (permissive licence) · get_code("72e3e725ea2ff6db")
How it ran

no invocation recorded.

Also present in other papers' code

Of 17 samples lifted from this paper's linked repositories, 17 carry a function identity and 0 do not. Of the 17 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 17 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.

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 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.

For agents

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

get_harvested_code_for_paper("2405.17374")
get_code_for_paper("2405.17374")
have("2405.17374")

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

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

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

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

Connect an agent — have() is free.