Embedded document stores - Low-Level Design
Created: 2026-12-01 HLD Link: ../../high-level-design.md
Overview
SQLiteVecDocStore and DuckDBDocStore implement AbstractDocumentStore the
same way LanceDBDocStore does: required table_name, storage_path under
~/.llamabot/..., default sentence-transformers model
minishlab/potion-base-8M, lazy imports, and append / extend / retrieve /
reset. Users swap stores by changing the class name.
Both stores persist to a single file ({table_name}.db or
{table_name}.duckdb), run hybrid BM25 + vector search, and fuse rankings with
reciprocal rank fusion.
SQLiteVecDocStore
- Documents table + FTS5 virtual table + sqlite-vec
vec0virtual table. - sqlite-vec 0.1.9 wheels cover macOS arm64/x86_64, linux x86_64/aarch64, and Windows amd64 (the Nov 2024 archive existed because aarch64 linux wheels were missing).
- Connection: stdlib
sqlite3whenenable_load_extensionworks; otherwisesqlean.py. Error text tells the user topip install llamabot[sqlite-vec]. No system SQLite or Homebrew install.
DuckDBDocStore
- Documents table with
FLOAT[dim]embeddings, FTS extension (BM25), VSS extension (HNSW). - Prefer
duckdb-core-ext-vssandduckdb-core-ext-ftswheels viaget_extension_load_path()/extension_directories. Fall back toINSTALL+LOADif the wheel is missing or the DuckDB version does not match. SET hnsw_enable_experimental_persistence = truebefore ATTACH so HNSW indexes survive reopen. WAL recovery for HNSW is experimental; an unclean shutdown can corrupt the index or lose data. Checkpoint after writes and onclose(), and use the store as a context manager.- FTS: prefer DuckDB 2.x
incremental=1(INSERT/DELETE triggers). Treat the index as incremental only when those triggers exist. If they are absent (static index, or incremental create failed), rebuild FTS after writes so BM25 stays current across close/reopen. - Pin DuckDB 2.0.1 and matching
duckdb-core-ext-vss/duckdb-core-ext-ftswheels. LlamaBot requires Python 3.13+, which DuckDB 2.x supports.
Shared behaviour
| Topic | Choice |
|---|---|
| Duplicate documents | Skip, same as LanceDB / TurboVec |
| Embedder | shared_sentence_transformer |
| Fusion | Reciprocal rank fusion, k=60 |
| Optional extras | sqlite-vec and duckdb, also listed in rag |
Error Handling
| Condition | Message |
|---|---|
| Missing sqlite-vec | Install llamabot[sqlite-vec] |
| sqlite3 cannot load extensions and sqlean.py missing | Install llamabot[sqlite-vec] (includes sqlean.py) |
| Missing duckdb | Install llamabot[duckdb] |
| VSS or FTS cannot load | Install llamabot[duckdb] (includes extension wheels) |