Long-term personalized memory for ANY local LLM via Ollama + ChromaDB + LangChain
Project description
local-persona-memory
Long-term personalized memory for ANY local LLM running via Ollama.
Your AI assistant forgets everything when the session ends. This library fixes that — permanently, privately, and with zero cloud dependency.
What it solves
Most RAG libraries are built for searching documents. This library is built for remembering people. It stores user preferences, facts, skills, and goals, then injects the most relevant memories into every LLM response automatically.
Supported models
Works with any model in the Ollama library:
| Use case | Recommended model |
|---|---|
| General assistant | llama3, llama3.1, mistral |
| Fast / lightweight | phi3, gemma2:2b, tinyllama |
| Coding assistant | codellama, deepseek-coder |
| Multilingual | qwen2, qwen2.5 |
| Reasoning | deepseek-r1, qwen2.5:14b |
Install
pip install local-persona-memory
Prerequisites:
- Install Ollama
- Pull a model and the embedding model:
ollama pull llama3 ollama pull nomic-embed-text
- Run
ollama serve(or open the Ollama app)
Quick start
from local_persona_memory import PersonaMemoryManager
# Works with any Ollama model
mem = PersonaMemoryManager(user_id="alice", model="llama3")
# Store memories
mem.remember("Alice is a Python developer building AI tools")
mem.remember("Alice prefers concise answers and code examples")
# Learn from documents
mem.ingest_pdf("notes.pdf")
# Chat with automatic memory context
response = mem.chat("What should I work on today?")
print(response)
# Inspect stored memories
print(f"Stored {mem.memory_count()} memories")
Advanced usage
from local_persona_memory import PersonaMemoryManager, LLMConfig, MemoryConfig, MemoryCategory
mem = PersonaMemoryManager(
user_id="bob",
llm_config=LLMConfig(
model="mistral", # any Ollama model
temperature=0.4,
context_window=8192, # increase for larger models
),
memory_config=MemoryConfig(
top_k_memories=8, # retrieve more memories per query
chunk_size=512, # PDF chunk size in characters
similarity_threshold=0.3,
embedding_model="nomic-embed-text",
),
)
# Categorise memories for better filtering
mem.remember("Bob knows Rust and Go", category=MemoryCategory.SKILL)
mem.remember("Bob wants to build a CLI tool", category=MemoryCategory.GOAL)
# Recall with category filter
skill_memories = mem.recall("programming languages", category=MemoryCategory.SKILL)
How it works
User message
│
▼
[Embed with nomic-embed-text]
│
▼
[ChromaDB similarity search] ──► Top-K relevant memories
│
▼
[Build prompt: system + memories + message]
│
▼
[Generate with Ollama model]
│
▼
Personalised response
Memories persist to ~/.local_persona_memory/ between sessions. Each user gets an isolated ChromaDB collection.
Contributing
Contributions welcome! See CONTRIBUTING.md. Open an issue first for large changes.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file local_persona_memory-0.2.0.tar.gz.
File metadata
- Download URL: local_persona_memory-0.2.0.tar.gz
- Upload date:
- Size: 39.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30d3352077442561771ea5c8f99493a31531e1ad644f9716e64a2db0af10a243
|
|
| MD5 |
f7d666b3be97b384c5475f692304e074
|
|
| BLAKE2b-256 |
67c2f267c22d5f997201f45e33e86667f5ed46f3abc2a655f17e59b97a4b2a34
|
File details
Details for the file local_persona_memory-0.2.0-py3-none-any.whl.
File metadata
- Download URL: local_persona_memory-0.2.0-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
825c9df2337350107b985e9901da2ba814c7453620e776972baac6c60a693157
|
|
| MD5 |
9de8fbbf49d1732feef66ee8f73c1315
|
|
| BLAKE2b-256 |
2fd4ad8149bcf617f78a402ecccd9ed0b731fd677631449be1cd0c4e01bbf66c
|