SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.15404 · 2025

How Should We Enhance the Safety of Large Reasoning Models: An Empirical Study

arXiv · PDF · Open in the Atlas

Code that ran

11 of 11 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; 1 honoured the contract we drafted, 4 violated it and 1 has no contract verdict; 5 failures of our instrument; 0 no recorded run), measured 2026-11-24; 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/2505.15404.json · badge: /api/ran/2505.15404.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
thu-coai/lrm-safety-study canonical (classifier label)
classifier basis not recorded on the link
11 ran · 0 no recorded run
FunctionStatusWhere it lives
check_sympy_equivalence Ran
ran, violated the contract we drafted
thu-coai/lrm-safety-study/reasoning_evaluation/utils/math_normalization.py
pointer only (licence: MIT); the stored copy get_code serves, from gair-nlp/weak-to-strong-reasoning, is pointer only (licence: NONE) · get_code("33973ae45a70d4fe")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from gair-nlp/weak-to-strong-reasoning, and GitHub detected no licence in that repository 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.

choice_answer_clean Ran
ran; our contract draft was wrong, not the code
thu-coai/lrm-safety-study/reasoning_evaluation/utils/grader.py
pointer only (licence: MIT); the stored copy get_code serves, from QwenLM/Qwen2.5-Math, is pointer only (licence: NONE) · get_code("809c0178a7ae90ff")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from QwenLM/Qwen2.5-Math, and GitHub detected no licence in that repository 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.

flatten_dict Ran
ran; our contract draft was wrong, not the code
thu-coai/lrm-safety-study/trl/trl/core.py
code served (permissive licence) · get_code("dfd0ecd9cb25af69")
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 numpy as np
from collections.abc import Mapping

torch.manual_seed(0)

# Create a nested dictionary with various data types
nested_dict = {
    'model': {
        'layers': {
            'layer1': 0.5,
            'layer2': 0.3
        },
        'name': 'test_model'
    },
    'training': {
        'epochs': 100,
        'batch_size': 32
    },
    'data': 42
}

# The function takes:
# 1. nested: dict - a nested dictionary to flatten
# 2. sep: str - separator to use when concatenating keys (default '/')

