Vector DB Guide
Vector DB Guide
Vector Databases
AI by Hand ✍
Prof. Tom Yeh
Hosted by:
1
Roadmap
+Vector
Database Retrieval
Query
distance similarity
1 2 3 dog 2 1 0
* * * * * *
2 2 0 cat 1 2 0
= = = ∑ = = = ∑
2 4 0 6
Result Result
2 2 0 6 cat 1 2 0
2 2 0 6 4 cat 1 2 0 4
Embedding 1 Embedding 2
a an the how why who what are is am be was you we I they she he she me him her
0 -1 0 1 0 1 0 0 -1 1 0 0 0 3 1 0 -1 0 0 0 -1 0
2 0 2 0 0 0 -1 1 0 0 0 2 1 0 2 0 2 0 0 2 0 0
-1 0 -1 1 2 0 0 1 0 1 -1 0 0 -1 0 3 0 0 -1 0 2 -1
0 1 0 0 1 0 1 0 1 0 1 -2 0 0 0 1 0 1 0 1 0 1
1 0 0
0 1 1
1 1 0
0 0 0
1 0 0
0 1 1
1 1 0
0 0 0
a an the how why who what are is am be was you we I they she he she me him her
0 -1 0 1 0 1 0 0 -1 1 0 0 0 3 1 0 -1 0 0 0 -1 0
2 0 2 0 0 0 -1 1 0 0 0 2 1 0 2 0 2 0 0 2 0 0
-1 0 -1 1 2 0 0 1 0 1 -1 0 0 -1 0 3 0 0 -1 0 2 -1
0 1 0 0 1 0 1 0 1 0 1 -2 0 0 0 1 0 1 0 1 0 1
0 0
1 1
1 0
0 0
AI by Hand ✍ 2024 © Tom Yeh 30
Word vectors à Sentence vector
Method 2: Average
1 0 0
0 1 1
0 1 0
0 0 0
query = Query(post_index)
._________(post)
._________(relevance_space.text, Param("________"))
Source: Superlinked.com
emb
Query 9 -8 9 9 0 3 1 -6 0 11 3 13 -2 6 15 -9 7 6 -5 8
{ max | min }
emb
Query 6 8 9 9 1 10 0 9 12 15 2 13 12 6 15 9 7 6 5 8
{ max | min }
Word Sentence
Embedding Embedding
Vectors Vector
1 0 0
0 1 1
1 1 0
0 0 0
1 0 0
0 1 1
1 1 0
0 0 0
1 1 1
1 0 -1 0 1
1 0 0
0 1 1
1 1 0
0 0 0
1 1 1
1 0 -1 0 1 1 0 1
0 1 1 0 0
AI by Hand ✍ 2024 © Tom Yeh 43
How to combine across positions and
features?
1 0 0
0 1 0
1 1 1
1 0 0 0 0
0 1 1 2 1
1 1 0 1 0
0 0 0 0 0
1 1 1
1 0 -1 0 1