SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2024.emnlp-main.758 · EMNLP · 2024

Fewer is More: Boosting Math Reasoning with Reinforced Context Pruning

Fan Yang, Li, Kwang-Ting Cheng, Mao Yang, Xijie Huang, Lyna Zhang

Open in the Atlas

Code that ran

6 of 9 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 3 have no contract verdict; 3 failures of our instrument; 3 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/2024.emnlp-main.758.json · badge: /api/ran/2024.emnlp-main.758.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
HuangOwen/CoT-Influx canonical (classifier label)
classifier basis: census
6 ran · 3 no recorded run
FunctionStatusWhere it lives
apply_rotary_pos_emb Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
HuangOwen/CoT-Influx/llama_model/modeling_llama.py
code served (permissive licence) · get_code("f725bc2d76076485")
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 tuple, ndim 5, 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

torch.manual_seed(0)

# Create small tensors for q and k
# Shape: (batch_size=2, seq_len=3, hidden_dim=4)
q = torch.randn(2, 3, 4)
k = torch.randn(2, 3, 4)

# Create cos and sin tensors
# The function squeezes dimensions 1 and 0, then indexes by position_ids
# So we need shape that allows this: (1, 1, seq_len, hidden_dim)
cos = torch.randn(1, 1, 5, 4)
sin = torch.randn(1, 1, 5, 4)

# Create position_ids
# Shape: (batch_size=2, seq_len=3)
position_ids = torch.tensor([[0, 1, 2], [1, 2, 3]])

