This is a simple interactive chatbot built using Gemini 1.5 Flash, LangChain, and FAISS inside a Jupyter Notebook on Google Colab. It answers student queries using PDF lecture notes.
- π Retrieval-Augmented Generation (RAG) to answer questions using custom lecture notes
- π¬ Real-time question-answering using Gemini 1.5 Flash
- π§ Embedding generation with
models/embedding-001 - β‘ Fast and low-latency responses ideal for chatbots
- π Vector similarity search with FAISS
- π‘οΈ Secure API key usage via Google Colab secrets
-
PDF Upload
Lecture notes are uploaded as a PDF and parsed into raw text usingpdfplumber. -
Text Chunking
The extracted text is split into manageable chunks usingCharacterTextSplitterwith overlapping context. -
Embedding Generation
Each chunk is embedded usingGoogleGenerativeAIEmbeddingsfor semantic similarity. -
Vector Storage
Embeddings are stored and indexed using FAISS for fast similarity search. -
Query Answering
A custom prompt instructs Gemini to act as a CTSE teaching assistant. LangChainβsRetrievalQAcombines retrieval and generation to answer user questions using relevant chunks. -
Interactive Chat
Users ask questions through the notebook and receive clear, formatted answers using Markdown display.
-
Download the Notebook
Download the Jupyter notebook (.ipynb) from this GitHub repository. -
Open in Google Colab
Go to Google Colab and upload the notebook. -
Set the Gemini API Key in Colab Secrets
Before running the notebook:- Go to Google AI Studio and obtain a Gemini API key by creating a new API key.
- In Google Colab, open the "Secrets" panel (ποΈ icon on the left sidebar).
- Create a new secret named:
GOOGLE_API_KEY - Paste your Gemini API key as the value.
- Make sure the notebook has access to the secret (enable notebook access if prompted).
-
Run All Cells in Order
The notebook will:- Ask you to upload a PDF file of your lecture notes.
- Automatically process the content, generate embeddings, and prepare the retrieval system.
-
Ask Questions and Get Answers
Enter any question related to the lecture notes in the final cell and receive an AI-generated answer based only on the uploaded content.
- Vihangi Rathnayake
- Developed as part of the SE4010 β Current Trends in Software Engineering course assignment.