Reasoning-aware context runtime for RAG — chunk, retrieve, and allocate the document context an LLM should see, with citations and a Decision Report. In-process, no vector DB.
Project description
RedHop
A reasoning-preserving context runtime for RAG.
Hand it a document and a question. RedHop chunks, retrieves, and allocates the context your model should actually see — then tells you what it kept, what it dropped, and why, with citations back to the source. No vector database, no LLM, all in-process.
import redhop
doc = redhop.Document.from_file("contract.pdf")
ctx = doc.context("What is the governing law?")
answer = llm.generate(ctx.text()) # any LLM provider — no lock-in
pip install redhop
One self-contained wheel — no Python dependencies. The default lexical tier needs no model at all; the semantic/rerank tiers download a small model on first use (cached).
The idea
Retrieval quality is not the same as reasoning quality. Transformers tolerate irrelevant context far better than they tolerate missing reasoning links — so the chunk a multi-hop answer depends on is often low-relevance to the query and gets silently pruned. RedHop's default keeps it, and makes the trade-off visible. It is not a retriever, vector database, agent framework, or workflow engine — it does one thing: turn a document and a query into the right prompt context, and explain the decision.
It explains every decision
Every call returns a Decision Report — what it kept, what it dropped, and why, including when it deliberately leaves a small context untouched.
print(ctx.report)
RedHop Decision Report
══════════════════════
Decision: Auto → pruning (intervened on a diluted context)
Why:
- large/diluted contexts dilute attention; pruning recovers signal density
Result:
- removed distractor chunks, kept all query-relevant evidence
- preserved a second-hop link a plain relevance filter would drop
Diagnostics
───────────
Chunks: 24 → 3
Second-hop rescues: 1
Read the fields directly via ctx.report.auto_decision, total_tokens,
retained_evidence_ratio, or call doc.analyze(query) for the report without
assembling a context.
Cite the evidence
Every selected chunk remembers where it came from:
for c in ctx.citations:
print(c["source"], c["page"], c["heading"])
# contract.pdf 3 None -> "contract.pdf, p.3"
# notes.md None "Refunds" -> "notes.md -> Refunds"
Loading documents
| On-ramp | For |
|---|---|
Document.from_text(text) |
text you already have |
Document.from_chunks([...]) |
content you already chunked |
Document.from_file("x.pdf") |
a file — PDF, DOCX, PPTX, XLSX, Markdown, or text/code |
Document.from_bytes(data, source="x.pdf") |
bytes you fetched (S3 / GCS / HTTP / DB) |
Document.from_folder("./docs", persist=True) |
a whole directory, with an optional incremental on-disk index |
Retrieval tiers — no vector database
Start at the lexical default — it handles most document QA because the words in the question are usually the words in the answer — and climb only when the failure shape calls for it. All in-process, no ANN, no index server.
# Default — most docs (code, API refs, runbooks, financial reports, handbooks)
doc = redhop.Document.from_file("contract.pdf")
ctx = doc.context("What is the governing law?")
# Structured docs with parallel clauses (regional overrides, per-region sub-sections):
doc = redhop.Document.from_file("msa.pdf", retrieval="hybrid", model="bge-small")
ctx = doc.context("What law applies in the UK?", include_heading=True, neighbors=1)
# Synonym-mismatch corpora (HR FAQs, support tickets where users phrase
# things very differently from the docs). Cross-encoder adds 5–10× latency
# — verify it helps on your corpus before enabling.
doc = redhop.Document.from_file("support.md",
retrieval="hybrid", model="bge-small", rerank="cross-encoder")
The 60-second decision guide with trade-offs and query-writing tips: CHOOSING_A_CONFIG.
Assembly strategies
strategy= |
What it does |
|---|---|
reasoning_preserving (default) |
keep query-relevant seeds and rescue low-relevance chunks linked to one; drop only unlinked junk |
distractor_filtered |
drop everything below a query-grounding bar |
max_density |
greedily pack the densest chunks into the budget |
raw_topk |
keep retrieval order until the budget fills |
auto |
size-gated: pass small contexts through, prune large/diluted ones |
Already have chunks from your own retriever? Use redhop.build_context(query, retrieved_chunks=chunks, ...) for the low-level surface.
Documentation
Full docs, the comparison vs LangChain / LlamaIndex, and the evidence behind every default: https://redhopai.com
Apache-2.0. Also available for Node.js (npm install redhop) and Rust
(cargo add redhop).
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 Distributions
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 redhop-0.1.3.tar.gz.
File metadata
- Download URL: redhop-0.1.3.tar.gz
- Upload date:
- Size: 253.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c79aaceeb157173369957b05cd70828a29f5f0e70c65b5abfdcd1d7a9ab78968
|
|
| MD5 |
20e8229f024c9e1df8e62ee6e65dba89
|
|
| BLAKE2b-256 |
8c1788260e62ef9f739f506bf5ad336f384ab28a0a511458dddee15c38c6cb8a
|
Provenance
The following attestation bundles were made for redhop-0.1.3.tar.gz:
Publisher:
release-python.yml on vysakh0/redhop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redhop-0.1.3.tar.gz -
Subject digest:
c79aaceeb157173369957b05cd70828a29f5f0e70c65b5abfdcd1d7a9ab78968 - Sigstore transparency entry: 1684529207
- Sigstore integration time:
-
Permalink:
vysakh0/redhop@0c532a2cb448882b289c7532c888efcf635e6a69 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vysakh0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0c532a2cb448882b289c7532c888efcf635e6a69 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file redhop-0.1.3-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: redhop-0.1.3-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 12.7 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2cbad780fd25ca02b3f46036e6dd58b13e336877d38a933dbcf9acd8b07f7bf
|
|
| MD5 |
651f8b21e367acc7ea465fb6f3595999
|
|
| BLAKE2b-256 |
ebbd53afc62faa3f14d81ef10480a2787f89ab769fd83ed80a30565bd786c307
|
Provenance
The following attestation bundles were made for redhop-0.1.3-cp39-abi3-win_amd64.whl:
Publisher:
release-python.yml on vysakh0/redhop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redhop-0.1.3-cp39-abi3-win_amd64.whl -
Subject digest:
b2cbad780fd25ca02b3f46036e6dd58b13e336877d38a933dbcf9acd8b07f7bf - Sigstore transparency entry: 1684529372
- Sigstore integration time:
-
Permalink:
vysakh0/redhop@0c532a2cb448882b289c7532c888efcf635e6a69 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vysakh0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0c532a2cb448882b289c7532c888efcf635e6a69 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file redhop-0.1.3-cp39-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: redhop-0.1.3-cp39-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 16.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6bdad493db257acdcf2a55eec261261a5df7cdab8512792eb64324b002ffadc
|
|
| MD5 |
7bcf9dd7afc7341dd0be456b07840656
|
|
| BLAKE2b-256 |
d7353e0a1589832ad8924ea53764e708a03f07066efd0805001a86e646aa4816
|
Provenance
The following attestation bundles were made for redhop-0.1.3-cp39-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release-python.yml on vysakh0/redhop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redhop-0.1.3-cp39-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
a6bdad493db257acdcf2a55eec261261a5df7cdab8512792eb64324b002ffadc - Sigstore transparency entry: 1684529822
- Sigstore integration time:
-
Permalink:
vysakh0/redhop@0c532a2cb448882b289c7532c888efcf635e6a69 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vysakh0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0c532a2cb448882b289c7532c888efcf635e6a69 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file redhop-0.1.3-cp39-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: redhop-0.1.3-cp39-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 16.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b016035c79cf3d0b69353aa20acb05eeaf9668ca931aef0f649b5a2bbf51d086
|
|
| MD5 |
9157d142b10927ec927ae70e47a66f87
|
|
| BLAKE2b-256 |
9bcd8688c44273695d8cddcaf88ab761f3bd084e506082c188cff3730193affa
|
Provenance
The following attestation bundles were made for redhop-0.1.3-cp39-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release-python.yml on vysakh0/redhop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redhop-0.1.3-cp39-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
b016035c79cf3d0b69353aa20acb05eeaf9668ca931aef0f649b5a2bbf51d086 - Sigstore transparency entry: 1684530190
- Sigstore integration time:
-
Permalink:
vysakh0/redhop@0c532a2cb448882b289c7532c888efcf635e6a69 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vysakh0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0c532a2cb448882b289c7532c888efcf635e6a69 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file redhop-0.1.3-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: redhop-0.1.3-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 13.7 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd2d911b46af2e288081d5b5bf423575589e97bef179284dae0942ccf6369fcd
|
|
| MD5 |
9256bdbf8b1ca9fed660ccb4358c7ab0
|
|
| BLAKE2b-256 |
3c1d877380f092146986dd39876d6240d21fc9334c17a146dba0490c778f94d8
|
Provenance
The following attestation bundles were made for redhop-0.1.3-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release-python.yml on vysakh0/redhop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redhop-0.1.3-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
fd2d911b46af2e288081d5b5bf423575589e97bef179284dae0942ccf6369fcd - Sigstore transparency entry: 1684530307
- Sigstore integration time:
-
Permalink:
vysakh0/redhop@0c532a2cb448882b289c7532c888efcf635e6a69 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vysakh0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0c532a2cb448882b289c7532c888efcf635e6a69 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file redhop-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: redhop-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 15.0 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
533b05adf10f06f513b046330de5797da230944cd4ee7c2dff4abc53a63f5733
|
|
| MD5 |
fbc6946300683140eefba5629429bd6b
|
|
| BLAKE2b-256 |
aa864df0851e29c58fde58eec72c1ea7ff8e484d27d38410e05a4e44509f1da2
|
Provenance
The following attestation bundles were made for redhop-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release-python.yml on vysakh0/redhop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
redhop-0.1.3-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
533b05adf10f06f513b046330de5797da230944cd4ee7c2dff4abc53a63f5733 - Sigstore transparency entry: 1684530415
- Sigstore integration time:
-
Permalink:
vysakh0/redhop@0c532a2cb448882b289c7532c888efcf635e6a69 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/vysakh0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@0c532a2cb448882b289c7532c888efcf635e6a69 -
Trigger Event:
workflow_dispatch
-
Statement type: