U9 · Secondary

Video lesson RAG

A course platform for an online school where students ask questions about a lesson and get answers with clickable citations that jump the video to the right moment. Retrieval combines HyDE, hybrid search (vector + full-text) and reranking.

private

Engineering decisions

  • Async ingestion: uploads go into a BullMQ queue and a worker in its own container extracts audio with ffmpeg, transcribes it with Deepgram and creates embeddings. PDFs follow the same path.
  • Chunks of about 500 tokens with a 50-token overlap, keeping each chunk's start time for citations.
  • Multi-stage retrieval: HyDE writes a hypothetical answer and searches with its embedding; vector (HNSW) and full-text (tsvector) results are merged with Reciprocal Rank Fusion; Cohere reranks the top 20 down to 5.
  • Citations formatted as [Title, MM:SS] become buttons that seek the player to that point in the lesson.
  • When the best score is below 0.65, the answer comes with a low-confidence warning. Repeated questions are served from a 24-hour Redis cache.
  • Each stage (HyDE, search, rerank, transcription) is logged as a Langfuse span.

Stack

Next.js 16TypeScriptPostgreSQLpgvectorDrizzle ORMBullMQRedisOpenAICohere RerankDeepgram

What it shows

Online schools and course libraries with a lot of video content that want students to get answers about a lesson without leaving the player.