SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2604.05114 · 2026

π 2 : Structure-Originated Reasoning Data Improves Long-Context Reasoning Ability of Large Language Models

Sha Li, Thinh Pham, Nguyen Nguyen, Pratibha Zunjare, Tu Vu, Quyet Do

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 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; 10 failures of our instrument; 0 no recorded run), measured 2026-11-23; 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/2604.05114.json · badge: /api/ran/2604.05114.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
vt-pi-squared/pi-squared canonical (classifier label)
classifier basis: census
10 ran · 0 no recorded run
FunctionStatusWhere it lives
chunk_text Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/utils.py
code served (permissive licence) · get_code("0e2958714bc2629c")
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

# Analyze the function: chunk_text takes:
# - text: str - the main input to chunk
# - max_chunk_size: int - maximum size of each chunk
# - chunk_on: tuple of str - delimiters to split on
# - chunker_i: int - index into chunk_on (used recursively)

# The function recursively splits text based on delimiters and merges chunks
# No models, tensors, or complex objects needed - just strings and basic types

# Create a sample text that's longer than max_chunk_size to trigger chunking
sample_text = """This is a long text that needs to be chunked into smaller pieces.

This is the second paragraph with some content.

And here is a third paragraph. It contains multiple sentences. Each sentence ends with a period. This helps test the chunking logic on different delimiters."""

# The sample text should be longer than max_chunk_size to test the logic
ARGS = {
    'text': sample_text,
    'max_chunk_size': 100,
    'chunk_on': ('\n\n', '\n', '. '),
    'chunker_i': 0
}
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
clean_reasoning_traces Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/v1_merge_and_postprocess_full_data_pipeline.py
code served (permissive licence) · get_code("03d867be253839c0")
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 clean_reasoning_traces(reasoning_traces: str) -> str:
    """
    Clean reasoning traces by:
    1. Removing Python code blocks
    2. Removing repetitive keywords/artifacts
    3. Making it more human-like
    """
    if not reasoning_traces:
        return ''
    reasoning_traces = re.sub('```python.*?```', '', reasoning_traces, flags=re.DOTALL)
    artifacts = ['Purpose and action in natural language:', '**Purpose and action in natural language:**', 'Corresponding code snippet:', '**Corresponding code snippet:**', 'The corresponding code snippet to support the logic:']
    intermediate_result_phrases = ['Resulting intermediate variable:', 'Resulting intermediate variables:', '**The resulting intermediate variable:**']
    for artifact in artifacts:
        reasoning_traces = reasoning_traces.replace(artifact, '')
    for phrase in intermediate_result_phrases:
        reasoning_traces = reasoning_traces.replace(phrase, 'The intermediate result is:\n')
    reasoning_traces = re.sub('\\n{3,}', '\n\n', reasoning_traces)
    reasoning_traces = reasoning_traces.strip()
    return reasoning_traces

# Test input with various artifacts and code blocks
test_reasoning_traces = """
**Purpose and action in natural language:**
This function processes data.


def example():
    return 42


Some explanation here.


**Corresponding code snippet:**
More details.

Resulting intermediate variable:
The result is computed.




Additional notes here.
"""

ARGS = {
    "reasoning_traces": test_reasoning_traces
}
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
clean_reasoning_traces Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/v2_merge_and_postprocess_ctqar.py
code served (permissive licence) · get_code("83374f34b08beb7e")
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 clean_reasoning_traces(reasoning_traces: str) -> str:
    """
    Clean reasoning traces by:
    1. Removing Python code blocks
    2. Removing repetitive keywords/artifacts
    3. Making it more human-like
    """
    if not reasoning_traces:
        return ''
    reasoning_traces = re.sub('```python.*?```', '', reasoning_traces, flags=re.DOTALL)
    artifacts = ['Purpose and action in natural language', 'Corresponding code snippet']
    intermediate_result_phrases = ['Intermediate variable']
    lines = reasoning_traces.splitlines()
    cleaned_lines = []
    for line in lines:
        if any((artifact.lower() in line.lower() for artifact in artifacts)):
            continue
        if any((phrase.lower() in line.lower() for phrase in intermediate_result_phrases)):
            cleaned_lines.append('The intermediate result is:')
        else:
            cleaned_lines.append(line)
    reasoning_traces = re.sub('\\n{3,}', '\n\n', '\n'.join(cleaned_lines)).strip()
    return reasoning_traces

# Test input with various elements the function handles
test_reasoning = """This is a reasoning trace.
Purpose and action in natural language: do something
Here is some analysis.

x = 1 + 2

Intermediate variable: temp_var
More reasoning here.



Multiple newlines above.
Corresponding code snippet: some code
Final thoughts."""

ARGS = {
    "reasoning_traces": test_reasoning
}
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
dspy_simple_format_correction Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/sampling_reasoning_trace.py
code served (permissive licence) · get_code("14f5ee8c933b96b8")
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 numpy as np

# Analyze the function: it takes a single parameter 'text' which is a string
# The function performs string replacements on it
# So we need to provide a string with some of the patterns that get corrected

text_input = "This is a [[##test with ##]] and [[# space and #]] patterns"

ARGS = {
    "text": text_input
}
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 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
load_jsonl Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/v1_merge_and_postprocess_full_data_pipeline.py
code served (permissive licence) · get_code("bbf4c6a9a91e3bea")
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 tempfile
import json
import os

