RepoOpenBMB (MiniCPM)OpenBMB (MiniCPM)published Sep 27, 2026seen 10h

OpenBMB/T2Mem

Python

Open original ↗

Captured source

source ↗
published Sep 27, 2026seen 10hcaptured 10hhttp 200method plain

OpenBMB/T2Mem

Description: Experiment code for T2Mem: Test-Time Memory Construction.

Language: Python

License: MIT

Stars: 3

Forks: 0

Open issues: 0

Created: 2026-09-27T02:30:08Z

Pushed: 2026-09-27T06:21:33Z

Default branch: main

Fork: no

Archived: no

README:

📖 Introduction

T $^2$ Mem enables LLMs to reason over long interaction histories by deferring memory construction to test time. It extracts lightweight episode-level metadata offline, then adaptively retrieves and organizes metadata and raw interactions to progressively build query-specific memory as reasoning unfolds. T $^2$ Mem consistently outperforms strong baselines on LoCoMo and LongMemEval across different backbone LLMs while substantially reducing memory construction overhead.

![](figs/model.png)

⚙️ Setup

1. Create Python Environment

Use Python 3.10 or newer.

git clone https://github.com/OpenBMB/T2Mem.git
cd T2Mem
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

2. Configure APIs

cp .env.example .env

Edit .env with the endpoints, API keys, and served model names for the LLM, embedding model, and evaluation judge. All three use OpenAI-compatible APIs. run.py loads .env automatically.

3. Prepare data

Download either or both datasets and place the files in data/:

| Dataset | Download | Filename | |---|---|---| | LoCoMo | Official data | locomo10.json | | LongMemEval | Cleaned dataset | longmemeval_s_cleaned.json |

data/
├── locomo10.json
└── longmemeval_s_cleaned.json

🔧 Reproduction Guide

1. Run

Check the configuration, then run all datasets found in data/:

python run.py --check --temperature 0.0 --answer-max-tokens 1024
python run.py --temperature 0.0 --answer-max-tokens 1024

To run a single dataset, add locomo or longmemeval after run.py. To generate predictions without evaluation, add --skip-eval.

Alternatively, run the stages in order:

python run.py locomo --stage preprocess
python run.py locomo --stage index --temperature 0.0
python run.py locomo --stage retrieve
python run.py locomo --stage infer --temperature 0.0 --answer-max-tokens 1024
python run.py locomo --stage evaluate

Replace locomo with longmemeval for LongMemEval.

2. View outputs

  • outputs/: model predictions.
  • eval-results/: judgments and accuracy summaries.
  • data/: processed data, indexes, and retrieval files.

📧 Contact

For questions, suggestions, or bug reports, please contact:

xinhaidong@stumail.neu.edu.cn