Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊAI Engineering with PythonModule 3 Β· RAG Β· Recapβ€ΊπŸŽ― Review: AI engineering module 3 recapscenario64 / 105
+80 XP
Task
Build a tiny end-to-end RAG in pure stdlib: `mini_rag(query, docs)`. 1. **Embed**: use `fake_embed(s) = sum(ord(c) for c in s) % 100`. (Real embeddings are 1024-dim β€” this 0-99 scalar is just for the recap.) 2. **Score**: compute `abs(fake_embed(doc) - fake_embed(query))` for each doc. 3. **Retrieve top-3**: sort ascending by distance (tie-break alphabetically to stay deterministic). 4. **Augment**: return `{"query": query, "context": [top-3 doc strings], "answer": f"Based on {len(context)} docs..."}`. The harness prints the query, then each retrieved doc on its own line, then the answer.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…