SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.06754 · 2024

ALaRM: Align Language Models via Hierarchical Rewards Modeling

arXiv · PDF · Open in the Atlas

Code that ran

7 of 14 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; 7 failures of our instrument; 7 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/2403.06754.json · badge: /api/ran/2403.06754.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
halfrot/ALaRM canonical (classifier label)
classifier basis: census
7 ran · 7 no recorded run
FunctionStatusWhere it lives
api_endpoint_from_url Ran
ran; our contract draft was wrong, not the code
halfrot/ALaRM/eval/api_request_parallel_processor.py
code served (permissive licence) · get_code("4d9eaca9e25c5a7a")
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 re

def api_endpoint_from_url(request_url):
    """Extract the API endpoint from the request URL."""
    match = re.search('^https://[^/]+/v\\d+/(.+)$', request_url)
    if match is None:
        match = re.search('^https://[^/]+/openai/deployments/[^/]+/(.+?)(\\?|$)', request_url)
    return match[1]

# Test case 1: Standard API endpoint format
request_url_1 = "https://api.example.com/v1/chat/completions"

# Test case 2: Azure OpenAI deployment format
request_url_2 = "https://my-resource.openai.azure.com/openai/deployments/my-deployment/chat/completions?api-version=2023-05-15"

ARGS = {
    "request_url": request_url_1
}
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
convert_to_scalar Ran
ran; our contract draft was wrong, not the code
halfrot/ALaRM/trl/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
create_position_ids_from_input_ids Ran
ran; our contract draft was wrong, not the code
halfrot/ALaRM/long-form-QA/my_longformer.py
code served (permissive licence) · get_code("ce0ed06559b93e81")
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 2, dtype family int, shape (2, 4) 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 input_ids tensor: shape (batch_size=2, seq_length=4)
# Use token IDs where 0 is the padding token
input_ids = torch.tensor([
    [0, 5, 6, 7],
    [0, 8, 0, 9]
], dtype=torch.long)

# padding_idx indicates which token ID represents padding
padding_idx = 0

ARGS = {
    "input_ids": input_ids,
    "padding_idx": padding_idx,
}
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 2, dtype family int, shape (2, 4) — shape (2, 4) 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
extract_between_tags Ran
ran; our contract draft was wrong, not the code
halfrot/ALaRM/eval/utils.py
code served (permissive licence) · get_code("0b7a8a7264a0accb")
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 re

def extract_between_tags(text, start_tag='<|im_start|>', end_tag='\n<|im_end|>'):
    pattern = re.compile(f'{re.escape(start_tag)}(.*?){re.escape(end_tag)}', re.DOTALL)
    return pattern.findall(text)

# Construct valid arguments
text = "prefix <|im_start|>content1\n<|im_end|> middle <|im_start|>content2\n<|im_end|> suffix"
start_tag = '<|im_start|>'
end_tag = '\n<|im_end|>'

ARGS = {
    'text': text,
    'start_tag': start_tag,
    'end_tag': end_tag
}
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 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
make_conversation Ran
ran; our contract draft was wrong, not the code
halfrot/ALaRM/eval/utils.py
code served (permissive licence) · get_code("0095bac7d232b398")
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 re
import tempfile
import os

def extract_between_tags(text, start_tag='<|im_start|>', end_tag='\n<|im_end|>'):
    pattern = re.compile(f'{re.escape(start_tag)}(.*?){re.escape(end_tag)}', re.DOTALL)
    return pattern.findall(text)

def make_conversation(query, output_1, output_2, prompt_template):
    with open(prompt_template, 'r', encoding='UTF-8') as f:
        file_content = f.read()
        system_prompt = extract_between_tags(file_content, start_tag='<|im_start|>system\n')[0]
        user_prompt = extract_between_tags(file_content, start_tag='<|im_start|>user\n')[0].replace('{instruction}', query).replace('{output_1}', f'{output_1}').replace('{output_2}', f'{output_2}')
    conversation = [{'role': 'system', 'content': system_prompt}, {'role': 'user', 'content': user_prompt}]
    return conversation

# Create a temporary prompt template file
prompt_content = """<|im_start|>system
You are a helpful assistant.
<|im_end|>
<|im_start|>user
Please compare the following outputs:
Instruction: {instruction}
Output 1: {output_1}
Output 2: {output_2}
<|im_end|>"""

# Write to a temporary file
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt', encoding='UTF-8')
temp_file.write(prompt_content)
temp_file.close()

ARGS = {
    'query': 'What is the capital of France?',
    'output_1': 'Paris is the capital of France.',
    'output_2': 'The capital of France is Paris.',
    'prompt_template': temp_file.name
}
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 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
stack_dicts Ran
ran; our contract draft was wrong, not the code
halfrot/ALaRM/trl/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
tril_bfloat16 Ran
ran; our contract draft was wrong, not the code
halfrot/ALaRM/long-form-QA/my_longformer.py
code served (permissive licence) · get_code("d37f5dbfe7b33d1e")
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. 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)

# Create a small bfloat16 tensor for testing
# Using distinct dimensions: 2x4 to make shapes unambiguous
input_tensor = torch.randn(2, 4, dtype=torch.bfloat16)

# Define arguments
ARGS = {
    "input_tensor": input_tensor,
    "diagonal": 0
}
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, shape (2, 4) — shape (2, 4) as a later run recorded it
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
extract_elements Not yet run
unverified (harvested, no recorded run)
halfrot/ALaRM/eval/eval_compare.py
code served (permissive licence) · get_code("f1f4f80a9d8b05bd")
How it ran

