memlayer  by divagr18

LLM memory layer for contextual agents

Created 3 months ago
259 stars

Top 97.9% on SourcePulse

GitHubView on GitHub
Project Summary

Memlayer provides a "plug-and-play" memory layer for Large Language Models (LLMs), enabling developers to add persistent, intelligent recall capabilities to AI agents with minimal code. It addresses the challenge of LLMs lacking inherent long-term memory, allowing them to maintain context across conversations, extract structured knowledge, and proactively surface relevant information. The target audience includes engineers building sophisticated, contextual AI applications, offering a quick integration path to enhance conversational AI.

How It Works

Memlayer employs a hybrid storage approach, combining a vector store (ChromaDB) for semantic similarity search with a knowledge graph (NetworkX) for entity relationships. It features "salience filtering" to intelligently determine which conversational data is important enough to store, using either ML models (LOCAL/ONLINE modes) or keyword-based methods (LIGHTWEIGHT mode). Retrieval is optimized across three tiers—Fast (<100ms), Balanced (<500ms), and Deep (<2s)—allowing developers to balance latency and depth of recall based on the specific use case. This multi-faceted approach ensures efficient and accurate memory management for LLM-powered agents.

Quick Start & Requirements

  • Installation: pip install memlayer
  • Prerequisites: Python 3.10+. Depending on the chosen memory mode, local models (sentence-transformers) or API access (OpenAI, Anthropic, Google) may be required. ChromaDB and NetworkX are core dependencies.
  • Links: Documentation, Examples

Highlighted Details

  • Universal LLM Support: Integrates seamlessly with OpenAI, Claude, Gemini, Ollama, and LMStudio.
  • Plug-and-play: Requires as little as 3 lines of Python code for basic integration.
  • Intelligent Memory Filtering: Three modes (LOCAL, ONLINE, LIGHTWEIGHT) offer configurable salience filtering accuracy and cost trade-offs.
  • Hybrid Search: Combines vector similarity with knowledge graph traversal for robust information retrieval.
  • Multi-Tier Retrieval: Offers Fast, Balanced, and Deep search tiers optimized for different latency requirements.
  • Proactive Reminders: Supports scheduling tasks and receiving automatic reminders.
  • Observability: Built-in tracing provides detailed metrics for search operations.

Maintenance & Community

The project is maintained by Divyansh Agrawal. Support and feature requests are handled via GitHub Issues. Community engagement is encouraged via the getmemlayer Twitter handle.

Licensing & Compatibility

Memlayer is released under the MIT License, which is permissive for commercial use and integration into closed-source projects.

Limitations & Caveats

The LOCAL memory mode has a startup time of approximately 10 seconds due to model loading. The LIGHTWEIGHT mode offers faster startup (<1s) but sacrifices accuracy with keyword-based filtering and lacks vector storage. Deep search tier latencies can reach up to 2 seconds. Specific guidance may be needed for ChromaDB file locking on Windows.

Health Check
Last Commit

3 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
10 stars in the last 30 days

Explore Similar Projects

Starred by Eric Zhu Eric Zhu(Coauthor of AutoGen; Research Scientist at Microsoft Research) and Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems").

ReMe by agentscope-ai

1.4%
993
LLM chatbot framework for long-term memory
Created 1 year ago
Updated 4 days ago
Feedback? Help us improve.