CoolFace
Apppublic

shantanu006/hackerx

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

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-flash model 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

KeyValue
Content-Typeapplication/json
AuthorizationBearer <YOUR_TOKEN>

Request Body

The request body must be a JSON object with the following structure:

json
{
  "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?"
  ]
}