Key takeaways
- Vector embeddings turn text, images or audio into numbers that capture meaning, so software can compare by similarity.
- They are created by neural models trained so that related items land close together in vector space.
- Store them in vector databases or vector extensions of existing databases, alongside IDs and metadata.
- Embeddings can be partly inverted to recover text, so protect them like the data they came from.
- Never mix embeddings from different models; small precision changes in the same model usually keep distances meaningful.
Vector embeddings exist because computers cannot compare meaning directly: an embedding model converts text, images or audio into a list of numbers where similar meanings sit close together, so software can search, cluster and recommend by similarity instead of exact words. They are the retrieval engine of RAG systems such as RAG.NextUpgrad and the identity layer of FaceVision. This page covers why they matter, how they work and are created, storage, inversion, GraphRAG, quantization, and when to use them.
Why do we use vector embeddings?
We use vector embeddings because they let software measure similarity of meaning. Keyword matching fails when people use different words; embeddings recognise that "reset password" and "forgot my login" are related, enabling semantic search, recommendations and retrieval.
They also compress complex data into compact numbers that standard algorithms can process: clustering similar documents, detecting duplicates, classifying text with little training data, and finding similar images or faces. In FaceVision, a face becomes an embedding, and recognition compares embeddings rather than storing or comparing photos. One representation powers many tasks, which is why embeddings became foundational in modern AI systems.
What are embeddings in vector search?
In vector search, embeddings are the vectors stored in the index and the vector made from the query. The search returns stored items whose embeddings are closest to the query embedding, usually by cosine similarity.
Also asked as: why vector embeddings
Both sides must come from the same model so they share one vector space. The index uses approximate nearest-neighbour structures such as HNSW to search millions of vectors quickly. Results carry IDs and metadata so the application can show documents, products or images. In RAG, the top chunks then go to a language model. Adding keyword search alongside, in hybrid search, covers exact identifiers that embeddings can blur.
How do vector embeddings work?
An embedding model maps each input to a point in a high-dimensional space, typically hundreds to thousands of dimensions. Training arranges this space so that related inputs are close and unrelated ones are far apart, letting distance stand in for similarity.
Each dimension is not a single human-readable feature; meaning is spread across all of them. Directions in the space can encode relationships, as the classic word2vec example of king and queen showed. Modern models use transformers that read whole sentences, so the same word in different contexts gives different vectors. Similarity is computed with cosine similarity or dot product, which are cheap enough to compare at scale.
How are vector embeddings created?
They are created by passing data through a trained embedding model: text through a text encoder, images through an image encoder. The model outputs a fixed-length vector for each input. Models are trained on large datasets to place related pairs close together.
Common training uses contrastive learning: the model sees pairs that should match, such as a question and its answer, or an image and its caption, and pairs that should not, and adjusts so matches score higher. You rarely train your own; you choose a pretrained model from open-source libraries or an API provider, chunk your data sensibly, and embed it in batches. Fine-tuning an embedding model on your domain can help when general models miss specialised vocabulary.
How do I create vector embeddings with Sentence Transformers?
Install the library, load a pretrained model, and call encode on a list of texts. Normalise embeddings so dot product equals cosine similarity.
Also asked as: how to create vector embeddings using sentencetransformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")
emb = model.encode(["How do I reset my password?", "Steps to change your login"],
normalize_embeddings=True)
print(emb.shape) # (2, 384)
print(emb[0] @ emb[1]) # cosine similarity
Run pip install sentence-transformers first. Encode in batches for large datasets and use a GPU if available. Choose a model by testing on your own queries; multilingual models exist for Hindi and other languages.
Where are vector embeddings stored?
Embeddings are stored in vector databases, vector extensions of existing databases such as pgvector for PostgreSQL, search engines with vector support, or in-memory libraries such as FAISS. Each embedding is saved with an ID and metadata linking it to its source.
Choose by scale and existing stack: if you already run PostgreSQL and have up to a few million vectors, pgvector keeps everything in one database. Dedicated vector databases suit larger scale or heavy filtering. Libraries suit offline experiments. Whatever the store, keep the original source data, so you can re-embed when you change models, and record which model and version created each vector.
Can vector embeddings be reversed?
Partly, yes. Research has shown that text embeddings can be inverted to reconstruct much of the original text: a 2023 study recovered a large share of short inputs exactly from their embeddings using an iterative method. So embeddings are not anonymised data.
Treat embeddings as sensitive as their source: encrypt them at rest, control access, and avoid sharing them with untrusted parties. Face embeddings are biometric data under many privacy laws, which is why FaceVision stores embeddings only, never images, behind authenticated APIs, and still treats those embeddings as sensitive. Techniques such as adding noise or using private models reduce inversion risk but can reduce search quality.
Does GraphRAG use vector embeddings?
Yes. Microsoft's GraphRAG builds a knowledge graph by having a language model extract entities and relationships from text, then summarises communities of related entities. Its local search uses embeddings to find entities related to a question, then gathers connected graph information.
Its global search answers broad questions using community summaries rather than vector retrieval alone. So GraphRAG combines graphs and embeddings rather than replacing embeddings. It shines for questions that span many documents, such as themes across a corpus, but costs more to build because of extensive model calls during indexing. For straightforward factual questions, standard hybrid RAG is usually cheaper and sufficient.
Are vector distances still relevant with the same model but different quantization?
Mostly yes: embeddings from the same model at different precisions, such as float32 and int8, or a quantised version of the model, usually stay close enough that distances remain meaningful, though rankings can shift slightly. Embeddings from different models are never comparable.
Also asked as: are vector distances still relevant if embeddings are created with the same model but different quantization
Practical guidance: embed your whole corpus and your queries with the same model version and precision where possible. If you quantise stored vectors for memory savings, use the database's supported scheme and rescore top results with full-precision vectors. If you switch to a quantised model for serving, measure retrieval recall on an evaluation set; if it drops, re-embed the corpus with the new model.
When should I use vector embeddings?
Use embeddings when you need similarity by meaning: semantic search over documents, RAG, recommendations, duplicate detection, clustering and classification with little labelled data. Skip them when exact matching or structured queries solve the problem.
Also asked as: when to use vector embeddings
Exact lookups such as order numbers, filters such as price ranges, and reports with SQL do not need embeddings. Many real systems combine both: keyword search for exact terms, embeddings for meaning, and filters for structure. Start simple, measure whether embeddings improve results on real queries, and add them where they help. Remember the costs: embedding computation, storage, and re-embedding when models change.
Sources
- Sentence Transformers, documentationsbert.net
- Morris et al., Text Embeddings Reveal (Almost) As Much As Text (2023)arxiv.org
- Microsoft, GraphRAG documentationmicrosoft.github.io
- Edge et al., From Local to Global: A Graph RAG Approach to Query-Focused Summarization (2024)arxiv.org
- Mikolov et al., Efficient Estimation of Word Representations in Vector Space (2013)arxiv.org





