SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2025.findings-emnlp.228 · EMNLP Findings · 2025

FG-PRM: Fine-grained Hallucination Detection and Mitigation in Language Model Mathematical Reasoning

Xinya Du, Ruosen Li, Ziming Luo

Open in the Atlas

Code that ran

7 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 4 no recorded run), measured 2026-11-24; 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/2025.findings-emnlp.228.json · badge: /api/ran/2025.findings-emnlp.228.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
du-nlp-lab/FG-PRM canonical (classifier label)
classifier basis: census
7 ran · 4 no recorded run
FunctionStatusWhere it lives
calculate_f1_scores Ran
ran, honoured the contract we drafted
du-nlp-lab/FG-PRM/src/analysis/distribution_analysis_gpt_retrieve.py
code served (permissive licence) · get_code("c1e4f526ca410daf")
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 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 numpy as np
from statistics import fmean
from sklearn.metrics import f1_score, precision_recall_fscore_support

torch.manual_seed(0)

# Construct data and results for the function
data = [
    {
        'cot': ['step1', 'step2', 'step3'],
        'inject_step': 2
    },
    {
        'cot': ['step1', 'step2'],
        'inject_step': 1
    }
]

results = [
    {
        'flags': [0, 1, 0]
    },
    {
        'flags': [1, 0]
    }
]