no invocation recorded.

flatten_dict Not yet run
unverified (harvested, no recorded run)
halfrot/ALaRM/trl/trl/core.py
code served (permissive licence) · get_code("1782ce5551146615")
How it ran

no invocation recorded.

inference Not yet run
unverified (harvested, no recorded run)
halfrot/ALaRM/MT/eval_sft.py
code served (permissive licence) · get_code("cf012dc64e397403")
How it ran

no invocation recorded.

num_tokens_consumed_from_request Not yet run
unverified (harvested, no recorded run)
halfrot/ALaRM/eval/api_request_parallel_processor.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from Leirunlin/Text-level-Graph-Attack, is pointer only (licence: NONE) · get_code("27007d0ec4adb00b")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from Leirunlin/Text-level-Graph-Attack, 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. No invocation recorded.

reward_shape Not yet run
unverified (harvested, no recorded run)
halfrot/ALaRM/MT/train_ppo.py
code served (permissive licence) · get_code("4d5ecb11d933a1d3")
How it ran

no invocation recorded.

split_text_to_sentences Not yet run
unverified (harvested, no recorded run)
halfrot/ALaRM/long-form-QA/reward_utils.py
code served (permissive licence) · get_code("e7f95d91543ac720")
How it ran

no invocation recorded.

split_text_to_subsentences Not yet run
unverified (harvested, no recorded run)
halfrot/ALaRM/long-form-QA/reward_utils.py
code served (permissive licence) · get_code("11589c4018cfc261")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 9 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 0 the same month, 9 later) and 5 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
create_position_ids_from_input_ids 8 other papers
6 dated earlier, 2 later
2021.emnlp-main.154 (2021 (year only))
Reconstruction Attack on Instance Encoding for Language Understanding
2104.08247 (2021-04)
What to Pre-Train on? Efficient Intermediate Task Selection
2201.03514 (2022-01)
Black-Box Tuning for Language-Model-as-a-Service
and 5 more not named here
num_tokens_consumed_from_request 4 other papers
2 dated earlier, 2 later
2309.07430 (2023-09)
Adapted Large Language Models Can Outperform Medical Experts in Clinical Text Summarization
2309.16595 (2023-09)
Can LLMs Effectively Leverage Graph Structural Information through Prompts, and Why?
2405.16405 (2024-05)
Intruding with Words: Towards Understanding Graph Injection Attacks at the Text Level
and 1 more not named here
api_endpoint_from_url 2 other papers
1 dated earlier, 1 later
2402.14007 (2024-02)
Can Watermarks Survive Translation? On the Cross-lingual Consistency of Text Watermark for Large Language Models
2025.findings-acl.605 (2025 (year only))
LEMMA: Learning from Errors for MatheMatical Advancement in LLMs
convert_to_scalar 2 other papers
1 dated earlier, 1 later
2402.11078 (2024-02)
Model Editing by Standard Fine-Tuning
2501.06911 (2025-01)
Risk-Averse Fine-tuning of Large Language Models
flatten_dict 2 other papers
1 dated earlier, 1 later
2402.11078 (2024-02)
Model Editing by Standard Fine-Tuning
2501.06911 (2025-01)
Risk-Averse Fine-tuning of Large Language Models
split_text_to_sentences 2 other papers
1 dated earlier, 1 later
2402.04315 (2024-02)
Training Language Models to Generate Text with Citations via Fine-grained Rewards
2410.06554 (2024-10)
The Accuracy Paradox in RLHF: When Better Reward Models Don't Yield Better Language Models
split_text_to_subsentences 2 other papers
1 dated earlier, 1 later
2402.04315 (2024-02)
Training Language Models to Generate Text with Citations via Fine-grained Rewards
2410.06554 (2024-10)
The Accuracy Paradox in RLHF: When Better Reward Models Don't Yield Better Language Models
stack_dicts 2 other papers
1 dated earlier, 1 later
2402.11078 (2024-02)
Model Editing by Standard Fine-Tuning
2501.06911 (2025-01)
Risk-Averse Fine-tuning of Large Language Models
tril_bfloat16 1 other paper
1 later
2410.06554 (2024-10)
The Accuracy Paradox in RLHF: When Better Reward Models Don't Yield Better 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-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 introduce ALaRM, the first framework modeling hierarchical rewards in reinforcement learning from human feedback (RLHF), which is designed to enhance the alignment of large language models (LLMs) with human preferences. The framework addresses the limitations of current alignment approaches, which often struggle with the inconsistency and sparsity of human supervision signals, by integrating holistic rewards with aspect-specific rewards. This integration enables more precise and consistent guidance of language models towards desired outcomes, particularly in complex and open text generation tasks. By employing a methodology that filters and combines multiple rewards based on their consistency, the framework provides a reliable mechanism for improving model alignment. We validate our approach through applications in long-form question answering and machine translation tasks, employing gpt-3.5-turbo for pairwise comparisons, and demonstrate improvements over existing baselines. Our work underscores the effectiveness of hierarchical rewards modeling in refining LLM training processes for better human preference alignment. We release our code at https://ALaRM-fdu.github.io.

For agents

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

get_harvested_code_for_paper("2403.06754")
get_code_for_paper("2403.06754")
have("2403.06754")

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

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

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

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

Connect an agent — have() is free.