This project is a web application built with FastAPI and Nextjs that allows users to upload documents and generate a quiz based on their content. The application uses LangChain, ChromaDB, and Ollama embeddings to process documents and retrieve relevant answers through Retrieval-Augmented Generation (RAG).
- Dynamically upload documents
- Process and split text into smaller chunks for improved retrieval
- Store document embeddings in ChromaDB
- Use Ollama embeddings for vector similarity search
- Generate a quiz with 8 questions based on the content
- Submit your answers and receive feedback
- Different types of questions (Yes/No, multiple choice, short response)
- FastApi (Backend Web Framework)
- LangChain (Document Processing & Retrieval)
- ChromaDB (Vector Database)
- Ollama (Embeddings for text retrieval)
- NextJS (Frontend Interface)
- Unstructured.io (Document Parsing)
Before getting started, make sure you have the following installed:
- Python 3.11 or later
- A virtual environment manager (e.g.,
venv,virtualenv)
-
Clone the repository:
git clone https://github.com/OussamaBenSlama/Ollama-RAG-PDF
-
Navigate to the project directory:
cd backend -
Create a virtual environment (optional but recommended):
python3 -m venv .venv
-
Activate the virtual environment:
- On Windows:
.\venv\Scripts\activate
- On Windows:
-
Install dependencies:
pip install -r requirements.txt
-
Install Ollama and download the model:
- First, ensure you have Ollama installed. If you haven't, you can get it from ollama.com.
- Then, run the following command to download the Llama3 model:
ollama run llama3:latest
-
Set up and run the Next.js frontend:
- Navigate to the
projectdirectory:
cd project- Install the required dependencies for Next.js:
npm install
- Start the Next.js development server:
npm run dev
- The frontend will now be available at
http://localhost:3000.
- Navigate to the
Once you've completed these steps, you're ready to use both the backend and frontend of the application.
Once you've completed these steps, you're ready to use the application.
- Upload a PDF file through the web interface.
- The system will generate a quiz with 8 questions based on the content of the document.
- Respond to each question in the quiz.
- Submit your answers when you're finished.
- Receive feedback on your responses.