# Create a temporary JSONL file for testing
temp_dir = tempfile.mkdtemp()
jsonl_file_path = os.path.join(temp_dir, "test_data.jsonl")

# Write some test data to the JSONL file
test_data = [
    {"id": 1, "text": "hello"},
    {"id": 2, "text": "world"},
    {"id": 3, "text": "test"}
]

with open(jsonl_file_path, 'w', encoding='utf-8') as f:
    for item in test_data:
        f.write(json.dumps(item) + '\n')

# Also create a JSON file for testing the .json branch
json_file_path = os.path.join(temp_dir, "test_data.json")
with open(json_file_path, 'w', encoding='utf-8') as f:
    json.dump(test_data, f)

ARGS = {
    "file_path": jsonl_file_path
}
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
load_table_from_markdown Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/helper.py
code served (permissive licence) · get_code("ceec5f41dc1351d7")
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 DataFrame. 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

# Create a valid markdown table string
md_table = """
| Name | Age | Score |
|------|-----|-------|
| Alice | 25 | 95.5 |
| Bob | 30 | 87.3 |
| Charlie | 28 | 92.1 |
"""

ARGS = {
    "md_table": md_table
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataFrame — a DataFrame output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataFrame output the recorded ndim 2 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
remove_attribute_tags Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/v1_merge_and_postprocess_full_data_pipeline.py
code served (permissive licence) · get_code("847109c87e2f2337")
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 remove_attribute_tags(text: str) -> str:
    """Remove attribute tags like <team_home>, <team_away>, etc."""
    text = re.sub('<[^>]+>', '', text)
    return text

ARGS = {
    "text": "The <team_home>home team</team_home> played against the <team_away>away team</team_away> yesterday."
}
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
replace_variables_with_values Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/v2_merge_and_postprocess_ctqar.py
code served (permissive licence) · get_code("ff0f7941757d7df9")
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
import json
import pandas as pd
from io import StringIO

# Create a simple HTML table string
df_html = """
<table>
    <tr><th>Name</th><th>Value</th></tr>
    <tr><td>Alice</td><td>100</td></tr>
    <tr><td>Bob</td><td>200</td></tr>
</table>
"""

# Create reasoning traces with placeholders
reasoning_traces = "The result is {result} and the sum is {total}."

# Create Python code that defines variables to be used in replacement
python_code = """
result = 42
total = df['Value'].sum()
"""

ARGS = {
    'reasoning_traces': reasoning_traces,
    'python_code': python_code,
    'df_html': df_html,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — 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
search_for_avoid_keyword Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/gen_code_qa_reasoning_trace.py
code served (permissive licence) · get_code("b13e08cf1e96cdcb")
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.

# Analyzing the function: search_for_avoid_keyword
# - Takes a single parameter: question (a string)
# - Converts to lowercase
# - Checks if any avoided keywords are in the question
# - Returns the first matching keyword or None

ARGS = {
    "question": "This is a list of data in a table format"
}
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
simplify_to_md_or_str Ran
ran; our contract draft was wrong, not the code
vt-pi-squared/pi-squared/datasets/ours/code/helper.py
code served (permissive licence) · get_code("95a360faa75ae644")
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 pandas as pd
import numpy as np

# Test case 1: Single value DataFrame (1, 1)
df_single = pd.DataFrame([[42]])

# Test case 2: Single column DataFrame
df_column = pd.DataFrame({'A': [1, 2, 3, 4]})

# Test case 3: Single row DataFrame
df_row = pd.DataFrame({'A': [10], 'B': [20], 'C': [30]})

# Test case 4: Multi-row, multi-column DataFrame
df_multi = pd.DataFrame({
    'Name': ['Alice', 'Bob', 'Charlie'],
    'Age': [25, 30, 35],
    'Score': [85.5, 90.0, 78.5]
})

# Test case 5: Series
series_simple = pd.Series([1, 2, 3, 4], name='values')

ARGS = {
    'df': df_multi
}
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 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

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 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 10 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-23.

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 study a pipeline that curates reasoning data from initial structured data for improving long-context reasoning in large language models (LLMs). Our approach, π 2 , constructs high-quality reasoning data through rigorous QA curation: 1) extracting and expanding tables from Wikipedia, 2) from the collected tables and relevant context, generating realistic and multi-hop analytical reasoning questions whose answers are automatically determined and verified through dual-path code execution, and 3) backtranslating step-by-step structured reasoning traces as solutions of QA pairs given realistic web-search context. Supervised fine-tuning with GPT-OSS-20B and QWEN3-4B-INSTRUCT-2507 on π 2 yields consistent improvements across four long-context reasoning benchmarks and our alike π 2 -Bench, with average absolute accuracy gains of +4.3% and +2.7% respectively. Notably, our dataset facilitates self-distillation, where GPT-OSS-20B even improves its average performance by +4.4% with its own reasoning traces, demonstrating π 2 's usefulness. Our code, data, and models are open-source at https://github.com/vt-pi-squared/pi-squared.

For agents

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

get_harvested_code_for_paper("2604.05114")
get_code_for_paper("2604.05114")
have("2604.05114")

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

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

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

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

Connect an agent — have() is free.