Skip to main content
Vector Databases and Why Are
They Used in Modern AI
Marko Lohert
Span
Agenda
What is a
vector
database?
Popular vector
databases
Why are vector
databases
used in
modern AI?
What is a
vector
database?
Popular vector
databases
Why are vector
databases
used in
modern AI?
Why do we need a vector database?
• In some applications we need
• To find similar data (not the exact match)
• Semantic search – content aware search, search based on
meaning
• … And we need to find data fast
Vector database stores and
manages high-dimensional
vector data and allows
similarity search.
Basic idea behind a vector database
• For every piece of data (text, image, ... ) a vector is stored
in vector database
• „Apple” -> [0.52, 0.56, 0.80, … 0.83]
• These vectors have a fixed number of dimensions
• Similar data is clustered together
• Find similar data in database == find similar vectors
Data -> vector
apple Apple orange Raspberry Pi 5
is_fruit 1 0 1 0
round 0.86 0 0.93 0
expensive 0.01 9.97 0.02 0.74
use_electricity 0 0.97 0 0.12
company_type 0 0.9 0 0.75
related_to_computers 0 1 0 1
related_to_phone 0 1 0 0
vectors
Data represented as vectors
• Grouping by similarity
• Hundreds / thousands of
dimensions
Image source: https://weaviate.io/blog/what-is-a-vector-database
Embedding
• Embedding == an array of numbers that is used to describe the
data
• Data can be text (word, sentence), image ..
• Often words „embedding” and „vector” are used
interchangeable
• Note:
• word „vector” puts focus on numerical representation itself
(mathematics), and word „embedding” puts focus on representing
data stored in database
Embedding
• A vector database stores embeddings (+ data)
• Embeddings are used to search for (similar) data
• Embeddings capture semantic meaning and context  similar
data have embeddings that are near each other in high-
dimensional vector space
How to calculate an embedding from
an input data?
• Embedding model uses machine learning models to turn
input text, image… into vector / embedding
Image source:
https://medium.com/@junxie2/vector-in-machine-learning-a24880e3b96a
Embedding model
Embedding models
• OpenAI
• text-embedding-ada-002 (1536 dimensions)
• text-embedding-3-small (1536 dimensions)
• text-embedding-3-large (3072 dimensions)
• Google Gemini
• Multiple embedding models
• Ollama Embeddings
• Multiple embedding models
• Hugging Face
• …
Types of embeddings
• Word embeddings
• Individual words as vectors
• Used techniques: Word2Vec, GloVe, FastText, …
• Sentence embeddings
• Entire sentences as vectors
• Used models: Universal Sentence Encoder (USE), SkipThought, …
• Document embeddings
• Document as vector (from articles to books)
• Used techniques: Doc2Vec and Paragraph Vectors
Types of embeddings
• Image embeddings
• Images as vectors (capture different visual features)
• Used techniques convolutional neural networks (CNNs), pre-
trained models like ResNet and VGG generate image
embeddings
• Used for image classification, object detection, and finding
similar images
• …
How to find similar vectors?
• Once we have vectors,
generated by embedding
models, we can search for
similar vectors
• Similar vectors  data with
similar meaning
Image source: https://weaviate.io/blog/what-is-a-vector-database
How to find similar vectors
• Multiple methods for calculating distances
• Distance between vectors vs similarity between vectors
• Let’s take a look at 3 of those methods for calculating
similarity …
Euclidean Distance
• Squared Euclidean distance (L2-Squared distance)
measures the distance between two vectors x and y:
distance =
Manhattan distance
• Manhattan distance (L1 norm or Taxicab Distance)
measures the distance between two vectors x and y
distance =
Cosine similarity
• Measures the angle between two vectors
=
Cosine similarity
• Measures the similarity between documents regardless of
the magnitude
• One of the most used similarity measurements
• Commonly used in Natural Language Processing (NLP)
Embeddings Index
• Vector databases can contain a huge number of vectors
• For faster search vectors need to be indexed
• There are different ways for calculating indexes
• Inverted File (IVF), Navigable Small World (NSW), …
Different approaches to implementing
vector databases
1. Fully vectorized database (Stand-alone)
• Example: Chroma, Pinecone …
2. Extensions for traditional databases
• For example: pgvector, an open-source extension for
PostgreSQL (https://github.com/pgvector)
Advantages of vector databases
• Speed / performance
• various indexing techniques for faster searching
• Scalability
• Flexibility
• Vector databases can handle higher complexity of using images,
videos or other multidimensional data.
• Semantic search
Disadvantages of vector databases
• Because vector databases provide approximate results,
applications requiring greater accuracy will need a
different database
Use cases for vector databases
• Semantic search
• Search based on the meaning or context
• Recommendation engine
• Web shop recommends similar items to items user has
previously bought (in vector database find nearest neighbor of
previously bought items)
• Natural-language search
• Artificial Intelligence / Enhancing LLM capabilities
Database comparison
Relational database
• Data is in tables – rows and
columns
• Looks for the exact match
select productName
from Product
where productId = xxxxx
• Highly versatile and can be
used for many different
applications
Vector database
• Data represented as
vectors
• Looks for similar data
• Finds products similar to
apple
What is a
vector
database?
Popular vector
databases
Why are vector
databases
used in
modern AI?
Chroma
• https://www.trychroma.com
• A lightweight vector database
• Used in RAG applications
• Open source - license: Apache 2.0
• GitHub: https://github.com/chroma-core/chroma
Chroma
• Default embedding model: all-MiniLM-L6-v2
• 384 dimensions
• Created by Sentence Transformers (https://www.sbert.net)
• More info at Hugging Face:
https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
Install Chroma
Python
pip install chromadb
chroma run
JavaScript
pip install chromadb
chroma run
# install the JS client
and the (optional) default
embedding function
npm install --save
chromadb chromadb-default-
embed
# set "type": "module" in
your package.json
Chroma database structure
• https://www.pinecone.io
• Used for recommendation systems and search engines
• Multiple embedding model supported
• https://docs.pinecone.io/models/overview
• Pinecone serverless on Azure, AWS, and Google Cloud
Platform
• Pricing plan:
• Starter – for trying out and for small applications (free)
• Standard – for production applications at any scale (paid)
• Enterprise – for mission-critical production applications (paid)
• https://qdrant.tech
• Multiple cloud providers: Azure, AWS, Google Cloud
Platform
• Pricing plan
• Managed Cloud (free)
• Hybrid Cloud (starting from $0.014 per hour)
• Custom (price on request)
• https://weaviate.io
• Open source
• Integrates semantic search and knowledge graphs ->
weaviate is used for natural language processing (NLP)
• Multiple cloud providers: Azure, AWS, Google Cloud
Platform
• Free trial
• Pricing plan
• Serverless Cloud (starting at $25 per month)
• Enterprise Cloud
• Bring Your Own Cloud
What is a
vector
database?
Popular vector
databases
Why are vector
databases
used in
modern AI?
Why are vector databases used in
modern AI / LLM?
• Vector databases deliver performance for GenAI
• Vector databases can handle large amounts of complex
data
• Vector database speed up the training of models because
they enable faster data retravel
• Long-term memory for LLM-s
Vector Databases and RAG
• RAG (Retrieval-Augmented Generation)
• Enables LLMs to use external data (our company data)
• Allows LLMs to access the current (up-to-date) data
• RAG needs fast access to data, and vector databases are
effective at storing, indexing and retrieving that data
• Vector databases are essential for RAG applications
Vector search in Azure AI Search
• More info:
https://learn.microsoft.com/en-us/azure/search/vector-search-overvi
ew
Key messages
• Vector database stores and manages high-dimensional vector
data and allows similarity search.
• Vector databases: Chroma, Pinecone, qdrant, weaviate…
• Vector databases + modern AI:
• Performance
• Vector databases are essential for RAG applications
• Long-term memory for LLM-s
• …
Vector Databases and Why Are They Used in Modern AI - Marko Lohert - ATD 2024