Limits of Transformer Language Models on Learning to Compose Algorithms

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.

Paper

References (64)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer Fa354/10 · confidence 3/52024-07-07

Summary

This paper studies whether transformers can efficiently learn compositional discrete tasks. In particular, the paper introduces two new tasks: pointer execution neighbor and pointer execution reverse multicount as well as using multiplication and highest subsequence sum from prior work. First, small models are trained from scratch, showing substantially slower learning on the composition than on the subtasks. Next, API models are prompted to solve the same tasks and perform somewhat poorly. Some theory is also provided showing how models that memorize can struggle to learn compositions efficiently.

Strengths

1. The paper proposes an interesting question as to whether we can determine whether a language model has some higher level concept of task composition that allows it to learn compositions of previously learned tasks efficiently. 2. The paper includes a nice theoretical result via a complexity theory reduction that shows how composition is hard if we assume stylized models that memorize the training data.

Weaknesses

1. H1 as written cannot be disproven empirically since the "constant" could just be larger than those tested. It seems in the experiments "constant" means 100. If that is what is meant, then just say so in the hypothesis. 2. It is not clear if the notion of "sub-task" is somehow atomic and unique. This makes hypothesis H2 and H3 somewhat ill-defined too. It is possible that there are different sub-tasks (and perhaps many more of them) that better track how the model actually learns. Just because we can posit one way to compositionally solve the task does not mean that the model will learn that way (or even that it can necessarily represent that composition). 3. It is not clear why the new tasks are necessary or what specifically they add over prior, simpler tasks. There needs to be more justification of the somewhat complicated tasks to explain why they are necessary. Generally the presentation of these tasks and the results was unclear and could use improvement to make it more visually clear how matches and transitions are meant to happen in the tasks and more precisely what all the baselines are doing in the experiments. 4. It is not clear why one would expect an untrained small (150m) language model to somehow be able to compose subtasks without being trained to perform composition. As such, the results that the composition does not just arise and indeed takes longer to learn is not surprising. 5. I am somewhat worried that the way the strings representing the nodes are designed is interacting badly with the tokenizers in the API experiments. These are clearly "out of distribution" types of words and they may be tokenized in ways that make it very difficult to solve the task. Did you do any analysis of how these strings get tokenized? The tokenizers are publicly available. Also, it is difficult to fit this section into the story of the paper since there is no comparison to the learning of the subtasks.

Questions

See weaknesses.

Rating

4

Confidence

3

Soundness

2

Presentation

1

Contribution

2

Limitations

Limitations of not solving the issues raised are addressed in the paper.

Reviewer teuc6/10 · confidence 2/52024-07-12

Summary

This paper focuses on analyzing the transformer language models' learning and transferability on compositional discrete tasks. Specifically, it has four hypothesis, and the author studies for a variety of language models, whether does these hypothesis hold. H1. An LLM can learn to perform a compositional task with constant number of datapoints. H2. An LLM can learn to perform a compositional task, given as many sample as the most difficult sub-task required. H3. An LLM can learn to perform a compositional task, given the data samples of relearning all sub-tasks for learning the composition. H4. An LLM can learn to perform a compositional task, given more data samples in H3. The authors introduces a new benchmark for creating systematic sub-tasks and testing compositionally. With LLaMA model, H4 holds; with both GPT-4 and Gemini, using H1 (prompting) fails to perform the tasks, or multi-round code generation with COT technique.

Strengths

Originality: 3.5 / 5 This paper examines how the number of datapoint samples affects the learning of compositional tasks in existing transformer-based large language models (LLMs). The authors created a new, challenging compositional dataset based on computation graphs and demonstrated that learning compositional tasks with LLMs is highly data-inefficient. While the BIG-bench paper indicates the insufficiency of reasoning and compositional abilities in LLMs, this paper innovatively provides a concrete, quantitative, and extensive study on the extent of this insufficiency. Quality: 3.5/5 The empirical study is pretty extensive with both LLaMA, GPT-4 and Gemini. There are multiple prompting techniques adopted with GPT-4 and Gemini, all of them fails to generate a reliable result. There are also very interesting theotrical proofs in the appendix to bolster the authors' claims. Clarity: 3/5 Figure 1 is hard to understand just by staring at the graph. For each task, it only provides one example which is non-trivial at all. One can hardly figure out its ground truth program for each example, and whether in a task of PE, is the underlying program the same across all the datapoints. I believe a descriptive caption by the side of each task is necessary. For example, PE refers to a program that takes a sequence of words and returns a list of words all colored green, where the first output word matches the first input word, and any subsequent output word starts with the last two characters of the previous word. However, the figures and tables in the experimental section are pretty clear and helpful to understand. Significance: 2.5/5 Understanding the problem of the data inefficiency in transformer based LLMs is important to the community which focuses on data efficiency and reasoning, such as neuro-symbolic community.

