SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2506.10822 · 2025

ReCUT: Balancing Reasoning Length and Accuracy in LLMs via Stepwise Trails and Preference Optimization

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 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 8 have no contract verdict; 0 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/2506.10822.json · badge: /api/ran/2506.10822.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
neuir/recut canonical (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
analyze_test_results Ran
ran on a synthesized input
neuir/recut/evaluate/evaluate_length.py
code served (permissive licence) · get_code("5394b27a305c456c")
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 json
import tempfile
from pathlib import Path

# Create a temporary JSON file with test data
test_data = [
    {
        "Output": "This is a correct answer with some length",
        "Metrics": {
            "is_valid_answer": True,
            "em": 1,
            "acc": 1,
            "f1": 1.0,
            "math_equal": True
        }
    },
    {
        "Output": "This is another correct mathematical answer",
        "Metrics": {
            "is_valid_answer": True,
            "em": 1,
            "acc": 1,
            "f1": 1.0,
            "math_equal": True
        }
    },
    {
        "Output": "This is an incorrect answer that failed",
        "Metrics": {
            "is_valid_answer": False,
            "em": 0,
            "acc": 0,
            "f1": 0.0,
            "math_equal": False
        }
    },
    {
        "Output": "Another wrong output with different length",
        "Metrics": {
            "is_valid_answer": False,
            "em": 0,
            "acc": 0,
            "f1": 0.0,
            "math_equal": False
        }
    },
    {
        "Output": "Partially correct",
        "Metrics": {
            "is_valid_answer": True,
            "em": 0,
            "acc": 1,
            "f1": 0.5,
            "math_equal": False
        }
    }
]

# Create temporary files
temp_input = tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False, encoding='utf-8')
json.dump(test_data, temp_input)
temp_input.close()

temp_output_path = tempfile.mktemp(suffix='.json')

ARGS = {
    "input_file": temp_input.name,
    "output_file": temp_output_path,
    "save_output": True
}
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 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_final_answer Ran
ran on a synthesized input
neuir/recut/src/long2short_reward_generate.py
code served (permissive licence) · get_code("8bc54889033168e8")
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 extract_final_answer(generated_text):
    """从生成的文本中提取最终答案"""
    if not generated_text:
        return None
    final_section_pattern = '(?:Final answer|FINAL ANSWER|final answer).*?\\\\boxed\\{(.*)\\}'
    final_section_matches = re.findall(final_section_pattern, generated_text)
    if final_section_matches:
        return final_section_matches[-1].strip()
    boxed_pattern = '\\\\boxed\\{(.*)\\}'
    boxed_matches = re.findall(boxed_pattern, generated_text)
    if boxed_matches:
        return boxed_matches[-1].strip()
    return None


# Setup test data
test_text_with_final_answer = "Some reasoning here. Final answer: \\boxed{42}"
test_text_with_boxed = "Some calculation. \\boxed{3.14}"
test_text_empty = ""
test_text_none = None

ARGS = {
    "generated_text": test_text_with_final_answer
}
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
find_generation_by_length Ran
ran on a synthesized input
neuir/recut/src/long2short_dpo.py
code served (permissive licence) · get_code("bbae4c79ee31ac2a")
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 typing import Dict, List, Any, Optional

torch.manual_seed(0)

# Create sample generations with different total_length values
generations = [
    {
        'total_length': 42,
        'text': 'This is a sample generation',
        'id': 1
    },
    {
        'total_length': 15,
        'text': 'Short one',
        'id': 2
    },
    {
        'total_length': 100,
        'text': 'This is a much longer generation with more content',
        'id': 3
    },
    {
        'total_length': 5,
        'text': 'Hi',
        'id': 4
    }
]

ARGS = {
    'generations': generations,
    'maximum': True
}
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
generate_output_paths Ran
ran on a synthesized input
neuir/recut/src/long2short_split_optimal.py
code served (permissive licence) · get_code("53ad32b801cb7bea")
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 pathlib import Path
import tempfile
import os

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()

# Create a test input file path (don't need to actually create the file)
input_file = os.path.join(temp_dir, "test_input.txt")

ARGS = {
    "input_file": input_file
}
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 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
merge_text Ran
ran on a synthesized input
neuir/recut/src/long2short_dpo.py
code served (permissive licence) · get_code("c426029e35919853")
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
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'previous_text': 'Hello world',
    'text': 'this is a test'
}
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
process_data Ran
ran on a synthesized input
neuir/recut/src/long2short_dpo.py
code served (permissive licence) · get_code("5565601a35e6f32a")
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 json
import os
import tempfile
from collections import OrderedDict

# Create temporary directory for test files
temp_dir = tempfile.mkdtemp()

# Create minimal optimal_solutions_4k_incorrect.json
optimal_incorrect_data = [
    {
        "problem": "What is 2+2?",
        "solution": "The answer is 4."
    },
    {
        "problem": "What is 3+3?",
        "solution": "The answer is 6."
    }
]

optimal_incorrect_path = os.path.join(temp_dir, "optimal_solutions_4k_incorrect.json")
with open(optimal_incorrect_path, 'w', encoding='utf-8') as f:
    json.dump(optimal_incorrect_data, f, ensure_ascii=False)

