Vector Databases and Embeddings Explained: The Guide I Needed 5 Months Ago

From what embeddings actually are to how similarity search works under the hood, clearly explained for anyone building with AI.For the past 5 months, I have been building RAG pipelines, ingesting documents, chunking them, storing vectors, querying Pinecone, and passing context to an LLM. It worked.…

From what embeddings actually are to how similarity search works under the hood, clearly explained for anyone building with AI.For the past 5 months, I have been building RAG pipelines, ingesting documents, chunking them, storing vectors, querying Pinecone, and passing context to an LLM. It worked. Results came back. The system responded intelligently.But if you had asked me what actually happens when a vector is stored, I would have fumbled. I was using these tools. I did not understand them.So I stopped and went back to basics. This article is everything I pieced together about vector databases and embeddings, what they actually are, how they connect, and how semantic search works under the hood.If you are building with AI and have the same gap, this one is for you.What is a Vector Database?If you have worked with relational databases, here is the fastest way to understand a vector database.A relational database stores structured data in rows and columns, with exact values. You search by matching. Ask for all users where age = 25 and you get exactly that. It understands what something is.A vector database does something fundamentally different. It stores meaning represented as numbers, and those numbers are called vectors. It searches by similarity, not by exact match. It understands what something means.Relational databases and vector databases serve different purposes:This shift from matching to meaning is what makes vector databases the backbone of every modern AI search system.Vector SpaceThink about a job search platform. You are looking for a “software engineer” role. But some companies post the same role as “backend developer”. Others call it “programmer” or “software developer”.A keyword search misses all of them because the words do not match exactly. A vector database solves this by converting every piece of text into a vector and placing similar meanings physically close together in space.Picture a city map: every location has coordinates, and similar places cluster together naturally. Vector space works the same way, except instead of 2 dimensions, it works with hundreds or thousands:"software engineer" → [0.23, -0.45, 0.78, ... 1536 values]"backend developer" → [0.21, -0.43, 0.75, ... 1536 values] ← close"chef" → [-0.67, 0.34, -0.22, ... 1536 values] ← far“software engineer” and “backend developer” produce nearly identical vectors, with the same meaning, different words. “chef” produces completely different numbers, unrelated meaning, far apart in vector space.This multi-dimensional map is called a vector space, and it is where all your vectors live.IndexAn index in a vector database is the equivalent of a table in a relational database; it is the container that holds all your vectors.If you’re familiar with relational databases, here’s the easiest way to think about a vector database:One critical rule: every vector inside one index must have the same number of dimensions, because all vectors must live in the same vector space to be compared.You cannot compare a location on a 2D map with one on a 3D map. They live in different spaces. The same rule applies to vectors.NamespaceA namespace is a logical partition inside an index, a way to separate data without creating a new index.Think of it like floors in an office building. The building is your index. Each floor is a namespace. Everyone lives under the same roof, but different teams work on different floors and never interfere with each other.Real example: Imagine a company knowledge base with one index and three namespaces.Three namespaces living inside one index — each isolated during searchAll three live inside the same index. But when an employee searches for “how many leaves do I get”, only the hr-policies namespace is searched. Engineering docs and finance reports are completely invisible to that query.When would you use multiple namespaces? Multi-tenant applications, environment separation, and different data purposes, anywhere data has genuinely different roles that should never mix during search.Semantic Search vs Similarity SearchThese two terms get used interchangeably. They are not the same thing.Semantic search is the goal: finding results by meaning, not keywordsSimilarity search is the mechanism comparing vectors mathematically to achieve that goalThink of finding a song. Semantic search is “find me songs that feel like a road trip.” Similarity search is the music app's behind-the-scenes comparison of audio patterns to find those songs.Semantic search is the experience. Similarity search is what happens underneath. You cannot have one without the other.How It All ConnectsBefore diving into embedding models, here is how everything we covered so far works together.Vector DB stores the vectors. The embedding model creates them. Neither works without the other. Now, let us understand the embedding model in depth.What is an Embedding Model?An embedding model is a separate piece of software with one single responsibility: to convert text into vectors.Think of it like a translator. Your text is in human language. Vector databases understand only numbers. The embedding model translates text → numbers."I love Java" → [0.23, -0.87, 0.45, 0.12, …]"I enjoy Java" → [0.21, -0.85, 0.44, 0.11, …] ← close"I hate Python" → [-0.67, 0.34, -0.22, 0.89, …] ← farIt does not convert text to random numbers. It places similar meanings closer together in numeric space.Embedding Model vs LLMThis is one of the most commonly confused concepts in AI development.If you’re wondering how an LLM differs from an Embedding Model, here’s the easiest way to think about it:Think of a hospital. The LLM is the doctor who talks to you, understands you, and gives answers. The embedding model is the lab technician you never interact with; they silently convert your sample into numbers the doctor can analyse.The Golden Rule: The same embedding model must be used for both storage and search. Mixing models produces completely wrong results; they generate vectors in different spaces that cannot be compared.The 5 Properties of an Embedding ModelWhen you create an index in a vector database, you select an embedding model. That choice defines these 5 properties, and they directly affect how your entire search pipeline behaves.1. DimensionsDimensions = how many coordinates a single vector has.Think of a 2D map; you need 2 numbers to locate any place (x, y). A vector space needs hundreds or thousands of numbers, each capturing a different nuance of meaning.Important: Dimensions are fixed by the embedding model you choose. You cannot change them after index creation.2. Max InputMax Input = the maximum amount of text the embedding model can process at one time.Think of a scanner machine. Some scanners fit 1 page, others 50. If your document has 100 pages and the scanner can scan only 1 page at a time, you cut it into pieces and scan them one by one. That is exactly why chunking exists.Critical warning: If your chunk size exceeds Max Input, the model silently truncates the extra text, which means that meaning is lost forever, producing poor-quality vectors and wrong search results.3. MetricMetric = the formula used to measure similarity between two vectors.Think of finding the nearest hospital in a city. You can measure distance as a straight line through buildings, as the actual road distance, or just by direction. Same city, same locations, but different measurement methods give different results.For text and RAG: Cosine is almost always the right choice.4. Vector TypeVector Type = how the vector numbers are structured, and it determines what kind of search you can run.Dense Vector: every dimension has a value. Produced by embedding models. Used for semantic search. Captures meaning."software engineer" → [0.23, -0.45, 0.78, 0.12, 0.67, -0.34, …]Every single dimension has a numberSparse Vector: most dimensions are zero. Only matching keywords have values. Used for keyword search."software engineer" → [0, 0, 0, 0.98, 0, 0, 0, 0.87, 0, 0, …]Mostly zeros; only matching keywords have valuesDense = describing a person by their full personality and behaviour. Sparse = describing a person by only their name and age.Combine both, and you get Hybrid Search: semantic understanding plus keyword precision. Best of both worlds.5. ModalityModality = what type of data the embedding model accepts as input.Think of translators: some only handle English-to-French. Some handle multiple languages. Some can even translate sign language. Each embedding model is built to handle specific types of input.Text — documents, sentences, notesImage — photos, diagrams, screenshotsMultimodal — text and images combinedFor RAG with PDFs and documents: Modality = Text.Wrapping UpVector databases and embedding models are no longer black boxes. You now know what vectors are, how they are stored, how search actually works under the hood, and what properties determine the quality of your entire pipeline.This is the foundation on which every RAG system is built. And now you have it.Follow me on Medium for more articles on Java, Spring AI, and real-world AI implementation. Have questions or a different take? Drop a comment; I read every one.Let’s connect on LinkedIn: Akshay Vadsara — linkedin.com/in/akshay-vadsaraThis story is published on Generative AI. Connect with us on LinkedIn and follow Zeniteq to stay in the loop with the latest AI stories.Subscribe to our newsletter and YouTube channel to stay updated with the latest news and updates on generative AI. Let’s shape the future of AI together!Vector Databases and Embeddings Explained: The Guide I Needed 5 Months Ago was originally published in Generative AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Source: Generative AI Pub — Published — Category: Image AI

🔗 Read full article on Generative AI Pub →