Weaknesses

As stated in the strengths above. One of the main issue is the clarity issue of the tasks. Besides "what is the task", I also want to understand "why these two tasks are needed". What do PEN and PERM these two datasets bring?

Questions

Q1. Is the PEN dataset only corresponding to one underlying program? Q2. What are the insights of PEN and PERM these two datasets?

Rating

6

Confidence

2

Soundness

3

Presentation

3

Contribution

2

Limitations

I believe the stated limitation regarding addressing weaknesses in the LLM is not appropriate for this specific paper. Instead, the limitation should focus on the choice of the compositional dataset.

Reviewer teuc2024-08-11

Your response has clarified my concerns. I have raised my score from 4 to 6. I really hope these clarifications can go into the revised version of the paper to improve the clarity and presentation.

Authorsrebuttal2024-08-11

Thank you very much for raising your score, we are glad that our response clarified your concerns. We will indeed incorporate all this material in the revised version of the manuscript. Once again, thanks for highlighting these issues and contributing to the improvement of our work.

Reviewer DGs47/10 · confidence 4/52024-07-13

Summary

This paper evaluates the compositional learning abilities of Transformer-based models with LLaMA-like architecture on tasks requiring the composition of several discrete sub-tasks. To this end, the paper reuses two existing compositional algorithmic tasks and introduces two new ones, focusing on how many samples are needed for models to learn to compose the sub-tasks compared to the sample efficiency of learning the sub-tasks themselves. The study measures the efficiency of models when trained from scratch and the effectiveness of prompting the pretrained language models GPT-4 and Gemini. The experiments suggest that hypotheses that compositional learning requires no more samples than the sum of samples needed for each subtasks should be rejected. The paper also performs few-shot prompting with GPT-4 and Gemini with different prompting techniques to investigate their ability to learn to compose or decompose algorithms in-context and find that they are unreliable for executing sub-tasks or correcting errors in multi-round code generation. Finally, the paper uses complexity theory to support these findings, suggesting that when training feedforward models to memorize information with gradient descent, the sample inefficiency is inevitable.

Strengths

1. Aside from achieving state-of-the-art performance on many academic benchmarks, transformer-based language models are the undisputed workhorse for numerous real-world applications. However, their training does not necessitate compositional learning explicitly, while many of the tasks they are tasked at solving do require such capability. As such, understanding the limits and requirements for these models to learn to compose independent skills is key to drive our understanding of these foundational models and to improve them. 2. The analyzed tasks in the paper are very well defined to verify that a model that learns a task must know how to perform the subtasks, and that given capability to solve the subtasks, a model must only learn to compose these abilities to solve the task itself. Creating such settings is not trivial, and goes a long way to enhance our understanding of the compositional learning abilities of transformer models. 3. The paper provides a very thorough literature review and contextualizes the work around prior work very well. 4. The presentation of the paper is generally very nice, making a technical read easier and fluent.

Weaknesses

1. The authors correctly identify tokenization as a possible negative confounder in the defined testbed, and thus use character-based tokenization for the training experiments. However, the same care is not taken when investigating the abilities of GPT4 and gemini to perform in-context-learning. Namely, given the highly synthetic nature of the inputs, it is highly possible that both the out-of-domain distribution of these inputs (deviating from natural texts) as well as differences in how inputs are tokenized (for example, one key can be tokenized with a single token, another by three tokens, and a third be tokenized along with parts of the corresponding value) confounds and skew the results, hindering their usefulness. 2. Moreover, while the authors study many prompting techniques to evaluate GPT4 and Gemini, they use a constant 8-shot prompting. It is known that these models can benefit greatly from increased number of demonstrations, and has been shown that for out-of-domain tasks, one has to prompt the model with significantly more than 8 prompts to perform well (e.g. Levy et al., 2022, Bertsch et al. 2024, Agarwal et al. 2024) 3. The proposed testbed is very well defined, but a single transformer based model is being studied. Understanding the contextualization of the results given difference in the model and tasks properties (for example width-depth ratio, scaling behavior with respect to parameter count or effect length of the inputs) would be very beneficial.ֿ

