Elephas
by roldychn
README.md
# Elephas
*In Asimov's* Foundation*, an Elephas is the device that stores recordings and replays them untouched — memory a civilization can carry. Elephas hands that device to your agent.*
[简体中文](README.zh-CN.md) · [Agent integration](docs/agents.md) · [Blackwell setup](docs/blackwell.md)
Elephas is a local multimodal RAG for **agents**. It gives an agent tools to carry decisions and images from one conversation into the next. When you ask what you decided, the agent can retrieve your exact words, their source and any later correction. When you ask for a photo, it can return the original file. The tools run over MCP on a workstation or an NVIDIA DGX Spark.
Download the [Elephas v0.2.1 release](https://github.com/roldychn/elephas/releases/tag/v0.2.1) for the current package and examples. Upgrading from the earlier name? Read the [upgrade notes](docs/upgrading.md).
## Measured on shipping hardware
The 0.2.0 release was timed on real devices, not on a leaderboard. Six distinct checks: each returned the expected item first, and both stored files came back byte-identical in all five completed runs.
Loopback HTTP timings: image rows are medians of five warm repetitions; the text row is the first uncached query. These are historical v0.2.0 measurements, not a new v0.2.1 benchmark.
| Check | DGX Spark GB10 | RTX PRO 6000 |
| --- | ---: | ---: |
| First uncached text question, both revisions reranked | 75.4 ms | 114.6 ms |
| Describe a stored portrait (text → image) | 11.2 ms | 11.1 ms |
| Match a portrait (image → image) | 68.1 ms | 39.5 ms |
| Match a screenshot (image → image) | 240.3 ms | 80.6 ms |
- One official **Nemotron-3.5-Embed-1B-NVFP4** encoder searches image pixels and text; the official **Nemotron-3.5-Rerank-1B-BF16** model reranks text candidates.
- The workstation row ran inside a 2.5 GiB PyTorch allocation cap while a separate inference job held most of the card, with BF16 reranking on CPU. The Spark row ran both models on the GPU.
- Triton and PyTorch NVFP4 packers produced identical E2M1 bytes and FP8 block scales on every shape tested (10/10 parity cases per GPU).
- **NVFP4 keeps the footprint small.** The official 1B encoder checkpoint is 1.2 GB on disk at NVFP4 versus 3.0 GB for the same checkpoint at BF16. With both models on the GPU, the stack peaked at 4.22 GiB allocated and 4.25 GiB reserved in the torch allocator on the Spark. Reproduce with `python examples/vram_probe.py` in a configured GPU environment.
- Server start loads both checkpoints (~31 s on the Spark; reported per run in the raw data). Timings exclude startup. These are small personal notebooks, not a corpus benchmark.
- Full protocol, failed-run caveats and per-run readings: [docs/validation.md](docs/validation.md) · [blackwell-results.json](docs/blackwell-results.json)
## Give your agent a memory
For example, tell your agent **“Use A4 for the print edition.”** Later, say **“Use A5 for print. Keep the PDF at A4.”** In a fresh conversation, ask **“What size did we settle on for print?”**
An agent using Elephas saves the original decision with `remember`, links the correction to it, then calls `recall` from the new conversation. It can answer **“A5 for print. The PDF stays A4.”** The returned quote and source turn let you verify both parts. If you ask what changed, `revisions` gives it the earlier A4 decision too.
### Connect Codex
From a source checkout, install the MCP server and register it with Codex. The text-memory workflow runs locally on CPU.
For native Windows Arm64, prepare the [OpenSSL build dependency](docs/blackwell.md#rtx-spark-on-windows-11-arm64) first.
```sh
uv tool install --python 3.12 ".[agent]"
codex mcp add elephas -- elephas mcp
```
Start a new Codex session. Add this to your agent instructions so it knows when to use the tools:
> Keep reusable decisions and preferences in Elephas with my exact words, their conditions and the source turn. Link corrections to the earlier record. When I ask what I chose, look it up and check the quote before answering. Respect requests to keep something out of memory.
For an executable version of the print example, run `uv run --locked --extra agent python examples/agent_memory.py`. It opens two MCP sessions against one temporary database, so you can inspect the result without writing to your own notebook. Other stdio clients can launch the same server. [Client configuration, tool arguments and shared Spark setup](docs/agents.md)
## Give your agent image recall on Blackwell
If you share a photo with your agent, the host can pass the permitted attachment bytes to `attach_image`. In a later conversation, ask **“Can you find the portrait with the orange flight suit?”** The agent calls `find_images` with that description and `original_image` with the matching receipt to inspect or return the photo.
GPU mode searches image pixels and text with the shared Nemotron encoder. CPU mode searches image captions. Install the GPU runtime and checkpoints on the machine where the MCP server will run, then launch `elephas mcp --gpu` through your client. A workstation client can also launch the server on a headless Spark over SSH.
[DGX Spark and Linux RTX](docs/blackwell.md#dgx-spark-and-linux-workstations) · [RTX Spark on Windows Arm64](docs/blackwell.md#rtx-spark-on-windows-11-arm64) · [Other Blackwell devices](docs/blackwell.md#choose-your-machine) · [Hardware results](docs/validation.md)
## Inspect what the agent saved
Run `elephas serve` and open `http://127.0.0.1:7341` to browse the default notebook. If the agent uses `--db`, give the browser server the same path on the same machine. You can inspect a quote, compare revisions or download a stored image.

To explore a separate sample notebook, run `elephas demo` or `elephas demo --gpu` in a configured GPU environment. Under **Images**, search for `orange flight suit`. In the **Flight portrait** result, click **Download original**. [Watch the walkthrough](docs/walkthrough.webp)
## Storage and scope
Text, images and revisions live in SQLite. The default path is `~/.local/share/elephas/notebook.sqlite`. Set `ELEPHAS_HOME` to change the directory. Back up with the SQLite backup API or stop writers before copying the file. `elephas forget-chain RECEIPT` removes the revision chain and originals with no remaining references. Prior backups have their own lifecycle.
The MCP client supplies the speaker, source and complete user message. Elephas checks that the saved quote occurs in that message. For a stronger source check, `remember_from_turn` can verify the user role and recover the original question from an explicitly configured Codex transcript. Retrieval returns candidates for the agent to check against the question. This release targets personal collections and scans the eligible vectors in memory.
An existing Spark RAG service can also be queried through the read-only CLI adapter. Set `ELEPHAS_SPARK_URL` and run `elephas recall "which format did I choose?" --spark --scope owner`.
## Verify a checkout
```sh
uv run --locked python -m unittest discover -s tests -v
uv run --locked --extra agent python examples/agent_memory.py
```
Elephas code uses the [Apache License 2.0](LICENSE). The photograph and fonts have [separate credits and licenses](elephas/assets/CREDITS.txt). NVIDIA distributes its model weights separately.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues