acceptodds
Published as a conference paper at NeurIPS 2026

How Do Language Models Compose Functions?

Apoorv Khandelwal, Ellie Pavlick

Abstract

While large language models (LLMs) appear to be increasingly capable of solving compositional tasks, it is an open question whether they do so using compositional mechanisms. In this work, we investigate how feedforward LLMs solve two-hop factual recall tasks, which can be expressed compositionally as . We first confirm that modern LLMs continue to suffer from the "compositionality gap", i.e. their ability to compute both and does not entail their ability to compute the composition . We then decode residual stream representations and identify two processing mechanisms: one which solves tasks *compositionally*, computing along the way to , and one which solves them *directly*, without any detectable signature of the intermediate variable . Finally, we find that embedding space geometry is strongly related to which mechanism is employed, where the idiomatic mechanism is dominant when tasks are represented by translations from to in the embedding spaces.

Keywords:
Sydney

Reviews

Among:
Shape:
123456this paper, Bottom 49%
Figure 1. Mean review rating of the reviewed papers at NeurIPS 2026. This paper averages 4.33 over 3 reviews, above 49% of the others.
Reviewer_GFE1OpenReview ↗
Rating
4
Clarity
3
Confidence
4
Originality
3
Quality
3
Significance
3
Read review
Summary

The paper studies the mechanism by which LLMs solve multi-hop questions of the form g(f(x)), for which two strategies exist: 1. "Idiomatic" prediction, where the LLM directly memorizes g(f(x)); 2. Compositional, where the model computes f(x) and then applies g. The authors apply the logit lens to quantify a "signature" of the first step of the compositional solution, f(x). The authors compose a dataset including different types of compositional questions, such as the Spanish translation of an antonym, the birth year of the singer of a given song, etc. It is demonstrated that the ability to solve the individual questions f(x) and g(x) does not correlate with the ability to solve the composition (compositional gap). Then, the paper analyzes the mechanism of the solution with the logit lens. It is demonstrated that in some of the examples there is a signature of the compositional solution in the form of a high reciprocal rank of f(x). Finally, it is shown that there is a medium-strong negative correlation between the existence of a steering vector mapping the subject to the final answer and the proxy for the compositional solution.

Strengths and weaknesses

The paper studies a very interesting question that has implications for the practicalities of LLM usage, as compositional solutions are presumably more generalizing (although this is not directly tested in the paper). Beyond the practical uses, there is scientific interest in understanding LLMs' factual recall as a model of human factual recall, and in identifying whether a symbolic, compositional solution is necessary for an agent that shows high linguistic competence. The experimental design is mostly clear, and the new compositional dataset is clearly described and used. The findings, particularly the lack of correlation between performance and compositionality and the representational evidence, are interesting.

I think, however, that there are several issues that should be addressed. First, the writing seems hasty at times, with some of the experimental details not clearly stated (e.g., how exactly the steering vectors are calculated).

More importantly, I am not convinced by the construct validity of the evaluation, i.e., whether it actually measures what it aims to measure. The goal is to quantify compositional behavior, but in practice the main metric being used is the maximum reciprocal rank of the first answer f(x). It's not clear whether this is indeed a good metric of a compositional solution. First, f(x) can appear in the representation even if the model directly computes g(f(x)). I'm not quite sure that the causal intervention experiments in the appendix mitigate this concern, as the representation being patched might contain features necessary for the identification of x (which is required to compute the answer regardless of whether the model computes compositionally or not). Second, the experiments do not control for different confounds.

The experimental pipeline constructs ICL examples with a mapping x→g(f(x)) for particular g, f, and then presents the model with a test example. For the logit lens of f(x) to be regarded as a signature of a compositional solution, it is necessary to show that f(x) selectively appears when the model is queried with examples showing the f() relation, and not with others. The null hypothesis that is not tested is that f() always appears in the logit projection for particular xs, even if the model is asked to solve the zero-shot ("the birth year of the author of X is…"), or that f(x) appears even when the model is queried with f'≠f. It seems to me that f(x) appearing in the projection can be interpreted as evidence that the model knows f(x) at all, which is presumably a prerequisite for a compositional solution. More broadly, it is not so clear to me why the paper focuses on the ICL setting, as opposed to directly querying the model with the 2-hop question.

