SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.05459 · 2024

From Sparse Dependence to Sparse Attention: Unveiling How Chain-of-Thought Enhances Transformer Sample Efficiency

arXiv · PDF · 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-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/2410.05459.json · badge: /api/ran/2410.05459.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
zhqwqwq/Learning-Parity-with-CoT canonical (classifier label)
classifier basis: census
7 ran · 4 no recorded run
FunctionStatusWhere it lives
get_data Ran
ran, honoured the contract we drafted
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig1/fig1.2.py
code served (permissive licence) · get_code("d2002c8cd5325059")
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 torch
import numpy as np

torch.manual_seed(0)

# Construct a result dict that matches what get_data expects
result = {
    'log_history': [
        {
            'loss': 0.5,
            'epoch': 1.0
        },
        {
            'eval_exact_match': 0.85,
            'eval_loss': 0.3,
            'mean_min_attention_entropy_over_token': 0.2,
            'epoch': 1.0
        },
        {
            'loss': 0.4,
            'epoch': 2.0
        },
        {
            'eval_exact_match': 0.90,
            'eval_loss': 0.25,
            'mean_min_attention_entropy_over_token': 0.18,
            'epoch': 2.0
        },
        {
            'loss': 0.35,
            'epoch': 3.0
        },
        {
            'eval_exact_match': 0.92,
            'eval_loss': 0.22,
            'mean_min_attention_entropy_over_token': 0.15,
            'epoch': 3.0
        }
    ]
}

ARGS = {
    'result': result
}
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 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
get_result Ran
ran; our contract draft was wrong, not the code
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig1/fig1.1.py
code served (permissive licence) · get_code("74f79a1e9c94f8ce")
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 os
import tempfile
import shutil

# Create a temporary directory structure with a trainer_state.json file
temp_dir = tempfile.mkdtemp()

# Create a subdirectory (the function iterates through os.listdir and uses the first directory)
subdir = os.path.join(temp_dir, 'checkpoint_1')
os.makedirs(subdir, exist_ok=True)

# Create a trainer_state.json file with some sample content
trainer_state = {
    'best_model_checkpoint': 'checkpoint-500',
    'best_metric': 0.95,
    'best_metric_checkpoint': 'checkpoint-500',
    'epoch': 3.0,
    'global_step': 1500,
    'is_hyper_param_search': False,
    'is_local_process_zero': True,
    'is_world_process_zero': True,
    'max_steps': 3000,
    'num_train_epochs': 3,
    'total_flos': 0.0,
    'train_batch_size': 32,
    'trial_name': None,
    'trial_params': None
}

trainer_state_path = os.path.join(subdir, 'trainer_state.json')
with open(trainer_state_path, 'w') as f:
    json.dump(trainer_state, f)

ARGS = {
    'path': temp_dir
}
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
get_result Ran
ran; our contract draft was wrong, not the code
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig1/fig1.2.py
code served (permissive licence) · get_code("f933eda64995a961")
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 os
import tempfile
import shutil

# Create a temporary directory structure with the expected layout
temp_dir = tempfile.mkdtemp()

# Create nested directory structure: path -> subdir -> trainer_state.json
subdir = os.path.join(temp_dir, 'subdir')
os.makedirs(subdir, exist_ok=True)

# Create a trainer_state.json file with valid JSON content
trainer_state = {
    'epoch': 1,
    'global_step': 100,
    'best_metric': 0.95,
    'best_model_checkpoint': '/path/to/checkpoint'
}

trainer_state_path = os.path.join(subdir, 'trainer_state.json')
with open(trainer_state_path, 'w') as f:
    json.dump(trainer_state, f)

# Also create a 'tmp' directory that should be skipped
tmp_dir = os.path.join(temp_dir, 'tmp')
os.makedirs(tmp_dir, exist_ok=True)

ARGS = {
    'path': temp_dir
}
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
get_result Ran
ran; our contract draft was wrong, not the code
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig10/fig10.py
code served (permissive licence) · get_code("51c4a892dac37e02")
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 os
import tempfile

# Create a temporary directory structure with a trainer_state.json file
temp_dir = tempfile.mkdtemp()
nested_dir = os.path.join(temp_dir, "subdir")
os.makedirs(nested_dir, exist_ok=True)

# Create a valid trainer_state.json file
trainer_state = {
    "best_metric": 0.95,
    "best_model_checkpoint": "checkpoint-100",
    "epoch": 10,
    "global_step": 1000,
    "is_local_process_zero": True,
    "is_world_process_zero": True,
    "max_steps": 2000,
    "num_train_epochs": 20,
    "total_flos": 1000000,
    "train_batch_size": 32,
    "training_loss": 0.5
}

