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.

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.1.tar.gz (312.9 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.1-cp39-abi3-win_amd64.whl (12.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

redhop-0.2.1-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.1-cp39-abi3-manylinux_2_28_aarch64.whl (16.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

redhop-0.2.1-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.1.tar.gz.

File metadata

  • Download URL: redhop-0.2.1.tar.gz
  • Upload date:
  • Size: 312.9 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.1.tar.gz
Algorithm Hash digest
SHA256 0b7576d9f341ccc28837676e8bcd15433ac4c24169cbb41ffaa556b98bf5cfa3
MD5 248681933c6c5f1ad751874b469cfdec
BLAKE2b-256 3aa1e6238a8f8a9acc782d2b08370f63255293a7e2aed171ac798957fe116986

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: redhop-0.2.1-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.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 16ea04174473af8acc1eb81691c5530fe361fe9f09d9029feef6a7ac29c8e7f0
MD5 e7e53d467cf4508a0db7f7f73987e255
BLAKE2b-256 d5629ac2244acdee76385817b40b7d1ac050047342d180bb5ac37f3966615dbb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e4280ceec0d986403ba2dd96faa7c1530942e2685ed94c001370007771cc0eb
MD5 6f2513f747519526f25ff4d5b7ef606b
BLAKE2b-256 d674d7a006c59b679545d4635e9990d767f381f20725dbba51137dcc1ce0eac5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.1-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 af36c36b2f536c44e6e55c39c5cc55b64bddfd84681118947afed54cfee48be2
MD5 1067b4a1ef95fa066ca1437c215da837
BLAKE2b-256 8872c8186a12edcb5b272b78eab300668990cbeab02e8bb7e852d22fa5809932

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b79bf3acd076bb18e2d9d123dd6b0d7cdf1b144c8082c07547700ce026623be2
MD5 0f0344ff6d7df9b114f8d098ded7bcce
BLAKE2b-256 2481ff06614b97c5498b28fec9bbb114ccacff2dbaae4bd3ce99b79e788bdf51

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for redhop-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b566eb37e0855c73be693bd42ac8262fd35c311fbe0fe4f1f927f6e2c9c20252
MD5 51f9c14da49fa3e1a7b7f71feeec488f
BLAKE2b-256 9033849442da763e0d1ac70356abaa9e7071dbbe5bb2601688726cbb6eb24ac9

See more details on using hashes here.

Provenance

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