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.2

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.2
File Size Uploaded Provenance Actions
qmdc_semantic-2.0.2.tar.gz 50.9 kB Without provenance Details for qmdc_semantic-2.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 93.9 kB

Release files / qmdc_semantic-2.0.2.tar.gz

Download URL qmdc_semantic-2.0.2.tar.gz
Size 50.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6ca1df5bbf10b2d69ce642f2381fb4df0d6572d17a778eca744092a0a126899d
BLAKE2b-256 checksum
How to use checksums
b7ed8430f54d4a40cf6c28c5033a551474758a6ec669acf4118a55f666057338
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.2-py3-none-any.whl

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

Security for qmdc-semantic 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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