Complexity Control Facilitates Reasoning-Based Compositional Generalization in Transformers

Zhongwang Zhang, Pengxiao Lin, Zhiwei Wang, Yaoyu Zhang, Zhi‐Qin John Xu

Abstract

Transformers often rely on memorization rather than learning underlying logical rules, leading to failures in compositional generalization. This paper demonstrates that "complexity control"—achieved through smaller parameter initialization scales and higher weight decay—is critical for shifting models from rote memorization to rule-based reasoning. By restricting model capacity, Transformers are incentivized to learn simpler, primitive-level rules that generalize to out-of-distribution (OOD) scenarios.

Introduction: The Memorization Trap

Despite their success, Transformers frequently struggle with compositional generalization: the ability to take known concepts in novel ways. While a model might achieve near-perfect accuracy on training data (In-Distribution), it often fails when encountering new combinations (Out-of-Distribution). This research investigates whether models are truly learning logic or merely memorizing input-output mappings, and how we can steer them toward the former.

Methodology and Complexity Control

The authors identify two primary levers for controlling model complexity:

  1. Initialization Scale: Controlled by an "initialization rate" ($\gamma$), where higher $\gamma$ implies a smaller initial weight scale.
  2. Weight Decay: A standard regularization technique that penalizes large weights, further constraining the model's effective capacity.

To analyze these effects, the study employs mechanistic interpretability tools, including attention masking, neuron condensation analysis, and stable rank measurements to quantify the effective dimensionality of weight matrices.

Experimental Setup: The Two-Anchor Task

A central benchmark in this study is the Two-Anchor Composite Function task. In this synthetic environment, models must apply sequential arithmetic operations (e.g., $+5$ then $-2$) to a "key token."

The Two-Anchor Composite Function task setup, illustrating how seen and unseen anchor pairs are used to test In-Distribution (ID) and Out-of-Distribution (OOD) performance.

This setup allows for a clean separation between seen combinations (used for training and ID testing) and unseen combinations (used for OOD testing), directly measuring the model's ability to compose learned primitives.

Key Insights: The Three Phases of Learning

The research identifies a clear transition in model behavior governed by complexity control, categorized into three distinct phases:

  • Phase 1: The model fails to learn even the training data due to excessive or insufficient complexity constraints.
  • Phase 2 (The Memorizer): The model achieves high ID accuracy but zero OOD generalization. It treats composite mappings as unique, memorized entities.
  • Phase 3 (The Reasoner): The model achieves high accuracy on both ID and OOD data. It learns individual "primitive" rules and composes them logically.

A crucial finding is that reasoning-based solutions possess lower complexity (lower stable rank) than memorization-based ones. By "squeezing" the model's capacity, it is forced to find the simplest explanation—the underlying rule.

Results and Generalization

The benefits of complexity control were validated across multiple benchmarks:

  • Concept Graphs: Reducing initialization scale fixed a common failure mode where models incorrectly combined attributes (e.g., generating a triangle instead of a circle).
  • SCAN & COGS: Models with strong complexity control consistently outperformed standard models on OOD tasks.
  • Reasoning vs. Speed: While memorization is initially "easier" for the model to fit, finding the logical rule in the reasoning phase requires more training steps as task complexity increases, indicating a deeper search for generalizable patterns.

Conclusion and the Memory-Reasoning Dilemma

While complexity control facilitates reasoning, it introduces a trade-off: the model's ability to memorize arbitrary, non-logical facts (like specific dates or names) may be impaired. Future work may explore hybrid architectures, such as Mixture of Experts (MoE) or Retrieval-Augmented Generation (RAG), to balance the need for both robust reasoning and factual memory.

Summary updated

BibTeX
@misc{zhang2025complexity,
  author = {Zhongwang Zhang and Pengxiao Lin and Zhiwei Wang and Yaoyu Zhang and Zhi‐Qin John Xu},
  title = {{Complexity Control Facilitates Reasoning-Based Compositional Generalization in Transformers}},
  year = {2025},
  eprint = {2501.08537},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.08537},
}
Figure