shantanu006/hackerx
0
Multi-Document AI Query Engine
This project is a high-performance FastAPI application that provides a robust Question-Answering (Q&A) service over a set of multiple documents. It leverages a sophisticated AI pipeline to deliver accurate answers with low latency, designed to be stable and efficient even on free-tier cloud platforms.
๐ Features
- Multi-Document Support: Ingests and reasons over several PDF documents simultaneously to provide comprehensive answers.
- Lean, Sparse-First Retrieval: Utilizes a fast, offline BM25 keyword search for initial context retrieval. This ensures high speed and efficiency by minimizing expensive API calls.
- Fused Single-Pass Reasoning: Employs a single, powerful call to the
gemini-1.5-flashmodel for final answer generation, drastically reducing API usage and latency. - Memory-Optimized: Built with a stateless, on-the-fly engine that avoids heavy in-memory caching, making it highly stable for low-resource environments.
- Secure Endpoint: The API is protected by Bearer token authentication.
๐ ๏ธ Tech Stack
- Backend: Python 3.11, FastAPI
- AI Model: Google Gemini 1.5 Flash
- PDF Parsing: PyMuPDF
- Retrieval Algorithm: Rank_BM25
โ๏ธ API Documentation
Endpoint
POST /api/v1/hackrx/run
This endpoint processes a list of documents and questions, returning a list of corresponding answers.
Headers
Request Body
The request body must be a JSON object with the following structure:
{
"documents": [
"[https://your-document-url-1.pdf](https://your-document-url-1.pdf)",
"[https://your-document-url-2.pdf](https://your-document-url-2.pdf)"
],
"questions": [
"What is the policy on pre-existing conditions?",
"What is the grace period for premium payment?"
]
}