ARGS = {
    'data': data,
    'results': results
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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
calculate_f1_scores Ran
ran, honoured the contract we drafted
du-nlp-lab/FG-PRM/src/analysis/evaluate_reasoning_steps.py
code served (permissive licence) · get_code("f9029fbd18a44781")
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 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.

from statistics import fmean
from sklearn.metrics import f1_score, precision_recall_fscore_support

# Construct valid arguments for calculate_f1_scores
data = [
    {
        'cot': [1, 2, 3, 4],
        'inject_step': 2
    },
    {
        'cot': [1, 2, 3],
        'inject_step': 1
    },
    {
        'cot': [1, 2, 3, 4, 5],
        'inject_step': 3
    }
]

results = [
    {
        'flags': [0, 1, 0, 0]
    },
    {
        'flags': [1, 0, 0]
    },
    {
        'flags': [0, 0, 1, 0, 0]
    }
]

ARGS = {
    'data': data,
    'results': results
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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
calculate_hallucination_score Ran
ran, honoured the contract we drafted
du-nlp-lab/FG-PRM/src/analysis/evaluate_llm_reasoning_steps.py
code served (permissive licence) · get_code("2de1e120b3ecfd3f")
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 float, 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)

results = [
    {'flags': [True, False, True, True]},
    {'flags': [False, True, False]},
    {'flags': [True, True]}
]

ARGS = {
    'results': results
}
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 float, 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
convert Ran
ran; our contract draft was wrong, not the code
du-nlp-lab/FG-PRM/src/analysis/human_eval.py
code served (permissive licence) · get_code("559dcd696b3548d8")
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 pandas as pd
import numpy as np

hallucinations = ['Context Inconsistency', 'Logical Inconsistency', 'Instruction Inconsistency', 'Logical Error', 'Factual Inconsistency', 'Fabrication']

# Create a sample line (pandas Series) with the required structure
line_data = {
    'problem': 'Solve for x: 2x + 3 = 7',
    'Context Inconsistency': 'The context does not match the problem.',
    'Context Inconsistency-Wrong step': 2,
    'Logical Inconsistency': 'The logical flow is broken.',
    'Logical Inconsistency-Wrong step': 1,
    'Instruction Inconsistency': np.nan,
    'Instruction Inconsistency-Wrong step': np.nan,
    'Logical Error': 'There is a mathematical error.',
    'Logical Error-Wrong step': 3,
    'Factual Inconsistency': np.nan,
    'Factual Inconsistency-Wrong step': np.nan,
    'Fabrication': 'This step was made up.',
    'Fabrication-Wrong step': 4,
}

line = pd.Series(line_data)

ARGS = {
    'line': line
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — 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
extract_results Ran
ran; our contract draft was wrong, not the code
du-nlp-lab/FG-PRM/src/analysis/distribution_analysis_gpt_retrieve.py
code served (permissive licence) · get_code("dacff19def037842")
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_results(prompts, responses):
    data = []
    for prompt, response in zip(prompts, responses):
        new_data = {'prompt': prompt, 'response': response}
        match = re.search('(?s:.*)step 1:', response, re.I)
        if match is not None:
            span = match.span()
            response = response[span[-1] - 7:].strip()
        response = [r.strip() for r in response.split('\n') if '' != r]
        flags = []
        for step in response:
            match = re.search('Step (\\d): (Yes|No)', step)
            if match is not None:
                idx = int(match.group(1))
                content = match.group(2)
                flag = 1 if 'Yes' == content else 0
                if len(flags) >= idx:
                    flags[idx - 1] = flag
                else:
                    flags.append(flag)
        new_data['flags'] = flags
        data.append(new_data)
    return data


# Setup code to construct valid arguments
prompts = [
    "Is this correct?",
    "Check the logic"
]

responses = [
    "Here is my analysis:\nStep 1: Yes\nStep 2: No\nStep 3: Yes",
    "Let me think step by step.\nStep 1: No\nStep 2: Yes"
]

ARGS = {
    'prompts': prompts,
    'responses': responses
}
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
extract_results Ran
ran; our contract draft was wrong, not the code
du-nlp-lab/FG-PRM/src/analysis/evaluate_llm_reasoning_steps.py
code served (permissive licence) · get_code("a71cca8765e9aca0")
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 numpy as np
from tqdm import tqdm

torch.manual_seed(0)

# Construct valid arguments for extract_results
prompts = [
    "What is the answer?",
    "Is this correct?"
]

responses = [
    """Step 1: Yes
Step 1: Let me think about this carefully.
Step 2: Yes
Step 3: No""",
    """Here is my analysis:
Step 1: No
Step 2: Yes
Step 3: Yes
Step 4: No"""
]

ARGS = {
    'prompts': prompts,
    'responses': responses
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — 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
extract_results Ran
ran; our contract draft was wrong, not the code
du-nlp-lab/FG-PRM/src/analysis/evaluate_reasoning_steps.py
code served (permissive licence) · get_code("1b30b69f74d513c6")
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 numpy as np
import re

torch.manual_seed(0)

# Construct valid arguments for extract_results function
# The function expects:
# - prompts: list of strings
# - responses: list of strings containing step-by-step Yes/No answers

prompts = [
    "Is this a valid question?",
    "Can we proceed with this?"
]

responses = [
    "Step 1: Yes\nStep 2: No\nStep 3: Yes",
    "step 1: yes\nStep 2: No"
]

ARGS = {
    "prompts": prompts,
    "responses": responses
}
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 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
answer_questions Not yet run
unverified (harvested, no recorded run)
du-nlp-lab/FG-PRM/src/analysis/evaluate_llm_reasoning_steps.py
code served (permissive licence) · get_code("4677c3ab04313c82")
How it ran

no invocation recorded.

find_hallucination_in_steps Not yet run
unverified (harvested, no recorded run)
du-nlp-lab/FG-PRM/src/analysis/distribution_analysis.py
code served (permissive licence) · get_code("8fadc85fd96f515f")
How it ran

no invocation recorded.

get_rouge_scores Not yet run
unverified (harvested, no recorded run)
du-nlp-lab/FG-PRM/src/fgrlhf/evaluators.py
code served (permissive licence) · get_code("b3257abd722edb60")
How it ran

no invocation recorded.

postprocess_text Not yet run
unverified (harvested, no recorded run)
du-nlp-lab/FG-PRM/src/fgrlhf/evaluators.py
code served (permissive licence) · get_code("94a55f838c975848")
How it ran

no invocation recorded.

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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 9 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
postprocess_text 2 other papers
2 dated earlier
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
get_rouge_scores 1 other paper
1 dated earlier
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-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

Hallucinations in large language models (LLMs) pose significant challenges in tasks requiring complex multi-step reasoning, such as mathematical problem-solving. Existing approaches primarily detect the presence of hallucinations but lack a nuanced understanding of their types and manifestations. In this paper, we first introduce a comprehensive taxonomy that categorizes the common hallucinations in mathematical reasoning tasks into six types. We then propose FG-PRM (Fine-Grained Process Reward Model), an augmented model designed to detect and mitigate hallucinations in a finegrained, step-level manner. To address the limitations of manually labeling training data, we propose an automated method for generating fine-grained hallucination data using LLMs. Our FG-PRM demonstrates superior performance across two key tasks: 1) Finegrained hallucination detection: classifying hallucination types for each reasoning step; and 2) Verification: ranking multiple LLMgenerated outputs to select the most accurate solution. Our experiments show that FG-PRM excels in fine-grained hallucination detection and substantially boosts the performance of LLMs on GSM8K and MATH benchmarks. These results highlight the benefits of finegrained supervision in enhancing the reliability and interpretability of LLM reasoning processes. Codes and datasets are available at: https://github.com/du-nlp-lab/FG-PRM.

For agents

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

get_harvested_code_for_paper("2025.findings-emnlp.228")
get_code_for_paper("2025.findings-emnlp.228")
have("2025.findings-emnlp.228")

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

curl https://syntology.ai/api/ran/2025.findings-emnlp.228.json

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

[![Syntology run record](https://syntology.ai/api/ran/2025.findings-emnlp.228.svg)](https://syntology.ai/paper/2025.findings-emnlp.228)

Connect an agent — have() is free.