Skip to main content

memo Helps Researchers Model How Minds Think About Other Minds

A new programming language called memo addresses long-standing challenges in "theory of mind" research by offering specialized syntax and dramatically faster computation.
  • cartoon of two women with thought bubbles showing them imagining what the other is thinking
    The goal of the memo team is to model how the mind reasons about other minds: "thinking about thinking."
    Credit: Eve Montie/iStock

A team of researchers from MIT has introduced memo, a domain-specific probabilistic programming language designed to make it far easier — and far faster — to build computational models of how humans think about the thoughts, beliefs, and intentions of other people. Essentially, memo is a programming language specialized for reasoning about reasoning – especially the kinds of reasoning that human minds specialize in.

The work addresses a long-term research challenge in computational cognitive science and cognitive AI of creating models that explain the thoughts one person may have about another person's thoughts. This recursive quality of human cognition is called "theory of mind," and it underlies many of our everyday social interactions — from negotiation and persuasion to empathy and game-playing. It has long fascinated researchers in cognitive neuroscience, linguistics, behavioral economics, moral psychology, robotics, and many other fields. A paper introducing memo, authored by Kartik Chandra, Tony Chen, Josh Tenenbaum, and Jonathan Ragan-Kelley, was published in the 2025 Proceedings of the Association for Computing Machinery on Programming Languages and received the ACM SIGPLAN Distinguished Paper Award

The story of memo began in June 2024, when, over lunch at the Annual Meeting of the Society for Philosophy and Psychology, a group of researchers started to commiserate over how difficult it was to build computational models of theory-of-mind reasoning using the tools available at the time: writing the model's code could take weeks of engineering effort, and once the models were built, they ran very slowly, sometimes taking days to return results. They agreed there had to be a better approach, and a collaborative effort led to memo and a community of researchers starting to use it in their work. Officially, “memo” stands for “mental models.” But the project's website offers several additional expansions: mental modeling, memoized matrix operations, model-expressed-model-optimized, and metacognitive memos.

photograph of Kartik Chandra in front of a tree
Kartik Chandra, MIT grad student

memo's goal was to make cognitive models of reasoning about reasoning easier to write and run by taking advantage of modern programming language techniques and hardware capabilities. Most programming languages offer programmers words like if or repeat in sequences of instructions; memo instead offers words like think, know, want, and imagine to build “models of minds that are reasoning, and possibly reasoning about other minds,” says Chandra. By using memo, models can often be both significantly simpler to express, with up to three times fewer lines of code, and dramatically faster to execute and fit to data, in some cases, 3,000 times faster, or more.

The team identified two root causes of slow-downs in most models. The first is a correctness problem: existing probabilistic programming languages offer generic primitives, which force researchers to manually translate rich mental concepts — believe, want, imagine — into terms like if and repeat. That translation is a common source for subtle bugs. One common mistake is accidentally allowing one simulated agent to “read the mind” of another by mixing up variables that belong to different mental worlds.

The second problem is efficiency. Modeling a mind thinking about another mind thinking about yet another mind leads to a combinatorial explosion of possible world states — and possible world states possibly imagined by possible minds — making computation intractable.

memo addresses both problems. On the correctness side, it provides syntax and semantics purpose-built for representing distinct mental agents, preventing the kinds of cross-contamination bugs that plague implementations in general-purpose languages. On the efficiency side, memo takes an unusual approach: it compiles models down to array programs that can run in parallel on modern hardware, such as GPUs. The inference algorithm is also end-to-end differentiable, enabling rapid parameter fitting via gradient descent.

One of memo’s distinctive contributions is catching a subtle class of errors that researchers have rarely named previously. When building computational models of how minds work, it is surprisingly easy to accidentally write a program in which one agent has impossible powers — reading another's mind, or directly controlling another’s behavior. “When you're programming a computational model of thinking,” Chandra explains, “it's very easy to slip up and make a bug that causes your model to actually have some mind control, or some kind of mind reading or clairvoyance — things that we think of as impossible with respect to how minds work.” memo directly checks programs for these types of violations and flags them, in the same spirit that an ordinary programming language warns you when you try to divide by zero. “In memo, you might get an error saying: you’re trying to have Alice read Bob’s mind, but you can't do that.”

Prof. Josh Tenenbaum, SQI Director of Science and a Professor in MIT’s Department of Brain and Cognitive Sciences, explains that memo speeds up the process of both developing and debugging models: “There’s an interaction between these steps: one is an inner loop inside the other. Every time you write and change the code, you have to run it, see what it does, then debug it, and fix it. The memo code is both easy to write and debug, and super fast to run in order to test whether your model is working and if not, improve it. So that's what leads to these really big speedups, which can be sometimes hundreds or thousands of times faster than the same models effectively would have been to develop in another way.” 

memo was built to address an existing research need, and it was developed quickly through a positive feedback loop with the scientific community. Instead of creating a tool and hoping other researchers would find and use it, Chandra reached out to researchers himself to directly discuss their research needs and the challenges they’ve experienced with existing models. The resulting iterative design loop was tight and generative: memo improvements quickly made researchers’ models faster, which encouraged more ambitious models, which revealed memo’s limits, which drove further improvements. 

For such a new initiative, memo has already had a notable impact. The researchers published memo as free and open-source software. It is being used by researchers at nine universities, has supported analyses in several published papers, and has been incorporated into courses at MIT's Department of Brain and Cognitive Sciences and Dartmouth College, as well as the Computational Summer School on Modeling Social and Collective Behavior (COSMOS), and the new textbook ProbLang v2.

Beyond replicating existing models faster, memo also opens the door to new kinds of research — including models that interface with deep learning systems and models that reason about the computational cost of reasoning itself. 

The researchers see memo as more than a productivity tool. By lowering the barrier to building and testing theory-of-mind models, they hope to accelerate scientific progress across the many fields that study how minds understand other minds.

Prof. Tenenbaum says, “From my point of view, as a scientist and a faculty member I think a lot about the total development time for a graduate student, a postdoc, or another researcher to develop and test a new model. And using memo makes things that could have taken a year might now take a week, or something that could have taken months, now take a day.”