Basics of NLP and RAG · Lesson 1
Introduction to RAG & Text Representation
Retrieval-Augmented Generation (RAG) fetches relevant passages from your knowledge base and puts them in the prompt, so the model answers from current, private and citable facts instead of memory alone.
To search by meaning, text is turned into numbers. Older methods counted words (bag-of-words, TF-IDF). Modern systems use embeddings: dense vectors produced by a neural model where similar meanings sit close together.
Similarity between two embeddings is usually measured with cosine similarity — the angle between the vectors.
Key points
- RAG = retrieve relevant text, then generate with it
- Reduces hallucination and adds up-to-date knowledge
- Embeddings place similar meanings near each other
- Cosine similarity compares vector direction