Skip to main content
QUICK REVIEW

[Paper Review] Compositional Processing Emerges in Neural Networks Solving Math Problems

Jacob Russin, Roland Fernandez|arXiv (Cornell University)|May 19, 2021
Natural Language Processing TechniquesComputer Science13 references21 citations
TL;DR

This paper investigates whether neural networks solve math problems through compositional processing—breaking down expressions into subcomponents, computing their values, and combining them according to rules like order of operations. Using activation analysis in transformers trained on the Mathematics Dataset, the authors find strong evidence that representations of partial results emerge at operator positions, indicating that models implicitly learn and apply compositional semantics without explicit architectural design.

ABSTRACT

A longstanding question in cognitive science concerns the learning mechanisms underlying compositionality in human cognition. Humans can infer the structured relationships (e.g., grammatical rules) implicit in their sensory observations (e.g., auditory speech), and use this knowledge to guide the composition of simpler meanings into complex wholes. Recent progress in artificial neural networks has shown that when large models are trained on enough linguistic data, grammatical structure emerges in their representations. We extend this work to the domain of mathematical reasoning, where it is possible to formulate precise hypotheses about how meanings (e.g., the quantities corresponding to numerals) should be composed according to structured rules (e.g., order of operations). Our work shows that neural networks are not only able to infer something about the structured relationships implicit in their training data, but can also deploy this knowledge to guide the composition of individual meanings into composite wholes.

Motivation & Objective

  • To investigate whether neural networks trained on math word problems implicitly learn and apply compositional semantics, similar to human cognition.
  • To determine if models decompose arithmetic expressions into subcomponents, compute their values, and combine them via structured rules such as order of operations.
  • To assess whether compositional processing emerges in standard transformers and TP-Transformers without explicit architectural support for compositionality.
  • To evaluate the extent to which learned representations encode partial results, particularly at operator positions.
  • To understand the implications of emergent compositionality for generalization and systematic reasoning in neural networks.

Proposed method

  • Trained standard transformers and TP-Transformers on the Mathematics Dataset, which contains 112 million math word problems across multiple domains.
  • Performed representation probing by analyzing hidden state activations across the input sequence to detect when and where partial results (e.g., values of sub-expressions) are encoded.
  • Used correlation analysis between hidden states and expected partial results (e.g., 20 for '4*5') to identify representations aligned with sub-expression values.
  • Focused on operator positions to test whether they encode the results of operations (e.g., '+' or '*' positions encoding the sum or product of operands).
  • Recomputed correlations across the full input sequence to assess whether constituent symbols also carry information about their sub-expression values.
  • Compared results between standard transformers and TP-Transformers to evaluate the impact of tensor product representations on compositional learning.

Experimental results

Research questions

  • RQ1Do neural networks trained on math problems implicitly learn to decompose expressions into subcomponents and compute their values compositionally?
  • RQ2Are representations of partial results encoded in the hidden states of transformers, particularly at operator positions?
  • RQ3To what extent do standard transformers and TP-Transformers differ in their ability to represent compositional semantics?
  • RQ4Does the presence of partial result representations correlate with improved generalization on out-of-distribution problems?
  • RQ5Can emergent compositional processing in neural networks be linked to systematic reasoning and combinatorial generalization?

Key findings

  • Hidden state representations at operator positions in both standard and TP-Transformer models show strong correlations with the numerical values of sub-expressions (e.g., r = 0.47 for TP-Transformer on '4*5+2*3').
  • Representations of constituent symbols (e.g., digits and operators) also carry information about their sub-expression values, with correlations of r = 0.201 (TP) and r = 0.189 (standard) for partial results.
  • The correlation between hidden states and partial results peaks at operator positions, indicating that these locations encode the results of intermediate computations.
  • Despite strong evidence of compositional processing, correlations are not perfect, suggesting that representations encode more than just quantities—possibly including constituent structure and context.
  • The models generalize poorly on extrapolation tasks (e.g., larger numbers, more terms), indicating that emergent compositionality is imperfect and insufficient for full systematic generalization.
  • The results suggest that compositionality emerges in neural networks through large-scale training on diverse data, even without explicit architectural support for compositionality.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.