This project is a Retrieval-Augmented Generation (RAG) AI Teaching Assistant. It uses your own video course data to answer student questions with video titles, timestamps, and summarized explanations.
Move all your video files to the videos folder.
Convert all the video files to MP3 by running:
python videos_to_mp3.pyConvert all the MP3 files to JSON by running:
python mp3s_to_jsons.pyUse the process_jsons.py script to convert the JSON files to a dataframe with embeddings and save it as a joblib pickle:
python process_jsons.py- Load the joblib file into memory.
- Create a relevant prompt using the user query.
- Feed it to the LLM (for example
llama3.2:latest). - Store the LLM response in a file called
response.txt:
with open("response.txt", "w") as f:
f.write(llm_response)We use [yt-dlp] to download videos in 144p quality:
yt-dlp -f "bestvideo[height=144]+bestaudio/best[height=144]" "ytvideo.link"Once the video is downloaded (in .webm format), use ffmpeg to convert it into an MP3 file:
ffmpeg -i "input_video_name.webm" output_audio_file.mp3We used the Whisper “medium” model to create transcripted chunks from the MP3 files. This also allows Hindi to English translation. We stored these transcripted chunks into the jsons folder, creating a separate folder per video.
-
Transcripts were split into very small chunks
-
Limited context was available for the LLM
-
5 consecutive chunks are merged into one larger chunk
-
Provides richer semantic context to the LLM
-
Reduces fragmented and incomplete answers
-
Improves reasoning over longer explanations
-
This update significantly improves answer quality and coherence.
We used bge-m3 (via Ollama) to create vector embeddings of the chunked transcripted text. We also created vector embeddings of the user query to match them with the most relevant answer chunks.
- Similarity search: cosine similarity.
- Top results: We take the top 5 matching chunks for each user query.
- Local open-source model: llama3.2:latest (via Ollama)
- GPT-5 via OpenAI API
-
Better reasoning capabilities
-
More accurate grounding in retrieved context
-
Clearer and more structured responses
-
Stronger understanding of long-context inputs
User Query:
Where was meta description mentioned in this course, that it is important for SEO?
LLM Response:
Meta description is mentioned as an important keyword for SEO in Video 3 called "Basic Structure of an HTML Website".
Video 3: "Basic Structure of an HTML Website"
• 0:48 – 0:50 → Definition of Meta description
• 0:49 – 0:51 → Importance of meta description for SEO
• 1:03 – 1:05 → Brief explanation of Google's use of meta description
Tip: Watch from the beginning (around 0:44) to understand the full context.
Finally, we store the generated response into response.txt:
with open("response.txt", "w") as f:
f.write(llm_response)- Retrieval-Augmented Generation (RAG) pipeline.
- Fully automated processing of course videos.
- Timestamp conversion to minutes:seconds format.
- Context-aware answers with video number + title + timestamps.
- Responses stored in
response.txtfor easy retrieval.
