Imagine an AI assistant that actually knows you. Not just one that knows your name, but one that remembers your boss is flying to Amsterdam next week, recalls that you prefer aisle seats, and automatically updates your calendar when the flight time changes.
Current Large Language Models (LLMs) are incredible generalists, but they often struggle to be good “personal assistants.” They suffer from what we might call the “Goldfish Memory” problem—context is limited, and specific personal details are often lost in the noise or hallucinated.
Today, we are diving deep into a fascinating paper titled “Crafting Personalized Agents through Retrieval-Augmented Generation on Editability Memory Graphs.” The researchers propose a novel architecture called EMG-RAG. This isn’t just another chatbot wrapper; it is a sophisticated system that combines graph theory, reinforcement learning, and LLMs to create an agent with a memory that is editable, structured, and smart enough to know what to remember.
If you are a student of NLP or AI architecture, this paper offers a masterclass in solving three specific problems: collecting scattered data, editing memories dynamically, and selecting the right combination of facts to answer complex questions.
The Core Problem: Why is Personalization Hard?
Before we inspect the solution, we need to understand why this is difficult. The authors identify three main hurdles in building personalized agents:
- Data Collection: Personal data is messy. It lives in screenshots, casual chat logs, emails, and calendar invites. Extracting “memories” from this noise is difficult.
- Editability: Life changes. A flight gets delayed; a hotel booking is cancelled. If an AI stores information in a static database or simply feeds everything into a long context window, updating a specific fact without breaking others is a nightmare.
- Selectability: This is the most subtle but critical challenge. To answer a question like “What time is my boss’s flight?”, the AI needs to combine several discrete memories: (a) Who is the boss? (b) Where are they going? (c) Which flight number did I book? (d) What is the departure time for that flight number?
Standard Retrieval-Augmented Generation (RAG) usually relies on “Top-K” retrieval—finding the top 5 or 10 chunks of text similar to the query. But for the complex question above, a simple similarity search might miss the connection between “Boss” and “Flight EK349.”
The Solution: EMG-RAG
The researchers introduce EMG-RAG, a solution that structures memory as a graph and uses a Reinforcement Learning (RL) agent to navigate it. Let’s break down the methodology into its three distinct phases.
Phase 1: From Chaos to Memories (Data Collection)
The first step is turning raw user interaction—like a chat log or a screenshot of a flight confirmation—into structured data.
The authors utilize a “business dataset” from a real smartphone AI assistant. They employ a clever pipeline using GPT-4. First, GPT-4 processes the raw text (and OCR from screenshots) to extract atomic “memories.” Next, to train their system, they need practice questions. They again use GPT-4 to look at a sequence of memories and generate Question-Answer (QA) pairs.

As shown in the table above, the system doesn’t just store the text. It breaks it down into discrete facts (\(M_1\) through \(M_6\)). For example, \(M_2\) is “I booked the EK349 flight,” and \(M_4\) is the specific time of that flight. This granular separation is essential for the next phase.
Phase 2: The Editable Memory Graph (EMG)
This is where the architecture shines. Instead of a vector database (a standard list of embeddings), the authors construct a three-layer graph.
- Memory Type Layer: High-level categories like Relationship, Preference, Event, or Attribute.
- Memory Subclass Layer: More specific buckets (e.g., Travel, Family).
- Memory Graph Layer: The actual entity-relation graph.
Why a graph? Because memories are relational. “Amsterdam” is related to “Boss,” which is related to “Trip.”

Take a close look at Figure 2(a) above. This structure allows for Editability. Real-world data is dynamic. The system supports three specific operations:
- Insertion: Adding a new seat number (\(M_7\)).
- Deletion: Removing an expired voucher (\(M_8\)).
- Replacement: Changing the flight time (\(M_9\)).
Because the data is structured as a graph, the system can locate the specific node (e.g., the flight entity) and update its attributes without having to retrain a model or rewrite a massive document.
Phase 3: Smart Retrieval with Reinforcement Learning
Now we have a graph of memories. When a user asks a question, how do we find the answer?
Standard RAG would convert the question to a vector and grab the closest nodes. But as we discussed, complex questions require hopping between nodes. The authors model this retrieval process as a Markov Decision Process (MDP).
They create an “agent” that starts at relevant nodes in the graph and decides where to go next. This is a Reinforcement Learning approach.
The State (\(s\)): The agent needs to know “where am I?” and “is this relevant?”. The state is defined by comparing the question to the current location in the graph.

In this equation:
- \(N_Q\) and \(R_Q\) are entities and relations in the Question.
- \(N_G\) and \(R_G\) are entities and relations in the Graph (the current node).
- \(C\) represents cosine similarity. Essentially, the agent looks at how similar the current memory node is to the user’s question.
The Action (\(a\)): At every node, the agent makes a binary decision:

