TLDR: A position paper proposes AlgEval, a framework to systematically understand the algorithms LLMs learn and use, focusing on identifying basic “algorithmic primitives” and their composition. A case study on graph navigation shows LLMs don’t use classical search algorithms but rather emergent, competition-driven strategies. This research advocates for algorithmic understanding as an alternative to pure scaling, aiming for more efficient, transparent, and reliable AI.
Large Language Models (LLMs) have become incredibly powerful, but a fundamental question remains largely unanswered: What specific algorithms do these models actually learn and use to solve problems? Current research often prioritizes improving performance through sheer scale, leaving a significant gap in our theoretical and empirical understanding of how these complex systems arrive at their solutions.
This challenge leads to issues with transparency, trustworthiness, and compliance with AI regulations. Without understanding the underlying computational steps, it’s difficult to truly interpret why an LLM makes a certain decision or how to make it more reliable.
To address this, a new framework called AlgEval is proposed. AlgEval aims to systematically investigate the algorithms LLMs learn and employ. It focuses on uncovering “algorithmic primitives” – the basic, fundamental operations reflected in the model’s internal workings, such as its latent representations, attention mechanisms, and inference-time computations. The framework also seeks to understand how these primitives are combined to solve specific tasks.
The authors argue that this algorithmic understanding offers a crucial alternative to the current resource-intensive scaling paradigm. By understanding the algorithms, we can potentially develop more sample-efficient training methods, improve performance, and design novel AI architectures, including those for multi-agent systems. This approach could lead to more human-understandable interpretability, allowing us to grasp the model’s internal reasoning.
Unpacking AlgEval: Primitives, Composition, and Evaluation
AlgEval conceptualizes algorithms as modular subroutines that can be reused and recombined. It proposes building a “vocabulary” of algorithmic primitives. Examples of such primitives identified in existing interpretability research include function vectors (for in-context learning), vector arithmetic, steering vectors, and key-value memory retrieval. These are considered domain-general building blocks.
The framework then looks at “algorithmic composition” – how these basic primitives are combined to form more complex algorithms. This ties into the broader debate about whether LLMs truly engage in compositional reasoning or if their performance relies on less effective strategies like memorization.
To evaluate these algorithms, AlgEval integrates existing interpretability techniques with new approaches. Key methodologies include analyzing neural representations (patterns of activity across layers) and attention mechanisms (how information flows between tokens). These analyses help reveal the network structures and transformations that underpin algorithmic primitives and their composition. The framework also emphasizes the identification of “subgraphs” and “circuits” within the model that perform specific functions.
The paper outlines five crucial steps for implementing AlgEval: (a) identifying and cataloging algorithmic primitives, (b) designing simple tasks that require these primitives, (c) creating a library of mechanisms that implement the primitives, (d) analyzing how primitives compose, and (e) using ablation studies to determine the role of specific primitives.
New Frontiers: In-Context Learning and Inference-Time Compute
AlgEval extends its focus to modern LLM paradigms. It investigates how In-Context Learning (ICL) influences the use of specific algorithms. Furthermore, it applies to “inference-time compute,” where LLMs perform intermediate computations through their sequential outputs, such as Chain-of-Thought prompting or explicit tree search. This sequential output can be more amenable to algorithmic analysis than the high-dimensional computations of a single feedforward pass. The paper also highlights how reinforcement learning, as seen in models like DeepSeek R1, can lead to emergent behaviors like backtracking by enabling “learning to infer” through compressed memory representations.
A Case Study in Graph Navigation
To demonstrate its utility, the paper presents a case study on LLMs performing graph navigation tasks, specifically finding paths between rooms in a tree-like graph. The researchers tested whether models like Llama-3.1 (8B and 70B parameters) implement classical search algorithms such as Breadth-First Search (BFS) or Depth-First Search (DFS).
The findings were insightful: the LLMs’ attentional and representational patterns did not neatly align with these classical search algorithms. Instead, the models appeared to incrementally direct attention towards the correct path, and the representations of key nodes (like the goal and competing nodes) progressively separated across layers. This suggests a “competition-driven separation” as an emergent algorithmic strategy, rather than an exhaustive search. Interestingly, scaling up the model from 8B to 70B parameters showed similar patterns, only more pronounced, indicating a consistent underlying strategy.
This research underscores the importance of algorithmic explanations in making LLM behaviors interpretable, especially when they deviate from human-designed algorithms. For more technical details, you can refer to the full research paper: Position: We Need An Algorithmic Understanding of Generative AI.
Also Read:
- Unpacking How AI Designs Algorithms: A Deep Dive into LLM-Generated Optimizers
- The ‘Lost-in-the-Later’ Effect: A New Look at How LLMs Use Context
Looking Ahead
The authors call for more theoretical research to bridge the gap between high-level explanations and low-level processes in LLMs. Future directions include designing AI architectures with algorithms in mind, incentivizing algorithmic building blocks during training, and steering LLMs towards specific algorithms through training or in-context learning. Ultimately, a deeper algorithmic understanding of LLMs promises to enhance their sample efficiency, reduce environmental emissions, improve safety compliance, and help address algorithmic bias, leading to more transparent, reliable, and theoretically grounded generative AI.


