Winnie-the-Pooh in 768 Dimensions: Semantic Search for Codex Pets on YDB
Яндекс
A developer built a semantic search for the Codex Pets catalog using embeddings stored in YDB. The system combines lexical, textual semantic, and visual semantic rankings. Tests show improved NDCG and Recall metrics compared to lexical search alone.
The Codex Pets catalog contains 153 approved animated pets that accompany AI agents. As the catalog grew, tag-based search became impractical, failing to find pets described by appearance rather than exact tags. The author implemented semantic search: text fields (name, description, tags) are encoded into 768-dimensional vectors, and a multimodal model generates captions for four selected animation frames which are also vectorized. YDB stores the vectors and computes cosine similarity via Knn::CosineSimilarity. Four new tables were added to handle embeddings, captions, recommendations, and versioning. The search merges three ranked lists using Weighted Reciprocal Rank Fusion, with lexical and textual weights of 1 and a tuned visual weight. The visual branch can fail independently, falling back to lexical results. Testing showed semantic search improves NDCG@5 from 0.539 to 0.724 and Recall@5 from 0.528 to 0.743 on the full set of 14 queries.
- Abbreviations
- YDB = Yandex Database — Yandex Database (база данных Яндекса)
- NDCG = Normalized Discounted Cumulative Gain — Нормализованный дисконтированный кумулятивный выигрыш
- MRR = Mean Reciprocal Rank — Средний обратный ранг
- KNN = K-Nearest Neighbors — K ближайших соседей
- YQL = Yandex Query Language — Язык запросов Яндекса
- API = Application Programming Interface — Программный интерфейс приложения
- HTTP = HyperText Transfer Protocol — Протокол передачи гипертекста
- MCP = Model Context Protocol — Протокол контекста модели
Source: Habr — хаб ML —
original
