---
id: 16915
lang: en
title: "Ozon trains a small model to generate search suggestions within 300 ms"
published_at: "2026-10-27 20:01:49"
source_name: "Habr: Ozon Tech"
source_url: "https://habr.com/ru/companies/ozontech/articles/1040182/?utm_source=habrahabr&utm_medium=rss&utm_campaign=corporate_blog"
canonical_url: "https://news.hamidun.com/en/news/16915"
categories: ["llm", "business"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# Ozon trains a small model to generate search suggestions within 300 ms

> **Краткая суть (BLUF):** Search suggestions on Ozon have to appear within 300 ms, or the user notices the lag. They used to be picked from a prebuilt index and ranked with gradient boosting, but rare queries and typos like Adibas hit a ceiling. Now a compact transformer with hundreds of millions of parameters completes the query using clicks, filters and past queries. Takeaway: a small model is enough for search, as long as filters and result checks surround it.  • Inference: TensorRT-LLM on a GPU cluster, tens of thousands of requests per second • Two training stages: pretraining on event chains, then fine-tuning for suggestions • Output filters: ban lists, a check that results are non-empty, duplicate removal

You type "cross" into the search bar, and a moment later "nike sneakers", "running sneakers" and "kids' sneakers" appear beneath it. Ozon has 300 milliseconds for all of this. If the system thinks longer, the user sees a "freeze" and finishes the query by hand. The search team described how it approached this limit from the other side: it stopped selecting suggestions from a ready-made list and started generating them.

## Why the classic setup hit a ceiling

For a long time, suggestions were built the way recommender systems work. First comes retrieval: candidates are pulled by prefix from a prebuilt index. Then gradient boosting over decision trees ranks them by relevance, popularity and other features. The setup is stable and predictable, which is why many large search engines use it.

But it has three weak spots. First, the system chooses only from what it already knows: nobody will suggest "purple sneakers with unicorns and sequins" if no such query exists in the index. Second, prefix search handles typos poorly: Adibas and Adidas are nearly the same thing to a human, but not to an index. Third, quality is capped by features that engineers came up with. Every new signal requires manual work, and complex patterns, such as rare but regular purchases, do not fit into a fixed set of factors. The index gets more expensive, and new features deliver less and less.

## How the generative model works

Ozon did not take an off-the-shelf LLM. Marketplace language consists of brands, SKUs, abbreviations and transliteration such as "iphone 17 pro" or "powerbank 20000" (typed in Cyrillic), and a ready-made model does not know how these words relate to shopper behavior on a specific platform. So the team trained a compact decoder-only transformer with a few hundred million parameters. Instead of ordinary text, it receives a sequence of actions: queries, clicks, views, filter actions and add-to-cart events.

Training runs in two stages:

- Pretraining on chains of user events. A chain can include about a hundred actions and span months. The loss is computed over all tokens, and the model learns the platform's general language: which queries follow one another, and how typos and spelling variants lead to the same products.
- Fine-tuning for suggestion generation. The context and an incomplete prefix serve as the condition, and the loss is computed only over the tokens of the target suggestion. For example, after a query about a Samsung tablet, a memory filter and a click on the Galaxy Tab S11 Ultra, the target is "case for samsung galaxy tab s11 ultra".

Several options in the response come from beam search, which keeps multiple likely continuations at once. The team started with "taptags", short continuations of the query. These are closer to a language model's native task and less noisy than full suggests, which must lead straight to a good results page. Full suggestions are the next step.

## Control and production

Generation removes the control the index provided: a suggestion from a database can be checked and banned in advance, but a generated phrase cannot. The risks are quite practical: clumsy grammar, duplicates like "nike men's sneakers" and "men's sneakers nike", extra continuations for an already complete query, profanity from user logs, and attractive suggestions that return no products.

Ozon covers these at two levels. Before launch, it computes an offline metric called expected actions count. It shows how many actions a user needs to reach the target query that was followed by a useful action, such as adding to the cart. Typo-correction quality is measured separately. This does not replace A/B tests, but it reflects the user scenario better than "did the suggestion match the log". At inference time, ban lists and regular expressions run, a result-size check filters out suggestions with empty results, and logical duplicates are removed.

For inference, the team uses TensorRT-LLM on a GPU cluster. Requests are balanced across several GPUs and assembled into batches, which allows tens of thousands of requests per second within the 300 ms limit.

The first iterations were modest. Basic generation of short continuations and then multi-word suggestions raised CTR but barely moved conversion metrics. So a rise in clicks does not yet mean users buy faster. The third step addressed typos: the training set was supplemented with organic corrections from the spell-checker and synthetic errors based on the statistics of real typos. The team also added a special correction token so the model can not only complete a query but also fix the part already typed.

For search developers, the takeaway is this: a small domain model with session history can replace the "index plus ranking" pairing, but only together with strict post-processing and a metric tied to the user's path. The provided excerpt of the material contains no final figures for business-metric gains, so it is too early to judge the final effect from it. The architecture and the list of pitfalls, however, can be used as a checklist.

---
- **Первоисточник:** [Habr: Ozon Tech](https://habr.com/ru/companies/ozontech/articles/1040182/?utm_source=habrahabr&utm_medium=rss&utm_campaign=corporate_blog)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/16915
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
