Skip to main content

📚 HieRAG – Hierarchical Retrieval-Augmented Generation

hie_rag is a modular, extensible Python package designed for Hierarchical Retrieval-Augmented Generation (Hie-RAG). It enables you to extract, split, embed, summarize, and query documents using both chunk- and tree-level semantics, all backed by a vector database.


✅ Features

  • PDF/DOCX/XLSX/CSV/PPT ingestion and intelligent semantic splitting
  • Hierarchical summarization tree building
  • Embedding-based similarity search
  • Vector DB indexing and querying (e.g., Qdrant)
  • Full streaming interface for frontend integration

📦 Components Used

Module Role
HieRAG Main interface for processing, querying, and managing indexes.
Split Split raw text into chunks
Process Adds metadata and embeddings to chunks
TreeIndex Builds tree-based hierarchical summaries
Utils Text extraction and token handling
Vectordb Stores and queries summaries/chunks
AiClient Handles embedding API (e.g., OpenAI, HuggingFace, Ollama)

🛠 Installation

pip install hie-rag

⏯︎ How to Use

Initialize HieRAG

from hie_rag import HieRag

hierag = HieRag(base_url="http://localhost:11434")

[!NOTE] Ensure you have set u an AI server. You should have a chatting model and a embedding model running.

Process and Index a File

with open("sample.pdf", "rb") as f:
    file_bytes = f.read()

for status in hierag.process_and_save_index_stream(
    file_name="sample.pdf",
    uploaded_file=file_bytes,
    min_chunk_size=300,
    max_chunk_size=500
):
    print(status)
{
  "status": "✅ Done",
  "file_id": "abc123",
  "summary_count": 5,
  "chunk_count": 22
}

Query the Summaries or Chunks

Query Summaries by text:

results = hierag.query_summaries_by_text("What is the contract duration?")

Query Chunks by text:

results = hierag.query_chunks_by_text("Explain clause 3.4", file_id="abc123")

List & Manage Indexed Files

List All Indexed Files

hierag.list_summaries()

View Chunks of a File

hierag.list_chunks(file_id="abc123")

Delete a File Index

hierag.delete_index(file_id="abc123")

Get the Summary of a File

hierag.get_summary(file_id="abc123")

Metadata

Release files for hie-rag 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hie-rag 0.2.5
File Size Uploaded Provenance
hie_rag-0.2.5.tar.gz 13.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hie-rag 0.2.5
File Interpreter ABI Platform
hie_rag-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / hie_rag-0.2.5.tar.gz

Download URL hie_rag-0.2.5.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b5a23b3fb769358559ccf2c6004c4e2df0641b485e215424f06b293554965741
BLAKE2b-256 checksum
How to use checksums
f63531e7f16171d661a98838f51aa436cb1b1417b4874a91e192b515111c6189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / hie_rag-0.2.5-py3-none-any.whl

Download URL hie_rag-0.2.5-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a7cf1e0db37ecf7dd5a371a1d47738162ec252e229b026fb84488f6e2a59d16
BLAKE2b-256 checksum
How to use checksums
4a014fd3b37ca669f154f9f8509b95cb8976d780dc81f90b0d7b3544920dfc6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for hie-rag 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page