An intelligent, AI-powered tool that automatically generates high-quality Exam Preparation Questions and Answers from PDF documents. This application leverages state-of-the-art LLMs via Groq and advanced RAG (Retrieval-Augmented Generation) pipelines to transform static study materials into interactive learning resources.
- Instant PDF Preview: View your uploaded study material immediately while the AI works in the background.
- Iterative Question Generation: Produces a curated set of 10 comprehensive questions covering the entire document.
- Automated Answering: Uses a RAG pipeline to provide accurate answers based solely on the document's context.
- CSV Export: Download the generated Q&A pairs in a structured CSV format for offline study or integration into other tools (like Anki).
- Modern UI: Clean, responsive interface built with Bootstrap, FontAwesome, and SweetAlert2.
- Backend: FastAPI (Python)
- AI Orchestration: LangChain (LCEL)
- LLM Hosting: Groq (using high-speed inference)
- Vector Database: FAISS
- Embeddings: HuggingFace (
sentence-transformers/all-MiniLM-L6-v2) - Frontend: HTML5, Vanilla JS, Bootstrap 5, jQuery
To ensure maximum coverage of long documents without exceeding model context limits, the application employs an Iterative Refinement Strategy:
- Initial Chain: The first chunk of the document is used to generate an initial set of questions.
- Refinement Loop: As the app processes subsequent chunks, it uses a specialized
refine_question_prompt. This prompt asks the LLM to either update existing questions with more relevant information from the new context or add new ones, ensuring the final list represents the most important concepts of the entire file.
For generating answers, we use a robust Retrieval-Augmented Generation architecture:
- Vector Search: The document is split into overlapping chunks and stored in a FAISS vector index using HuggingFace embeddings.
- Parallel Retrieval: Using LangChain Expression Language (LCEL), we implement a
RunnableParallelchain. This chain simultaneously fetches the relevant context from the vector store and passes the user question to the prompt, optimizing performance.
To maintain a "Premium" user experience:
- Async File I/O: PDF uploads use
aiofilesto prevent blocking the server. - Threaded Execution: Heavy AI processing is handled in a separate thread pool (FastAPI standard
defendpoints), allowing the main event loop to remain responsive and serve the PDF file immediately after upload.
- Python 3.11+
- Groq API Key
-
Clone the repository:
git clone https://github.com/your-username/Question-Answer-Creator-Application.git cd Question-Answer-Creator-Application -
Set up Environment Variables: Create a
.envfile in the root directory:GROQ_API_KEY=your_actual_api_key_here
-
Install Dependencies:
conda create -n qanda python=3.11 -y conda activate qanda pip install -r requirements.txt
-
Run the Application:
python app.py
Access the app at
http://localhost:8000
- Upload: Drag and drop or select a PDF file (Max 5 pages recommended for best results).
- Preview: The PDF will appear in the viewer instantly.
- Wait: The "Generate" spinner indicates the AI is analyzing the text and refining questions.
- Download: Once finished, click the yellow download button to get your
QA.csvfile.
Distributed under the MIT License. See LICENSE for more information.