DevPrep

All topics › AI fundamentals for developers

Embeddings and RAG: how a model answers from your documents

Middle PRO

Essence

An embedding is a vector of hundreds or thousands of numbers that encodes the meaning of a text. Texts with similar meaning get nearby vectors, even if they share no words. RAG (Retrieval-Augmented Generation) uses this for search: before asking the LLM, we find relevant document fragments and insert them into the prompt. The model answers from up-to-date data instead of "from memory".

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store