Remote embedding API support for SimpleMem - Efficient Lifelong Memory for LLM Agents.
SimpleMem Remote extends the original SimpleMem with support for remote embedding APIs (OpenAI, Bailian, etc.) instead of local SentenceTransformers models. This provides:
- Faster initialization - No need to load large local models (~9s saved)
- Configurable dimensions - Support for 512, 1024, and other embedding dimensions
- Batch processing - Efficient batch embedding API calls
- OpenAI-compatible - Works with any OpenAI-compatible API endpoint
clawhub install simplemem-remotepip install simplemem openai lancedb pyarrow numpySet the following environment variables:
# Required
export OPENAI_API_KEY="your-api-key"
# Optional
export OPENAI_BASE_URL="https://api.openai.com/v1"
export LLM_MODEL="gpt-4o-mini"
export EMBEDDING_MODEL="text-embedding-v4"
export EMBEDDING_DIMENSION="512"
export EMBEDDING_BATCH_SIZE="10"from simplemem_wrapper import SimpleMemRemote
# Initialize
memory = SimpleMemRemote()
# Add memories
memory.add("User likes coffee, especially oat milk lattes")
memory.add("User's favorite programming language is Python")
# Finalize to process buffered memories
memory.finalize()
# Search
results = memory.retrieve("What does the user like?")
print(results)# Add a memory
python simplemem_wrapper.py add "User lives in Shanghai"
# Finalize
python simplemem_wrapper.py finalize
# Search
python simplemem_wrapper.py search "Where does the user live?"
# Stats
python simplemem_wrapper.py stats| Metric | Local (all-MiniLM-L6-v2) | Remote (text-embedding-v4, 512d) |
|---|---|---|
| Initialization | ~9000ms (model loading) | ~100ms |
| Retrieval | ~1400ms | ~300ms |
| Vector Size | 1536 bytes | 2048 bytes (512 floats) |
For text-embedding-v4:
- 2048, 1536, 1024, 768, 512, 256, 128, 64
Lower dimensions = smaller storage + faster search, with minor quality trade-off.
Tested with:
- OpenAI API
- Alibaba Cloud Bailian (百炼)
- Azure OpenAI
- Any OpenAI-compatible endpoint
-
Remote Embedding API
- Replaced local SentenceTransformers with OpenAI-compatible API
- Added configurable embedding dimensions via
dimensionsparameter - Batch embedding support to reduce API calls
-
Custom VectorStore
RemoteVectorStoreclass that uses remote embedding- Properly initializes with correct vector dimensions
-
Cleaner Interface
SimpleMemRemoteclass as the main entry point- Simplified configuration via environment variables
- Original SimpleMem: https://github.com/aiming-lab/SimpleMem
- Paper: https://arxiv.org/abs/2601.02553
MIT License