# awais-asghar/ai-based-exam-paper-generator-using-rag architecture

> Architecture diagram of the GitHub repository awais-asghar/ai-based-exam-paper-generator-using-rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/awais-asghar/ai-based-exam-paper-generator-using-rag
- Repository: https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag

## Overview

This repository is a notebook-based RAG exam-paper generator. Users provide a typed PDF and configure question types, counts, subject, and difficulty; the pipeline extracts and chunks text, retrieves context, generates and validates questions, then exports a formatted paper with an answer key. A parallel TF-IDF baseline and ROUGE-L/readability evaluation are also documented. Runtime components are represented at the notebook path because the notebook source was not sampled; the README documents their pipeline relationships.

Main entry points: [`src/ai-based-exam-paper-generator-using-rag.ipynb`](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb) (Notebook pipeline), [`output/exam_paper_RAG_difficult.pdf`](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/output/exam_paper_RAG_difficult.pdf) (RAG exam PDF), [`output/exam_paper_BASELINE_difficult.pdf`](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/output/exam_paper_BASELINE_difficult.pdf) (Baseline exam PDF)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Document Preparation"]
  node_pipeline["Notebook pipeline"]
  node_extract["PDF extraction"]
  node_chunk["Text chunking"]
end

subgraph group_retrieval["Context Retrieval"]
  node_embed["Dense embeddings"]
  node_faiss[("FAISS index")]
  node_tfidf["TF-IDF baseline"]
  node_retrieve["Context retrieval"]
end

subgraph group_generation["Paper Generation"]
  node_generate["Question generation"]
  node_validate["Output validation"]
  node_export["PDF export"]
end

subgraph group_evaluation["Comparison and Evaluation"]
  node_evaluate["Metric evaluation"]
  node_metrics["ROUGE and readability"]
end

node_user(("Exam creator"))
node_pdf["Source PDF"]
node_groq{{"Groq LLaMA"}}
node_ragpaper["RAG exam PDF"]
node_baselinepaper["Baseline exam PDF"]

node_user -->|"configures"| node_pipeline
node_user -->|"provides"| node_pdf
node_pipeline -->|"runs"| node_extract
node_pdf -->|"supplies text"| node_extract
node_extract -->|"passes text"| node_chunk
node_chunk -->|"encodes chunks"| node_embed
node_embed -->|"indexes vectors"| node_faiss
node_chunk -->|"fits lexical index"| node_tfidf
node_pipeline -->|"requests context"| node_retrieve
node_retrieve -->|"searches"| node_faiss
node_retrieve -.->|"searches baseline"| node_tfidf
node_pipeline -->|"configures questions"| node_generate
node_retrieve -->|"provides context"| node_generate
node_generate -->|"prompts"| node_groq
node_groq -->|"returns questions"| node_generate
node_generate -->|"checks output"| node_validate
node_validate -->|"provides paper"| node_export
node_export -->|"writes PDF"| node_ragpaper
node_pipeline -->|"runs comparison"| node_evaluate
node_evaluate -->|"scores RAG output"| node_ragpaper
node_evaluate -.->|"scores baseline"| node_baselinepaper
node_evaluate -->|"computes scores"| node_metrics

click node_pipeline "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_extract "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_chunk "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_embed "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_faiss "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_tfidf "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_retrieve "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_generate "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_validate "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_export "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_ragpaper "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/output/exam_paper_RAG_difficult.pdf"
click node_baselinepaper "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/output/exam_paper_BASELINE_difficult.pdf"
click node_evaluate "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"
click node_metrics "https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pipeline,node_extract,node_chunk toneBlue
class node_embed,node_faiss,node_tfidf,node_retrieve toneAmber
class node_generate,node_validate,node_export toneMint
class node_evaluate,node_metrics toneRose
class node_user,node_pdf,node_groq toneIndigo
class node_ragpaper,node_baselinepaper toneTeal
```

## Components

### Document Preparation

- [Notebook pipeline](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [PDF extraction](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [Text chunking](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`

### Context Retrieval

- [Dense embeddings](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [FAISS index](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [TF-IDF baseline](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [Context retrieval](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`

### Paper Generation

- [Question generation](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [Output validation](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [PDF export](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`

### Comparison and Evaluation

- [Metric evaluation](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`
- [ROUGE and readability](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/src/ai-based-exam-paper-generator-using-rag.ipynb): `src/ai-based-exam-paper-generator-using-rag.ipynb`

### Other components

- **Exam creator**
- **Source PDF**
- **Groq LLaMA**
- [RAG exam PDF](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/output/exam_paper_RAG_difficult.pdf): `output/exam_paper_RAG_difficult.pdf`
- [Baseline exam PDF](https://github.com/awais-asghar/ai-based-exam-paper-generator-using-rag/blob/main/output/exam_paper_BASELINE_difficult.pdf): `output/exam_paper_BASELINE_difficult.pdf`

## Connections

- Exam creator → Notebook pipeline: configures
- Exam creator → Source PDF: provides
- Notebook pipeline → PDF extraction: runs
- Source PDF → PDF extraction: supplies text
- PDF extraction → Text chunking: passes text
- Text chunking → Dense embeddings: encodes chunks
- Dense embeddings → FAISS index: indexes vectors
- Text chunking → TF-IDF baseline: fits lexical index
- Notebook pipeline → Context retrieval: requests context
- Context retrieval → FAISS index: searches
- Context retrieval → TF-IDF baseline: searches baseline
- Notebook pipeline → Question generation: configures questions
- Context retrieval → Question generation: provides context
- Question generation → Groq LLaMA: prompts
- Groq LLaMA → Question generation: returns questions
- Question generation → Output validation: checks output
- Output validation → PDF export: provides paper
- PDF export → RAG exam PDF: writes PDF
- Notebook pipeline → Metric evaluation: runs comparison
- Metric evaluation → RAG exam PDF: scores RAG output
- Metric evaluation → Baseline exam PDF: scores baseline
- Metric evaluation → ROUGE and readability: computes scores
