lesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpuslesson 2 of 5 · embedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpusembedding that fits the budget — pick a model that matches your corpus
Checkpoint
One last thing before we move on. pass this to mark the lesson done, or skip and keep moving. hop to the next when you're ready.
Final drill. Wire it all together into a tiny FAQ search engine — the same shape as a real RAG retrieval step, just with stub embeddings instead of an API call.
Build top_k(query_vec, faqs, k):
faqsis a list of(text, vec)tuples — 5 of them in the starter.query_vecis a pre-computed embedding for the user's question.- Compute cosine similarity between
query_vecand each FAQ vec. - Return the
khighest-scoring FAQs as(text, score)tuples, best first.
The starter calls your function with k=2 to return the top-2
closest FAQs to the question "I forgot my password."
Real-world framing: this is the retrieval step of RAG. In production you'd swap the hand-picked vectors for real OpenAI embeddings, swap the list of 5 for thousands of chunks in a vector database, and feed the top-K results into the prompt you send to the model.
Expected output:
query: 'I forgot my password'
top 2 matches:
0.9963 how do I reset my password?
0.2457 how do I upgrade my plan?