state_file_path = os.path.join(nested_dir, "trainer_state.json")
with open(state_file_path, 'w') as f:
    json.dump(trainer_state, f)

ARGS = {
    "path": temp_dir
}
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
get_result Ran
ran; our contract draft was wrong, not the code
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig3/fig3.1.py
code served (permissive licence) · get_code("7a1c0e1ab0c7c812")
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 os
import tempfile
import shutil

# Create a temporary directory structure with a trainer_state.json file
temp_dir = tempfile.mkdtemp()
nested_dir = os.path.join(temp_dir, 'subdir')
os.makedirs(nested_dir)

# Create a valid trainer_state.json file
trainer_state = {
    'best_model_checkpoint': 'checkpoint-100',
    'best_metric': 0.95,
    'best_model_score': 0.95,
    'epoch': 3.0,
    'global_step': 1000,
    'is_hyper_param_search': False,
    'is_local_process_zero': True,
    'is_world_process_zero': True,
    'log_history': [],
    'max_steps': -1,
    'num_train_epochs': 3,
    'trial_name': None,
    'trial_params': None
}

trainer_state_path = os.path.join(nested_dir, 'trainer_state.json')
with open(trainer_state_path, 'w') as f:
    json.dump(trainer_state, f)

ARGS = {
    'path': temp_dir
}
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
get_sample_complexity Ran
ran, honoured the contract we drafted
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig1/fig1.1.py
code served (permissive licence) · get_code("079afa7927f435e5")
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 int, ndim 0, dtype family int, 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
import numpy as np

# Construct a valid result dict that matches what get_sample_complexity expects
result = {
    'log_history': [
        {
            'epoch': 1,
            'eval_exact_match': 0.5,
        },
        {
            'epoch': 2,
            'eval_exact_match': 1,  # This will trigger the return
        },
        {
            'epoch': 3,
            'eval_exact_match': 0.8,
        },
    ]
}

ARGS = {
    'result': result
}
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 int, ndim 0, dtype family int, 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
get_sample_complexity Ran
ran, honoured the contract we drafted
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig3/fig3.1.py
code served (permissive licence) · get_code("8db5b57cf1d3aaec")
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)

# Construct a result dict with log_history containing eval_exact_match scores
result = {
    'log_history': [
        {
            'epoch': 0.1,
            'eval_exact_match': 0.5
        },
        {
            'epoch': 0.2,
            'eval_exact_match': 0.95  # This will trigger the threshold condition
        },
        {
            'epoch': 0.3,
            'eval_exact_match': 0.8
        },
        {
            'epoch': 0.4,
            'eval_exact_match': 0.9
        }
    ]
}

thre = 0.9

ARGS = {
    'result': result,
    'thre': thre
}
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
get_gpt_transformer_config Not yet run
unverified (harvested, no recorded run)
zhqwqwq/Learning-Parity-with-CoT/src/model/gpt2.py
code served (permissive licence) · get_code("9d3fda4033473ab8")
How it ran

no invocation recorded.

get_gpt_transformer_model Not yet run
unverified (harvested, no recorded run)
zhqwqwq/Learning-Parity-with-CoT/src/model/gpt2.py
code served (permissive licence) · get_code("efcac756bf9d7fc8")
How it ran

no invocation recorded.

get_gpt_transformer_model_from_config Not yet run
unverified (harvested, no recorded run)
zhqwqwq/Learning-Parity-with-CoT/src/model/gpt2.py
code served (permissive licence) · get_code("b4474d60399e6582")
How it ran

no invocation recorded.

my_plot Not yet run
unverified (harvested, no recorded run)
zhqwqwq/Learning-Parity-with-CoT/Figures/Fig2/fig2.1.py
code served (permissive licence) · get_code("ec6f56e7758ab392")
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, 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 11 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-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

Chain-of-thought (CoT) significantly enhances the reasoning performance of large language models (LLM). While current theoretical studies often attribute this improvement to increased expressiveness and computational capacity, we argue that expressiveness is not the primary limitation in the LLM regime, as current large models will fail on simple tasks. Using a parity-learning setup, we demonstrate that CoT can substantially improve sample efficiency even when the representation power is sufficient. Specifically, with CoT, a transformer can learn the function within polynomial samples, whereas without CoT, the required sample size is exponential. Additionally, we show that CoT simplifies the learning process by introducing sparse sequential dependencies among input tokens, and leads to a sparse and interpretable attention. We validate our theoretical analysis with both synthetic and real-world experiments, confirming that sparsity in attention layers is a key factor of the improvement induced by CoT.

For agents

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

get_harvested_code_for_paper("2410.05459")
get_code_for_paper("2410.05459")
have("2410.05459")

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

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

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

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

Connect an agent — have() is free.