Skip to main content

EdgeMem

EdgeMem is a 0-LLM-token memory management system for multi-session agent conversations. It builds lightweight local memory indexes from dialogue turns, routes questions through timeline and graph structure, and optionally calls an LLM only for final answer generation and evaluation. Because its core ingestion and retrieval path is low-cost and local-first, it is suitable for edge devices; optional LLM-enhanced features will continue to expand over time.

Highlights

  • Edge-first ingestion: local entity extraction, keyword extraction, time parsing, and JSON persistence.
  • Structured memory retrieval: timeline retrieval, hypergraph routing, tri-graph diffusion, optional embedding retrieval, and score fusion.
  • LoCoMo and LongMemEval-S support: reproducible CLIs for long-term memory QA retrieval and generation.
  • Explainable evidence: every retrieved snippet includes source, score, session, speaker, and timestamp metadata.
  • Standalone visual demo: docs/edgemem_visual_demo.html demonstrates graph-routed memory vs summary-only memory.

Project Layout

edgemem_op/
  edgemem/                    # Core Python package
    cli/                      # answer/evaluate/baseline CLIs
    data_models.py            # MemoryNode, HyperEdge, HyperGraph, Evidence
    timeline.py               # Timeline retriever
    hypergraph.py             # Hypergraph memory and routing
    trigraph.py               # Entity/keyword-turn-session graph retriever
    embedding_retriever.py    # Optional embedding retriever
    generator.py              # Evidence-to-answer prompt
    eval_judge.py             # LLM-as-judge evaluation
  edgemem_memory_plugin/      # Embeddable memory plugin facade
  scripts/                    # Analysis and demo trace utilities
  docs/                       # Method notes, formulation, visual demo
  evaluation/data/locomo/     # Place LoCoMo data here locally; not committed
  longmemeval/...             # Place LongMemEval-S cleaned data here locally; not committed
  examples/traces/            # Exported retrieval trace example
  requirements.txt            # Minimal runtime dependencies
  pyproject.toml              # Package metadata

Installation

cd edgemem_op
python -m pip install -r requirements.txt
edgemem-init
edgemem-doctor

If you want to use a larger spaCy model:

edgemem-init --model en_core_web_md
export EDGEMEM_SPACY_MODEL=en_core_web_md

Configuration

EdgeMem reads OpenAI-compatible API settings from environment variables:

export LLM_API_KEY="your-key"
export LLM_BASE_URL="https://api.openai.com/v1"  # optional
export LLM_MODEL="gpt-4o-mini"

export EMB_API_KEY="$LLM_API_KEY"                # only needed for embed/triembed
export EMB_BASE_URL="$LLM_BASE_URL"
export EMB_MODEL="text-embedding-3-small"

You can also copy my_config.example.py to my_config.py for local development, but do not commit my_config.py.

Python Memory Plugin

EdgeMem can be embedded directly as a long-term memory plugin:

from edgemem_memory_plugin import EdgeMemMemoryPlugin, MemoryEvent, MemoryQuery

memory = EdgeMemMemoryPlugin()
memory.write_event(
    MemoryEvent(
        user_id="demo_user",
        session_id="session_1",
        text="I care about turn-level R@5 for LongMemEval.",
    )
)

hits = memory.retrieve(
    MemoryQuery(
        user_id="demo_user",
        query="What metric do I care about?",
        top_k=3,
        mode="fused",
        rerank="trigraph",
    )
)
print(memory.format_context(hits))

Run the included example:

python edgemem_memory_plugin/examples/basic_usage.py

Quick Start

Package smoke tests after installation:

edgemem-init
edgemem-doctor
edgemem-memory-demo
edgemem-smoke-longmemeval --help
edgemem-smoke-locomo --help

If the spaCy model download is blocked, the package can still run basic smoke tests with spaCy's blank English fallback, but NER quality will be lower.

Timeline-only baseline:

python -m edgemem.cli.answer \
  --dataset evaluation/data/locomo/locomo10.json \
  --mode timeline \
  --question "When did Caroline go to the LGBTQ support group?"

Fused timeline + tri-graph retrieval:

