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


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.4.tar.gz (261.6 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.4-cp39-abi3-win_amd64.whl (12.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

redhop-0.1.4-cp39-abi3-manylinux_2_28_x86_64.whl (16.5 MB view details)

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

redhop-0.1.4-cp39-abi3-manylinux_2_28_aarch64.whl (16.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

redhop-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl (15.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: redhop-0.1.4.tar.gz
  • Upload date:
  • Size: 261.6 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.4.tar.gz
Algorithm Hash digest
SHA256 5a3d6fd7c1ab60b4dbebfd8141e9c341ce8c08e91c2783271c488e5052fc9640
MD5 bde0ef65ea7d47fdfadc8f5bfb45636a
BLAKE2b-256 ecb20d67985600913670a488ab78919d08aa5f051185f6e2309830845bfa7330

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.4.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.4-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: redhop-0.1.4-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.4-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8eb32320f013c5a6c00d257ca2134008cae5af11b5ca8d656f58406e5d73f59f
MD5 f5ac1006ed68edc12814936ffb90ec0a
BLAKE2b-256 0a8a1b695386aff878ae10470243ae5f294ed8d8f13388e802c7d0f7e3ed931e

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.4-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.4-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for redhop-0.1.4-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ddbf690c029e69b44592ced4327932e522ea1d1157035910f17917666fb4363c
MD5 700f73ccd8a78b620169d6dbfcfe56d0
BLAKE2b-256 47a6908af42797318281196d5a7685a9eb71e189c82f0d3bc878563f2deec303

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.4-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.4-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for redhop-0.1.4-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1eba40fe26ece84d2b2e0f59f5451b75b68ec9f5b7eb8987e134f973c2b9d1cf
MD5 e90df27f28a482fdd6ec93b52f79a6a9
BLAKE2b-256 849c1b52ac174604f72c692a15bb862c5e0da7f49c23e6d2823ea32ff79cc9aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.4-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.4-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for redhop-0.1.4-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e0b06e4e872c0b4e2afc2a6057c3e200f377c7da61d393fc11c6375fa3b14e4
MD5 64c6149dfe097eb97aa075192c2f4758
BLAKE2b-256 c5332cdb9aac44772f1be77aae616f1a9dcdbf4e13e9199eea9de085c4406c5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.4-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.4-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for redhop-0.1.4-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9868082cb72415a8bc00fe606460924b19e26b26c8db28e70dafbe5cef9890a5
MD5 5bbaf3840114b0b338dd1029f42e7081
BLAKE2b-256 acfd82a9db0b08c18ac33153e417402d5d7acefd0d18bfe41a352bc5586b9364

See more details on using hashes here.

Provenance

The following attestation bundles were made for redhop-0.1.4-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