- 1 (Including): Keep this memory for the final answer and explore connected nodes.
- 0 (Stopping): Do not include this memory; prune this path.
The Reward (\(r\)): This is the “boosting” part of the process. How does the agent know if it did a good job? It checks the quality of the answer generated by the LLM.

Here, \(\Delta\) is a metric (like ROUGE or BLEU scores) that measures how close the generated answer (\(\hat{A}\)) is to the ground truth (\(A\)).
- If adding a memory increases the score (\(\hat{A}' > \hat{A}\)), the agent gets a positive reward.
- If adding a memory confuses the LLM and lowers the score, the agent gets a negative reward.
The total reward is the cumulative improvement in the answer quality from the start of the search to the end:

Training the Agent Training an RL agent from scratch can be unstable. The authors use a two-stage approach:
- Warm-Start (WS): They first train the agent using standard supervised learning (Binary Cross Entropy), effectively teaching it the basics of “good” vs. “bad” memories based on the training data labels.

- Policy Gradient (PG): Once the agent understands the basics, they switch to Reinforcement Learning (using the REINFORCE algorithm) to fine-tune the decision-making process based on the actual rewards defined above.

Experiments and Results
The theory sounds solid, but does it work? The authors tested EMG-RAG on a massive dataset of 11.35 billion raw text entries (filtered down to 0.35 billion memories) from real users.
They compared their method against several strong baselines:
- NiaH (Needle in a Haystack): Dumping everything into the context window.
- Naive RAG: Standard vector search.
- M-RAG: A multi-agent RAG approach.
Performance on Applications
They evaluated the system on three tasks: Question Answering (QA), Autofilling Forms (AF), and User Services (US).

As Table 2 shows, EMG-RAG dominates across the board.
- In Question Answering, it achieves a BLEU score of 75.99 with GPT-4, significantly higher than M-RAG (64.16).
- The performance holds up even with smaller models like ChatGLM3-6B, suggesting that the intelligence is in the retrieval architecture, not just the underlying LLM.
The “Time Travel” Test (Continuous Edits)
The most impressive result is how the system handles time. The researchers simulated a 4-week period where users constantly added, deleted, or changed memories.

In Table 3, look at the comparison between M-RAG and EMG-RAG over weeks 1 through 4.
- M-RAG’s performance degrades over time (QA score drops from 88.48 to 85.09). This is likely because old, outdated memories clutter the retrieval process.
- EMG-RAG maintains high performance (QA stays around 95-96). The graph structure allows it to surgically update facts (like changing a flight time) so the agent always retrieves the current truth.
Ablation Studies: Do we need all the parts?
Science requires verifying that every component is necessary. The authors removed specific parts of the system to see what would happen.

Table 4 confirms that:
- Removing Activated Nodes (starting the search from relevant points rather than the root) hurts performance significantly.
- Removing the Policy Gradient (PG) stage (the RL part) also causes a drop. The Warm-Start is good, but the RL fine-tuning is what pushes the accuracy to the next level.
The Importance of “K”
Finally, they analyzed how many starting points (Activated Nodes) the graph search needs.

Interestingly, more isn’t always better. Table 5 shows that \(K=3\) is the sweet spot.
- Too few (\(K=1\)): You might miss the relevant part of the graph.
- Too many (\(K=5\)): You introduce noise and slow down the system (inference time jumps from 2.14s to 3.32s).
Real-World Deployment
The researchers didn’t just leave this in the lab. They deployed it for an online A/B test with real users.

The new EMG-RAG system showed a 3-4% improvement across all categories compared to the old system. While this might look small compared to the lab results, in a live product with millions of interactions, a 4% gain in user satisfaction is massive.
They also performed a rigorous data quality evaluation to ensure the memories being extracted were accurate.

Both human evaluators and GPT-4 based evaluators found the extracted memories to be highly accurate (>90%), validating the data collection pipeline.
Finally, to give you a flavor of what exactly is being stored, here is the taxonomy of memories the system supports:

Conclusion & Implications
The EMG-RAG paper represents a significant step forward for personal AI agents. It moves us away from the idea of “memory” as a static bucket of text and towards memory as a dynamic, structured knowledge graph.
Key Takeaways:
- Structure Matters: Organizing personal data into a graph enables precise editing and updating, solving the issue of conflicting or outdated information.
- Smart Navigation: Instead of blindly retrieving top matches, using an RL agent to traverse associations allows the system to answer complex, multi-hop questions.
- End-to-End Optimization: By using the final answer quality as a reward signal, the retrieval mechanism learns to get better over time.
For students and researchers, this paper highlights that the future of LLM applications isn’t just about bigger models or larger context windows. It’s about architecture—how we structure data and how we design the agents that interact with it. As our digital lives become more complex, systems like EMG-RAG will be essential for creating AI assistants that are truly helpful, personalized, and, most importantly, reliable.
](https://deep-paper.org/en/paper/2409.19401/images/cover.png)