๐ฏ Objective
Learn the most important pattern in modern AI: Retrieval-Augmented Generation (RAG).
You will build a system that allows an LLM to "read" your app's private database to answer questions.
Daily Breakdown
Day 1
Introduction to Embeddings
Topic: Turning text into math.
Tasks:
- Use
NLModel or a Core ML embedding model to convert sentences into vectors (arrays of Floats).
- Calculate Cosine Similarity between two vectors in Swift.
Day 2
The Vector Database (SwiftData + Embeddings)
Topic: Local Storage for AI.
Tasks:
- Extend SwiftData to store vector embeddings alongside traditional metadata.
- Implement a basic "Nearest Neighbor" search logic to find relevant data chunks.
Day 3
Chunking & Context Injection
Topic: Managing the "Context Window."
Tasks:
- Create a "Chunking Engine" that breaks long PDFs/Notes into 500-token pieces.
- Logic: User Query โ Search Vector DB โ Get Top 3 Chunks โ Inject into LLM Prompt.
Day 4
Ranking & Re-ranking
Topic: Improving Accuracy.
Tasks:
- Implement a "Re-ranker" logic to filter out irrelevant search results before they hit the LLM.
- Use Natural Language Framework to tag parts of speech to improve search intent.
Day 5
End-to-End RAG Architecture
Topic: System Design.
Tasks:
- Optimize the pipeline: Ensure the "Retrieval" phase doesn't block the UI thread.
- Implement "Source Attribution" (showing the user exactly which document the AI used for its answer).
๐งช
Friday Lab: "Second Brain"
Project: A private "Personal Wiki" app.
- Feature: User can paste long articles into the app.
- Feature: The app automatically embeds and stores them.
- Feature: A chat interface where you ask "What did I learn about [Topic] last week?" and the app answers using only your stored notes.
- Constraint: Zero network calls. Everything must reside in the local
.sqlite store.