Questions

1. Can you imagine similar experiments with more natural compositional tasks that can be learnt, and then used to benchmark SOTA LLMs in the settings they were designed and trained for? For example, do you think it is possible to use something similar to the unobserved local structures as proposed by Bogin et al. (2022) to create such settings? 2. Can you try repeating the experiments with clear instruction for GPT4/Gemini but using as keys only tokens in their respective vocabularies separated by e.g ‘-‘ so that the tokenization and highly synthetic nature of the task would have less detrimental effect on the results? 3. What are the exact specifications of the trained model? You mentioned it is 150M parameters, does that mean it is a 12-layer decoder only model? What was the training procedure in terms of hyperparameters? Do you see any scaling behaviors a-la Kaplan et al., 2020? For example, does using a larger model decrease the amount of samples needed? Also, does the depth of the model affect the ability to learn to compose subtasks? 4. Presentation suggestion - in a few places in the text, it would be very helpful for the reader to be able to read the descriptions if they were coupled with examples. 1. In section 2.2 you define sub-tasks in the computation graphs. I think including a small demonstration of such a computational graph, along with toy examples of sub-tasks and tasks would go a long way to make this section clearer and improve the smoothness of the reading. 2. In Section 3 you define and explain the different tasks and subtasks of your testbed. While Figure 1 is very nice and contributes a lot, it does not explicitly show the different sub-tasks or the procedures involved in deriving the output from each input, and in some cases (for example the counts in PERM) it may take time for the reader to understand what are the exact tasks. I think a more explicit demonstration of the procedure would be very helpful. It can either be a step-by-step demonstration of the procedure for each task (added in the appendix for brevity), or even a textual derivation of the procedure applied to clarify the operations being performed at every step. 3. In section 4, it will be very useful to add a table with an example input and output used for each task and their statistics (e.g. length, histogram on number of neighbor steps needed etc). If the inputs and outputs in Figure 1 are representative, you can also say that directly and point there.

Rating

7

Confidence

4

Soundness

4

Presentation

3

Contribution

3

Limitations

The authors discuss some limitations, but do not directly address the generalizability of their findings to natural tasks subtasks composition.

Reviewer qmuR4/10 · confidence 2/52024-07-15

Summary

The paper investigates the capabilities of Transformer-based language models in learning compositional discrete tasks. The authors evaluate both training LLaMA models and prompting GPT-4 and Gemini-Pro on tasks that require the learning of compositions of several discrete sub-tasks. The results indicate that these models exhibit significant sample inefficiency: LLaMA models require more data to learn compositional tasks than to relearn all sub-tasks from scratch, and in-context prompting with GPT-4 and Gemini is unreliable and often fails in multi-round code generation. The findings are supported by a theoretical analysis showing the sample inefficiency of gradient descent in memorizing feedforward models.

Strengths

- The paper evaluates both training from scratch and in-context prompting methods, providing a thorough analysis of the models' capabilities. - The authors introduce new algorithmic tasks designed to test compositional learning and providing a theoretical framework to support the empirical findings. - The study offers a deep dive into the limitations of current LLMs, supported by both empirical data and theoretical arguments, which can guide future research in learning compositional tasks.

Weaknesses