python -m edgemem.cli.answer \
  --dataset evaluation/data/locomo/locomo10.json \
  --mode fused \
  --rerank trigraph \
  --context-window 1 \
  --question "When did Caroline go to the LGBTQ support group?"

Run the LoCoMo evaluation:

python -m edgemem.cli.evaluate \
  --dataset evaluation/data/locomo/locomo10.json \
  --mode fused \
  --rerank trigraph \
  --run-name locomo_all_trigraph_context \
  --max-workers 10 \
  --context-window 1 \
  --verbose

Run LoCoMo retrieval-only detailed metrics without answer generation:

python -m edgemem.cli.evaluate_locomo_retrieval \
  --dataset evaluation/data/locomo/locomo10.json \
  --mode fused \
  --rerank trigraph \
  --top-k 5 \
  --ks 1,3,5,10 \
  --context-window 1 \
  --run-name locomo_retrieval_detailed \
  --verbose

This writes turn/session/context retrieval metrics to results/locomo_retrieval_summary_<run-name>.json.

Convenience smoke test wrapper:

edgemem-smoke-locomo \
  --dataset evaluation/data/locomo/locomo10.json \
  --limit 5

Add --with-llm plus LLM_API_KEY/LLM_BASE_URL/LLM_MODEL to generate answers and run LLM-as-judge.

Run EdgeMem retrieval on LongMemEval-S cleaned:

python -m edgemem.cli.evaluate_longmemeval \
  --dataset longmemeval/longmemeval-data-cleaned/data/longmemeval_s_cleaned.json \
  --mode fused \
  --rerank trigraph \
  --retrieval-top-k 50 \
  --generation-top-k 5 \
  --context-window 1 \
  --run-name longmemeval_s_cleaned_edgemem \
  --verbose

This command evaluates retrieval without calling an LLM. Add --generate to also write results/longmemeval_hypotheses_<run-name>.jsonl with {question_id, hypothesis} lines for the official LongMemEval QA evaluator.

Convenience smoke test wrapper:

edgemem-smoke-longmemeval \
  --dataset longmemeval/longmemeval-data-cleaned/data/longmemeval_s_cleaned.json \
  --limit 3

Dataset pages:

Visual Demo

Open this file directly in a browser:

docs/edgemem_visual_demo.html

To export a real retrieval trace from the current code:

python scripts/export_edgemem_trace.py \
  --dataset evaluation/data/locomo/locomo10.json \
  --conversation-index 0 \
  --qa-index 0 \
  --top-k 5 \
  --max-nodes 80 \
  --output examples/traces/edgemem_trace_demo.json

Notes for Open Source Release

  • my_config.py, .env, caches, generated results, benchmark datasets, and real API keys are intentionally ignored.
  • Download LoCoMo and LongMemEval data separately before running benchmark CLIs.
  • The core non-embedding retrieval path requires no LLM during ingestion or retrieval.
  • LLM calls are used by generator.py, eval_judge.py, embedding retrieval, and scripts that explicitly rejudge results.

Metadata

Release files for edgemem 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for edgemem 0.1.3
File Size Uploaded Provenance Actions
edgemem-0.1.3.tar.gz 46.8 kB Without provenance Details for edgemem-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for edgemem 0.1.3
File Interpreter ABI Platform Actions
edgemem-0.1.3-py3-none-any.whl Python 3 none any Details for edgemem-0.1.3-py3-none-any.whl

Total release size: 107.8 kB

Release files / edgemem-0.1.3.tar.gz

Download URL edgemem-0.1.3.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d96d0270b2ad2d166e28e100161cd94325cee18db30fa9f5736c57aee5ef73e0
BLAKE2b-256 checksum
How to use checksums
73352b8dc3b098d8d26a588adb68c00623d38adb8e16ee41003a4ac1e5e5a92a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / edgemem-0.1.3-py3-none-any.whl

Download URL edgemem-0.1.3-py3-none-any.whl
Size 60.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9be1d510de2ec28ba6790808ad141f657da090f36d7dbc35fd360d3abcd280c6
BLAKE2b-256 checksum
How to use checksums
fe8e6190649b5c5de7e5cfde65508ba1b0feeb1ec7feec272772f7eb74fae6d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for edgemem 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page