# Slide: Cross-Lecture Semantic Search (RAG) in Bioinformatics ---

Cross-Lecture Semantic Vector Search (RAG)

How AI Assistants Retrieve Knowledge Across All Lectures & Readings via 768-D Vector Embeddings

STEP 1: INDEX CURRICULUM

Course Knowledge Ingestion

🎬 Video Transcripts
Lectures 1–11 with Timestamps
📄 Reading PDFs & Manuals
38 Papers (Kallisto, Sleuth, FastQC)
💻 Master R Scripts
Steps 1–8 (Workflows & Functions)
✂️ Chunked (300w) & Embedded
gemini-embedding-001 (768-D)
STEP 2: SEMANTIC SEARCH

Vector Space Matching

Student on Lecture 1:
"How do I run tximport in R?"
📐 Cosine Similarity Search:
• Converts query to 768-D vector
• Measures angle against all course chunks
• Finds closest biological concept cluster
🎯 Matched Chunks (Score: 0.89):
• Lecture 4: Differential Expression
• Step 2 Script + Soneson 2015 PDF
STEP 3: GENERATE & CITE

Grounded Answer + Hyperlinks

⚡ Ask DIY (Gemini 2.5 Flash):
To import Kallisto transcript abundances into R, use tximport to summarize counts to the gene level:
txi <- tximport(files, type="kallisto", tx2gene=tx2gene)
Sources:
📄 [Soneson2015_tximport.pdf] (Section 2.1)
Key Concept: Semantic vectors enable discovery of relevant concepts across the entire curriculum, regardless of which page the student is viewing.
DIY Transcriptomics
--- ## 📖 Detailed Explanation & Reference Notes (For Instructor) ### How This Pipeline Works: 1. **Step 1: Offline Knowledge Ingestion (The "Library")** * Course documents (video transcripts, reading PDFs, and Master Step scripts) are split into standardized **300-word chunks** with a **50-word overlap**. * Each chunk is passed through the `gemini-embedding-001` model, producing a **768-dimensional floating-point vector** representing its semantic meaning. * Vectors are indexed in Firestore (`course_knowledge_embeddings`). 2. **Step 2: Real-Time Vector Similarity Matching (The "Search")** * When a student types a question on any page (e.g. asking about `tximport` while viewing Lecture 1), the system embeds the query into the exact same 768-D vector space. * A mathematical **Cosine Distance search** compares the query vector against all chunks in the entire curriculum. * The top 5 highest-similarity chunks are retrieved in milliseconds, pulling relevant context from downstream modules (like Lecture 4 and Step 2). 3. **Step 3: Grounded Answer Synthesis (The "Response")** * The 5 retrieved chunks + current page context + student query are injected into the Gemini 2.5 Flash prompt. * The LLM synthesizes an answer strictly based on course knowledge and appends direct hyperlinks to the exact lecture page or PDF paper in `/Reading/files/`. --- ## 📊 Summary Table | Stage | Input Data | Transformation | Output | | :--- | :--- | :--- | :--- | | **1. Indexing** | Transcripts, PDFs, R scripts ($L_1 \dots L_{11}$) | Chunking (300w) + `gemini-embedding-001` | 768-D Vector Index in Firestore | | **2. Semantic Search** | Student Question on Lecture 1 | Query Embedding + Cosine Similarity | Top 5 Relevant Chunks (Lecture 4 / Step 2) | | **3. DOM Scanning** | Browser DOM (`