Vector Databases Full Course for Beginners – Embeddings, Similarity Search & ChromaDB

freeCodeCamp.org

Summary

This seven-part course teaches beginners how vector databases power semantic search, recommendation systems, and retrieval-augmented generation (RAG) pipelines. The instructor begins by contrasting traditional keyword-based relational databases with high-dimensional vector search, then breaks down one-dimensional feature arrays, cosine similarity, Euclidean distance, and subword tokenization. Using a 300-dimension GloVe playground and OpenAI's tokenizer, he shows how tokens become geometric coordinates where conceptual relationships can be calculated mathematically.

In the second half, the course transitions from theory to implementation and system architecture. The instructor demonstrates how to generate 768-dimension embeddings in Google Colab using Google's gemini-embedding-001 model, visualize semantic clusters in 3D via Principal Component Analysis (PCA) and Plotly, and understand internal database layers including IVF and HNSW indexing. Finally, he builds a persistent ChromaDB collection in Python that retrieves relevant documents by meaning rather than shared keywords.

How time-sensitive the topic is: Evergreen

By the numbers

  • 15 years: Instructor's experience working as a software engineer alongside 4 years as a lead AI engineer. (Mentioned at 0:51)
  • -1 to 1 score range: Possible output range of the cosine similarity function between two vectors. (Mentioned at 35:06)
  • 53 tokens: Number of subword tokens generated from a 252-character sample paragraph in OpenAI's tokenizer. (Mentioned at 54:29)
  • 2048 tokens: Input token limit for Google's gemini-embedding-001 text embedding model. (Mentioned at 1:12:55)
  • 128 to 3072 dimensions: Configurable output dimension range supported by Google's Gemini embedding models. (Mentioned at 1:13:01)
  • 8,192 tokens: Input token limit for Google's multimodal Gemini Embedding 2 model. (Mentioned at 1:14:02)
  • 768 dimensions: Output dimensionality configured in the Google Colab demo for generating and querying Gemini embeddings. (Mentioned at 1:16:57)

Questions this video answers

Why must you use the exact same embedding model for both storing and querying a vector database?

Every embedding model maps meaning into its own distinct mathematical coordinate system. Using the same model and output dimensionality for both ingestion and retrieval ensures that the query vector and stored vectors live in the same vector space and can be accurately compared.

YouTube: freeCodeCamp.org, 3:42 to 11:04

From this keypoint: codeEdx outlines the two-phase vector DB pipeline

What is the difference between cosine similarity and Euclidean distance in vector search?

Cosine similarity measures the angle between two vectors from -1 to 1 and ignores their magnitude, whereas Euclidean distance measures the straight-line distance between vector endpoints from 0 to infinity. Cosine similarity is preferred for text embeddings because directional alignment captures semantic meaning regardless of document length.

YouTube: freeCodeCamp.org, 32:21 to 40:37

From this keypoint: Measuring direction with cosine similarity

When should you use Euclidean distance instead of cosine similarity?

Euclidean distance should be used when the actual magnitude and physical separation between points matter, such as in GPS navigation, robotics, and spatial coordinate systems. In those domains, straight-line distance carries the core signal rather than vector angle.

YouTube: freeCodeCamp.org, 40:37 to 45:15

From this keypoint: When to use Euclidean distance instead

Why do modern LLMs and embedding models use subword tokenization instead of word or character tokenization?

Character tokenization produces an excessive number of tokens, while whole-word tokenization requires a massive vocabulary that treats related word forms as completely separate entries. Subword tokenization splits words into reusable roots and suffixes (like 'global' and 'ization'), optimizing token counts and reducing API costs.

YouTube: freeCodeCamp.org, 45:44 to 57:26

From this keypoint: codeEdx contrasts three tokenization methods

Why did AI systems move from word embedding models like Word2Vec to text and multimodal embedding models?

Word embedding models like Word2Vec and GloVe generate static vectors for individual words in isolation, so they cannot distinguish 'bank' in 'river bank' from 'bank account'. Text and multimodal embedding models process full sentences, documents, and images together to preserve contextual meaning.

YouTube: freeCodeCamp.org, 1:03:43 to 1:11:48

From this keypoint: From static word models to multimodal embeddings

How can you visualize 768-dimension vector embeddings in a 3D chart?

Because humans cannot visualize 768 dimensions directly, you can apply Principal Component Analysis (PCA) to reduce the 768-dimension arrays down to 3 dimensions while retaining the most important variance. Those 3D coordinates can then be plotted interactively using libraries like Plotly to inspect semantic clusters.

YouTube: freeCodeCamp.org, 1:12:17 to 1:22:09

From this keypoint: codeEdx generates and plots Gemini embeddings

What are the main internal architectural layers of a vector database?

A vector database consists of four core layers: an API gateway for client requests, an indexing layer that uses algorithms like IVF or HNSW to avoid slow linear scans, a replicated storage layer for durability, and a query processing layer that filters and ranks nearest neighbors. Together they enable millisecond searches across millions of vectors.

YouTube: freeCodeCamp.org, 1:22:45 to 1:29:26

From this keypoint: Four core layers inside a vector database

Do vector databases replace traditional SQL relational databases?

No, vector databases do not replace traditional relational databases. In production systems, relational databases remain the primary system of record for structured data, while the vector database operates alongside them as a semantic retrieval layer.

YouTube: freeCodeCamp.org, 17:13 to 22:38

From this keypoint: Pairing vector retrieval with relational systems

Credible AI™ signals

Confidence: Accurate Technical Instruction. The instructor accurately explains core vector database concepts, linear algebra formulas for cosine similarity and Euclidean distance, and tokenization mechanics. Live coding demonstrations in Google Colab using Google's Gemini API and ChromaDB execute as described and ground the theoretical explanations.

Bias: Tool-Focused Pedagogy. The course is strictly educational and objective in its mathematical and architectural explanations. It exhibits only a minor practical preference for the tools chosen for its hands-on demonstrations, specifically Google's Gemini embedding models and ChromaDB.

Originality (65%): Structured Beginner Curriculum. While the underlying concepts of vectors, embeddings, and similarity search are standard computer science material, the instructor synthesizes them into a cohesive, accessible seven-part curriculum with clear visual analogies and working Python notebooks.

Depth (72%): Solid Foundational Walkthrough. The course builds from first principles—calculating dot products and Euclidean distances by hand—before moving to tokenization, PCA dimensionality reduction, internal database layers, and practical API implementation, though it treats advanced indexing like IVF and HNSW only at a high level.

Key points (13)

  • Short (22 min): key points 1, 5 and 11
  • Medium (40 min): key points 1, 2, 5, 9, 11 and 13
  • Relaxed (1h 33min): all 13 key points

1. codeEdx outlines the two-phase vector DB pipeline

Timestamp: 00:03:42 to 00:11:04 (7 min)

Speaker: YouTube: freeCodeCamp.org

A vector database stores, indexes, and searches high-dimensional embeddings through a two-phase pipeline: ingestion and retrieval. During ingestion, an embedding model converts raw data into floating-point arrays and builds approximate nearest neighbor indexes; during retrieval, a user query is embedded with the exact same model to rank the top K nearest neighbors.

Impact: High. Why it matters: Using the identical embedding model for both ingestion and querying is mandatory because vectors can only be compared when they inhabit the exact same mathematical space.

“It is because all the embeddings must live in the same vector space to be comparable. That is why we need to use here the same embedding model.”

In the video, at 9:37

2. Why keyword search fails on unstructured data

Timestamp: 00:11:11 to 00:17:11 (6 min)

Speaker: YouTube: freeCodeCamp.org

Traditional relational databases rely on fixed schemas, rows, and exact keyword matching, which fails when searching unstructured data like PDFs, audio, or video if the user's exact words are absent. Vector databases overcome this by indexing thousands of dimensions with clustering and approximate nearest neighbor algorithms to search millions of items in milliseconds.

Impact: High. Why it matters: Organizations dealing with unstructured documents cannot rely solely on SQL keyword filters if they want to capture user intent without exact phrasing matches.

“So vector databases scale because they avoid the brute force search right they don't search in a linear fashion right they avoid this brute force search and instead they use smart indexing”

In the video, at 16:24

3. Pairing vector retrieval with relational systems

Timestamp: 00:17:13 to 00:22:38 (5 min)

Speaker: YouTube: freeCodeCamp.org

Vector databases do not replace traditional relational databases; instead, traditional databases remain the system of record while vector databases sit on top as a semantic retrieval layer. In recommendation engines like Netflix, Amazon, and YouTube, both user behavior histories and item attributes are converted into vectors to find nearest neighbor matches.

Impact: Medium. Why it matters: System architects should design hybrid storage layers rather than migrating transactional records into a vector database.

“The traditional databases are still used as the system of record whereas the vector database are used to build a semantic retrieval layer on top of your traditional databases.”

In the video, at 19:16

4. codeEdx defines feature vectors and dimensions

Timestamp: 00:23:01 to 00:32:21 (9 min)

Speaker: YouTube: freeCodeCamp.org

In machine learning, a vector is strictly a one-dimensional array of numbers—unlike scalars or multi-dimensional matrices—where each number represents a distinct feature of an object. Just as cars with similar speed, mileage, and price cluster together in 1D, 2D, or 3D space, modern embeddings with up to 3,000 dimensions cluster similar items in n-dimensional space.

Impact: Medium. Why it matters: Understanding that array length equals feature count bridges simple geometric plots and 3,000-dimension production embeddings.

“So in machine learning, a vector is a onedimensional array of numbers. It's just a onedimensional array of numbers where each number represents a feature of an object.”

In the video, at 23:31

5. Measuring direction with cosine similarity

Timestamp: 00:32:21 to 00:40:37 (8 min)

Speaker: YouTube: freeCodeCamp.org

Cosine similarity measures the angle between two vectors by dividing their dot product by the product of their magnitudes, yielding a score from -1 (opposite) to 0 (orthogonal/unrelated) to 1 (identical direction). As shown by comparing [2, 0, 1] and [4, 0, 2], doubling a vector's magnitude still produces a cosine similarity of 1 because only direction captures semantic meaning.

Impact: High. Why it matters: Cosine similarity is the preferred metric for text embeddings because document length or feature magnitude does not distort semantic alignment.

“So that is the important thing to note here that in cosine similarity all that matters is whether two vectors are pointing in the same direction or not. The magnitude is actually irrelevant”

In the video, at 39:21

6. When to use Euclidean distance instead

Timestamp: 00:40:37 to 00:45:15 (5 min)

Speaker: YouTube: freeCodeCamp.org

Euclidean distance calculates the straight-line distance between two points by taking the square root of the sum of squared coordinate differences, ranging from 0 for identical points to infinity. While essential for physical-world applications like GPS and robotics where magnitude matters, it is used less often than cosine similarity for text embeddings.

Impact: Medium. Why it matters: Choosing between Euclidean distance and cosine similarity depends on whether absolute coordinate magnitude or directional orientation carries the signal in a dataset.

“Whereas ukidian distance on the other hand measures how far apart those two vectors are. So here the magnitude of those two vectors play a big role”

In the video, at 44:19

7. codeEdx contrasts three tokenization methods

Timestamp: 00:45:44 to 00:57:26 (12 min)

Speaker: YouTube: freeCodeCamp.org

Because embedding models cannot read raw text and charge users by token count, a tokenizer first converts inputs into numerical token IDs. Character tokenization creates bloated token counts and word tokenization struggles with massive vocabularies, so modern LLMs use subword tokenization to split words like 'globalization' into reusable roots and suffixes.

Impact: High. Why it matters: Subword tokenization directly controls API billing costs and context window consumption across all modern embedding and language models.

“And that is the concept of subword tokenizer where the words are broken down to optimize the number of tokens.”

In the video, at 56:54

8. Vector arithmetic on semantic word coordinates

Timestamp: 00:58:08 to 01:03:42 (6 min)

Speaker: YouTube: freeCodeCamp.org

While token IDs are arbitrary symbols with no semantic meaning, embedding models transform tokens into multi-dimensional coordinates where meaning is preserved. In a 300-dimension GloVe playground, performing vector arithmetic such as 'king - man + woman' yields 'queen', and 'Delhi - India + Japan' yields 'Tokyo', proving that conceptual relationships map to spatial geometry.

Impact: High. Why it matters: Converting symbolic tokens into geometric coordinates allows mathematical operations to resolve semantic analogies and conceptual proximity.

“For example, let's say if I were to perform this vector calculation, king minus men plus woman and try to calculate, you can see that it relates to queen.”

In the video, at 1:01:19

9. From static word models to multimodal embeddings

Timestamp: 01:03:43 to 01:11:48 (8 min)

Speaker: YouTube: freeCodeCamp.org

Early word embedding models like Word2Vec and GloVe embed single words in isolation, failing to distinguish 'bank' in 'river bank' versus 'bank account'. Modern systems therefore use text embedding models that capture full sentence or document context, or multimodal models like Google's Gemini Embedding 2 that embed text, images, audio, video, and PDFs together.

Impact: High. Why it matters: Developers building RAG pipelines must select text or multimodal embedding models rather than legacy word embeddings to preserve sentence-level context.

“Now since this embeddings are generated for individual words the thing is we would not know what bank actually refers to in the sentence. So the main main drawback of word embedding is that the context is missing”

In the video, at 1:05:23

10. codeEdx generates and plots Gemini embeddings

Timestamp: 01:12:17 to 01:22:09 (10 min)

Speaker: YouTube: freeCodeCamp.org

Using Google's gemini-embedding-001 model in Google Colab, the instructor generates 768-dimension embeddings for sample sentences and computes a cosine similarity matrix with scikit-learn. Applying Principal Component Analysis (PCA) reduces those 768 dimensions down to 3D so Plotly can visually confirm that semantically related sentences cluster together.

Impact: Medium. Why it matters: Dimensionality reduction via PCA provides a practical diagnostic tool for engineers to visually inspect high-dimensional embedding clusters.

“So it reduces 768 dimensions to three dimensions so that we can visualize this in three-dimensional space.”

In the video, at 1:20:24

11. Four core layers inside a vector database

Timestamp: 01:22:45 to 01:29:26 (7 min)

Speaker: YouTube: freeCodeCamp.org

Internally, every vector database comprises four components: an API gateway for ingestion and query endpoints, an indexing layer using Inverted File Index (IVF) or Hierarchical Navigable Small Worlds (HNSW) to avoid brute-force scans, a replicated and partitioned storage layer for durability, and a query processing layer for filtering and ranking.

Impact: High. Why it matters: Understanding the separation between indexing (IVF/HNSW), storage replication, and query post-processing clarifies how vector databases maintain low latency at billion-vector scale.

“So first we have the API gateway and then we have the indexing layer then there's query processing layer and then we also have a storage layer.”

In the video, at 1:23:22

12. Storing Gemini vectors in a ChromaDB collection

Timestamp: 01:29:51 to 01:35:38 (6 min)

Speaker: YouTube: freeCodeCamp.org

In the final project, the instructor installs ChromaDB, initializes a persistent client, and creates a collection named 'codedex_chromadb_demo'—analogous to a SQL table. He then stores the 768-dimension Gemini embeddings alongside their raw source documents and unique record IDs.

Impact: Medium. Why it matters: Storing the original document text and IDs alongside the vector array inside ChromaDB allows applications to immediately retrieve human-readable results.

“So what we are doing here is along with the vector embeddings for each text we are also storing the actual text. So you have your documents and then you also have the embeddings for those documents”

In the video, at 1:35:04

13. Running semantic queries in ChromaDB by meaning

Timestamp: 01:35:38 to 01:39:30 (4 min)

Speaker: YouTube: freeCodeCamp.org

To search ChromaDB, the query string must first be embedded using gemini-embedding-001 with the exact same 768-dimension setting (since the model defaults to 3,072). Querying the single word 'programming' retrieves sentences about writing a Python function and a Java class, and querying 'electronics' retrieves sentences about an iPhone and a smartphone camera, despite zero keyword overlap.

Impact: High. Why it matters: Explicitly matching query dimensionality to collection dimensionality prevents runtime mismatches and enables true concept-based retrieval.

“Now what is interesting here is that in this two text you don't have programming anywhere that keyword is not present inside these two text but still it is able to match those text which relate to programming”

In the video, at 1:38:11

Conflicts of interest (1)

Promotion of Course Creator's Gumroad Resources

Commercial conflict, Low severity

The course creator codeEdx links to a Gumroad store page selling or distributing accompanying course resources.

Significance: Viewers are encouraged to use the instructor's specific notebook templates and supplementary materials while following the demonstrations.

Key sources

  • YouTube: freeCodeCamp.org

Who's in this

  • Google
  • Gemini
  • ChromaDB
  • OpenAI
  • ChatGPT
  • Netflix
  • Amazon
  • YouTube
  • GloVe
  • Word2Vec
  • Cohere
  • Microsoft

Also mentioned

  • Google Colab (First mentioned at 1:14:47)
  • Python (First mentioned at 1:17:50)
  • CodeBERT (First mentioned at 1:10:31)
  • pandas (First mentioned at 1:15:09)
  • scikit-learn (First mentioned at 1:15:12)
  • Java (First mentioned at 1:18:54)
  • Android (First mentioned at 1:19:09)
  • Plotly (First mentioned at 1:21:00)
  • Delhi (First mentioned at 1:01:48)
  • India (First mentioned at 1:01:51)
  • Japan (First mentioned at 1:01:51)
  • Tokyo (First mentioned at 1:01:55)
  • Apple (First mentioned at 1:38:54)
  • iPhone (First mentioned at 1:38:54)

This analysis was generated by skim (skim.plus), an AI-powered content analysis platform by Credible AI. Scores and classifications represent the platform's AI-generated assessment and should be considered alongside other sources.