{"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/limits-of-transformer-language-models-on","title":"Limits of Transformer Language Models on Learning to Compose Algorithms","arxiv_id":"2402.05785","date":"2024-02-08","proceeding":null,"authors":["Jonathan Thomm","Giacomo Camposampiero","Aleksandar Terzic","Michael Hersche","Bernhard Schölkopf","Abbas Rahimi"],"abstract":"We analyze the capabilities of Transformer language models in learning compositional discrete tasks. To this end, we evaluate training LLaMA models and prompting GPT-4 and Gemini on four tasks demanding to learn a composition of several discrete sub-tasks. In particular, we measure how well these models can reuse primitives observable in the sub-tasks to learn the composition task. Our results indicate that compositional learning in state-of-the-art Transformer language models is highly sample inefficient: LLaMA requires more data samples than relearning all sub-tasks from scratch to learn the compositional task; in-context prompting with few samples is unreliable and fails at executing the sub-tasks or correcting the errors in multi-round code generation. Further, by leveraging complexity theory, we support these findings with a theoretical analysis focused on the sample inefficiency of gradient descent in memorizing feedforward models. We open source our code at https://github.com/IBM/limitations-lm-algorithmic-compositional-learning.","url_abs":"https://arxiv.org/abs/2402.05785v5","url_pdf":"https://arxiv.org/pdf/2402.05785v5.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":"limits-of-transformer-language-models-on","repo_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"code-generation","task_name":"Code Generation"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt-4","method_name":"GPT-4"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.05785","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.05785"}},"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/ibm/limitations-lm-algorithmic-compositional-learning","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":3,"unverified":5},"by_repo_kind":{"official":{"samples":8,"ran":3,"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":"a838c0231008f30a","entry":"generate_text_gemini","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_llm.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_llm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a838c0231008f30a"}},{"code_sha256_prefix":"f2db033ab6f2498d","entry":"solve_pen","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_builder_pen.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_builder_pen.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f2db033ab6f2498d"}},{"code_sha256_prefix":"c5d98864dc78e01d","entry":"solve_perm","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_builder_perm.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_builder_perm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c5d98864dc78e01d"}},{"code_sha256_prefix":"7bfe356714c7bb6d","entry":"build_prompt","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_builder_perm.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_builder_perm.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7bfe356714c7bb6d"}},{"code_sha256_prefix":"95228c89a9638a61","entry":"generate_text","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_llm.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_llm.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"95228c89a9638a61"}},{"code_sha256_prefix":"5988ae55ce1db95e","entry":"generate_text_openai","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_llm.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_llm.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5988ae55ce1db95e"}},{"code_sha256_prefix":"075965a867f2f9fc","entry":"get_green_matching_words","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_builder_pen.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_builder_pen.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"075965a867f2f9fc"}},{"code_sha256_prefix":"b2d0b639fff8a846","entry":"transform_sample_to_triplets","repo":"ibm/limitations-lm-algorithmic-compositional-learning","repo_kind":"official","path":"prompting_experiment_utils/prompt_builder_pen.py","file_url":"https://github.com/ibm/limitations-lm-algorithmic-compositional-learning/blob/HEAD/prompting_experiment_utils/prompt_builder_pen.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b2d0b639fff8a846"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}