MEMENTO: Memory-Guided Memetic Code-as-Policy Evolution
The paper introduces MEMENTO, a memory-guided memetic framework that evolves executable code-as-policies for long-horizon embodied tasks by combining LLM-driven generation with structured feedback from an evolved evaluator, achieving superior performance and sim-to-real transfer compared to existing baselines.
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
Imagine you are trying to teach a robot to do a complex chore, like building a tower of blocks or making a sandwich. This isn't just about pressing a single button; it's a long sequence of steps where every move depends on the one before it. If the robot grabs the wrong block or opens the wrong door, the whole plan falls apart. This is the world of "embodied AI," where software meets the messy, physical world. The big challenge here is the "credit assignment problem": when the robot fails at the end of a long task, how do you know which specific step went wrong? Was it the first move, or the tenth?
To solve this, researchers are trying a clever trick called "code-as-policy." Instead of training a robot with vague instructions or trial-and-error rewards, they write the robot's brain as actual computer code. This is like giving the robot a recipe book instead of just a feeling. If the recipe fails, you can read it, see exactly which instruction was confusing, and rewrite it. But writing these recipes by hand is hard, and guessing the right code is even harder. This is where Large Language Models (LLMs)—the same AI brains that write essays and chat with us—come in. They can generate code, but they often need help figuring out why a piece of code failed so they can fix it properly.
This is the story of a new method called MEMENTO, which acts like a super-smart, memory-keeping editor for robot code. The researchers wanted to see if they could evolve better robot recipes by letting an AI write them, test them, and then use a special "memory" to remember what didn't work, so it wouldn't make the same mistakes again. They tested this on two tricky games: one where a robot arm has to solve a Tower of Hanoi puzzle (moving blocks without breaking the rules), and another where a robot has to navigate a virtual house to make a snack.
Here is how MEMENTO works, and what the team discovered.
The Problem with "Guess and Check"
Imagine you are trying to write a program to solve a puzzle. You ask an AI to write the code. It writes something, you run it, and it fails. If you just ask the AI to "try again" with a new, random idea, you might get a slightly different failure, but you aren't really learning. It's like trying to find a hidden key in a giant field by throwing darts blindfolded.
Previous methods tried to fix this by generating many different versions of the code at once and picking the best one. But the researchers found that this approach often missed the mark. It was like having a hundred people suggest different ways to fix a leaky pipe, but none of them actually looked at the specific spot where the water was dripping. They lacked a way to take a single good idea, tweak it carefully, remember what tweaks failed, and then combine the best parts of different ideas.
Enter MEMENTO: The Memory-Keeping Editor
The authors introduced MEMENTO, which stands for Memory-Guided Memetic Code-as-Policy Evolution. The name sounds fancy, but the idea is surprisingly human. Think of MEMENTO as a master editor working with a single "star" draft of a robot's brain.
The process happens in two main acts:
Act 1: Building the Judge
Before the robot even starts learning, MEMENTO creates a special "Judge" (an evaluator). This Judge is a piece of code that watches the robot try the task and gives it a score. But it doesn't just say "Pass" or "Fail." It gives a detailed report card: "You got the score, but you dropped the block here," or "You opened the door too fast." The researchers evolved this Judge first, making sure it was good at spotting exactly what went wrong in the robot's performance.
Act 2: The Three-Branch Search
Once the Judge is ready, the real evolution begins. MEMENTO doesn't just throw darts; it uses three specific strategies to improve the robot's code, all while keeping a "memory" of past failures:
- The Hill-Climber (The Careful Tinkerer): This branch takes the current best code and makes tiny, careful changes. If a change makes the robot better, it keeps it. If a change makes it worse, it remembers why that specific change failed. This "memory of rejected ideas" stops the AI from making the same mistake twice. It's like a hiker who tries a path, finds a dead end, marks it on a map, and tries a different path, ensuring they don't walk into the same bush again.
- The Macro-Mutator (The Big Idea Generator): Sometimes, tiny tweaks aren't enough. This branch takes the best code and makes big, bold changes—like rewriting a whole paragraph of the recipe. It's the "what if we tried a completely different approach?" moment.
- The Crossover (The Mixer): This is the magic ingredient. It takes the best result from the Careful Tinkerer and the best result from the Big Idea Generator and mixes them together. It's like taking the best ingredients from two different recipes to create a new, super-dish.
After trying these three paths, MEMENTO picks the single best result to be the "Elite" for the next round. This cycle repeats, slowly refining the code until the robot can solve the task.
The Results: Does It Actually Work?
The researchers tested MEMENTO in two very different worlds:
- Robosuite Tower of Hanoi: A robot arm stacking four blocks.
- AI2-THOR: A robot navigating a virtual kitchen to put an apple in a microwave and bread in a fridge.
They compared MEMENTO against two other popular methods (Eureka and REvolve). The results were clear: MEMENTO won.
In the Tower of Hanoi task, MEMENTO achieved a success rate of 0.97 ± 0.06 (meaning it solved the puzzle almost every time), while the other methods struggled, with one only getting 0.53 and the other failing completely (0.00). In the kitchen task, MEMENTO hit a perfect 1.00 ± 0.00 success rate, while the others managed only 0.40 and 0.00.
But the real magic wasn't just in the training room. The researchers tested if the robot could handle new situations it had never seen before.
- New Shapes: When they changed the blocks from cubes to weirdly shaped cylinders or asymmetrical objects, MEMENTO still solved the puzzle 0.87 of the time. The other methods crashed to 0.23 or 0.00.
- New Rooms: When they moved the kitchen robot to a completely new house layout it had never seen, MEMENTO still succeeded 0.78 of the time. The others dropped to 0.08.
This suggests that MEMENTO didn't just memorize the specific blocks or the specific kitchen; it actually learned the logic of the task.
The "Aha!" Moments (Ablation Studies)
To prove that their specific design was the secret sauce, the researchers tried removing parts of MEMENTO to see what happened.
- No Memory: When they removed the "memory" of rejected ideas, the robot got stuck making the same mistakes over and over.
- No Big Changes: When they only let the robot make tiny tweaks (no "Macro-Mutation"), it couldn't escape local traps.
- No Mixing: When they stopped mixing the best ideas (no "Crossover"), the robot couldn't combine the right strategies.
- No Judge Evolution: When they used a simple, untrained Judge instead of the evolved one, the robot couldn't figure out how to win.
Every single time they removed a piece, the performance dropped significantly, proving that the whole system was necessary.
From Simulation to Reality
The most exciting part? They took the best code MEMENTO evolved in the computer simulation and put it on a real physical robot (a Franka robot arm). They didn't retrain it or change the code; they just let it run.
The robot successfully solved the Tower of Hanoi puzzle in the real world 90% of the time (9 out of 10 tries). The one failure wasn't because the code was wrong; it was because the robot's camera misread the position of a block. This proved that the "code-as-policy" approach isn't just a simulation trick—it works in the real, messy physical world.
What This Means
The paper suggests that for robots to learn complex, long tasks, we need more than just random guesses. We need a system that remembers what didn't work, makes both small and big changes, and mixes the best ideas together. MEMENTO shows that by treating robot code like a recipe that can be edited, tested, and refined with a memory of past failures, we can teach robots to solve puzzles that were previously too hard for them.
The authors are careful to note that this was tested on specific tasks and that the method relies on the specific language model they used. They didn't claim this solves every robot problem, but they did show a very promising path forward for teaching robots to think in code.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.