Vector DBs & RAG (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is a Vector Embedding and how is it generated?
junior LevelMost AskedCode Examplevector-databasesBasic
In Simple Words: A vector embedding is a mathematical numerical representation of unstructured data (text, images, audio, video) converted into a dense array of floating-point numbers in a continuous vector space:
- Concept: Items with similar semantic meaning land closer together in high-dimensional vector space. For example, "king" and "queen" will have high cosine similarity.
- Generation: Created by passing text or images through pre-trained deep learning transformer models (e.g. OpenAI
text-embedding-3-small, Cohere Embed, BGE-large, Voyage AI).
typescript
// Generating an embedding using OpenAI SDK:
import OpenAI from "openai";
const openai = new OpenAI();
const response = await openai.embeddings.create({
model: "text-embedding-3-small",
input: "Kubernetes pod networking architecture",
dimensions: 1536,
});
const embedding: number[] = response.data[0].embedding;
console.log("Vector length:", embedding.length); // 1536 floating-point values