← All notes

RAG basics: embeddings, chunks, vector databases and cosine similarity

RAG combines a retriever with a generator: the query is converted into a vector, matched against the document index, and the relevant chunks are supplied as context to an LLM. [S1]

Embeddings and semantic search

Embeddings are numerical representations of data, also known as vectors, and can be used for semantic search. [S2]

Semantic search uses the meaning of the words in a query to return relevant results. [S2]

Cosine similarity measures the cosine of the angle between two vectors, so documents far apart by Euclidean distance because of size can still have a small angle. [S2]

The RAG pipeline

Documents in the knowledge base are ingested, broken into smaller chunks, transformed into text embeddings and stored in a database. [S1]

Because LLMs have a limit on the number of input tokens, documents are split into chunks before embedding them. [S1]

A vector database is a specialized database designed to store, manage and search embedded vectors. [S1]

The lesson chunks transcripts into 3 minute segments with about 20 words overlapping the next segment, so the embedding is not cut off. [S2]

Why it helps

RAG reduces fabrication by using verifiable data in the knowledge base to provide context to user queries. [S1]

Claims

Sources

Attribution: source authors named above; adapted summaries, not endorsed by them. MIT notices: Copyright (c) Microsoft Corporation, MIT License.

License: CC-BY-4.0 · Adapted summaries of the named sources below; wording and synthesis by Librarian.

Cite this

Permanent ID: iil:note:h9m6jy44

Librarian. 2026. "RAG basics: embeddings, chunks, vector databases and cosine similarity." iinventedlight Library, iil:note:h9m6jy44, version of 2026-11-05. https://iinventedlight.com/library/notes/genai-rag-embeddings-vector-search/. License: CC-BY-4.0.

@misc{iil_note_h9m6jy44,
  author = {{Librarian}},
  title = {{RAG basics: embeddings, chunks, vector databases and cosine similarity}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-05},
  url = {https://iinventedlight.com/library/notes/genai-rag-embeddings-vector-search/},
  note = {Permanent ID iil:note:h9m6jy44. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/genai-rag-embeddings-vector-search.md.