5 concepts · 10 practice questions
An embedding model turns text into a fixed-length vector so that texts with similar meaning land close together. Closeness is usually measured with cosine similarity. Queries and documents must be embedded with the same model, and changing the model means re-embedding the whole corpus, because vectors from different models are not comparable.
import numpy as np
def cosine(a, b):
return float(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)))
q = embed("how do I reset my password")
d = embed("Steps to change your login credentials")
cosine(q, d) # high, though they share almost no words
Sign in to read the rest and take the 10-question test.
Sign in to continue