Lightweight vector search for Markdown-based memory systems. Chunk, embed, index, and hybrid-search your .md knowledge base with sqlite-vec.
Project description
markdown-memory-vec
Lightweight vector search for Markdown-based memory systems. Chunk, embed, index, and hybrid-search your .md knowledge base with sqlite-vec.
Features
- Markdown-native: YAML frontmatter parsing for metadata (importance, type, tags)
- Smart chunking: Paragraph-aware splitting with configurable overlap (~400 tokens, 80 overlap)
- SHA-256 dedup: Never re-embed unchanged content — incremental indexing is fast
- Hybrid search: Combines semantic similarity (α), importance weighting (β), and temporal decay (γ)
- Zero-copy storage: sqlite-vec KNN search with cosine distance in a single
.dbfile
Quick Start
Installation
# Core only (YAML parsing, chunking, interfaces)
pip install markdown-memory-vec
# With vector search support (sqlite-vec + sentence-transformers)
pip install 'markdown-memory-vec[vector]'
Python API
from memory_vec import MemoryVectorService
svc = MemoryVectorService("/path/to/project")
svc.rebuild_index() # Full index build
results = svc.search("how to deploy") # Hybrid search
svc.close()
Low-level API
from memory_vec import (
SqliteVecStore,
SentenceTransformerEmbedder,
MemoryIndexer,
HybridSearchService,
)
store = SqliteVecStore("memory.db")
store.ensure_tables()
embedder = SentenceTransformerEmbedder()
indexer = MemoryIndexer(store, embedder, memory_root="/path/to/memory")
indexer.index_directory("/path/to/memory")
search = HybridSearchService(vec_store=store, embedder=embedder)
results = search.search("how to deploy")
for r in results:
print(f"{r.file_path} (score={r.hybrid_score:.3f}): {r.chunk_text[:80]}...")
CLI Usage
# Full rebuild
memory-vec /path/to/project --rebuild
# Incremental update (only changed files)
memory-vec /path/to/project --incremental
# Search
memory-vec /path/to/project --search "how to deploy" --top-k 5
# Statistics
memory-vec /path/to/project --stats
# Custom memory subdirectory
memory-vec /path/to/project --rebuild --memory-subdir "docs/memory"
# Verbose logging
memory-vec /path/to/project --rebuild -v
API Reference
High-level
| Class | Description |
|---|---|
MemoryVectorService |
All-in-one service: rebuild, incremental index, search, stats |
Components
| Class | Description |
|---|---|
SqliteVecStore |
sqlite-vec backed vector store with KNN search |
SentenceTransformerEmbedder |
Lazy-loading sentence-transformers embedder |
MemoryIndexer |
Markdown → chunks → embeddings → store pipeline |
HybridSearchService |
Hybrid scoring: α×semantic + β×importance + γ×temporal |
Interfaces
| Interface | Description |
|---|---|
IEmbedder |
Abstract embedder (embed, embed_batch, dimension) |
ISqliteVecStore |
Abstract vector store (add, search, delete, clear, count) |
Data Types
| Type | Description |
|---|---|
VectorRecord |
Record for insertion (id, embedding, metadata) |
VectorSearchResult |
Raw KNN result (id, distance, metadata) |
SearchResult |
Hybrid search result with all score components |
MemoryVecMeta |
Metadata dataclass for stored embeddings |
Utilities
| Function | Description |
|---|---|
chunk_text(text, chunk_size, overlap_size) |
Split text into overlapping chunks |
parse_frontmatter(text) |
Extract YAML frontmatter from Markdown |
content_hash(text) |
SHA-256 hex digest |
is_sqlite_vec_available() |
Check sqlite-vec availability |
is_sentence_transformers_available() |
Check sentence-transformers availability |
Architecture
┌─────────────────────────────────────────────────────┐
│ MemoryVectorService │
│ (high-level orchestration layer) │
├──────────┬──────────┬──────────────┬────────────────┤
│ │ │ │ │
│ Indexer │ Search │ Embedder │ Store │
│ │ │ │ │
│ .md file │ hybrid │ sentence- │ sqlite-vec │
│ → chunks │ scoring │ transformers│ KNN + meta │
│ → embed │ α+β+γ │ (lazy load) │ (cosine) │
│ → store │ │ │ │
└──────────┴──────────┴──────────────┴────────────────┘
▲ │
│ YAML frontmatter │
│ importance/type/tags ▼
┌─┴─────────────────────┐ ┌─────────────────────┐
│ Markdown Files │ │ vector_index.db │
│ (.claude/memory/) │ │ (single file) │
└───────────────────────┘ └─────────────────────┘
Configuration
HuggingFace Model
By default, uses paraphrase-multilingual-MiniLM-L12-v2 (384-dim, 50+ languages).
For users in China or regions with slow HuggingFace access:
# Use a mirror
export HF_ENDPOINT=https://hf-mirror.com
# Or use offline mode (model must be pre-cached)
export HF_HUB_OFFLINE=1
Hybrid Search Weights
Default: α=0.6, β=0.2, γ=0.2, λ=0.05
search = HybridSearchService(
vec_store=store,
embedder=embedder,
alpha=0.8, # Semantic weight
beta=0.1, # Importance weight
gamma=0.1, # Temporal decay weight
decay_lambda=0.03, # Slower decay
)
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 markdown_memory_vec-0.1.0.tar.gz.
File metadata
- Download URL: markdown_memory_vec-0.1.0.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faf8f536f5a159eb1a49fbf1a8fa915a57f8ad81bf1b2afb112c6f1592fa74c4
|
|
| MD5 |
3c04a0955b2dedd4f7313ba6d40b955e
|
|
| BLAKE2b-256 |
7a6c447bd028fa14a20c806fa8a971421d6e8dfb426671877597d2a1458c54d3
|
Provenance
The following attestation bundles were made for markdown_memory_vec-0.1.0.tar.gz:
Publisher:
publish.yml on aigente/markdown-memory-vec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_memory_vec-0.1.0.tar.gz -
Subject digest:
faf8f536f5a159eb1a49fbf1a8fa915a57f8ad81bf1b2afb112c6f1592fa74c4 - Sigstore transparency entry: 1102219114
- Sigstore integration time:
-
Permalink:
aigente/markdown-memory-vec@9877f0398aaf31e4db607e57b25693ce79c2ebbb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aigente
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9877f0398aaf31e4db607e57b25693ce79c2ebbb -
Trigger Event:
release
-
Statement type:
File details
Details for the file markdown_memory_vec-0.1.0-py3-none-any.whl.
File metadata
- Download URL: markdown_memory_vec-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d100cc58fcf47e60a0c4a308d2107ad3b3a9ba09cf3b5ced25a67a78b33bb4fc
|
|
| MD5 |
535b4855e2f70fac3e3245a13619abcf
|
|
| BLAKE2b-256 |
7c9ddb4c43a8ee269f572b2f5c9304102aa60a6aa44e2505a2ed48c0a0df1698
|
Provenance
The following attestation bundles were made for markdown_memory_vec-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on aigente/markdown-memory-vec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markdown_memory_vec-0.1.0-py3-none-any.whl -
Subject digest:
d100cc58fcf47e60a0c4a308d2107ad3b3a9ba09cf3b5ced25a67a78b33bb4fc - Sigstore transparency entry: 1102219115
- Sigstore integration time:
-
Permalink:
aigente/markdown-memory-vec@9877f0398aaf31e4db607e57b25693ce79c2ebbb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aigente
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9877f0398aaf31e4db607e57b25693ce79c2ebbb -
Trigger Event:
release
-
Statement type: