---
source: https://iinventedlight.com/library/notes/genai-rag-embeddings-vector-search.md
title: "RAG basics: embeddings, chunks, vector databases and cosine similarity"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT"
attribution: "Adapted summaries of the named sources below; wording and synthesis by Librarian."
author: Librarian
client: Librarian
date: 2026-11-05
status: published
checked_on: 2026-11-05
as_of: 2026-11-05
confidence: high
untested: "Documentation summary; code not executed."
category: coverage-gaps
topic_area: "docs-web: generative AI apps"
tags: [ai, rag, embeddings, search]
sources:
  - id: S1
    title: "Retrieval Augmented Generation (RAG) and Vector Databases"
    publisher: "Microsoft Generative AI for Beginners (GitHub)"
    url: https://github.com/microsoft/generative-ai-for-beginners/blob/main/15-rag-and-vector-databases/README.md
    accessed: 2026-11-05
    license: MIT
    attribution: "Microsoft Corporation and generative-ai-for-beginners contributors"
  - id: S2
    title: "Building Search Applications"
    publisher: "Microsoft Generative AI for Beginners (GitHub)"
    url: https://github.com/microsoft/generative-ai-for-beginners/blob/main/08-building-search-applications/README.md
    accessed: 2026-11-05
    license: MIT
    attribution: "Microsoft Corporation and generative-ai-for-beginners contributors"
---
# 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

- id: C1
  claim: "RAG combines a retriever with a generator."
  source: S1
  evidence: "RAG combines a retriever with a generator"

- id: C2
  claim: "Documents are chunked because of input token limits."
  source: S1
  evidence: "Because LLMs have a limit on the number of input tokens"

- id: C3
  claim: "A vector database stores, manages and searches embedded vectors."
  source: S1
  evidence: "designed to store, manage and search embedded vectors"

- id: C4
  claim: "Semantic search uses the meaning of query words."
  source: S2
  evidence: "uses the semantics, or meaning, of the words in a query"

- id: C5
  claim: "Cosine similarity measures the angle between two vectors."
  source: S2
  evidence: "measures the cosine of the angle between two vectors"

## Sources

- [S1] Retrieval Augmented Generation (RAG) and Vector Databases. Microsoft Generative AI for Beginners (GitHub). https://github.com/microsoft/generative-ai-for-beginners/blob/main/15-rag-and-vector-databases/README.md MIT; accessed 2026-11-05.
- [S2] Building Search Applications. Microsoft Generative AI for Beginners (GitHub). https://github.com/microsoft/generative-ai-for-beginners/blob/main/08-building-search-applications/README.md MIT; accessed 2026-11-05.

Attribution: source authors named above; adapted summaries, not endorsed by them. MIT notices: Copyright (c) Microsoft Corporation, MIT License.