# Create minimal error_thinking_pools_5.json
error_pools_data = [
    {
        "problem": "What is 2+2?",
        "model_generations": [
            {
                "previous_text": "Let me think",
                "text": "2+2 equals 5",
                "total_length": 20
            },
            {
                "previous_text": "Hmm",
                "text": "2+2 is 3",
                "total_length": 15
            }
        ]
    },
    {
        "problem": "What is 3+3?",
        "model_generations": [
            {
                "previous_text": "Computing",
                "text": "3+3 equals 7",
                "total_length": 22
            }
        ]
    }
]

error_pools_path = os.path.join(temp_dir, "error_thinking_pools_5.json")
with open(error_pools_path, 'w', encoding='utf-8') as f:
    json.dump(error_pools_data, f, ensure_ascii=False)

# Output path for results
output_path = os.path.join(temp_dir, "processed_dataset.json")

ARGS = {
    "optimal_incorrect_path": optimal_incorrect_path,
    "error_pools_path": error_pools_path,
    "output_path": output_path,
    "debug": False
}
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
process_math_problems Ran
ran on a synthesized input
neuir/recut/src/long2short_sft.py
code served (permissive licence) · get_code("b509dd8e750ca813")
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 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 json
import tempfile
import os

# Create a temporary directory for test files
temp_dir = tempfile.mkdtemp()

# Create a valid input JSON file with math problems
input_data = [
    {
        "problem": "What is 2 + 2?",
        "final_answer": "4",
        "selected_steps": ["2 + 2 = 4"]
    },
    {
        "problem": "Solve for x: 2x + 3 = 7",
        "final_answer": "x = 2",
        "selected_steps": ["2x + 3 = 7", "2x = 4", "x = 2"]
    },
    {
        "problem": "What is the square root of 16?",
        "final_answer": "4",
        "selected_steps": ["√16 = 4"]
    }
]

input_file = os.path.join(temp_dir, 'test_problems.json')
output_file = os.path.join(temp_dir, 'processed_solutions.json')

# Write valid JSON to input file
with open(input_file, 'w', encoding='utf-8') as f:
    json.dump(input_data, f, ensure_ascii=False, indent=2)

ARGS = {
    'input_file': input_file,
    'output_file': output_file
}
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 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
split_by_correctness Ran
ran on a synthesized input
neuir/recut/src/long2short_split_optimal.py
code served (permissive licence) · get_code("1bb412e3dea61577")
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 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 json
import tempfile
from pathlib import Path

# Create a temporary directory for test files
temp_dir = tempfile.mkdtemp()

# Create input JSON file with test data
input_data = {
    "results": [
        {
            "id": 1,
            "question": "What is 2+2?",
            "answer": "4",
            "is_correct": True
        },
        {
            "id": 2,
            "question": "What is 2+3?",
            "answer": "6",
            "is_correct": False
        },
        {
            "id": 3,
            "question": "What is 3+3?",
            "answer": "6",
            "is_correct": True
        },
        {
            "id": 4,
            "question": "What is 1+1?",
            "answer": "3",
            "is_correct": False
        }
    ]
}

input_file = Path(temp_dir) / "input.json"
with open(input_file, 'w', encoding='utf-8') as f:
    json.dump(input_data, f, ensure_ascii=False, indent=2)

output_correct = Path(temp_dir) / "output_correct.json"
output_incorrect = Path(temp_dir) / "output_incorrect.json"

ARGS = {
    "input_file": str(input_file),
    "output_correct": str(output_correct),
    "output_incorrect": str(output_incorrect)
}
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 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 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 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 8 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-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

Recent advances in Chain-of-Thought (CoT) prompting have substantially improved the reasoning capabilities of Large Language Models (LLMs). However, these methods often suffer from overthinking, leading to unnecessarily lengthy or redundant reasoning traces. Existing approaches attempt to mitigate this issue through curating multiple reasoning chains for training LLMs, but their effectiveness is often constrained by the quality of the generated data and prone to overfitting. To address the challenge, we propose Reasoning Compression ThroUgh Stepwise Trials (ReCUT), a novel method aimed at balancing the accuracy and length of reasoning trajectory. Specifically, ReCUT employs a stepwise exploration mechanism and a long-short switched sampling strategy, enabling LLMs to incrementally generate diverse reasoning paths. These paths are evaluated and used to construct preference pairs to train two specialized models (Gemini LLMs)-one optimized for reasoning accuracy, the other for shorter reasoning. A final integrated model is obtained by interpolating the parameters of these two models. Experimental results across multiple math reasoning datasets and backbone models demonstrate that ReCUT significantly reduces reasoning lengths by approximately 30-50%, while maintaining or improving reasoning accuracy compared to various baselines. All codes and data will be released via https://github.com/NEUIR/ReCUT.

For agents

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

get_harvested_code_for_paper("2506.10822")
get_code_for_paper("2506.10822")
have("2506.10822")

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

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

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

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

Connect an agent — have() is free.