How are embeddings used for document retrieval?
Reveal the answer and explore the explanation.
02EasyCoreHow are embeddings used for document retrieval?
Answer
EasyCore
How are embeddings used for document retrieval?
Answer
Maps inputs to vector representations that support similarity operations.
Practical example
Encode a question and document chunks into compatible vectors.
PythonRelated concept example
import numpy as np
q = np.array([1., 0.])
docs = np.array([[1., 0.], [0., 1.]])
scores = docs @ q / (np.linalg.norm(docs,axis=1)*np.linalg.norm(q))
print(scores.argsort()[::-1])Toy dense retrieval over nonzero vectors; production uses trained embeddings.
Reference: Further reading ↗