Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
38 changes: 38 additions & 0 deletions config/sequential_mem0_qwen35_4b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Mem0 preset for a local Qwen3.5-4B OpenAI-compatible endpoint.
# The Vast.ai launcher in scripts/vastai/overrides the endpoint and served-model
# values at runtime when the corresponding environment variables are set.
agent_name: Structure_rag_mem0_qwen35_4b
model: Qwen3.5-4B
temperature: 0.7
input_length_limit: 30000
model_context_window: 32768
buffer_length: 2000
output_dir: ./results/outputs/Qwen3.5-4B-mem0

# Mem0 runtime and retrieval settings.
agent_chunk_size: 4096
retrieve_num: 100
mem0_add_infer: true

# Local chat-completion endpoint.
provider: openai_compatible
api_key_env: OPENAI_API_KEY
base_url: http://127.0.0.1:9909/v1
base_url_env:
azure_endpoint:
azure_api_version:
tokenizer_encoding: cl100k_base

# Keep Qwen thinking disabled for Mem0 fact extraction and benchmark answers.
qwen3_disable_thinking: true

# Local embedding endpoint. Mem0's Qdrant collection uses the 4B model's
# 2560-dimensional vectors.
mem0_embedder_model: Qwen3-Embedding-4B
embedding_api_key_env: OPENAI_API_KEY
embedding_base_url: http://127.0.0.1:9009/v1
embedding_base_url_env:

# Optional prompt overrides. Empty values select benchmark-specific prompts.
mem0_fact_extraction_prompt:
mem0_memory_answer_prompt:
21 changes: 21 additions & 0 deletions requirements-mem0-vast.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Minimal MemoryData dependencies for the Mem0 + local OpenAI-compatible path.
# vLLM (and therefore torch/transformers) is installed separately by the Vast.ai
# launcher so the model server can use a recent Qwen3.5-compatible release.
numpy<2
python-dotenv
PyYAML
tqdm
datasets
tiktoken
httpx
openai==2.30.0
pydantic==2.12.5
pydantic_core==2.41.5
langchain-core==1.2.25
qdrant-client
posthog
pytz
mem0ai==1.0.10
nltk
rouge-score
editdistance
69 changes: 69 additions & 0 deletions scripts/vastai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Vast.ai: Mem0 with local Qwen3.5-4B

This launcher runs the MemoryData Mem0 benchmark against two local
OpenAI-compatible vLLM services:

- chat and fact extraction: `Qwen/Qwen3.5-4B`
- memory embeddings: `Qwen/Qwen3-Embedding-4B`

The default benchmark is the MemoryAgentBench `longmemeval_s*` subset using the
bundled 150k-context LongMemEval preset.

## Instance recommendation

Use a CUDA Vast.ai image with Python 3.11+ and enough disk space for both model
checkpoints. Two 16 GB or larger GPUs are preferred, one for Qwen3.5-4B and one
for Qwen3-Embedding-4B. A single 24 GB or larger GPU can host both services; the
launcher automatically assigns conservative memory fractions when they share a
GPU.

The default run is a one-query smoke test:

```bash
bash scripts/vastai/run_mem0_qwen35.sh
```

Run every query in the configured five-sample LongMemEval preset:

```bash
MAX_QUERIES=0 bash scripts/vastai/run_mem0_qwen35.sh
```

Remove the preset's five-sample cap and run every available LongMemEval sample:

```bash
MAX_QUERIES=0 MAX_TEST_SAMPLES=999999 bash scripts/vastai/run_mem0_qwen35.sh
```

Run on explicit GPUs or with another dataset config:

```bash
LLM_GPU=0 \
EMBED_GPU=1 \
MAX_QUERIES=0 \
DATASET_CONFIG=benchmark/membench/config/MemBench_simple.yaml \
bash scripts/vastai/run_mem0_qwen35.sh
```

MemBench data must already exist under `datasets/MemBench/`. MemoryAgentBench
falls back to its Hugging Face dataset when the local copy is absent.

## Common overrides

| Variable | Default | Purpose |
| --- | --- | --- |
| `MAX_QUERIES` | `1` | Smoke-test query count; use `0` for every query in the selected samples |
| `MAX_TEST_SAMPLES` | preset value (`5` for LongMemEval) | Positive integer overriding the dataset sample cap |
| `FORCE` | `0` | Use `1` to discard and rebuild prior result/agent state |
| `LLM_GPU` | `0` | Physical GPU index for the chat server |
| `EMBED_GPU` | `1` when available, otherwise `0` | Physical GPU index for embeddings |
| `MAX_MODEL_LEN` | `32768` | Qwen3.5 vLLM context limit |
| `LLM_MODEL` | `Qwen/Qwen3.5-4B` | Hugging Face model ID or local model directory |
| `EMBED_MODEL` | `Qwen/Qwen3-Embedding-4B` | Embedding model ID or local directory |
| `KEEP_SERVERS` | `0` | Use `1` to leave servers running after the benchmark |
| `SKIP_INSTALL` | `0` | Use `1` after the virtual environment is fully prepared |
| `HF_HOME` | `~/.cache/huggingface` | Persistent model cache location |

Server logs and the generated runtime YAML are saved under
`.runtime-cache/vastai-mem0-qwen35/`. Benchmark outputs retain the normal
`results/outputs/` and `results/agents/` layout.
Loading