AlgoTrace: Algorithmic Primitives and Compositional Geometry of Reasoning in Language Models
The paper introduces AlgoTrace, a framework that identifies and manipulates reusable algorithmic primitives within the latent space of large language models, demonstrating that multi-step reasoning can be steered and composed through geometric operations on these vectors to enhance cross-task generalization.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Large language models are the engines behind modern artificial intelligence, capable of writing stories, solving equations, and navigating complex logic puzzles. For years, scientists have wondered how these systems actually think. Do they simply memorize patterns from their training data, or do they perform genuine, step-by-step reasoning? To answer this, researchers have begun looking inside the models, not at the words they produce, but at the invisible mathematical signals that flow through their internal layers as they work. These signals, often called latent activations, are the raw material of thought within the machine. The question has been whether these signals form a structured map where specific types of thinking happen in specific places, much like how different parts of the human brain specialize in different tasks. If such a map exists, it would mean that reasoning is not a chaotic blur, but a journey through a landscape of distinct, reusable mental tools.
A team of researchers has now mapped this landscape, revealing that large language models do indeed rely on a set of basic, reusable building blocks to solve problems. They call these building blocks "algorithmic primitives." Think of a primitive as a single, fundamental step in a larger process, such as finding the closest city to your current location when planning a trip, or checking if a mathematical equation balances. The researchers developed a new method to trace these steps as they happen inside the model. By watching how the model's internal signals change while it solves difficult problems, they were able to group similar moments of thought together. They found that when the model is solving a complex puzzle, it moves through a sequence of these distinct mental states, much like a traveler moving from one town to the next on a map.
To understand what was happening, the team tested the models on four very different types of challenges: finding the shortest route for a traveling salesman visiting multiple cities, solving logic puzzles with true and false statements, tackling difficult math competition problems, and navigating through a virtual maze. As the models worked through these tasks, the researchers recorded the internal signals at every step. They used a computer program to group these signals into clusters, finding that certain groups of signals consistently appeared when the model was doing specific things, like calculating a distance or verifying a solution. They then used an automated system to read the text the model was writing at those exact moments, confirming that the internal signals matched the external actions. For instance, one cluster of signals always appeared when the model was picking the nearest city to visit next, while another appeared when it was double-checking its work.
The most significant discovery was that these mental building blocks are not just passive markers; they can be actively controlled. The researchers extracted a specific "vector," which is essentially a direction in the model's internal space, for each of these primitives. They then injected these vectors back into the model while it was thinking. When they added the vector for "finding the nearest neighbor," the model immediately started using that strategy more often, even if it wasn't the best approach for the specific problem. When they added the vector for "generating a new path," the model began exploring more options. This proved that these internal signals are the direct cause of the model's behavior. By turning a specific mental switch on or off, the researchers could steer the model to think differently, suggesting that the model's reasoning is composed of these distinct, manipulable parts.
The study also showed that these building blocks can be combined. Just as you can mix primary colors to create new shades, the researchers found that adding two different primitive vectors together created a new, combined behavior. For example, they could take a vector that helped a model find the end of a path and another that helped it compare values, mix them, and the model would suddenly become capable of a more complex task that required both skills. This suggests that the model's ability to reason is not a single, monolithic skill, but a flexible geometry where simple operations can be assembled into complex solutions.
Furthermore, the researchers compared a standard model with one that had been specially trained to reason better. They found that the trained model used these building blocks more effectively. It relied less on brute-force guessing and more on structured steps like verification and planning. The trained model also showed a greater ability to transfer these skills from one type of problem to another. A mental tool learned while solving a math problem could be successfully used to help solve a navigation puzzle. This indicates that the training process did not just teach the model more facts, but actually strengthened its ability to compose and reuse these fundamental reasoning steps across different domains.
The findings offer a new way to look at artificial intelligence. Instead of viewing these models as black boxes that produce answers by magic, we can now see them as systems that walk through a structured space of algorithmic steps. The researchers demonstrated that by understanding the geometry of these steps, we can not only explain why a model makes a mistake but also fix it by adjusting the internal signals. This work suggests that the path to more reliable and capable artificial intelligence may lie in teaching these systems to better compose and generalize these basic building blocks, allowing them to solve problems they have never seen before by combining the tools they already possess.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.