SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2501.06911 · NeurIPS · 2024

Risk-Averse Fine-tuning of Large Language Models

Dileep Kalathil, Srinivas Shakkottai, Sapana Chaudhary, Ujwal Dinesha

arXiv · PDF · Open in the Atlas

Code that ran

3 of 5 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; 2 failures of our instrument; 2 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/2501.06911.json · badge: /api/ran/2501.06911.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
sapanachaudhary/ra-rlhf canonical (classifier label)
classifier basis not recorded on the link
3 ran · 2 no recorded run
FunctionStatusWhere it lives
convert_to_scalar Ran
ran; our contract draft was wrong, not the code
sapanachaudhary/ra-rlhf/trl/core.py
code served (permissive licence) · get_code("8483cffb5dea03d2")
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

torch.manual_seed(0)

# The function converts stats from a flattened dict to scalar dicts
# It handles torch.Tensor and np.ndarray objects with 0 or 1 dimensions
# Test with various types of values

ARGS = {
    "stats": {
        "loss": torch.tensor(0.5),  # 0-d tensor
        "accuracy": torch.tensor([0.95]),  # 1-d tensor with shape (1,)
        "learning_rate": 0.001,  # scalar float
        "epoch": 10,  # scalar int
        "numpy_scalar": np.array(0.42),  # 0-d numpy array
        "numpy_1d": np.array([0.88]),  # 1-d numpy array with shape (1,)
        "string_stat": "checkpoint",  # string
    }
}
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
run_experiment Ran
ran on a synthesized input
sapanachaudhary/ra-rlhf/benchmark/benchmark.py
code served (permissive licence) · get_code("d6e962139d6c0dec")
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 shlex
import subprocess

def run_experiment(command: str):
    command_list = shlex.split(command)
    print(f'running {command}')
    fd = subprocess.Popen(command_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, errors = fd.communicate()
    return_code = fd.returncode
    assert return_code == 0, f"Command failed with error: {errors.decode('utf-8')}"
    return output.decode('utf-8').strip()


ARGS = {
    "command": "echo 'Hello World'"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 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
stack_dicts Ran
ran; our contract draft was wrong, not the code
sapanachaudhary/ra-rlhf/trl/core.py
code served (permissive licence) · get_code("7dc16cc69c54c94d")
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.nn.utils.rnn import pad_sequence

torch.manual_seed(0)

WANDB_PADDING = -1

# Create a list of dicts with tensor values
# The function iterates over stats_dicts[0] keys, so all dicts must have same keys
# It flattens each tensor value and pads them

stats_dicts = [
    {
        'loss': torch.randn(2, 3),
        'accuracy': torch.randn(4, 2),
        'reward': torch.randn(5)
    },
    {
        'loss': torch.randn(3, 2),
        'accuracy': torch.randn(2, 3),
        'reward': torch.randn(4)
    }
]

ARGS = {
    'stats_dicts': stats_dicts
}
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
flatten_dict Not yet run
unverified (harvested, no recorded run)
sapanachaudhary/ra-rlhf/trl/core.py
code served (permissive licence) · get_code("1782ce5551146615")
How it ran

no invocation recorded.

scheduler_step Not yet run
unverified (harvested, no recorded run)
sapanachaudhary/ra-rlhf/trl/models/modeling_sd_base.py
code served (permissive licence) · get_code("55a252ad77e7e399")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 1 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
scheduler_step 4 other papers
2 dated earlier, 2 later
2305.18290 (2023-05)
Direct Preference Optimization: Your Language Model is Secretly a Reward Model
2410.06101 (2024-10)
Coevolving with the Other You: Fine-Tuning LLM with Sequential Cooperative Multi-Agent Reinforcement Learning
2509.12521 (2025-09)
Phi: Preference Hijacking in Multi-modal Large Language Models at Inference Time
and 1 more not named here
convert_to_scalar 2 other papers
2 dated earlier
2402.11078 (2024-02)
Model Editing by Standard Fine-Tuning
2403.06754 (2024-03)
ALaRM: Align Language Models via Hierarchical Rewards Modeling
flatten_dict 2 other papers
2 dated earlier
2402.11078 (2024-02)
Model Editing by Standard Fine-Tuning
2403.06754 (2024-03)
ALaRM: Align Language Models via Hierarchical Rewards Modeling
stack_dicts 2 other papers
2 dated earlier
2402.11078 (2024-02)
Model Editing by Standard Fine-Tuning
2403.06754 (2024-03)
ALaRM: Align Language Models via Hierarchical Rewards Modeling

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

We consider the challenge of mitigating the generation of negative or toxic content by the Large Language Models (LLMs) in response to certain prompts. We propose integrating risk-averse principles into LLM fine-tuning to minimize the occurrence of harmful outputs, particularly rare but significant events. By optimizing the risk measure of Conditional Value at Risk (CVaR), our methodology trains LLMs to exhibit superior performance in avoiding toxic outputs while maintaining effectiveness in generative tasks. Empirical evaluations on sentiment modification and toxicity mitigation tasks demonstrate the efficacy of risk-averse reinforcement learning with human feedback (RLHF) in promoting a safer and more constructive online discourse environment. Trigger Warning: This paper contains prompts and model outputs that can be offensive in nature.

For agents

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

get_harvested_code_for_paper("2501.06911")
get_code_for_paper("2501.06911")
have("2501.06911")

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

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

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

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

Connect an agent — have() is free.