How ussa24/document-based-qa-qg works
Project type and purpose
• This is a backend-centric, full-stack-style AI service (no dedicated “frontend” UI here) that exposes a FastAPI HTTP interface.
• Purpose: ingest PDF documents, build a Retrieval-Augmented Generation (RAG) pipeline using LangChain + FAISS + LLaMA-2, generate QA pairs, evaluate answers, and expose results via REST endpoints.
File structure
• Top-level Python modules:
• preprocessing.py – PDF text extraction, chunking, embedding generation
• llm.py – orchestration of LLM calls for question generation and answering
• scoring.py – post-hoc answer evaluation algorithm (cosine-filter + voting with prompts)
• create_score_report.py – aggregates scores and generates PDF reports
• generators.py – helper routines for building/serializing Q&A data
• fast_api.py – FastAPI application with endpoints
• Supporting folders:
• uploads/ – incoming PDF documents by category
• score_reports/ – generated PDF reports for marketing, etc.
• images/ – static docs for README
• Config and dependencies: requirements.txt, README.md
README for architecture insights
• FastAPI endpoints store text in MongoDB, retrieve PDFs & categories, serve QA, trigger evaluation.
• External systems: MongoDB, FAISS (local), HuggingFace Models, google-trans.
Essential architectural elements in detail
• REST endpoints exposed by FastAPI on its boundary