- The tasks and settings used in the experiments may not cover the full range of real-world applications, limiting the generalizability of the findings. - The performance and conclusions drawn are heavily dependent on the specific tasks designed by the authors, which might not fully represent other compositional learning scenarios. - Personally, it took me a while to understand how the given algorithmic tasks are designed and how they relate to the broader context of compositional learning. For instance, the `PERM' problem was not immediately intuitive to me.

Questions

- How well do the findings translate to practical, real-world applications beyond the synthetic tasks used in the experiments? Any specific reason to introduce new algorithmic tasks for evaluation? - Would the models perform differently on a broader variety of compositional tasks, particularly those that are more complex or domain-specific? - What specific modifications to model architecture or training strategies could be employed to enhance the sample efficiency of Transformer models in compositional learning?

Rating

4

Confidence

2

Soundness

2

Presentation

2

Contribution

2

Limitations

- The study focuses on a limited set of compositional tasks, which may not fully capture the diversity of problems faced in real-world applications.

Reviewer Fa352024-08-09

Thanks for the response and clarifications. 1. Using ideas like "a few demonstrations" is just not formal. And dressing this up as a formal hypothesis just seems to be misdirection when the experiments just choose some arbitrary number out of thin air. This is honestly a small part of the paper, and does not majorly impact my opinion, but it is bad practice. 2. Thanks for the discussion here. I agree that it is a tricky issue for sure, but I am still not totally convinced that these must be the ways to decompose the tasks or that it is conclusive that the model is actually learning them in the way presented. 3. Thanks for the figure. It is still not clear to me why the new task definitions are necessary. 4. Thanks again for the clarification. Indeed adding the hints that get closer to showing how to do composition is maybe helpful. I guess my point was that maybe these synthetic tasks are missing the diversity of natural data that may have more examples of *how* to do composition in a general sense. And just training on narrow subtasks and expecting composition to arise seems unrealistic (and also not being suggested by people in the literature as being something that would occur, to my knowledge) 5. Thanks for these extra experiments and investigation. This does seem to be better evidence that the tokenization is not a major issue. I will increase my score to a 4 to reflect the partial resolution of some of the issues I raised, but I think the remaining issues still leave the paper below the bar for acceptance in my mind, especially with several substantial changes to the paper being suggested.

Authorsrebuttal2024-08-11

Thank you for raising your score, for the additional comments on our work, and for your involvement in the review process, we really appreciate it. **(1)** We agree that the definition right now lacks formality and that this should be addressed. We propose a simple variation of our initial hypothesis, which does not affect either our observations or our experimental setup, yet fixes the weak definition of H1. - H1. A Transformer language model learns a compositional task with fewer samples than those required to learn its most difficult sub-task. - H2. A Transformer language model learns a compositional task with fewer samples than the sum of the samples needed to learn every sub-task. - H3. A Transformer language model learns a compositional task with approximately (the same order of magnitude) as many samples as the sum of the samples needed to learn every sub-task. - H4. A Transformer language model needs more data samples than in H3. **(2)** It is indeed hard, given the limited explainability of the internal mechanisms of Transformer models, to establish whether or not the model is effectively learning certain operations. However, the experiments on the task decomposition represent in our view a solid clue that LLaMa learns internal operations related to the set of primitives that we define (since pre-training on the compositional task results in a faster learning of the individual sub-tasks). Additionally, we argue that this experiment also proves the validity of our choice of primitives: when trained only on the compositional task, the model autonomously converges to operations that are related to them and can effectively compose them to solve the task. Hence, we believe that assuming that the model should be able to leverage the primitives in the given sub-tasks to learn the compositional task does not seem too far-fetched. This, in some sense, links back to some of your remarks in the initial review which we might now have completely addressed in the previous response. > Just because we can posit one way to compositionally solve the task does not mean that the model will learn that way (or even that it can necessarily represent that composition) In practice, the experiments on de-compositionality show exactly these two points. To sum up the rather long discussion on the topic, these were the main important clarifications and arguments. - _atomicity_: the sub-tasks are effectively atomic units roughly corresponding to a basic block of operations in the equivalent procedural programming language; - _uniqueness_: the sub-tasks are not unique because we could consider an arbitrary set of sub-tasks composed of primitives or combinations of primitives that make each one of them observable. However, we choose the minimal set of sub-tasks that makes every operation observable. - _validity of the primitive set_: experiments on task de-composition corroborates the hypothesis that the considered primitives can be learned and be effectively composed when training only on the full compositional task. This represents a validation of our choice of primitives and our experimental setup in general. - _relativity_: the measured inefficiency is relative to our specific definition of sub-tasks and primitives, as correctly pointed out. However, considering all the points above, we speculate that similar results could be measured also for alternative definitions. **(3)** We included an extensive rebuttal on the nature of the introduced tasks and why they are a meaningful contribution to the community in general in the response to reviewer teuc. We include a summary of our main arguments in the following list. - First, a main driver for the design of our new tasks was the absence in the landscape of research on compositional learning of algorithmic tasks based on the pointer execution (PE), a synthetic evaluation task first introduced by Bengio et al. [20] to test the generalization capabilities of deep learning models. This task limits the number of confounders in the data and, therefore, reduces (if not annihilates) the number of shortcut solutions that the model can find. In other words, pointer execution tasks force the model to learn an algorithmic (general) solution by design and not rely on any possible statistical shortcut that might compromise the validity of the observations. - Second, PEN and PERM are particularly suitable for benchmarking compositionality due to their algorithmic nature. We can decompose them into single atomic operations (referred to as primitives in the text), which can make learning the task easier if the model can identify and leverage their compositional nature. - Finally, our tasks represent a unique example in the sense that the failure of GPT-4 and Gemini-Pro is very apparent despite extreme help, e.g., providing multi-shot examples and showcasing limited compositionality of current SOTA models better than any task we are aware of.

Authorsrebuttal2024-08-11

**(4)** We agree with you that the synthetic tasks considered might be missing the diversity of natural data that may have more examples of how to do composition in a general sense. This is intentional. We chose to provide the model only with a minimal set of sub-tasks and avoid this kind of redundancy. Firstly, because in these settings the risk of learning spurious correlations and other possible confounding phenomena (such as the unobserved local structures anomalies pointed out by DGs4) would increase, possibly compromising our results. Secondly, because increasing the set of observed combinations of primitives beyond the minimal set is itself an inefficiency. We could also have provided many more combinations of sub-tasks to artificially "simulate" this regime, but that would have added an additional dimension to our investigation that is, however, inefficient by design. Finally, we cannot see any reason why a model that does not perform well on simple, well-defined synthetic tasks would perform better in a more natural and complex setting. Instead, the only solution that we see to the learning inefficiency consists in adding more inductive bias into the model, as was the case for example in our experiments with the additional prediction heads (experiments with the _auxiliary loss_ in Section 4.1). **(5)** We are happy to hear that our additional results on tokenization were satisfying. Thanks again for suggesting to investigate more closely into this aspect of our experiments. Finally, we understand your concern regarding the excessive changes to our initial submission. However, most of the proposed changes would be added in the form of Appendix material to address possible objections and secondary aspects of our study (e.g., tokenization, other models, etc.). The changes in the main document would concern mostly the presentation of the tasks, on which many reviewers (rightfully) had some concerns, while the main message of the paper and the main empirical results would remain consistent with the original submission.

Reviewer DGs42024-08-12

Thank you for the detailed responses. Many of questions were responded to and clarified and I'm more confident in my evaluation. I would like to note that my main concern which is the synthetic nature of the experiments remains unanswered. I appreciate the authors attempt to provide additional experimental results in the short rebuttal time. However, using English-words as tokens does not make it "in-distribution" as these n-grams are completely out-of-distribution compared to the training data of the model. If anything, using common full-word tokens as inputs induce a strong prior as encoded in their embeddings and is thus expected to deteriorate the performance. It is not trivial to design a similar testbed that does simulate an in-distribution task, but is a pursuit that if achieved will be most beneficial. Nevertheless, even this intermediate step of investigating the compositional abilities of model in a synthetic controlled setting is interesting and enriches our knowledge about the properties of transformer based language models. I thus wish to thank the authors for the answers, and choose to keep my score as is.

Authorsrebuttal2024-08-14

Thanks for your additional comments on our rebuttal, we are glad to hear that many of your questions were clarified and that you are even more confident about your positive judgment on our submission. Regarding the synthetic nature of the experiments, we understand your concerns and we agree that the scope of the additional experiments on Natural-PEN might be limited if the goal is to evaluate to what extent the pre-training can improve the compositionality of these large models. This ablation was mostly proposed to check whether the use of "rare" tokens in the tasks had an impact or not on the performance. We also agree that the design and evaluation of a similar testbed that simulates an in-distribution task will be valuable future work, but at the same time we still strongly argue for the importance of an evaluation on a synthetic setting which allows full controllability (see also the discussion on this with reviewers teuc and Fa35). Once again, thanks for your positive and constructive feedback and for your involvement in the review process, which we deeply appreciate.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC