feat: ingestion pipeline plus Qdrant + BM25 hybrid retrieval#3
Merged
Conversation
Ingestion side: - `loader.py` reads text PDFs (lazy `pypdf` import), markdown, and plain text. Scanned PDFs are out of scope. - `chunker.py` builds the hierarchical split: parent chunks at 1024 tokens, child chunks at 256 with 25-token (10%) overlap. Tokenisation via tiktoken `cl100k_base`. Chunk ids are dashed UUIDs so they double as Qdrant point ids. - `pipeline.py` chains detect, redact, persist redaction map, chunk, then hands clean parents + children to the injected `VectorSink`. Only redacted text leaves the function. - `redaction_store.py` persists `RedactionMap` per document as JSON with atomic tmp + rename writes and a path-traversal guard. Retrieval side: - `embedder.py` exposes `EmbedderBackend` Protocol so tests inject a hash-based fake. The real sentence-transformers backend lives in `_real_backends.py` and is lazy-loaded. - `store.py` adapts Qdrant. Single collection: child vectors with parent text + order stored as payload, so retrieval gives parent context with no second round-trip. Implements `VectorSink` so the ingestion pipeline can use it transparently. - `hybrid.py` adds `BM25Index` (rank_bm25 over child texts) and `HybridRetriever` that fuses dense + BM25 scores via min-max normalisation and a configurable weight. All tests are hermetic: `QdrantClient(location=":memory:")` for the store, deterministic fake embedders, no network. ADRs: 004 Hierarchical chunking 007 Qdrant over Chroma
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cl100k_base), pipeline orchestrator, on-diskRedactionMapStorewith atomic writes and path-traversal guardEmbedder+EmbedderBackendProtocol (real sentence-transformers backend lazy-loaded), Qdrant adapter (single collection with parent payload attached to each child),BM25Index+HybridRetrieverwith min-max score fusionQdrantClient(location=":memory:")Test plan
uv run ruff check .cleanuv run pyright0 errors / 0 warningsuv run pytest tests/test_ingestion_*.py tests/test_retrieval_*.pyall greenADRs referenced