Embeddings and a small RAG endpoint
Embeddings and a small RAG endpoint
The model has never read Relay's help centre. Asked how to export notes from Acme Notes, it will produce a plausible answer for some other product. Retrieval-augmented generation fixes this without training anything: find the few articles most relevant to the question and put them in the prompt. The model then answers from text it can see.
"Most relevant" is where embeddings come in. An embedding model turns a piece of text into a vector of a fixed length, arranged so that texts with similar meaning land close together. Embed every article once and store the vectors; embed the question at request time; ask the database for the nearest stored vectors. With the pgvector extension, that database is the PostgreSQL Relay already runs.
Continue reading
Pro unlocks every video lesson, the full notes and runnable code across the Python with AI course, from the language itself to agents, MCP, Langfuse and deployment.