Skip to content

About

Code for "EvoMemState: Evolving Memory State for Personal Agents"

Topics

Resources

Stars

22 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

EvoMemState: Evolving Memory State for Personal Agents

💡 Overview

Personal agents need to remember what a user said, track how that information changes, and decide how it should affect the current request. EvoMemState stores Persistent Facts in an evolving memory ontology. Retrieval produces a request-specific Relational State, and a policy generates a Reasoning State to guide a frozen response model.

  1. Ontology-Guided Memory State Induction extracts Persistent Facts from dialogue and organizes them in a personal memory ontology. The ontology maintains validity, scope, source, time, and relations such as SUPERSEDES and CONFLICTS_WITH.
  2. RL-Based State Evolution retrieves a Relational State containing relevant memories and their relations, then trains a Memory State Evolution Policy to generate a Reasoning State. The policy learns from the change in answer quality when that Reasoning State is supplied to a frozen response model.
  3. State-Aware Reasoning combines the Relational State and generated Reasoning State to produce the final response.

EvoMemState framework: memory state induction, policy training, and state-aware reasoning

The figure shows the full method from the manuscript, including policy training. This repository includes inference, GRPO policy training and the slime backend. Training data and model checkpoints are supplied separately.

📊 Main results

The complete main table from the EvoMemState manuscript is reproduced below. All values are on a 0–100 scale. Bold and underlined values mark the best and second-best results within each response model, following the manuscript. Higher is better (↑), except for sycophancy rate (↓). Averages are copied directly from the paper.

Memory system MemSyco-Bench MemTrapBench LoCoMo-Refined LoCoMo Overall Avg. ↑
WTU Acc. ↑ WTU Syco. ↓ HTU Acc. ↑ HTU Use ↑ Avg. ↑ Safety Score ↑ CogBias Acc. ↑ Bound. Acc. ↑ Trauma Acc. ↑ Avg. ↑ Judge Score ↑ Token F1 ↑ Judge Score ↑ Token F1 ↑
Response model: Qwen3-8B
NaiveRAG 36.355.351.664.042.460.263.977.093.473.639.038.434.435.847.4
MemGPT 29.066.754.067.039.062.266.064.552.461.345.740.036.837.045.7
MemoryBank 37.557.654.467.144.264.963.772.182.370.744.944.039.941.049.9
Mem0 25.947.852.063.836.356.869.381.985.573.425.726.921.423.839.2
A-MEM 42.849.149.261.245.464.265.077.691.874.641.839.136.437.149.6
LightMem 21.049.646.158.731.068.669.988.691.679.725.327.222.124.039.5
Supermemory 23.370.563.774.239.567.565.479.661.768.616.617.515.715.835.1
SimpleMem 33.458.644.152.637.770.968.384.695.879.951.346.645.346.453.6
PGMem 33.262.854.569.141.871.066.485.175.674.528.526.925.425.242.6
EvoMemState (Ours) 47.738.072.481.357.673.862.388.891.479.157.447.345.541.659.9
Response model: GPT-4o-mini
NaiveRAG 48.342.849.261.148.761.758.665.097.470.743.239.134.436.949.3
MemGPT 40.848.056.266.046.966.460.769.962.364.849.139.540.239.150.3
MemoryBank 48.942.248.362.348.766.459.873.490.572.552.846.642.745.354.2
Mem0 32.738.450.363.339.756.461.774.193.571.428.927.221.625.240.4
A-MEM 54.535.750.963.153.063.159.669.395.871.949.142.739.441.953.4
LightMem 25.042.946.960.433.870.263.880.895.277.524.226.921.825.139.3
Supermemory 35.056.352.965.942.267.458.874.276.469.215.816.014.914.835.5
SimpleMem 25.063.247.660.734.069.764.672.797.376.153.848.047.248.452.8
PGMem 39.654.453.766.345.273.960.981.183.174.719.818.916.717.639.1
EvoMemState (Ours) 53.131.967.680.158.973.973.988.890.478.760.848.546.445.261.2

WTU/HTU: When/How to Use memory. Syco.: sycophancy rate. Use: correct use. CogBias: cognitive bias. Bound.: boundary. The table reports manuscript results; the commands below describe how to run inference.

🥑 Repository structure

