Skip to main content

Modular RAG framework with support for FAISS, Weaviate, and Hybrid Search.

Project description

Hayagriva – Modular Retrieval-Augmented Generation Framework

Hayagriva

सर्वविद्याप्रसूत्यर्थं हयग्रीवोऽवतारतः वेदान् संरक्ष्य जगतां हितकारी सदा भवेत्

"To restore and protect all knowledge, Hayagriva has manifested. He safeguards the Vedas for the good of the world."

Hayagriva is a lightweight, modular Retrieval-Augmented Generation (RAG) framework that connects LLMs with efficient document retrieval. It focuses on grounded answers, fast iteration, and easy integration for developers and research teams.


Key Features

Retrieval-Augmented Generation

Combine contextual retrieval with LLMs to produce grounded, source-aware answers.

Supported LLM backend today: Groq.

Retrieval Strategies

Hayagriva supports multiple retrieval strategies (depending on vector store):

  • Vector Search: Dense semantic retrieval.
  • BM25: Sparse keyword retrieval (Weaviate).
  • Hybrid Search: Vector + keyword with configurable weighting (Weaviate).

Chunking Strategies

  • Word (Default): Sliding window on word count.
  • Recursive: Split by separators to preserve structure.
  • Semantic: Embedding-aware topic shifts.
  • Hierarchical: Parent/child chunking for broad + precise context.

Modular Vector Stores

  • FAISS: Lightweight, in-memory vector store.
  • Weaviate: Production-grade vector DB with hybrid/BM25.

Flexible Document Handling

  • Programmatic document ingestion.
  • File and directory ingestion helpers.
    • Directory ingestion reads .txt files by default.

Automatic chunking and metadata assignment are built in.


Installation

Default (Lightweight)

Core libraries only:

pip install hayagriva

CPU Support (Recommended for Local Testing)

Installs sentence-transformers and faiss-cpu:

pip install "hayagriva[cpu]"

GPU Support

Installs sentence-transformers and faiss-gpu:

pip install "hayagriva[cuda]"

Python Usage

Example setup scripts are available in setup/, and capability-focused examples are grouped under examples/.

Example Categories

The examples are split by what part of the RAG pipeline you want to try:

  • examples/ingestion/: load text or .txt files without embeddings or LLM calls.
  • examples/chunking/: run word, recursive, semantic, or hierarchical chunking.
  • examples/indexing/: embed chunks and write them to FAISS or Weaviate.
  • examples/retrieval/: retrieve chunks without calling Groq.
  • examples/end_to_end/: complete Groq-powered RAG flows.
  • examples/vectorstores/weaviate/: Weaviate vector, BM25, and hybrid examples.

For local FAISS and embedding examples:

bash setup/install_local_deps.sh
export GROQ_API_KEY="YOUR_GROQ_KEY"

For Weaviate examples:

bash setup/install_local_deps.sh
bash setup/start_weaviate.sh
export GROQ_API_KEY="YOUR_GROQ_KEY"

Basic Example (FAISS + Vector Search)

from hayagriva import Hayagriva, HayagrivaConfig

config = HayagrivaConfig(
    backend="groq",
    api_key="YOUR_GROQ_KEY",
    model="llama-3.1-8b-instant",
)

rag = Hayagriva(config)
rag.add_documents(["Hayagriva restores forgotten knowledge."])

response = "".join(rag.ask("Who retrieved the lost Vedas?"))
print(response)

Building Block Example (Chunking Only)

from hayagriva.config import ChunkingConfig
from hayagriva.core.chunker import WordChunker

chunker = WordChunker(ChunkingConfig(chunk_size=8, overlap=2))
chunks, metadata = chunker.chunk([
    "Hayagriva restores knowledge and RAG retrieves context before generation."
])

print(chunks)
print(metadata)

Structured Response (Answer + Metadata)

resp = rag.ask("Who retrieved the lost Vedas?", return_metadata=True)
print(resp["answer"])
print(resp["chunks"][0])
print(resp["retrieval"]["strategy"])

Returned metadata includes: retrieved chunk ranks/scores, chunking strategy, retrieval strategy, model backend, and vector store.

Customizing Embeddings

config = HayagrivaConfig(
    backend="groq",
    api_key="YOUR_KEY",
    embedding_model="intfloat/multilingual-e5-large",
)

Advanced Example (Weaviate + Hybrid Search)

from hayagriva import Hayagriva, HayagrivaConfig
from hayagriva.config import WeaviateConfig, RetrievalConfig, ChunkingConfig

weaviate_config = WeaviateConfig(
    url="http://localhost:8080",
    index_name="HayagrivaDocs",
)

config = HayagrivaConfig(
    backend="groq",
    api_key="YOUR_GROQ_KEY",
    vector_store="weaviate",
    weaviate=weaviate_config,
    retrieval=RetrievalConfig(strategy="hybrid", alpha=0.5, top_k=4),
    chunking=ChunkingConfig(strategy="recursive", chunk_size=500, overlap=50),
)

rag = Hayagriva(config)
rag.add_documents(["Hayagriva is an avatar of Vishnu."])

for token in rag.ask("Who is Hayagriva?"):
    print(token, end="", flush=True)

Requirements

  • Python 3.10+
  • API key for Groq

Optional (only if you use local embeddings or FAISS):

  • sentence-transformers
  • faiss-cpu or faiss-gpu

If using external vector databases:

  • weaviate-client

Roadmap

Expanded LLM Provider Support

  • Anthropic Claude
  • Google Gemini
  • DeepSeek
  • Local GGUF models and llama.cpp

Additional Vector Database Integration

  • ChromaDB
  • Additional pluggable backends

Memory-Augmented Chat

  • Multi-turn memory
  • Embedding-based long-term memory
  • Summarization-based memory compression

Use Cases

  • Retrieval-augmented assistants
  • Knowledge-base and enterprise search
  • Research and benchmarking of RAG pipelines
  • Lightweight production deployments
  • Internal document Q&A systems

Contributing

Contributions to model integrations, retrieval modules, and documentation are welcome. Submit issues or pull requests.


Support

For questions, bugs, or feature requests, open an issue on the project repository.

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

hayagriva-0.2.5.1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

hayagriva-0.2.5.1-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file hayagriva-0.2.5.1.tar.gz.

File metadata

  • Download URL: hayagriva-0.2.5.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hayagriva-0.2.5.1.tar.gz
Algorithm Hash digest
SHA256 3889d13b3c7ccc212f1f2b20a57b03e47abb1b55c0b1a1c8629555a09082b57a
MD5 72b014c0293d299ad66963c91ba04abf
BLAKE2b-256 285ec7fb4876052044d4f2aac06954193106e1e719cf05c0c3de8e8f0110446e

See more details on using hashes here.

File details

Details for the file hayagriva-0.2.5.1-py3-none-any.whl.

File metadata

  • Download URL: hayagriva-0.2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 28.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for hayagriva-0.2.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f11d2b22e24f061b983120274f3c8b739c32445b75570f9c9dd54b9e97c3e83
MD5 9459bc3f67e91346dc520fe6e8d82e84
BLAKE2b-256 ef3a1895b9d1383628884f851eda69333eababaa5c50df3572c962c60bad1e22

See more details on using hashes here.

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