AI & ML
Vector Embeddings
Quick Definition
High-dimensional mathematical array representations of text, audio, or images where semantic similarity translates directly to geometric proximity in vector space.
Architectural Deep Dive
Vector embeddings transform human language into points in high-dimensional space (typically 768 to 3072 dimensions). In this geometric space, conceptually related words and sentences ('king' and 'queen', or 'error: connection refused' and 'network timeout') are positioned close to each other. By computing cosine similarity or dot products between vectors, computers can understand semantic similarity rather than relying on exact keyword matching.
Why this matters in 2026: Forms the foundational mathematics behind modern semantic search, recommender engines, and RAG architectures.
Implementation Example (typescript)
// Cosine similarity formula between two vector embeddings
function cosineSimilarity(vecA: number[], vecB: number[]): number {
let dotProduct = 0;
let normA = 0;
let normB = 0;
for (let i = 0; i < vecA.length; i++) {
dotProduct += vecA[i] * vecB[i];
normA += vecA[i] * vecA[i];
normB += vecB[i] * vecB[i];
}
return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
}Mathematical definition of cosine similarity used in semantic vector databases.
Common Engineering Pitfalls
- •Comparing embeddings produced by two different embedding models (dimensions and spaces do not match).
- •Using vector search for exact ID, SKU, or regex lookups where traditional B-Tree indexes excel.