The causal experiments in appendix J are hard to interpret: in addition to the methodological issue I mentioned above, it seems the causal effect is stronger when the solution is NOT compositional, according to the proxy metric. Isn't this the opposite of what we expect to see?

Questions

Regarding the representational finding in Figure 4, the correlation is interesting, though I am curious about the interpretaiton of the authors to this finding. For the antonym-translation composition, do you really belief that this solution is not computed compositionally? it seems to me hard to believe that the model stores in its parameters tens of thousands of such compositions, which rarely appear in the training data.

Regarding figure 1, in an about third of the examples the orange bar > the yellow bar, i.e., the model supposedly solves the composition without solving the individual questions. These are examples that cannot be compositional, right? do you indeed see near-zero reciprocal rank for f(x)? It's also seem a bit suspicious that the model can, e.g., solve the antonym-german question without being able to solve the individual questions...

Limitations

yes

Paper formatting concerns

no

Final justification

the author response mitigates most of my concerns, but I still think the causal experiment I described is worth running, and the writing should improve. I increase my score to weak accept.

Reviewer_KLvyOpenReview ↗
Rating
4
Clarity
2
Confidence
3
Originality
3
Quality
3
Significance
3
Read review
Summary

The paper studies the phenomenon of compositionality in LLMs by studying the mechanism by which LLMs compose two tasks. First the authors demonstrate the compositionality gap in the models they study (Figure 1, 2 and the r^2=0). Then they focus on cases where the model does successfully compose, where they use logit lens style analysis to understand what happens in cases where the model appears to compose - in these cases they look for f(x) in the residual stream - where in Figure 3 they they look for f(x) and x (and g(x), f(g(x))) in the residual streams. Finally the authors propose an alternative which is that certain relationships are learnt through translation in embedding->unembedding space rather than composition; i.e., the model learns g(f(x)). They measure whether a task can done by translation or not by training a linear regression model.

Strengths and weaknesses

Overall the paper has interesting findings and strong claims, each with varying amounts of evidence, so I'll address them one claim at a time

Compositionality Gap

This is perhaps the most well demonstrated claim - that modern LLMs have a compositionality gap and their tasks do measure it. I think the compositonality gap goes deeper than these tasks indicate, for example I do not think recursion is well captured by this set up - none of the tasks the authors used seem to be f(f(x)). Additionally, I would love to know how modern SoTA LLMs perform on these tasks (ChatGPT, Gemini, Claude etc). However this section is already fairly strong - with large task diversity and comparison across many models.

Looking for f(x)

The second claim is that models do not always solve compositional tasks using composition, and the evidence provided is based on a logit-lens analysis. The authors do acknowledge that there are shortcomings to this approach (in section 4.1). I would like to see other approaches - for example if we ask the model to perform f(x), is there a relationship between the embeddings vs when we ask it to do g(f(x))? I do think Appendix J partially begins to address my concerns here, I would love to see it moved to the main body of the paper and expanded on - it currently only demonstrates results for a few task combinations, I wonder if we could construct tasks to do this kind of activation patching analysis.

Solving directly v/s solving compositionally

This section has a good experiment and analysis but I worry that the findings are easily confounded but there is no study of confounders. The authors find a correlation between tasks' ability-to-be-solved-by-translation v/s the presence of intermediate variables in the residual stream of models. Based on the experiments the claim could definitely be that "Embedding geometry is a good predictor of the observed processing signature.", but the current claim seems to be that "Embedding geometry causes the model to choose direct processing.". To support the latter I would expect at least a few confounders to be studied and ruled out, some examples: If x->f(g(x)) is more prevalent in training data, the model might be memorizing it, and the task would also be more doable through translation. Some proxy variable to measure prevalence in training data would be good. Perhaps training loss on the Question Answer pairs could be a good proxy.

Other Issues

  1. Very often the evidence provided in the Appendix is necessary for the argumentation in the main body. Perhaps the appendix can be compressed into easier to read plots and moved to the main body?
Questions

First concern is the logical leaps being made - I might bump my score a little if the claims were made weaker; But I would be concerned about significance if the claims were made weaker.

If the claims had stronger evidence (both the causality for the composition v/s translation claim AND the detection of intermediate variables) I would increment my score. Potential ablations for both were mentioned in strengths and weaknesses section already - sorry for not being able to follow the review template in this case.

