60-second card
Retrieval and ranking
RAG retrieves the most relevant chunks for a question, then the LLM answers from them.
- Steps: embed the question → search → pick the top k → prompt the LLM.
- A re-ranker re-scores the top 50 more carefully and keeps the best 5.
- More chunks isn't always better: irrelevant text distracts the model.
scores = {"c1": 0.82, "c2": 0.91, "c3": 0.40, "c4": 0.77}
print(sorted(scores, key=scores.get, reverse=True)[:2])Prints
['c2', 'c1']Remember: Good retrieval matters more than a clever prompt.
Common mistake: Stuffing 100 chunks into the prompt and getting a vaguer answer.