MIT-MI/MEM1
소개
MEM1: 효율적인 장기 에이전트를 위해 기억과 추론의 시너지를 학습합니다. ICLR 2026에 채택되었으며 NeurIPS 2025 MTI-LLM Workshop에서 Best Paper Award를 수상했습니다.
학습 및 교육측정된 스타 증가
- in 24h
- 0
- in 7 days
- +3
- in 15 days
- +5
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalMem1: Train your LLMs to reason and consolidate memory at the same time!
This repo is the official code implementation of MEM1: Learning to Synergize Memory and Reasoning for Efficient Long-Horizon Agents
[arXiv] | [Project Site]
Zijian Zhou^, Ao Qu^, Zhaoxuan Wu, Sunghwan Kim, Alok Prakash, Daniela Rus, Jinhua Zhao, and Bryan Kian Hsiang Low, Paul Pu Liang
⭐️ Please star this repository if you find it helpful!
Abstract: Modern language agents must operate over long-horizon, multi-turn interactions, where they retrieve external information, adapt to observations, and answer interdependent queries. Yet, most LLM systems rely on full-context prompting, appending all past turns regardless of their relevance. This leads to unbounded memory growth, increased computational costs, and degraded reasoning performance on out-of-distribution input lengths. We introduce MEM1, an end-to-end reinforcement learning framework that enables agents to operate with constant memory across long multi-turn tasks. At each turn, MEM1 updates a compact shared internal state that jointly supports memory consolidation and reasoning. This state integrates prior memory with new observations from the environment while strategically discarding irrelevant or redundant information. To support training in more realistic and compositional settings, we propose a simple yet effective and scalable approach to constructing multi-turn environments by composing existing datasets into arbitrarily complex task sequences. Experiments across three domains, including internal retrieval QA, open-domain web QA, and multi-turn web shopping, show that MEM1-7B improves performance by 3.5x while reducing memory usage by 3.7x compared to Qwen2.5-14B-Instruct on a 16-objective multi-hop QA task, and generalizes beyond the training horizon. Our results demonstrate the promise of reasoning-driven memory consolidation as a scalable alternative to existing solutions for training long-horizon interactive agents, where both efficiency and performance are optimized.
Demo Video
News
- (Oct 2025) MEM1 has been accepted at NeurIPS 2025 Workshop MTI-LLM for oral presentation! (2 out of 230 submissions)
- (Aug 2025) MEM1 has been accepted at COLM 2025 Workshop RAM2 for oral presentation!
Installation
Mem1 environment
# Install requirements. This may take a few minutes to complete.
conda create -n mem1 python=3.9
conda activate mem1
# install torch [or you can skip this step and let vllm to install the correct version for you]
pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu121
# install vllm
pip3 install vllm==0.6.3 # or you can install 0.5.4, 0.4.2 and 0.3.1
# install other dependencies
pip install -r requirements.txt
# install verl locally
cd Mem1/train
pip install -e .
# install flash attn
pip3 install flash-attn --no-build-isolation
Retriever environment (optional)
If you would like to call a local retriever as the search engine, you can install the environment as follows. (We recommend using a separate environment.)
conda create -n retriever python=3.10
conda activate retriever
# we recommend installing torch with conda for faiss-gpu
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.1 -c pytorch -c nvidia
pip install transformers datasets pyserini
## install the gpu version faiss to guarantee efficient RL rollout
conda install -c pytorch -c nvidia faiss-gpu=1.8.0
## API function
pip install uvicorn fastapi
Quick Start
- Download the necessary data:
cd setup/
python download.py
- Pre-process the multi-objective QA dataset (change the batch size for varying number of objectives)
cd Mem1/
bash gen_data/scripts/data_process_multi.sh --batch_size 2
- Launch a local retrieval server:
# First remember to change the `file_path` field of `Mem1/train/retrieval_launch.sh` to the path of your RAG files
cd Mem1/train/
bash retrieval_launch.sh
- Train the Mem1 model:
cd Mem1/train/
bash train_ppo.sh
Evaluation
- To evaluate MEM1 model, we need to first serve the model:
cd Mem1/inference
# Change the variables in start_vllm.sh
bash start_vllm.sh
Wait for the model to be served. Next, we also need to serve the retriever. Follow Step 3 for how to serve the retriever.
Collect the trajectories generated by Mem1 by running
cd Mem1
python inference/generate_rollout.py --model Mem-Lab/Qwen2.5-7B-RL-RAG-Q2-EM-Release --use_mem1 --data_file train/data/nq_hotpotqa_train_multi_2/test.parquet
The generated result is a jsonl file containing the generated trajectories. An example generated by running our released 7B model over the q2 test dataset can be found at examples/demo.jsonl.
- With the collected trajectories as a jsonl file, we can evaluate the performance
cd Mem1
python inference/eval.py --trajectory_jsonl_path [PATH_TO_TRAJ_FILE]
For example, to get the result with the demo file, run
cd Mem1
python inference/eval.py --trajectory_jsonl_path ../examples/demo.jsonl
Trained Model Details
- wandb: https://api.wandb.ai/links/Mem1/vl5osiui
- 🤗 HF Checkpoint: https://huggingface.co/Mem-Lab/Qwen2.5-7B-RL-RAG-Q2-EM-Release
Reference
Please use the following bibtex citation format for your reference.
@misc{2025mem1learningsynergizememory,
title = {MEM1: Learning to Synergize Memory and Reasoning for Efficient Long-Horizon Agents},
author = {Zhou, Zijian and Qu, Ao and Wu, Zhaoxuan and Kim, Sunghwan and Prakash, Alok and Rus, Daniela and Zhao, Jinhua and Low, Bryan Kian Hsiang and Liang, Paul Pu},
year = {2025},
archivePrefix= {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/2506.15841},
}
Acknowledgement
The codebase has referred to the following repositories:
Star History
관련 프로젝트 살펴보기
불러오는 중…