ARGS = {
    'nested': nested_dict,
    'sep': '/'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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
get_system Ran
ran on a synthesized input
thu-coai/lrm-safety-study/dataset/template.py
code served (permissive licence) · get_code("db61e0265be4a789")
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 = {
    't': 'short'
}
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
is_digit Ran
ran, violated the contract we drafted
thu-coai/lrm-safety-study/reasoning_evaluation/utils/grader.py
pointer only (licence: MIT); the stored copy get_code serves, from QwenLM/Qwen2.5-Math, is pointer only (licence: NONE) · get_code("fb37d3c84b18e368")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from QwenLM/Qwen2.5-Math, and GitHub detected no licence in that repository 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.

is_integer Ran
ran, violated the contract we drafted
thu-coai/lrm-safety-study/reasoning_evaluation/utils/math_normalization.py
pointer only (licence: MIT); the stored copy get_code serves, from gair-nlp/weak-to-strong-reasoning, is pointer only (licence: NONE) · get_code("b804c6d0a0ddb922")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from gair-nlp/weak-to-strong-reasoning, and GitHub detected no licence in that repository 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.

masked_mean Ran
ran; our contract draft was wrong, not the code
thu-coai/lrm-safety-study/trl/trl/core.py
code served (permissive licence) · get_code("4f7075aac2163cbc")
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 0, dtype family float, shape () 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 numpy as np

torch.manual_seed(0)

# Create small tensors for testing masked_mean
# values: tensor of shape (2, 4) with float values
values = torch.randn(2, 4)

# mask: binary tensor of same shape as values, with 0s and 1s
mask = torch.randint(0, 2, (2, 4)).float()

# axis: can be None or an integer axis
axis = None

ARGS = {
    "values": values,
    "mask": mask,
    "axis": axis,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () 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
masked_var Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
thu-coai/lrm-safety-study/trl/trl/core.py
code served (permissive licence) · get_code("67607956afbb2a83")
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 0, dtype family float, shape () 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

torch.manual_seed(0)

# Create small test tensors
# values: the tensor to compute variance over
# mask: binary mask to select which values to include
values = torch.randn(2, 4)  # shape (2, 4)
mask = torch.ones(2, 4)     # shape (2, 4), all ones means all values are included

ARGS = {
    "values": values,
    "mask": mask,
    "unbiased": True,
}
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 0, dtype family float, shape () — shape () 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
normalize_final_answer Ran
ran; our contract draft was wrong, not the code
thu-coai/lrm-safety-study/reasoning_evaluation/utils/math_normalization.py
pointer only (licence: MIT); the stored copy get_code serves, from gair-nlp/weak-to-strong-reasoning, is pointer only (licence: NONE) · get_code("31ee6b861ee71ef7")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from gair-nlp/weak-to-strong-reasoning, and GitHub detected no licence in that repository 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.

parse_digits Ran
ran, honoured the contract we drafted
thu-coai/lrm-safety-study/reasoning_evaluation/utils/grader.py
pointer only (licence: MIT); the stored copy get_code serves, from QwenLM/Qwen2.5-Math, is pointer only (licence: NONE) · get_code("7d4b7f8c3875b126")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from QwenLM/Qwen2.5-Math, and GitHub detected no licence in that repository 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.

str2bool Ran
ran, violated the contract we drafted
thu-coai/lrm-safety-study/attack_refusal_evaluation/run_gen_eval.py
code served (permissive licence) · get_code("7c508037b40522af")
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) and returned bool, ndim 0, dtype family float, shape () 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 argparse

def str2bool(v):
    if isinstance(v, bool):
        return v
    if v.lower() in ('yes', 'true', 't', 'y', '1'):
        return True
    elif v.lower() in ('no', 'false', 'f', 'n', '0'):
        return False
    else:
        raise argparse.ArgumentTypeError('Boolean value expected.')

# Test cases for str2bool
ARGS = {
    'v': 'true'  # string input that should convert to boolean
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () 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

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 10 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 7 the same month, 10 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
str2bool 175 other papers
156 dated earlier, 1 the same month, 16 later, 2 same year, order not determinable · 2 only as an assembly brick
1406.6247 (2014-06)
Recurrent Models of Visual Attention
1603.09382 (2016-03)
Deep Networks with Stochastic Depth
1710.10196 (2017-10)
Progressive Growing of GANs for Improved Quality, Stability, and Variation
and 172 more not named here
is_digit 18 other papers
8 dated earlier, 2 the same month, 7 later, 1 undated
2405.14365 (2024-05)
JiuZhang3.0: Efficiently Improving Mathematical Reasoning by Training Small Data Synthesis Models
2410.07985 (2024-10)
Omni-MATH: A Universal Olympiad Level Mathematic Benchmark For Large Language Models
2502.06703 (2025-02)
Can 1B LLM Surpass 405B LLM? Rethinking Compute-Optimal Test-Time Scaling
and 15 more not named here
parse_digits 18 other papers
8 dated earlier, 2 the same month, 7 later, 1 undated
2405.14365 (2024-05)
JiuZhang3.0: Efficiently Improving Mathematical Reasoning by Training Small Data Synthesis Models
2410.07985 (2024-10)
Omni-MATH: A Universal Olympiad Level Mathematic Benchmark For Large Language Models
2502.06703 (2025-02)
Can 1B LLM Surpass 405B LLM? Rethinking Compute-Optimal Test-Time Scaling
and 15 more not named here
choice_answer_clean 15 other papers
7 dated earlier, 2 the same month, 5 later, 1 undated
2410.07985 (2024-10)
Omni-MATH: A Universal Olympiad Level Mathematic Benchmark For Large Language Models
2502.06703 (2025-02)
Can 1B LLM Surpass 405B LLM? Rethinking Compute-Optimal Test-Time Scaling
2502.06773 (2025-02)
On the Emergence of Thinking in LLMs I: Searching for the Right Intuition
and 12 more not named here
flatten_dict 6 other papers
1 dated earlier, 2 the same month, 3 later
2504.20157 (2025-04)
Toward Evaluative Thinking: Meta Policy Optimization with Evolving Reward Models
2505.09655 (2025-05)
DRA-GRPO: Your GRPO Needs to Know Diverse Reasoning Paths for Mathematical Reasoning
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
and 3 more not named here
masked_mean 6 other papers
1 dated earlier, 2 the same month, 3 later
2504.20157 (2025-04)
Toward Evaluative Thinking: Meta Policy Optimization with Evolving Reward Models
2505.09655 (2025-05)
DRA-GRPO: Your GRPO Needs to Know Diverse Reasoning Paths for Mathematical Reasoning
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
and 3 more not named here
masked_var 6 other papers
1 dated earlier, 2 the same month, 3 later
2504.20157 (2025-04)
Toward Evaluative Thinking: Meta Policy Optimization with Evolving Reward Models
2505.09655 (2025-05)
DRA-GRPO: Your GRPO Needs to Know Diverse Reasoning Paths for Mathematical Reasoning
2505.15656 (2025-05)
Be Careful When Fine-tuning On Open-Source LLMs: Your Fine-tuning Data Could Be Secretly Stolen!
and 3 more not named here
check_sympy_equivalence 2 other papers
1 dated earlier, 1 later
2407.13647 (2024-07)
Weak-to-Strong Reasoning
2506.12860 (2025-06)
QFFT, Question-Free Fine-Tuning for Adaptive Reasoning
is_integer 2 other papers
1 dated earlier, 1 later
2407.13647 (2024-07)
Weak-to-Strong Reasoning
2506.12860 (2025-06)
QFFT, Question-Free Fine-Tuning for Adaptive Reasoning
normalize_final_answer 2 other papers
1 dated earlier, 1 later
2407.13647 (2024-07)
Weak-to-Strong Reasoning
2506.12860 (2025-06)
QFFT, Question-Free Fine-Tuning for Adaptive Reasoning

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

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 Reasoning Models (LRMs) have achieved remarkable success on reasoning-intensive tasks such as mathematics and programming. However, their enhanced reasoning capabilities do not necessarily translate to improved safety performance-and in some cases, may even degrade it. This raises an important research question: how should we enhance the safety of LRMs? In this paper, we present a comprehensive empirical study on how to enhance the safety of LRMs through Supervised Fine-Tuning (SFT). Our investigation begins with an unexpected observation: directly distilling safe responses from DeepSeek-R1 fails to significantly enhance safety. We analyze this phenomenon and identify five key risky patterns that contribute to it. We then demonstrate that explicitly addressing these issues during the data distillation process can lead to substantial safety improvements. Next, we explore whether a long and complex reasoning process is necessary for achieving safety. Interestingly, we find that simply using short or template-based reasoning process can attain comparable safety performance. These findings prompt a deeper reflection on the role of reasoning in ensuring safety. Finally, we conduct a comprehensive ablation study to reveal the impact of different training configurations. Overall, we hope our empirical study could provide a more holistic picture on enhancing the safety of LRMs. The code and data used in our experiments are released in https://github.com/thu-coai/LRM-Safety-Study.

For agents

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

get_harvested_code_for_paper("2505.15404")
get_code_for_paper("2505.15404")
have("2505.15404")

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

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

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

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

Connect an agent — have() is free.