A Local RAG-Based Framework for Multi-Format Question Generation and Document-Grounded Question Answering from PDF Content

A Local RAG-Based Framework for Multi-Format Question Generation and Document-Grounded Question Answering from PDF Content

Amir Hossein Baradaran1 Saeedeh Sadat Sadidpour2 Kaveh Ahangar Beik3 Seyed Mostafa Hosseini Shakib4

1) PhD student in Artificial Intelligence, Malek Ashtar University of Technology
2) Assistant Professor of Artificial Intelligence, Malek Ashtar University of Technology
3) Master s degree student in Artificial Intelligence, Malek Ashtar University of Technology
4) Master s degree student in Artificial Intelligence, Malek Ashtar University of Technology

IOI Code : AAHD-ABKEGH
Publication : National Conference on Information Technology, Nanotechnology, Artificial Intelligence and Technological Futures Studies(itnaf.ir)
Abstract :
    Large language models have demonstrated strong capabilities in natural language generation; however, directly applying their pretrained knowledge to document-specific educational tasks may result in responses that are insufficiently grounded in the target material. This paper presents a local retrieval-augmented generation (RAG) framework for automatic question generation and document-grounded question answering from PDF content. The proposed system integrates document text extraction and optical character recognition, overlapping text segmentation, semantic embedding, FAISS-based vector retrieval, and locally deployed large language models through Ollama. Dedicated prompting strategies are developed to generate four educational question formats: essay, short-answer, multiple-choice, and fill-in-the-blank questions. A refinement stage is further employed to improve the coverage and structure of the generated questions, while retrieval-based answer generation grounds responses in the most relevant portions of the source document. For interactive use, the framework is integrated into a Streamlit-based interface that enables PDF upload and conversational question answering. The implemented system demonstrates the feasibility of combining local language models, semantic retrieval, and task-specific prompting within a unified document-centered educational framework while reducing dependence on external cloud-based language-model services.

Keywords : retrieval augmented generation (rag) large language models automatic question generation question answering semantic retrieval faiss local llms educational nlp