Limitations

yes

Paper formatting concerns

N/A

Final justification

Comments somewhat addressed

Reviewer_EMSkOpenReview ↗
Rating
5
Clarity
3
Confidence
4
Originality
3
Quality
3
Significance
3
Read review
Summary

The authors study two-hop recall tasks through the lens of compositionality: do models pass through the intermediate state when answering a two-hop question? Or do they jump directly to the answer?

Strengths and weaknesses

Strengths:

  • Interesting and well-motivated question for understanding models' internal reasoning processes.
  • Clear and well-written paper with connection to broader questions about compositionality.
  • I'm geniunely surprised at the (still) relatively large compositionality gap of o4-mini and DeepSeek-R1
  • The shift in token rank from x -> f(x) -> g(f(x)) is compelling (along with the causal interventions in the appendices)

Weaknesses:

  • Parts of the paper read as overly defensive. For example: "Our findings reflect our specific tasks and experimental design." I understand that reviewers often don't understand the point of interpretability papers or ask for nonsensical experiments, but some of this took me out of the flow of the narrative.
  • It seems possible that the model does pass through an intermediate state and "compose" functions even when logit lens or patchscope doesn't pick it up? This just says that it may not represent the intermediate state in a way decodeable by these tools?

General Comments:

  • I don't understand this sentence in the Figure 3 caption: "The incorrect composition, f (g(x)), is shown by the red line when not distinct from g(f (x))." Should this be "when distinct from"?
  • I found the explanation in 5.1 to be confusing and it took me a few reads to understand what you actually did and I'm still not 100% sure: train a vector that you add to the averaged embeddings to predict the correct unembedding vector? While this seems to work, it's not clear to me that the correct thing to do is map directly to the unembedding vector (the unembeddings probably live in a different space than the residual stream)?
Questions

Did you use logit lens or the tuned lens? I've seen the tuned lens able to give meaningful decoding results much deeper in the model (although it seems like your logit lens results are surprisingly good?)

Limitations

It may be mentioned, but I think it's reasonable to emphasize that the absence of decodeable intermediate representations doesn't mean absence of intermediate representations.

Paper formatting concerns

N/A

Comments on the paper

1 comment
Meta-review

(a) Scientific claims and findings

This paper studies whether language models answer two-hop factual queries by composing functions or by relying on a direct association. Its strongest finding is a robust compositionality gap across relations and models. It further uses probing, activation interventions, and embedding geometry to characterize when an intermediate representation is detectable. The response clarifies the intended scope of these analyses: they provide evidence about representational signatures associated with composition, not a complete identification of a unique causal mechanism.

(b) Main strengths

The question is fundamental and the empirical core is unusually informative. The dataset, cross-model analysis, and attention to internal representations go beyond accuracy-only evaluation. Reviewer EMSk found the residual-stream progression and interventions compelling, while Reviewer KLvy regarded the compositionality-gap result as particularly strong. The response improves the paper by distinguishing predictive evidence from stronger causal claims and by addressing the requested controls and methodological details.

(c) Main weaknesses

The decoded rank of an intermediate fact is not itself a definitive test of compositional computation: presence may reflect knowledge rather than use, and absence may reflect decoder limitations. Likewise, the geometry analysis is strongest as a predictor of the observed signature, not as proof of causal mechanism selection. Reviewer GFE1 also raises reasonable cautions about what patching transfers. These are important limitations, but they constrain the interpretation more than the empirical finding itself.

(d) Assessment of the author response

The response substantially resolves the decision-critical issues by clarifying the construct being measured, providing or discussing selectivity and intervention controls, and narrowing causal language where the evidence is correlational. It also makes the lens, steering construction, and relation between geometry and the decoded signature clearer. I find this sufficient for acceptance provided that these qualifications and controls are incorporated prominently in the revision.

(e) Reviewer discussion and response

The reviewers agree that the compositionality-gap observation is valuable. Reviewer EMSk remained positive, while Reviewers GFE1 and KLvy appropriately pressed on construct validity and causal interpretation. After the response, the record supports a bounded interpretation of the mechanistic analyses rather than rejection of the paper's main empirical contribution.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.