ARGS = {
    "q": q,
    "k": k,
    "cos": cos,
    "sin": sin,
    "position_ids": position_ids,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 5, 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
convert_softmax_mask_to_digit Ran
ran on a synthesized input
HuangOwen/CoT-Influx/llama_model/modeling_utils.py
code served (permissive licence) · get_code("a0933c7edccb2056")
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 4, dtype family int, shape (2, 1, 1, 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)

# skim_mask should be a tensor that the function will compare to 0
# The function checks (skim_mask == 0), converts to int64, and unsqueezes twice
# So we need a tensor with some 0s and non-0s
skim_mask = torch.tensor([[0, 1, 0, 1],
                           [1, 0, 1, 0]], dtype=torch.float32)

ARGS = {
    "skim_mask": skim_mask
}
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 4, dtype family int, shape (2, 1, 1, 4) — shape (2, 1, 1, 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
data_reader Ran
ran on a synthesized input
HuangOwen/CoT-Influx/utils.py
code served (permissive licence) · get_code("cd2d8ca15274c624")
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 2, 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 tempfile
import os

# Create temporary dataset files for testing
temp_dir = tempfile.mkdtemp()

# Create a simple GSM8K format file
gsm8k_file = os.path.join(temp_dir, 'gsm8k.jsonl')
with open(gsm8k_file, 'w') as f:
    f.write('{"question": "What is 2+2?", "answer": "The answer is #### 4"}\n')
    f.write('{"question": "What is 3+3?", "answer": "The answer is #### 6"}\n')

# Create a simple AQUA format file
aqua_file = os.path.join(temp_dir, 'aqua.jsonl')
with open(aqua_file, 'w') as f:
    f.write('{"question": "What is 2+2?", "options": ["A) 3", "B) 4", "C) 5"], "correct": "B"}\n')
    f.write('{"question": "What is 5+5?", "options": ["A) 9", "B) 10", "C) 11"], "correct": "B"}\n')

# Create a simple CommonsenseQA format file
commonsensqa_file = os.path.join(temp_dir, 'commonsensqa.jsonl')
with open(commonsensqa_file, 'w') as f:
    f.write('{"question": {"stem": "What is a dog?", "choices": [{"label": "A", "text": "animal"}, {"label": "B", "text": "plant"}]}, "answerKey": "A"}\n')
    f.write('{"question": {"stem": "What is a cat?", "choices": [{"label": "A", "text": "animal"}, {"label": "B", "text": "plant"}]}, "answerKey": "A"}\n')

# Create a simple addsub format file
addsub_file = os.path.join(temp_dir, 'addsub.json')
with open(addsub_file, 'w') as f:
    json.dump([
        {"sQuestion": "What is 2 plus 3?", "lSolutions": [5.0]},
        {"sQuestion": "What is 10 minus 4?", "lSolutions": [6.0]}
    ], f)

# Create a simple strategyqa format file
strategyqa_file = os.path.join(temp_dir, 'strategyqa.json')
with open(strategyqa_file, 'w') as f:
    json.dump({
        "examples": [
            {"input": "Is a dog an animal?", "target_scores": {"Yes": 1}},
            {"input": "Is a rock alive?", "target_scores": {"Yes": 0}}
        ]
    }, f)

# Create a simple svamp format file
svamp_file = os.path.join(temp_dir, 'svamp.json')
with open(svamp_file, 'w') as f:
    json.dump([
        {"Body": "There are", "Question": "how many?", "Answer": "5"},
        {"Body": "I have", "Question": "what do I have?", "Answer": "10"}
    ], f)

# Create a simple bigbench_date format file
bigbench_date_file = os.path.join(temp_dir, 'bigbench_date.json')
with open(bigbench_date_file, 'w') as f:
    json.dump({
        "examples": [
            {"input": "What is the date?", "target_scores": {"2020-01-01": 1, "2020-01-02": 0, "2020-01-03": 0, "2020-01-04": 0, "2020-01-05": 0, "2020-01-06": 0}}
        ]
    }, f)

# Create a simple object_tracking format file
object_tracking_file = os.path.join(temp_dir, 'object_tracking.json')
with open(object_tracking_file, 'w') as f:
    json.dump({
        "examples": [
            {"input": "Track the object", "target_scores": {"left": 1, "right": 0, "center": 0}}
        ]
    }, f)

# Create a simple coin_flip format file
coin_flip_file = os.path.join(temp_dir, 'coin_flip.json')
with open(coin_flip_file, 'w') as f:
    json.dump({
        "examples": [
            {"question": "Flip a coin", "answer": "heads"},
            {"question": "Flip again", "answer": "tails"}
        ]
    }, f)

# Create a simple last_letters format file
last_letters_file = os.path.join(temp_dir, 'last_letters.json')
with open(last_letters_file, 'w') as f:
    json.dump({
        "examples": [
            {"question": "What are the last letters of 'hello'?", "answer": "o"},
            {"question": "What are the last letters of 'world'?", "answer": "d"}
        ]
    }, f)

# Create a mock args object
class Args:
    def __init__(self, dataset, dataset_path):
        self.dataset = dataset
        self.dataset_path = dataset_path

ARGS = {
    'args': Args(dataset='gsm8k', dataset_path=gsm8k_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 2, 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
evaluate Ran
ran on a synthesized input
HuangOwen/CoT-Influx/example_retrieval_pruner.py
code served (permissive licence) · get_code("49396419bb86c908")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
from transformers import GenerationConfig

torch.manual_seed(0)

# Stand-in tokenizer that implements the required interface
class StandInTokenizer:
    def __call__(self, text, return_tensors=None):
        # Return a dict with input_ids tensor
        # Using small tensor: batch_size=1, seq_len=3
        input_ids = torch.tensor([[101, 2054, 2003]], dtype=torch.long)
        return {'input_ids': input_ids}
    
    def decode(self, token_ids):
        # Simple mock decode
        return "This is a generated output."

# Stand-in model that implements the required interface
class StandInCausalLM(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def generate(self, input_ids, generation_config, return_dict_in_generate=False, output_scores=False, max_new_tokens=256):
        # Return an object with sequences attribute
        # Simulate generation output
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1] + 2  # Add some generated tokens
        
        class GenerationOutput:
            def __init__(self, sequences):
                self.sequences = sequences
        
        # Create mock output sequences
        output_sequences = torch.cat([
            input_ids,
            torch.randint(0, 1000, (batch_size, 2), dtype=torch.long)
        ], dim=1)
        
        return GenerationOutput(sequences=output_sequences)

# Create instances
tokenizer = StandInTokenizer()
model = StandInCausalLM()

# Define all arguments
ARGS = {
    'tokenizer': tokenizer,
    'model': model,
    'input': "Hello, how are you?",
    'temperature': 0.8,
    'top_p': 0.95,
    'top_k': 40,
    'num_beams': 1,
    'max_new_tokens': 256
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — 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
rotate_half Ran
ran; our contract draft was wrong, not the code
HuangOwen/CoT-Influx/llama_model/modeling_llama.py
code served (permissive licence) · get_code("b99eea6376d1e212")
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 Tensor, ndim 2, dtype family float, 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)

# The function rotate_half takes a single parameter 'x' which is a tensor
# It accesses x.shape[-1] to get the last dimension
# It uses indexing with [..., :] slicing notation
# It calls torch.cat() to concatenate tensors

# Create a small tensor with shape (2, 4) - batch size 2, hidden dim 4
x = torch.randn(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 float, 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
shuffleDict Ran
ran; our contract draft was wrong, not the code
HuangOwen/CoT-Influx/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from nku-hlt/role-play-prompting, is pointer only (licence: NONE) · get_code("ae2495a11361cc1d")
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 nku-hlt/role-play-prompting, 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.

generate_pruned_prompt Not yet run
unverified (harvested, no recorded run)
HuangOwen/CoT-Influx/example_retrieval_pruner.py
code served (permissive licence) · get_code("f12b1f0f45d9fc1f")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
HuangOwen/CoT-Influx/example_retrieval_pruner.py
code served (permissive licence) · get_code("ae6cc5127a6d387e")
How it ran

no invocation recorded.

print_now Not yet run
unverified (harvested, no recorded run)
HuangOwen/CoT-Influx/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from wjn1996/Chain-of-Knowledge, is pointer only (licence: NONE) · get_code("28145bbcf1d4f9ea")
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 wjn1996/Chain-of-Knowledge, 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.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 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, 2 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
rotate_half 360 other papers
58 dated earlier, 124 later, 175 same year, order not determinable, 3 undated · 30 only as an assembly brick
1901.02860 (2019-01)
Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context
2203.08913 (2022-03)
Memorizing Transformers
2302.13971 (2023-02)
LLaMA: Open and Efficient Foundation Language Models
and 357 more not named here
apply_rotary_pos_emb 83 other papers
15 dated earlier, 18 later, 50 same year, order not determinable · 6 only as an assembly brick
2306.15595 (2023-06)
Extending Context Window of Large Language Models via Positional Interpolation
2307.05695 (2023-07)
ReLoRA: High-Rank Training Through Low-Rank Updates
2307.06945 (2023-07)
In-context Autoencoder for Context Compression in a Large Language Model
and 80 more not named here
print_now 10 other papers
5 dated earlier, 5 same year, order not determinable
2210.03493 (2022-10)
Automatic Chain of Thought Prompting in Large Language Models
2305.13269 (2023-05)
Chain-of-Knowledge: Grounding Large Language Models via Dynamic Knowledge Adapting over Heterogeneous Sources
2308.07702 (2023-08)
Better Zero-Shot Reasoning with Role-Play Prompting
and 7 more not named here
shuffleDict 5 other papers
2 dated earlier, 3 same year, order not determinable
2210.03493 (2022-10)
Automatic Chain of Thought Prompting in Large Language Models
2308.07702 (2023-08)
Better Zero-Shot Reasoning with Role-Play Prompting
2401.04925 (2024-01)
The Impact of Reasoning Step Length on Large Language Models
and 2 more not named here

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 Language Models (LLMs) have shown impressive capabilities, yet they still struggle with math reasoning. In this work, we propose CoT-Influx, a novel approach that pushes the boundary of few-shot Chain-of-Thoughts (CoT) learning to improve LLM mathematical reasoning. Motivated by the observation that adding more concise CoT examples in the prompt can improve LLM reasoning performance, CoT-Influx employs a coarse-to-fine pruner to maximize the input of effective and concise CoT examples. The pruner first selects as many crucial CoT examples as possible and then prunes unimportant tokens to fit the context window. A math reasoning dataset with diverse difficulty levels and reasoning steps is used to train the pruner, along with a math-specialized reinforcement learning approach. As a result, by enabling more CoT examples with double the context window size in tokens, CoT-Influx significantly outperforms various prompting baselines across various LLMs (LLaMA2-7B, 13B, 70B) and 6 math datasets, achieving up to 4.40% absolute improvements. Remarkably, without any fine-tuning, LLaMA2-70B with CoT-Influx surpasses GPT-3.5 and a wide range of larger LLMs (PaLM, Minerva 540B, etc.) on GSM8K. CoT-Influx is a plug-and-play module for LLMs, adaptable in various scenarios. It's compatible with advanced reasoning prompting techniques, such as self-consistency, and supports different long-context LLMs, including Mistral-7B-v0.3-32K and Yi-6B-200K. Codes are available at https://github.com/HuangOwen/CoT-Influx

For agents

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

get_harvested_code_for_paper("2024.emnlp-main.758")
get_code_for_paper("2024.emnlp-main.758")
have("2024.emnlp-main.758")

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

curl https://syntology.ai/api/ran/2024.emnlp-main.758.json

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

[![Syntology run record](https://syntology.ai/api/ran/2024.emnlp-main.758.svg)](https://syntology.ai/paper/2024.emnlp-main.758)

Connect an agent — have() is free.