What is a Vector Database? (original) (raw)

Last Updated : 9 Oct, 2025

A vector database is a specialized type of database designed to store, index and search high dimensional vector representations of data known as embeddings. Unlike traditional databases that rely on exact matches vector databases use similarity search techniques such as cosine similarity or Euclidean distance to find items that are semantically or visually similar.

3333

Vector Database

What are Embeddings?

vector

Embeddings

How do they Work?

Implementation

This code uses FAISS to store 3 sample vectors and perform a similarity search using L2 distance. The query_vector is compared to all stored vectors and the indices and distances of the top 2 most similar vectors are returned.

Python `

import faiss import numpy as np data_vectors = np.array([ [0.1, 0.2, 0.3, 0.4], [0.2, 0.1, 0.4, 0.3], [0.9, 0.8, 0.7, 0.6], ], dtype='float32') dimension = data_vectors.shape[1] index = faiss.IndexFlatL2(dimension) index.add(data_vectors) query_vector = np.array([[0.1, 0.2, 0.3, 0.35]], dtype='float32') distances, indices = index.search(query_vector, k=2) print("Indices of closest vectors:", indices) print("Distances from query:", distances)

`

**Output:

Indices of closest vectors: [[0 1]]

Distances from query: [[0.0025 0.0325]]

Applications