Skip to content

Commit cc7122f

Browse files
authored
feat: API1.1 (#434)
## Description <!-- Please include a summary of the changes below; Fill in the issue number that this PR addresses (if applicable); Fill in the related MemOS-Docs repository issue or PR link (if applicable); Mention the person who will review this PR (if you know who it is); Replace (summary), (issue), (docs-issue-or-pr-link), and (reviewer) with the appropriate information. 请在下方填写更改的摘要; 填写此 PR 解决的问题编号(如果适用); 填写相关的 MemOS-Docs 仓库 issue 或 PR 链接(如果适用); 提及将审查此 PR 的人(如果您知道是谁); 替换 (summary)、(issue)、(docs-issue-or-pr-link) 和 (reviewer) 为适当的信息。 --> Summary: • Memory & Retrieval Core: async add (plain & preference), Preference Memory pipeline, Reranker strategy suite, BM25 for TreeTextMemory, MemReader structural parsing. • Scheduler & Observability: API scheduler modularization (schema/utils/analyzer), Redis ORM for history sync & mixture search, metrics + request logs, Nacos-based dynamic config. • Data & Infra: PolarDB graph backend with pool/timeout & fixes, unified graph factory (Nebula/Neo4j/PolarDB), Milvus interface & item optimizations, enhanced logging. • Evaluation: PrefEval standardization; LoCoMo/LongMemEval/PersonaMem pipeline upgrades; new utilities (e.g., mirix_utils.py). • Stability & Fixes: query scheduling, message schema, Tree search inputs, self-input prompts, SQLite list users, PolarDB value mapping; pool/timeout tuning, usage data removal, graph-call toggle. • Compatibility: adopt new async path/schemas/metrics; align preference fields; migrate tests to Redis ORM; configure PolarDB pool/timeout before rollout. • 记忆与检索内核:新增 async add(明文/偏好)、偏好记忆全链路、Reranker 策略集、TreeTextMemory 引入 BM25、MemReader 结构化解析。 • 调度与可观测性:API 调度模块化(schema/utils/analyzer)、Redis ORM(历史同步与混合搜索)、metrics 指标与请求日志、Nacos 动态配置。 • 数据与基础设施:PolarDB 图后端(连接池/超时与修复)、图工厂统一(Nebula/Neo4j/PolarDB)、Milvus 接口与数据项优化、日志链路增强。 • 评估体系:PrefEval 字段标准化;LoCoMo/LongMemEval/PersonaMem 评测升级;新增工具(如 mirix_utils.py)。 • 稳定性与修复:修复查询调度、消息 schema、树检索输入、自输入提示、SQLite 用户列表、PolarDB 值映射;连接池/超时优化、移除 usage 数据、图调用开关。 • 兼容性:适配异步路径/新 schema/metrics;偏好字段按新规范;测试迁移至 Redis ORM;启用 PolarDB 前配置连接池与超时并压测。 Fix: #424 #426 #423 #443 #384 #406 #445 • Scheduler/Query: fixed query-schedule edge cases (#424). • Schemas: corrected message schema inconsistencies (#426). • Search I/O: fixed TreeTextMemory searcher input mismatch (#423). • Prompts: fixed self-input prompt error (#443). • Storage: fixed SQLite list-users error (#384). • Graph/DB: corrected PolarDB value/graph issues (#406, #445). • 调度/查询:修复查询调度边界问题(#424)。 • Schema:修正消息 schema 不一致(#426)。 • 检索 I/O:修复 Tree 搜索器输入不匹配(#423)。 • 提示:修复自输入提示错误(#443)。 • 存储:修复 SQLite 用户列表错误(#384)。 • 图/数据库:修正 PolarDB 值与图相关问题(#406#445)。 Docs Issue/PR: (docs-issue-or-pr-link) Reviewer: @(reviewer) ## Checklist: - [ ] I have performed a self-review of my own code | 我已自行检查了自己的代码 - [ ] I have commented my code in hard-to-understand areas | 我已在难以理解的地方对代码进行了注释 - [ ] I have added tests that prove my fix is effective or that my feature works | 我已添加测试以证明我的修复有效或功能正常 - [ ] I have created related documentation issue/PR in [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) (if applicable) | 我已在 [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) 中创建了相关的文档 issue/PR(如果适用) - [ ] I have linked the issue to this PR (if applicable) | 我已将 issue 链接到此 PR(如果适用) - [ ] I have mentioned the person who will review this PR | 我已提及将审查此 PR 的人
2 parents acf65f4 + 119bbe2 commit cc7122f

File tree

163 files changed

+19548
-2207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+19548
-2207
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ evaluation/.env
1515
!evaluation/configs-example/*.json
1616
evaluation/configs/*
1717
**tree_textual_memory_locomo**
18+
**script.py**
1819
.env
1920
evaluation/scripts/personamem
2021

README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,20 @@
5454

5555
## 📈 Performance Benchmark
5656

57-
MemOS demonstrates significant improvements over baseline memory solutions in multiple reasoning tasks.
57+
MemOS demonstrates significant improvements over baseline memory solutions in multiple memory tasks,
58+
showcasing its capabilities in **information extraction**, **temporal and cross-session reasoning**, and **personalized preference responses**.
5859

59-
| Model | Avg. Score | Multi-Hop | Open Domain | Single-Hop | Temporal Reasoning |
60-
|-------------|------------|-----------|-------------|------------|---------------------|
61-
| **OpenAI** | 0.5275 | 0.6028 | 0.3299 | 0.6183 | 0.2825 |
62-
| **MemOS** | **0.7331** | **0.6430** | **0.5521** | **0.7844** | **0.7321** |
63-
| **Improvement** | **+38.98%** | **+6.67%** | **+67.35%** | **+26.86%** | **+159.15%** |
60+
| Model | LOCOMO | LongMemEval | PrefEval-10 | PersonaMem |
61+
|-----------------|-------------|-------------|-------------|-------------|
62+
| **GPT-4o-mini** | 52.75 | 55.4 | 2.8 | 43.46 |
63+
| **MemOS** | **75.80** | **77.80** | **71.90** | **61.17** |
64+
| **Improvement** | **+43.70%** | **+40.43%** | **+2568%** | **+40.75%** |
6465

65-
> 💡 **Temporal reasoning accuracy improved by 159% compared to the OpenAI baseline.**
66-
67-
### Details of End-to-End Evaluation on LOCOMO
68-
69-
> [!NOTE]
70-
> Comparison of LLM Judge Scores across five major tasks in the LOCOMO benchmark. Each bar shows the mean evaluation score judged by LLMs for a given method-task pair, with standard deviation as error bars. MemOS-0630 consistently outperforms baseline methods (LangMem, Zep, OpenAI, Mem0) across all task types, especially in multi-hop and temporal reasoning scenarios.
71-
72-
<img src="https://statics.memtensor.com.cn/memos/score_all_end2end.jpg" alt="END2END SCORE">
66+
### Detailed Evaluation Results
67+
- We use gpt-4o-mini as the processing and judging LLM and bge-m3 as embedding model in MemOS evaluation.
68+
- The evaluation was conducted under conditions that align various settings as closely as possible. Reproduce the results with our scripts at [`evaluation`](./evaluation).
69+
- Check the full search and response details at huggingface https://huggingface.co/datasets/MemTensor/MemOS_eval_result.
70+
> 💡 **MemOS outperforms all other methods (Mem0, Zep, Memobase, SuperMemory et al.) across all benchmarks!**
7371
7472
## ✨ Key Features
7573

@@ -83,6 +81,27 @@ MemOS demonstrates significant improvements over baseline memory solutions in mu
8381

8482
## 🚀 Getting Started
8583

84+
### ⭐️ MemOS online API
85+
The easiest way to use MemOS. Equip your agent with memory **in minutes**!
86+
87+
Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing).
88+
89+
90+
### Self-Hosted Server
91+
1. Get the repository.
92+
```bash
93+
git clone https://github.com/MemTensor/MemOS.git
94+
cd MemOS
95+
pip install -r ./docker/requirements.txt
96+
```
97+
98+
2. Configure `docker/.env.example` and copy to `MemOS/.env`
99+
3. Start the service.
100+
```bash
101+
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 8
102+
```
103+
104+
### Local SDK
86105
Here's a quick example of how to create a **`MemCube`**, load it from a directory, access its memories, and save it.
87106

88107
```python
@@ -104,7 +123,7 @@ for item in mem_cube.act_mem.get_all():
104123
mem_cube.dump("tmp/mem_cube")
105124
```
106125

107-
What about **`MOS`** (Memory Operating System)? It's a higher-level orchestration layer that manages multiple MemCubes and provides a unified API for memory operations. Here's a quick example of how to use MOS:
126+
**`MOS`** (Memory Operating System) is a higher-level orchestration layer that manages multiple MemCubes and provides a unified API for memory operations. Here's a quick example of how to use MOS:
108127

109128
```python
110129
from memos.configs.mem_os import MOSConfig

docker/.env.example

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,60 @@
11
# MemOS Environment Variables Configuration
2+
TZ=Asia/Shanghai
23

3-
# Path to memory storage (e.g. /tmp/data_test)
4-
MOS_CUBE_PATH=
4+
MOS_CUBE_PATH="/tmp/data_test" # Path to memory storage (e.g. /tmp/data_test)
5+
MOS_ENABLE_DEFAULT_CUBE_CONFIG="true" # Enable default cube config (true/false)
56

67
# OpenAI Configuration
7-
OPENAI_API_KEY= # Your OpenAI API key
8-
OPENAI_API_BASE= # OpenAI API base URL (default: https://api.openai.com/v1)
8+
OPENAI_API_KEY="sk-xxx" # Your OpenAI API key
9+
OPENAI_API_BASE="http://xxx" # OpenAI API base URL (default: https://api.openai.com/v1)
910

10-
# MemOS Feature Toggles
11-
MOS_ENABLE_DEFAULT_CUBE_CONFIG= # Enable default cube config (true/false)
12-
MOS_ENABLE_SCHEDULER= # Enable background scheduler (true/false)
11+
# MemOS Chat Model Configuration
12+
MOS_CHAT_MODEL=gpt-4o-mini
13+
MOS_CHAT_TEMPERATURE=0.8
14+
MOS_MAX_TOKENS=8000
15+
MOS_TOP_P=0.9
16+
MOS_TOP_K=50
17+
MOS_CHAT_MODEL_PROVIDER=openai
1318

14-
# Neo4j Configuration
15-
NEO4J_URI= # Neo4j connection URI (e.g. bolt://localhost:7687)
16-
NEO4J_USER= # Neo4j username
17-
NEO4J_PASSWORD= # Neo4j password
18-
MOS_NEO4J_SHARED_DB= # Shared Neo4j database name (if using multi-db)
19+
# graph db
20+
# neo4j
21+
NEO4J_BACKEND=xxx
22+
NEO4J_URI=bolt://xxx
23+
NEO4J_USER=xxx
24+
NEO4J_PASSWORD=xxx
25+
MOS_NEO4J_SHARED_DB=xxx
26+
NEO4J_DB_NAME=xxx
27+
28+
# tetxmem reog
29+
MOS_ENABLE_REORGANIZE=false
1930

2031
# MemOS User Configuration
21-
MOS_USER_ID= # Unique user ID
22-
MOS_SESSION_ID= # Session ID for current chat
23-
MOS_MAX_TURNS_WINDOW= # Max number of turns to keep in memory
32+
MOS_USER_ID=root
33+
MOS_SESSION_ID=default_session
34+
MOS_MAX_TURNS_WINDOW=20
35+
36+
# MemRader Configuration
37+
MEMRADER_MODEL=gpt-4o-mini
38+
MEMRADER_API_KEY=sk-xxx
39+
MEMRADER_API_BASE=http://xxx:3000/v1
40+
MEMRADER_MAX_TOKENS=5000
41+
42+
#embedding & rerank
43+
EMBEDDING_DIMENSION=1024
44+
MOS_EMBEDDER_BACKEND=universal_api
45+
MOS_EMBEDDER_MODEL=bge-m3
46+
MOS_EMBEDDER_API_BASE=http://xxx
47+
MOS_EMBEDDER_API_KEY=EMPTY
48+
MOS_RERANKER_BACKEND=http_bge
49+
MOS_RERANKER_URL=http://xxx
50+
# Ollama Configuration (for embeddings)
51+
#OLLAMA_API_BASE=http://xxx
2452

25-
# Ollama Configuration (for local embedding models)
26-
OLLAMA_API_BASE= # Ollama API base URL (e.g. http://localhost:11434)
53+
# milvus for pref mem
54+
MILVUS_URI=http://xxx
55+
MILVUS_USER_NAME=xxx
56+
MILVUS_PASSWORD=xxx
2757

28-
# Embedding Configuration
29-
MOS_EMBEDDER_BACKEND= # Embedding backend: openai, ollama, etc.
58+
# pref mem
59+
ENABLE_PREFERENCE_MEMORY=true
60+
RETURN_ORIGINAL_PREF_MEM=true

docker/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ volcengine-python-sdk==4.0.6
157157
watchfiles==1.1.0
158158
websockets==15.0.1
159159
xlrd==2.0.2
160-
xlsxwriter==3.2.5
160+
xlsxwriter==3.2.5

docs/openapi.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@
884884
"type": "string",
885885
"title": "Session Id",
886886
"description": "Session ID for the MOS. This is used to distinguish between different dialogue",
887-
"default": "0ce84b9c-0615-4b9d-83dd-fba50537d5d3"
887+
"default": "41bb5e18-252d-4948-918c-07d82aa47086"
888888
},
889889
"chat_model": {
890890
"$ref": "#/components/schemas/LLMConfigFactory",
@@ -939,6 +939,12 @@
939939
"description": "Enable parametric memory for the MemChat",
940940
"default": false
941941
},
942+
"enable_preference_memory": {
943+
"type": "boolean",
944+
"title": "Enable Preference Memory",
945+
"description": "Enable preference memory for the MemChat",
946+
"default": false
947+
},
942948
"enable_mem_scheduler": {
943949
"type": "boolean",
944950
"title": "Enable Mem Scheduler",

evaluation/.env-example

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,22 @@ MODEL="gpt-4o-mini"
33
OPENAI_API_KEY="sk-***REDACTED***"
44
OPENAI_BASE_URL="http://***.***.***.***:3000/v1"
55

6-
MEM0_API_KEY="m0-***REDACTED***"
7-
8-
ZEP_API_KEY="z_***REDACTED***"
96

107
# response model
118
CHAT_MODEL="gpt-4o-mini"
129
CHAT_MODEL_BASE_URL="http://***.***.***.***:3000/v1"
1310
CHAT_MODEL_API_KEY="sk-***REDACTED***"
1411

12+
# memos
1513
MEMOS_KEY="Token mpg-xxxxx"
16-
MEMOS_URL="https://apigw-pre.memtensor.cn/api/openmem/v1"
17-
PRE_SPLIT_CHUNK=false # pre split chunk in client end
18-
19-
MEMOBASE_API_KEY="xxxxx"
20-
MEMOBASE_PROJECT_URL="http://xxx.xxx.xxx.xxx:8019"
21-
22-
# Configuration Only For Scheduler
23-
# RabbitMQ Configuration
24-
MEMSCHEDULER_RABBITMQ_HOST_NAME=rabbitmq-cn-***.cn-***.amqp-32.net.mq.amqp.aliyuncs.com
25-
MEMSCHEDULER_RABBITMQ_USER_NAME=***
26-
MEMSCHEDULER_RABBITMQ_PASSWORD=***
27-
MEMSCHEDULER_RABBITMQ_VIRTUAL_HOST=memos
28-
MEMSCHEDULER_RABBITMQ_ERASE_ON_CONNECT=true
29-
MEMSCHEDULER_RABBITMQ_PORT=5672
14+
MEMOS_URL="http://127.0.0.1:8001"
15+
MEMOS_ONLINE_URL="https://memos.memtensor.cn/api/openmem/v1"
3016

31-
# OpenAI Configuration
32-
MEMSCHEDULER_OPENAI_API_KEY=sk-***
33-
MEMSCHEDULER_OPENAI_BASE_URL=http://***.***.***.***:3000/v1
34-
MEMSCHEDULER_OPENAI_DEFAULT_MODEL=gpt-4o-mini
17+
# other memory agents
18+
MEM0_API_KEY="m0-xxx"
19+
ZEP_API_KEY="z_xxx"
20+
MEMU_API_KEY="mu_xxx"
21+
SUPERMEMORY_API_KEY="sm_xxx"
22+
MEMOBASE_API_KEY="xxx"
23+
MEMOBASE_PROJECT_URL="http://***.***.***.***:8019"
3524

36-
# Graph DB Configuration
37-
MEMSCHEDULER_GRAPHDBAUTH_URI=bolt://localhost:7687
38-
MEMSCHEDULER_GRAPHDBAUTH_USER=neo4j
39-
MEMSCHEDULER_GRAPHDBAUTH_PASSWORD=***
40-
MEMSCHEDULER_GRAPHDBAUTH_DB_NAME=neo4j
41-
MEMSCHEDULER_GRAPHDBAUTH_AUTO_CREATE=true

evaluation/README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Evaluation Memory Framework
22

3-
This repository provides tools and scripts for evaluating the LoCoMo dataset using various models and APIs.
3+
This repository provides tools and scripts for evaluating the `LoCoMo`, `LongMemEval`, `PrefEval`, `personaMem` dataset using various models and APIs.
44

55
## Installation
66

@@ -16,16 +16,35 @@ This repository provides tools and scripts for evaluating the LoCoMo dataset usi
1616
```
1717

1818
## Configuration
19+
Copy the `.env-example` file to `.env`, and fill in the required environment variables according to your environment and API keys.
1920

20-
1. Copy the `.env-example` file to `.env`, and fill in the required environment variables according to your environment and API keys.
21+
## Setup MemOS
22+
### local server
23+
```bash
24+
# modify {project_dir}/.env file and start server
25+
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 8
26+
27+
# configure {project_dir}/evaluation/.env file
28+
MEMOS_URL="http://127.0.0.1:8001"
29+
```
30+
### online service
31+
```bash
32+
# get your api key at https://memos-dashboard.openmem.net/cn/quickstart/
33+
# configure {project_dir}/evaluation/.env file
34+
MEMOS_KEY="Token mpg-xxxxx"
35+
MEMOS_ONLINE_URL="https://memos.memtensor.cn/api/openmem/v1"
36+
37+
```
2138

22-
2. Copy the `configs-example/` directory to a new directory named `configs/`, and modify the configuration files inside it as needed. This directory contains model and API-specific settings.
39+
## Supported frameworks
40+
We support `memos-api` and `memos-api-online` in our scripts.
41+
And give unofficial implementations for the following memory frameworks:`zep`, `mem0`, `memobase`, `supermemory`, `memu`.
2342

2443

2544
## Evaluation Scripts
2645

2746
### LoCoMo Evaluation
28-
⚙️ To evaluate the **LoCoMo** dataset using one of the supported memory frameworks — `memos`, `mem0`, or `zep`run the following [script](./scripts/run_locomo_eval.sh):
47+
⚙️ To evaluate the **LoCoMo** dataset using one of the supported memory frameworks — run the following [script](./scripts/run_locomo_eval.sh):
2948

3049
```bash
3150
# Edit the configuration in ./scripts/run_locomo_eval.sh
@@ -45,10 +64,21 @@ First prepare the dataset `longmemeval_s` from https://huggingface.co/datasets/x
4564
./scripts/run_lme_eval.sh
4665
```
4766

48-
### prefEval Evaluation
67+
### PrefEval Evaluation
68+
Downloading benchmark_dataset/filtered_inter_turns.json from https://github.com/amazon-science/PrefEval/blob/main/benchmark_dataset/filtered_inter_turns.json and save it as `./data/prefeval/filtered_inter_turns.json`.
69+
To evaluate the **Prefeval** dataset — run the following [script](./scripts/run_prefeval_eval.sh):
4970

50-
### personaMem Evaluation
71+
```bash
72+
# Edit the configuration in ./scripts/run_prefeval_eval.sh
73+
# Specify the model and memory backend you want to use (e.g., mem0, zep, etc.)
74+
./scripts/run_prefeval_eval.sh
75+
```
76+
77+
### PersonaMem Evaluation
5178
get `questions_32k.csv` and `shared_contexts_32k.jsonl` from https://huggingface.co/datasets/bowen-upenn/PersonaMem and save them at `data/personamem/`
5279
```bash
80+
# Edit the configuration in ./scripts/run_pm_eval.sh
81+
# Specify the model and memory backend you want to use (e.g., mem0, zep, etc.)
82+
# If you want to use MIRIX, edit the the configuration in ./scripts/personamem/config.yaml
5383
./scripts/run_pm_eval.sh
5484
```

evaluation/configs-example/mem_cube_config.json

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)