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.

PyPI Python License Evidence layer

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

How it compares

Measured on identical documents + budgets + BM25 retrieval, RedHop beats LangChain on multi-hop evidence retention (77% vs 71%) and ties LlamaIndex on contracts (82% vs 86%, while beating LangChain at 73%) — without a vector database, an agent framework, or model finetuning.

Evidence retention vs LangChain vs LlamaIndex

Methodology + raw runs: FRAMEWORK_COMPARISON.md · framework_comparison.txt.

How it works

RedHop pipeline

Five stages: you bring documents and a query, RedHop owns parsing, chunking, retrieval, and context allocation, and you get a BuiltContext with the assembled prompt, citations, and a Decision Report. Each stage has an evidence-backed default that traces to a finding in docs/findings/.

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.

Sample Decision Report

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, source="document") 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.

Non-English content

Default is English Snowball. Swap with the language= kwarg — any of the 18 Snowball Porter2 languages (arabic, danish, dutch, english, finnish, french, german, greek, hungarian, italian, norwegian, portuguese, romanian, russian, spanish, swedish, tamil, turkish):

doc = redhop.Document.from_text(german_text, language="german")
# Now `Buch` finds chunks containing `Bücher` (and vice versa)

One analyzer drives both BM25 retrieval AND the grounding scorer, so they can't drift on what "the same term" means. Unknown names raise (we don't silently fall back to English). See the language guide for the full breakdown and the calibration disclaimer (we ship the stemmers; eval-corpus ranking quality on a real domain corpus is the user's call).

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://www.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.2.2.tar.gz (331.7 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.2.2-cp39-abi3-win_amd64.whl (12.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

redhop-0.2.2-cp39-abi3-manylinux_2_28_x86_64.whl (16.8 MB view details)

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

redhop-0.2.2-cp39-abi3-manylinux_2_28_aarch64.whl (16.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

redhop-0.2.2-cp39-abi3-macosx_11_0_arm64.whl (13.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

redhop-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl (15.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for redhop-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2a2361f8290661e8aba0e609dd58cb88db8f6af3873c066f9e1acc305c2f8bab
MD5 b24ec216da47b7f56881235c61310d3a
BLAKE2b-256 e748902991d242c85fb608dfcedc5dcdd259223e4c3c72ee51850405564fdd89

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: redhop-0.2.2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 12.9 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.2.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3f56bd68c101f639ab9d3749685b179b2a6531cdae87aab5fb48f7b30c377f2a
MD5 abdcc0e088d7483a8740012bbdfcf201
BLAKE2b-256 204925829c11c5f17ad8feeeb9cd3449b63189cc2c9bc7c0db0ff482685b2564

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.2-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cf141931dd289bb5e848fe8358a762ba181e9dd1f1e1578a895289b2a4889cc1
MD5 f514af04e6e32ee6825b4f5b1de29cf4
BLAKE2b-256 ddeda8343cd1464a4daded9a952fe77559f62ffd88481943bedb4a3571368dac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.2-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 918432c83515944c5c0d915c170a8fdc27c6a13714ab7749a51e736114182f49
MD5 0fcf8922496c78c291666341b711b402
BLAKE2b-256 360916c8a98c50cd75215ff9b0c66282aae9eecb07763bd8e726a3f6143c4a2e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 83e7327bd3109d62a3e217dc49fd4ae7a8bf5424a2a8aa11cad52a017706e2ab
MD5 6fa55f01474f8fdb4a5e7a3fe5698346
BLAKE2b-256 975aa04d36f46a717acc71f893ec537afc7988abbb702e1b9e4b4829616b8570

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a609e3fc371f2663fdccb857dbca6d9cf16d217aab144dbc2c099b819925393e
MD5 4c323f8978b6b3650328b0b6098ef66d
BLAKE2b-256 489bd8c1c883326f51133d6cb80e19ee9df59a152b7f58d7c41546d5f44514c7

See more details on using hashes here.

Provenance

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