Skip to main content

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-aware 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

A ladder; start cheap, climb only when a query needs it. All in-process, no ANN, no index server.

doc = redhop.Document.from_text(text, retrieval="lexical")   # BM25 (default)
doc = redhop.Document.from_text(text, retrieval="hybrid",   model="bge-small")  # BM25 -> dense rerank
doc = redhop.Document.from_text(text, retrieval="semantic", model="bge-small")  # exact cosine over all chunks

Add rerank="cross-encoder" on any tier for a precise (slower) second stage.

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://redhop.dev

Apache-2.0. Also available for Node.js (npm install redhop) and Rust (cargo add redhop).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redhop-0.1.2.tar.gz (240.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

redhop-0.1.2-cp39-abi3-win_amd64.whl (12.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

redhop-0.1.2-cp39-abi3-manylinux_2_28_x86_64.whl (16.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ x86-64

redhop-0.1.2-cp39-abi3-manylinux_2_28_aarch64.whl (16.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

redhop-0.1.2-cp39-abi3-macosx_11_0_arm64.whl (13.7 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

redhop-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl (15.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file redhop-0.1.2.tar.gz.

File metadata

  • Download URL: redhop-0.1.2.tar.gz
  • Upload date:
  • Size: 240.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for redhop-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9ba9e4766b2ddb0443253d7f2a1e63713f4076624c6a48ab445e39da977f5598
MD5 d4aa7debd98363551d9e05b8f84f0e0f
BLAKE2b-256 34f73b98feee4a96ba03099c676398f0c59c25951197ac1abf023bce95891cdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.2.tar.gz:

Publisher: release-python.yml on vysakh0/redhop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redhop-0.1.2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: redhop-0.1.2-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

Hashes for redhop-0.1.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b9902e2da34cc00772ab5e6b62816f9e8b408ade8ae261ca22c281a16e0e3a35
MD5 75295e07ccbd7a71911cb6472c5211e7
BLAKE2b-256 9e899c2afe0cc5fecacc7c3f6f812d8544e7ea96383d338b2bdaf7ec2ce15dd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.2-cp39-abi3-win_amd64.whl:

Publisher: release-python.yml on vysakh0/redhop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redhop-0.1.2-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for redhop-0.1.2-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ba0908f09247754fc00c025e30bd838777b3a94f17f83bb40e8cca45f8f67a6
MD5 8175b0cb72940c9014811eade9fb9e57
BLAKE2b-256 9c09d7f61e8cfacb78606f15ab4f8d6b9b4a258c677f75830656e1a6e25e5a31

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.2-cp39-abi3-manylinux_2_28_x86_64.whl:

Publisher: release-python.yml on vysakh0/redhop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redhop-0.1.2-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for redhop-0.1.2-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 120c761e7be3e9b6f095c1c3b14cb93e4fb3e9e378d87e395b4a403493c12d62
MD5 a5081ed2ac645563f0faee1d598ad163
BLAKE2b-256 aa464b73c9ba94ef6a0882111305304cb5fe2ebeeca87e4c66c7c79a7c6e9736

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.2-cp39-abi3-manylinux_2_28_aarch64.whl:

Publisher: release-python.yml on vysakh0/redhop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redhop-0.1.2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for redhop-0.1.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 038795e534cac77b56ebbcde5e6e3e8028e9d9c36637a400cc28b8e68dfa40a2
MD5 ab7c5e0dcb062984b2f846921ea79e47
BLAKE2b-256 bcb6338969ed0fd24ce3635c31d273d9980a91fb06c65abf0a3940c47278a715

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yml on vysakh0/redhop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file redhop-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for redhop-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dc47c17fbd34aee91a18c3ca962c482227cb2b56626677e1affbf28ed33ab029
MD5 284835417f292c8931d12a39e00d8019
BLAKE2b-256 86a8ce1c7537ca54c740f9906d77db3d43753ddede7c88b471e548acf09405e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.2-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python.yml on vysakh0/redhop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page