{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/from-sparse-dependence-to-sparse-attention","title":"From Sparse Dependence to Sparse Attention: Unveiling How Chain-of-Thought Enhances Transformer Sample Efficiency","arxiv_id":"2410.05459","date":"2024-10-07","proceeding":null,"authors":["Kaiyue Wen","Huaqing Zhang","Hongzhou Lin","Jingzhao Zhang"],"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.","url_abs":"https://arxiv.org/abs/2410.05459v1","url_pdf":"https://arxiv.org/pdf/2410.05459v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"from-sparse-dependence-to-sparse-attention","repo_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"attribute","task_name":"Attribute"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2410.05459","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.05459"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":7,"unverified":4},"by_repo_kind":{"official":{"samples":11,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"d2002c8cd5325059","entry":"get_data","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig1/fig1.2.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig1/fig1.2.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d2002c8cd5325059"}},{"code_sha256_prefix":"74f79a1e9c94f8ce","entry":"get_result","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig1/fig1.1.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig1/fig1.1.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"74f79a1e9c94f8ce"}},{"code_sha256_prefix":"f933eda64995a961","entry":"get_result","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig1/fig1.2.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig1/fig1.2.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f933eda64995a961"}},{"code_sha256_prefix":"51c4a892dac37e02","entry":"get_result","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig10/fig10.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig10/fig10.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"51c4a892dac37e02"}},{"code_sha256_prefix":"7a1c0e1ab0c7c812","entry":"get_result","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig3/fig3.1.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig3/fig3.1.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7a1c0e1ab0c7c812"}},{"code_sha256_prefix":"079afa7927f435e5","entry":"get_sample_complexity","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig1/fig1.1.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig1/fig1.1.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"079afa7927f435e5"}},{"code_sha256_prefix":"8db5b57cf1d3aaec","entry":"get_sample_complexity","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig3/fig3.1.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig3/fig3.1.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8db5b57cf1d3aaec"}},{"code_sha256_prefix":"9d3fda4033473ab8","entry":"get_gpt_transformer_config","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"src/model/gpt2.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/src/model/gpt2.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9d3fda4033473ab8"}},{"code_sha256_prefix":"efcac756bf9d7fc8","entry":"get_gpt_transformer_model","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"src/model/gpt2.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/src/model/gpt2.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"efcac756bf9d7fc8"}},{"code_sha256_prefix":"b4474d60399e6582","entry":"get_gpt_transformer_model_from_config","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"src/model/gpt2.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/src/model/gpt2.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b4474d60399e6582"}},{"code_sha256_prefix":"ec6f56e7758ab392","entry":"my_plot","repo":"zhqwqwq/Learning-Parity-with-CoT","repo_kind":"official","path":"Figures/Fig2/fig2.1.py","file_url":"https://github.com/zhqwqwq/Learning-Parity-with-CoT/blob/HEAD/Figures/Fig2/fig2.1.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ec6f56e7758ab392"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}