# Repository Briefing: WujiangXu/A-mem
> Source: https://repoforai.com/repo/WujiangXu/A-mem (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/WujiangXu/A-mem
- **Category**: RAG, Data & Memory (知识库 / 爬虫 / 记忆层)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: B+ (68/100 · Maintenance 26/35 · Adoption 16/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: CLI, API, Local AI
- **Momentum**: 1,019 ★ total (+0 24h / +2 7d) · 120 forks
- **When to Use**: Best for: Reproducing A-Mem on LoCoMo and testing how linked, revisable notes affect historical QA across model backends and retrieval depths. Skip if: You need a production multi-tenant memory API, a durable vector database, or a turnkey offline deployment.

## Overview
```text
### Architecture & Core Mechanics
A-Mem is a Python research memory layer for LLM agents. When new content arrives, it generates a structured note with contextual descriptions and tags, looks for related historical memories, and links them by similarity. Existing notes can also be refined, so the memory state is not simply an append-only collection of conversation chunks.

The tree separates the memory layer (`memory_layer.py`, `memory_layer_robust.py`), LLM text parsing (`llm_text_parsers.py`), and dataset loading (`load_dataset.py`) from the evaluation entrypoints. The manifest includes Sentence Transformers, PyTorch, scikit-learn, and `rank-bm25`, but those dependencies alone do not establish how retrieval scores are combined. The visible integration boundary is Python code plus model-backend selection, not a standalone database service or a verified plugin protocol.

### Key Capabilities & Differentiators
The original evaluator, `test_advanced.py`, requires OpenAI JSON schema support. `test_advanced_robust.py` removes that requirement and provides three backend choices: OpenAI, vLLM, and Ollama. The concrete examples use `gpt-4o-mini`, `Qwen/Qwen2.5-3B-Instruct` behind vLLM, and `qwen2.5:3b` through Ollama, with results written to a specified JSON file.

The LoCoMo run covers multi-hop, temporal, open-domain, single-hop, and adversarial QA. `--ratio` selects a dataset fraction, while `--retrieve_k` controls how many memories are retrieved per query and defaults to 10. `run_k_sweep.sh` reuses memories cached after the first pass and reruns QA, making retrieval depth tunable without rebuilding notes for each setting. That sweep does not measure memory construction cost, and no numerical result table is available for quantifying gains.

### Trade-offs & Limitations
Compared with append-only vector memory, A-Mem tests a different design choice: give retrieved items structured context and links, and let later evidence change earlier notes. That may help recover relationships that isolated chunks miss, but it adds generation and update work on ingestion. It also makes the memory state sensitive to model output and ingestion order, so comparisons should hold both constant.

The repository is a fit for evaluating memory policy, not a drop-in replacement for a vector database or managed memory service. The supplied interface does not establish durability guarantees, concurrent writes, tenant isolation, or a versioned service API. Choose simpler vector retrieval for a low-complexity baseline, and evaluate A-mem-sys if the goal is to build an agent around this design. MIT permits commercial reuse of the code subject to its notice requirements; models and datasets need separate review.

### Hardware & Deployment Guide
Set up a Python virtual environment or use the Conda example with Python 3.9, then install `requirements.txt`. For a first run, invoke `test_advanced_robust.py` with `--dataset data/locomo10.json`, the chosen `--backend` and `--model`, and a JSON `--output` path. OpenAI requires API access. For self-hosted generation, start the model service separately: the vLLM example uses an OpenAI-compatible server on port 30000, selected by `--sglang_port 30000`, with `float16` and a configured maximum model length of 8192. Ollama requires the selected model to be available locally.

No container recipe, fixed hardware envelope, or tagged release is provided. Local serving capacity depends on the chosen model, context length, and concurrency; hosted generation does not eliminate local embedding and evaluation work. For reproducible runs, record installed package versions, model identifiers, retrieval depth, and cache state: the dependency list is unpinned, and cached runs do not exercise the same path as cold runs.
```

## Key Capabilities
```text
- Memory representation: Generates structured notes with contextual descriptions and tags, links related memories, and supports revision.
- Implementation entrypoints: Pairs `memory_layer.py` and `memory_layer_robust.py` with separate original and robust evaluation scripts.
- Backend boundary: Original evaluation depends on OpenAI JSON schema support; the robust CLI accepts `openai`, `vllm`, and `ollama`.
- Retrieval tuning: `--retrieve_k` defaults to 10, and `run_k_sweep.sh` reuses cached memories to rerun QA at different retrieval depths.
- Evaluation scope: `data/locomo10.json` covers multi-hop, temporal, open-domain, single-hop, and adversarial QA.
- Adoption boundary: MIT-licensed reproduction code; A-mem-sys is the designated implementation for building agents.
```

## Quick Start / Clone
```bash
# Create and activate virtual environment
python -m venv a-mem
source a-mem/bin/activate  # Linux/Mac
a-mem\Scripts\activate     # Windows

# Install dependencies
pip install -r requirements.txt
```
