Semantic search for QMDC workspaces - hybrid search, graph walk, inferred edges
Project description
QMDC Semantic
Semantic search for QMDC workspaces with hybrid approach (FTS5 + Dense embeddings) and graph walk.
Installation
cd qmdc-semantic
uv pip install -e .
Requirements:
- Python 3.12+
- qmdc (install from
../qmdc-py) - sqlite-vec extension
- Ollama (for local embeddings) or OpenRouter API key
Quick Start
# 1. Index a workspace
qmdc-semantic index /path/to/workspace
# 2. Search
qmdc-semantic search /path/to/workspace "how to test LSP"
# Impact scan (query from file)
qmdc-semantic search /path/to/workspace --from-file task.qmd.md
Configuration
Create .qmdc-semantic/config.yaml in workspace or ~/.qmdc-semantic/config.yaml globally:
embedding:
provider: ollama # ollama | openrouter
model: nomic-embed-text
base_url: http://localhost:11434
# Or for OpenRouter:
# embedding:
# provider: openrouter
# model: openai/text-embedding-3-small
# api_key_env: OPENROUTER_API_KEY
chunking:
min_text_length: 10
long_field_threshold: 50
inferred:
similarity_threshold: 0.7
top_k: 50
Features
- Hybrid Search: Combines FTS5 keyword search with dense vector search
- RRF Fusion: Reciprocal Rank Fusion for combining rankings
- Graph Walk: Expands results through explicit and inferred edges
- Inferred Edges: Computes semantic similarity between objects
- Incremental Update: Hash-based diff for efficient re-indexing
- Parent Document Retrieval: Returns context for child chunks
CLI Commands
index
qmdc-semantic index [WORKSPACE_PATH] [--force] [--verbose]
Creates/updates embeddings in .qmdc-semantic/embeddings.db.
Options:
--force, -f: Reindex all chunks (ignore cache)--verbose, -v: Verbose output
search
qmdc-semantic search [WORKSPACE_PATH] "query" [-k N] [--depth N] [--from-file FILE]
Search for relevant objects.
Options:
-k, --top-k: Number of results (default: 10)--depth, -d: Graph walk depth (default: 2)--from-file, -f: Use file content as query (for impact scan)--verbose, -v: Verbose output
API Usage
from qmdc_semantic import load_config, Storage, extract_chunks, semantic_search
# Load config
config = load_config("/path/to/workspace")
# Initialize storage
storage = Storage("/path/to/workspace")
# Extract and index chunks (see cli.py for full flow)
chunks = extract_chunks("/path/to/workspace", config.chunking)
# Search
results = semantic_search(
storage=storage,
query="how to test LSP",
config=config,
top_k=10,
depth=2,
)
for result in results:
print(f"{result['object_kind']}: {result['object_id']}")
print(f" Score: {result['score']:.3f}")
Storage
Data is stored in .qmdc-semantic/embeddings.db (SQLite):
chunks: Metadata and text for each chunkvec_chunks_{dim}: Vector embeddings (via sqlite-vec)chunks_fts: FTS5 index for keyword searchinferred_edges: Semantic similarity edges
Git LFS: For large workspaces, consider using Git LFS for the database file:
git lfs track ".qmdc-semantic/*.db"
Development
# Install with dev dependencies
uv pip install -e ".[dev]"
# Run tests
uv run pytest tests/ -v
# Run linter
uv run ruff check .
License
AGPL-3.0-or-later © mikilabs
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 qmdc_semantic-1.0.0.tar.gz.
File metadata
- Download URL: qmdc_semantic-1.0.0.tar.gz
- Upload date:
- Size: 50.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48d89c275024e09c9fbeae6c4fe33c3825888674043a79499d98cd0943e687b8
|
|
| MD5 |
8238d2cded8971b4faeb3d690f0b2a38
|
|
| BLAKE2b-256 |
a1eadc43a6bac0ade18015b5cbad058077d742bede28d9e9f39bff9899245817
|
File details
Details for the file qmdc_semantic-1.0.0-py3-none-any.whl.
File metadata
- Download URL: qmdc_semantic-1.0.0-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca88f919080da9df773984f8d155bbf18c0024715a13e723020e2e0c7239490b
|
|
| MD5 |
2cafd631281e9d3f748b4d21e7248f7d
|
|
| BLAKE2b-256 |
36fdca3d7290fbfa76441f8344dfe1c9eb953b0f31a71af78b7fc8ac8b1e3f14
|