Skip to main content

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
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 chunk
  • vec_chunks_{dim}: Vector embeddings (via sqlite-vec)
  • chunks_fts: FTS5 index for keyword search
  • inferred_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

Metadata

Release files for qmdc-semantic 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qmdc-semantic 2.0.0
File Size Uploaded
qmdc_semantic-2.0.0.tar.gz 50.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qmdc-semantic 2.0.0
File Interpreter ABI Platform
qmdc_semantic-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 93.9 kB

Release files / qmdc_semantic-2.0.0.tar.gz

Download URL qmdc_semantic-2.0.0.tar.gz
Size 50.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f6ee51b956f504963262bd77c40d11f324bfc5512564d8b4b5af2dafe23e6dc7
BLAKE2b-256 checksum
How to use checksums
1c69163c74e414de7c9a75224cd75266e070f77e8a1e148a82e99bb337105fbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / qmdc_semantic-2.0.0-py3-none-any.whl

Download URL qmdc_semantic-2.0.0-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95d335eafb2d4c4aff9f900d91ec4d4121d342f9b3ae706927c4420f8dd22145
BLAKE2b-256 checksum
How to use checksums
747f8acd0bc487125e5bcb4f48f5b33a3d471f0bf49307561df5c558989b443b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release history Release notifications | RSS feed

2.0.1

2 release files

This release

2.0.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page