← Coding labs/

Fix Broken RAG Pipeline

Debuggingmedium~30 min
Objective

Fix three bugs so the RAG pipeline returns relevant, grounded answers.

Background

You've inherited a RAG pipeline that was working last week but now returns irrelevant or hallucinated answers. The team suspects recent changes to the chunking strategy and retrieval logic introduced regressions. Your job is to find and fix the bugs.

Requirements
  1. 1.Fix the chunk size to preserve semantic context (currently too large)
  2. 2.Add embedding normalization before cosine similarity search
  3. 3.Fix the prompt template variable mismatch in retrieval
Evaluation (100 points)
Chunk size is reasonable
chunk_size should be ≤ 1000 for effective semantic retrieval
20pt
Embeddings are normalized
Vectors must be L2-normalized before cosine similarity
25pt
Prompt template variables match
Template placeholders must match the format() arguments
20pt
Main uses reasonable config
The main() function should use a reasonable chunk_size
15pt
Retrieval uses proper cosine similarity
The retrieve method should compute correct cosine similarity
20pt
Hints
Select a file to start editing
Terminal
$
AI Assistant50K tokens left

Ask me about the code, bugs, or concepts.
I'll guide you in plain English, no code output.
Budget: 50K tokens per lab