Lesson 24 / 28
Semantic Search and Recommendations
Build search boxes and "similar items" features.
Items near other items
Semantic search: embed all documents once, embed each query at request time, return the nearest items, ideally merged with keyword search and filtered by metadata. "More like this": use an item's own vector as the query to find similar articles, products or support tickets. Recommendations: represent a user by the average (or a learned combination) of the vectors of items they liked, then fetch nearby items, remembering to exclude things already seen and to add diversity and business rules (stock, region, age restrictions). Cold-start items still get a vector from their content, which is an advantage over methods that need interaction history. Measure with click-through, conversion or task success, not only offline similarity.
Search, recommend, classify, retrieve
The same vectors power search, recommendations, classification and retrieval for language models.
Exclude what was already seen
For recommendations, remove items the user already viewed or bought before showing nearest neighbours.
Quick check: How can an item's vector be used for "more like this"?
- Convert it back to the original text
- Delete it
- Use it as the query to fetch its nearest neighbours
- Add it to the model
Answer
Use it as the query to fetch its nearest neighbours — An item is a point in the space; its neighbours are similar items.