Skip to content

bilaltahseen/document-qa-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retrieval Augmented QA System

A local Document QA system that allows users to upload PDF documents and ask questions about their content using a Retrieval Augmented Generation (RAG) approach. This project uses a lightweight LLM to perform inference directly on your machine.

Document QA System Interface

Features

  • PDF Document Upload: Upload PDF files to be processed for question answering.
  • Context-Aware QA: Ask questions specifically about the uploaded document.
  • Local Inference: Uses LiquidAI/LFM2-1.2B-RAG model running locally (default: CPU).
  • FastAPI Backend: robust and fast API for handling requests.
  • Simple Web Interface: Includes a basic static frontend for testing.

Tech Stack

  • Language: Python 3.13+
  • Framework: FastAPI
  • ML Libraries: PyTorch, Transformers, Accelerate
  • PDF Processing: pypdf
  • Server: Uvicorn

Prerequisites

  • Python 3.13 or higher
  • uv (recommended) or pip

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd document-qa-system
  2. Install dependencies using uv:

    uv sync

    Or using pip:

    pip install .

Usage

Starting the Server

Run the application using the main entry point:

python main.py

The server will start at http://0.0.0.0:8000.

Web Interface

Open your browser and navigate to: http://localhost:8000

API Endpoints

  • POST /api/upload

    • Upload a PDF file.
    • Returns a doc_id.
  • POST /api/ask

    • Body: {"doc_id": "string", "question": "string"}
    • Returns the answer generated by the model.

Configuration

Configuration constants are located in app/constants/config.py:

  • MODEL_NAME: Defaults to LiquidAI/LFM2-1.2B-RAG
  • DEVICE: Defaults to cpu (can be changed to cuda if available)

Project Structure

document-qa-system/
├── app/
│   ├── constants/       # Configuration and constants
│   ├── static/          # Frontend static files
│   ├── inference.py     # ML model and QA logic
│   └── main.py          # FastAPI application definition
├── data/                # Example data
├── main.py              # Application entry point
├── pyproject.toml       # Project dependencies
└── README.md            # Project documentation

About

A local Document QA system that allows users to upload PDF documents and ask questions about their content using a Retrieval Augmented Generation (RAG) approach. This project uses a lightweight LLM to perform inference directly on your machine.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages