Similarity Search
Similarity Search encompasses all tasks related with retrieving relevant data (documents,
samples, observations, etc) given a query.
Suppose a user is asking how to use ShapeletsVecDB, and we encode this request in a 4-dimensional vector:
Natural Language:Text vector:Encoded Query:how to use Shapelets in Python?[how,to,use,Shapelets,in,Pyton,?][22,34,1,0]
Further assume that we have stored 3 vectors of documentation files in our ShapeletsVecDB instance:
Shapelets Engine:ShapeletsVecDB Python:Shapelets Data Apps:[1,11,−56,20][20,29,3,−2][120,33,−17,25]
We'd like to retrieve ShapeletsVecDB Python (the second vector) since it is the one more closely
related with the initial request.
We can quantify how close two given vectors are with Statistical Distances. One of the most popular ones is the Euclidean Distance:
d(x,y)=i=1∑n(xi−yi)2
Thus, we get:
d(Encoded Query, Shapelets Engine)d(Encoded Query, ShapeletsVecDB Python)d(Encoded Query, Shapelets Data Apps)=67.97=6.08=102.74
The minimum distance is 6, correspoding to the ShapeletsVecDB Python document, which means it is the closest
vector to the query.
We would use this to either feed an LLM with relevant context or for any other retrieval task.