.
├── README.md
├── .env.example                    # Endpoint configuration template
├── assets/evomemstate_framework.png # Manuscript framework
├── config/                         # Ontology and benchmark configuration
├── evomemstate/
│   ├── builder.py                  # Memory construction
│   ├── extractor.py                # Ontology-guided extraction
│   ├── ontology.py                 # Persistent ontology and updates
│   ├── retrieval.py                # Relational State retrieval
│   ├── reasoning_state.py          # Reasoning State inference
│   ├── reasoning_state_reward.py   # Frozen-answer improvement reward
│   ├── reasoning_state_policy.py   # Policy prompts and training records
│   ├── training_data.py            # External manifest conversion
│   ├── slime_step_info.py          # Rollout metrics
│   ├── prompting.py                # Context for the answer model
│   ├── harness/                    # Context pipeline and rules
│   ├── memsyco_adapter.py          # MemSyco integration
│   ├── memtrap_adapter.py          # MemTrap integration
│   └── run_locomo.py               # LoCoMo-Refined inference
├── slime/                          # Vendored GRPO training backend
├── scripts/                        # Training and benchmark entry points
├── docs/                           # Installation and implementation notes
├── tests/                          # Offline checks
├── envs/                           # Environment definitions
├── pyproject.toml
└── requirements.txt

datasets/ and outputs/ are local runtime directories ignored by Git.

🚀 Run

1. Install dependencies

From the repository root, using Python 3.12:

pip install -e .
pip install -r datasets/MemSyco-Bench/requirements.txt

Place MemSyco-Bench at datasets/MemSyco-Bench first. Copy .env.example to .env and fill MEMORY_*, REASONING_STATE_*, GEN_B_*, and JUDGE_* with your model names, endpoints, and keys. Keep credentials in .env.

2. Build memory graphs

bash scripts/install_memsyco_adapter.sh
python -m evomemstate.prebuild_graphs --tasks all --limit 3

3. Run inference

MODE=smoke bash scripts/run_evomemstate_memsyco.sh

The runner loads .env, reuses existing graphs, and runs inference and scoring on three examples per task. Results are saved to outputs/evomemstate_memsyco/. Use --limit 0 for full graph construction and MODE=full for full inference.

4. Train the Reasoning State policy (GRPO)

Requires a Linux CUDA training environment with PyTorch, SGLang, Megatron-LM and compatible fused kernels installed. Install the included backend:

pip install -e ./slime

Supply a policy checkpoint, its converted Megatron torch_dist checkpoint and prepared training JSONL. Set the frozen answer endpoint in your local environment, then train:

export MEGATRON_PATH=/path/to/Megatron-LM
export HF_CHECKPOINT=/path/to/Qwen3-4B-Instruct-2507
export REF_TORCH_DIST=/path/to/Qwen3-4B-Instruct-2507_torch_dist
export PROMPT_DATA=/path/to/reasoning_state_train.jsonl
export ANSWER_MODEL=YOUR_FROZEN_ANSWER_MODEL
export ANSWER_BASE_URL=https://YOUR_PROVIDER/v1
# Set ANSWER_API_KEY locally, or use GEN_B_API_KEY from .env.
bash scripts/run_reasoning_state_rl.sh

Training updates only the policy, using the frozen answer score improvement with and without the generated Reasoning State, plus format and answer-leakage penalties. Outputs default to outputs/slime_saved/evomemstate-reasoning-state-qwen3-4b/. No datasets or model weights are bundled. For checkpoint conversion and training input format, see RL setup. After training, export and serve the policy, then point REASONING_STATE_* at its endpoint for inference.

Citation

If you use this code, please cite the accompanying EvoTeam paper:

@article{xiang2026evomemstate,
  title={EvoMemState: Evolving Memory State for Personal Agents},
  author={Xiang, Zhishang and Tang, Yunbo and Liu, Zhongqiao and Chen, Junkai and Chen, Zerui and Hu, Qingguo and Zhang, Yuxuan and Grant, William and Zhang, Qinggang Zhang and Su, Jinsong},
  journal={arXiv preprint arXiv:2611.03743},
  year={2026}
}

About

Code for "EvoMemState: Evolving Memory State for Personal Agents"

Topics

Resources

Stars

22 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages