Structured PDF retrieval with typed evidence blocks, hybrid search, and grounded citations.
Project description
SectionIQ
SectionIQ is a local-first Python library for structured PDF retrieval. It ingests PDFs into typed evidence blocks, builds hybrid sparse+dense indexes, and returns grounded answers with page/block citations.
The core design is deliberately not tree-first: hierarchy is used as context and a ranking prior, while retrieval still fans out across sparse, dense, heading, and table-aware signals.
Install
pip install sectioniq # core: BM25 + hash embeddings, no API key needed
pip install "sectioniq[local]" # + local semantic embeddings (model2vec, ~30MB, no torch)
pip install "sectioniq[pdf]" # + layout-aware extraction (PyMuPDF, two-column support)
pip install "sectioniq[ocr]" # + OCR for scanned PDFs (ocrmypdf; needs Tesseract)
pip install "sectioniq[openai]" # + OpenAI embeddings, reranking, answer generation
Recommended local setup: pip install "sectioniq[local,pdf]".
For local development:
uv venv --python 3.11
source .venv/bin/activate
uv pip install -e ".[dev,bench]"
python -m pytest
Try It in 60 Seconds
A real session against a public-domain U.S. Army maintenance manual (127 pages), fully local, no API key. Ingest + index takes well under a second:
pip install sectioniq
curl -L -o tm3.pdf "https://commons.wikimedia.org/wiki/Special:Redirect/file/TM-1-1500-204-23-3.pdf"
sectioniq ingest tm3.pdf --index
Ingested 'Tm 1 1500 204 23 3' (127 pages) -> 40ab9bf3-8025-5be2-8118-2d90fbf81c2c
blocks=2977 tables=23 warnings=0 headings=1208
Indexed 2977 blocks from 1 document(s).
sectioniq search "fuel cell purging procedure"
1. [paragraph] Tm 1 1500 204 23 3 (p.38, 40ab9bf3...:b00780)
6 After purging of the fuel cell has been completed, wait approximately two to
three hours, and test fuel cell for the presence of dangerous fuel vapors...
2. [paragraph] Tm 1 1500 204 23 3 (p.73, 40ab9bf3...:b01507)
Purge fuel cell prior to inspection and repair. Refer to paragraph 2-5f(4)
purging procedure.
...
sectioniq answer "How should fuel cells be purged before maintenance?"
(4) Purging. Fuel cells may be purged and preserved by either of the following
methods. [Tm 1 1500 204 23 3 (p.37, 40ab9bf3...:b00742)]
...
Citations:
- Tm 1 1500 204 23 3 (p.37, 40ab9bf3...:b00742)
(Extractive answer: verbatim evidence. Set OPENAI_API_KEY for synthesized answers.)
Everything works without an API key: search runs locally, and answer returns
extractive, citation-backed evidence. Set OPENAI_API_KEY for synthesized
answers and LLM reranking. Run sectioniq info to inspect the local store.
Python Quick Start
from sectioniq import SectionIQ
engine = SectionIQ(store_path=".sectioniq")
doc_id = engine.ingest("/path/to/public-manual.pdf")
engine.build_index()
hits = engine.search("What safety cautions apply before maintenance?", top_k=5)
for hit in hits:
print(hit.block_type, hit.citation, hit.text_preview)
result = engine.answer("What safety cautions apply before maintenance?", top_k=5)
print(result.answer)
print(engine.get_citations(result))
Configuration
SectionIQ picks the best available backends automatically:
| Embeddings | Reranker | Answers | |
|---|---|---|---|
| No API key (core) | Deterministic hash (lexical) | Heuristic | Extractive with citations |
No API key + [local] |
model2vec semantic | Heuristic | Extractive with citations |
OPENAI_API_KEY set |
OpenAI embeddings | LLM reranker | Synthesized, grounded |
Optional environment variables:
SECTIONIQ_EMBEDDING_MODELSECTIONIQ_LOCAL_EMBEDDING_MODEL(defaultminishlab/potion-base-8M)SECTIONIQ_RERANK_MODELSECTIONIQ_LLM_MODEL
Benchmark Results
Measured on the public-domain U.S. Army TM-1-1500-204-23 corpus (9 volumes,
2,231 pages, 62,813 blocks with layout-aware extraction) with 20 public
queries at top_k=5, fully local, no API key:
| System | Source recall@5 | Term recall@5 | p50 query |
|---|---|---|---|
SectionIQ [local,pdf] (semantic + layout-aware) |
0.90 | 0.75 | 19 ms |
SectionIQ [pdf] (hash + layout-aware) |
0.85 | 0.65 | 17 ms |
| SectionIQ core (hash + pypdf) | 0.85 | 0.60 | 12 ms |
| Naive 400-char chunk baseline | 0.75 | 0.50 | — |
| Tree-first hierarchy baseline | 0.60 | 0.35 | — |
Ingest throughput: ~350 pages/s with PyMuPDF (~250 pages/s with pypdf); full 62k-block index build in ~3 s. SectionIQ sweeps the table/spec lookups (1.00 recall) that tree-first navigation and naive chunking miss. See docs/benchmarking.md for the full methodology and reproduction steps.
Public Benchmark Corpus
SectionIQ uses the public-domain U.S. Army TM-1-1500-204-23 aviation
maintenance manual series as its release validation corpus. The tracked manifest
contains source URLs and metadata only; downloaded PDFs stay local and ignored.
python scripts/prepare_public_corpus.py
python scripts/benchmark_vs_pageindex.py --rebuild-index
To include the optional PageIndex comparison:
python scripts/benchmark_vs_pageindex.py --run-pageindex
See docs/benchmarking.md for the benchmark workflow.
Privacy
SectionIQ stores extracted PDF text, metadata, and indexes in the configured local store. Do not commit local stores, PDFs, notebooks, spreadsheets, logs, or benchmark outputs from private documents.
Documentation
- docs/architecture.md: pipeline, modules, store layout, extension points
- docs/api.md: SDK and CLI reference
- docs/benchmarking.md: methodology and reproduction steps
Project Layout
src/sectioniq/: library codebenchmarks/: public corpus manifest and public query setdocs/: architecture, API reference, benchmarkingtests/: unit testsexamples/: local example runnersscripts/: corpus preparation, benchmark, and release-safety utilities
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 sectioniq-0.1.0.tar.gz.
File metadata
- Download URL: sectioniq-0.1.0.tar.gz
- Upload date:
- Size: 55.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f894a6aa320aec52003ab0b40397f99c445b09832a439e87cc8f9a1af253f47
|
|
| MD5 |
475e840ed44b440c163094377802096a
|
|
| BLAKE2b-256 |
30af489d92779139c1e15afdd43caaaf31bb2657664c9ece6cd9ccbb969c3eb3
|
Provenance
The following attestation bundles were made for sectioniq-0.1.0.tar.gz:
Publisher:
publish.yml on Vedant-Ratn-Nema/SectionIQ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sectioniq-0.1.0.tar.gz -
Subject digest:
8f894a6aa320aec52003ab0b40397f99c445b09832a439e87cc8f9a1af253f47 - Sigstore transparency entry: 1790730054
- Sigstore integration time:
-
Permalink:
Vedant-Ratn-Nema/SectionIQ@67d3db310518076f520fbe2070a2637615068128 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Vedant-Ratn-Nema
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67d3db310518076f520fbe2070a2637615068128 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sectioniq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sectioniq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3eb1e414714885b38fdd141d73766497e97853aef2633660baee41b05b41433c
|
|
| MD5 |
a523ca02f3590920577a27fa28d3f96e
|
|
| BLAKE2b-256 |
76d64aa62c2a14bce8cb0ed1fbd15499956564e18c0debec078ea5599daaa645
|
Provenance
The following attestation bundles were made for sectioniq-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Vedant-Ratn-Nema/SectionIQ
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sectioniq-0.1.0-py3-none-any.whl -
Subject digest:
3eb1e414714885b38fdd141d73766497e97853aef2633660baee41b05b41433c - Sigstore transparency entry: 1790730202
- Sigstore integration time:
-
Permalink:
Vedant-Ratn-Nema/SectionIQ@67d3db310518076f520fbe2070a2637615068128 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Vedant-Ratn-Nema
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@67d3db310518076f520fbe2070a2637615068128 -
Trigger Event:
push
-
Statement type: