Code and full results: https://github.com/sabertooth-123/RAG_yt_chatbot
I measured it and the measurements taught me more than the building did.
The problem you are watching a three hour technical talk. You want to know one specific thing. Scrubbing the timeline is slow and googling gives you an answer from somewhere else on the internet which may not be what this speaker said. So I built this in which you paste a youtube link, ask questions in plain english and then get answers with clickable timestamps
<aside> 💡
› What two files make up a large language model?
A parameters file holding the model weights — 140 GB for Llama 2 70B — and a run file containing the code that executes them, about 500 lines of C with no other dependencies [1][2].
[1] 1:34 youtube.com/watch?v=zjkBMFhNj_g&t=94s [2] 2:15 youtube.com/watch?v=zjkBMFhNj_g&t=135s
› What is the attention mechanism?
I cannot find this information in the video.
</aside>
The second answer is the whole point. The video never mentions attention, so the bot says so instead of answering from general knowledge.
What I built is a RAG system Retrieval-Augmented Generation. It's the standard way to make a language model answer questions about content it was never trained on.
Retrieval — search a collection of documents for the few relevant bits.
Augmented — paste those bits into the model's prompt as context.
Generation — the model answers from that context instead of from memory.
Without RAG, asking a model about a specific YouTube video means hoping it memorised that video during training. It didn't. It will confidently make something up.
Everything below is really about three hard parts nobody warns you about: retrieval is the bottleneck, "use only this context" isn't enough, and measuring whether it worked is harder than building it.
The big picture
flowchart LR
A[YouTube URL] --> B[Get subtitles]
B --> C[Clean them up]
C --> D[Cut into passages]
D --> E[Convert to numbers]
E --> F[(Save to database)]
F --> G[Search]
G --> H[Write the answer]
H --> I[Answer + timestamps]
Get the Words Youtube serves subtitles through an API and crucially each line comes with a timestamp
<aside> 💡
0:00 - 0:03 "hi everyone so recently" 0:03 - 0:06 "I gave a 30-minute talk" 0:06 - 0:09 "on large language models"
</aside>
Some videos have human-written subtitles. Most have auto-generated ones. A few have none at all. Those don’t work yet. Local speech recognition with Whisper would fix that, but this project was more about learning than about stacking on features.
Clean them up Auto generated subtitles are messier than they look. Three problems are there