{"slug": "how-pinterest-built-llm-powered-search-in-20-languages-with-minimal-training", "title": "How Pinterest Built LLM-Powered Search in 20 Languages With Minimal Training", "summary": "Pinterest built an LLM-powered search relevance system that operates in 20 languages while keeping training costs low, according to a ByteByteGo analysis of publicly shared details. Pinterest used a large language model to generate training data for a smaller, faster model that scores search results live, labeling relevance on a five-level scale from L5 (highly relevant) to L1 (highly irrelevant) with human annotators setting the baseline. The approach separates relevance from engagement prediction so results match user intent, such as \"small balcony garden ideas,\" rather than only likely interaction.", "body_md": "## [Developer workshop: Low-latency AI with Rust (Sponsored)](https://go.bytebytego.com/scyllaDB_120126)\n\n*Build a high-performance Rust app where AI agents learn from shared, real-time memory*\n\nWant to learn how to scale fast AI decision loops? Join us for this free interactive workshop.\n\nAs you explore key principles of designing low-latency systems with Rust, you will learn how to:\n\n- Build and compile a real-world Rust app that runs many concurrent decision loops\n- Connect it to ScyllaDB (NoSQL data store) as a shared, persistent memory subsystem\n- Negotiate data modeling and query tradeoffs for AI workloads, such as single-row partitions and counters as incremental updates\n- Manage and monitor the database for consistently low latencies as concurrency grows\n\nAll attendees will get a 3-chapter excerpt from the *Latency* book by Pekka Enberg (published by Manning).\n\nWhen you search for something on Pinterest, you express an intention with just a few words. For example, a query like “small balcony garden ideas” tries to describe something that you want to find. Pinterest needs to find out all the useful Pins that might satisfy this search query and decide how to order them.\n\nHere, a Pin is a piece of content on Pinterest that contains an image or video. It sometimes links to an external webpage. Search relevance tries to measure how well the content satisfies the intention behind the query.\n\nPinterest uses a powerful language model to help judge if a search result is relevant. But running that model again and again during live searches would be quite expensive. Therefore, they used that model to produce training data for a smaller model that can answer things quickly.\n\nIn this article, we’ll try to understand the design behind this approach. Here’s what we’ll cover:\n\n- How Pinterest defines relevance\n- How a language model gets enough information to judge a Pin\n- How Pinterest trained its model to make the right judgements\n- How it transfers those judgements into a live production search system\n- How the cost of training was reduced\n\n*Disclaimer: This post is based on publicly shared details from various sources. References at the end. Please comment if you notice any inaccuracies.*\n\n## How Pinterest Defines Relevance\n\nSearch relevance starts with understanding the request. As we saw using the earlier example, it’s all about understanding the user’s intent.\n\nFor the “balcony” query, a Pin that shows a compact arrangement of plants on a balcony would be highly relevant. On the other hand, a photograph of an enormous landscaped garden might look attractive and popular. But it would be less useful with space constraints.\n\nThis is the reason why Pinterest wanted an explicit relevance objective alongside engagement predictions while predicting stuff. Engagement just gives an estimate of whether people are likely to interact with something. Relevance estimates whether it addresses what they searched for. These measurements can complement each other. But they answer different questions.\n\nRelevance also comes in degrees. With some results, you are able to match the request closely. Others might provide partial help. Some have little connection to it. Pinterest handles these differences using different levels:\n\n- L5 stands for highly relevant. It directly matches the query or closely corresponds to it.\n- L4 stands for relevant, where you provide a close match or a useful substitute. But there might be minor differences.\n- L3 is for marginally relevant. It means that the result might relate to the query but satisfies only part of the intention.\n- L2 stands for irrelevant. It belongs to the broad category but doesn’t satisfy the query.\n- L1 is for highly irrelevant. It simply means that the result has no relationship to the search.\n\nHuman annotators use these guidelines to label examples consisting of a query and a Pin. These examples provide a baseline for what the model should learn. The resulting task is multiclass classification. When you provide a query and information about a Pin, you’ve to predict its relevance across different categories.\n\n## [Build with Gemini in Google Antigravity. (Sponsored)](https://go.bytebytego.com/antigravity_120126)\n\nGoogle Antigravity is made for how you actually ship software now. Built with Google’s frontier Gemini models, it lets you direct autonomous agents to plan changes, write code, run terminal commands, and verify their work in a real browser. Review inspectable plans and diffs as you go, from weekend prototypes to production codebases. Get started at no charge with a weekly quota. *Rate Limits and Terms apply.*\n\n## How to Give Information to the Language Model About a Pin\n\nBefore a model can judge relevance, you need to provide it with a useful representation of the content.\n\nThis is quite challenging for Pinterest because a lot of the content over there is visual in nature. You can have an image that communicates information that is left out by the title. For example, let’s say you might have a pin called “my favorite room”. It might show a particular furniture style, colour scheme, and room layout without mentioning any of that stuff in the title.\n\nPinterest handles this by bringing in text from several sources. Each source gives you a different view of the Pin.\n\nPin titles and descriptions provide the information that is written by the user who created the Pin. Titles and descriptions from linked webpages add information about the content behind it. For example, if you have a recipe Pin, the linked page might make the dish and its ingredients much clearer than the short description that the user has written on Pinterest.\n\nTo get information from the image itself, Pinterest uses synthetic image captions. These descriptions are generated by an existing image-captioning model called BLIP. A caption might talk about a wooden dining table, hanging lights, and white walls. This gives the relevance model textual evidence about the visual content.\n\nPinterest also includes user-curated board titles. These boards are collections where users save Pins. If a user saves an image to boards about compact kitchens, those titles can provide additional context about how they might interpret and use the image.\n\nFinally, Pinterest also includes high-engagement query tokens that are drawn from historical searches that have led to strong engagement with that Pin over the last few years. These help them understand further details about the kinds of searches for which people may have found the Pin useful.\n\nAll these sources complement one another. A caption talks about visible objects, a webpage describes the linked content behind the Pin, and board titles capture context written by users.\n\nThis way, the teacher model gets a richer textual understanding than a title alone could provide. The quality of how relevant something is depends partly on the quality of this description. A capable LLM still needs to find information about what the Pin contains.\n\n## How Pinterest Trained the Teacher Model\n\nOnce Pinterest has assembled the Pin’s text, it combines that text with the search query and passes them both through an LLM.\n\nThe architecture is known as a cross-encoder. Its main feature is that it processes the query and the candidate’s text together so that it is able to understand the relationship between the request and the content.\n\nFor example, let’s say you have a search for the term “egg-free birthday cake”. You might have a candidate that contains many matching words while talking about a cake that requires eggs. If we process the request together with the recipe information, we give an opportunity to the model to recognize that the ingredients matter.\n\nThis is different from turning a query and a Pin into compact representations separately and then comparing those representations. With joint processing, you allow for more detailed interaction between the two pieces of text. However, you need more computation for each pair.\n\nIn the architectural context, the LLM produces a representation of the combined input. This representation goes through an MLP (Multilayer Perceptron), which is a small network of computational layers. These layers convert the representation into scores for the five relevance levels.\n\nPinterest takes pretrained language models and adapts them using its human-annotated examples. This process is known as fine-tuning. The model starts with knowledge acquired during pretraining. It then learns how to apply that knowledge to Pinterest’s particular relevance guidelines.\n\nTraining uses cross-entropy loss. You can think of this as a way to measure how poorly the model’s predicted scores match the training labels. If you have a human judgment indicating that a Pin is highly relevant while the model gives that category very little probability, the training process adjusts the model to reduce the disagreement level.\n\nUsing a bunch of many examples, the model learns about Pinterest’s relevance task. It becomes the teacher because its predictions will eventually provide supervision for another model.\n\n## Why the Teacher Needs a Smaller Student\n\nYou can have a cross-encoder making useful judgments. But every Query-Pin pair also needs joint processing.\n\nThe same Pin can have very different relevance ratings for different searches. For example, you might have a photograph of a red sofa that is great for a search about “red living room furniture” and unhelpful for “blue bedroom furniture.” Therefore, the relevance depends on the combination of the query and the content.\n\nAt the scale of Pinterest Search, if you run an LLM over candidate pairs, you end up with a lot of computational cost and response-time pressure. Users want search results quickly, and relevance scoring is only one part of producing those results.\n\nPinterest handles this using the process of knowledge distillation. In this process, you have a capable teacher model generate predictions. A smaller student model learns to reproduce those judgments.\n\nThe teacher runs offline, outside the path that needs to respond immediately to a user’s search. Its predictions become training material. In contrast, the student runs online, where it must calculate relevance scores quickly enough for live search.\n\nWith distillation, you transfer useful behavior using training examples. The student model might have a different architecture and different inputs because its objective is to learn the teacher’s relevance judgments.\n\nOther techniques also make the process of training larger teacher models more manageable. For example, QLoRA combines compressed model weights with small trainable adapters. Similarly, mixed precision reduces the numerical precision used in parts of the computation, while gradient checkpointing trades additional computation for lower memory use.\n\nThese techniques help bring down training costs. The teacher-and-student setup also helps handle the challenge of serving relevant predictions at the time of live searches.\n\n## Turning Search Logs Into Training Set\n\nHuman labels give you a valuable starting point, but collecting them is expensive. Trained people must examine Query-Pin pairs and make judgments according to the relevance guidelines.\n\nPinterest already has a much larger source of examples. Its search logs.\n\nThese logs contain impressions, recording content shown during searches, and engagements, recording interactions with that content. The source dataset has billions of rows. However, knowing that a Pin was displayed or clicked doesn’t automatically give us a 5-level relevance judgment.\n\nPinterest uses the teacher model to provide those missing judgments for examples that are found from the logs.\n\nIn the training flow, the teacher model generates soft labels. It scores across the 5 relevance levels. For example, you might have a pair that gets substantial probability in both L4 and L5. This gives the student model more context about the teacher model’s uncertainty as well as the category that it prefers.\n\nThis process takes two ideas and combines them. Knowledge distillation talks about the transfer of information from the teacher model to the student. Semi-supervised learning deals with the use of human-labeled examples together with a much larger collection that doesn’t initially have the relevance labels.\n\nWith search logs, you also broaden the coverage of the training data. They are made up of queries from different countries and languages. They also contain changing interests and seasonal concepts that may be missing from the human-labeled collection.\n\nYou can have a multilingual teacher model apply its language capabilities to those examples to generate additional training supervision. This way, the student can learn from an even more varied collection of Query-Pin pairs.\n\n## How the Student Model Scores Live Search Results\n\nThe student model uses a lightweight feed-forward neural network. The inputs to this network come from features available to Pinterest’s search system. It’s organized into 3 groups.\n\nThe first group helps describe the query. These features include information about its interests, shopping intent, and a SearchSAGE query embedding. You can think of an embedding as a collection of numbers that represents the characteristics of some data point, such as a query or an image. A trained model learns these representations so that other models can use them as inputs.\n\nThe second group talks about the Pin. Pinterest uses PinSAGE embeddings, visual embeddings for the image, and SearchSAGE Pin embeddings. These provide multiple numerical views of the candidate content.\n\nThe third group deals with the relationship between the query and the Pin. It includes text-matching scores, BM25 scores across text fields, and historical engagement rates for the pair.\n\nFor reference, BM25 is a traditional search scoring method that is based on matching the terms used in a query against the text within a document. It takes care of factors such as how informative a term is and the length of the text being searched. With such features, you give the student direct evidence about word matching along with its learned representations.\n\nPinterest transforms these inputs into numerical representations and passes them through the student model’s feed-forward network to predict the 5-level relevance scores.\n\nDuring training, the student has already learnt to match the teacher model’s predictions. During live search, it computes its own predictions from its available features. The teacher model’s judgments are already ingrained into the parameters that it has learnt.\n\nFinally, the student model’s relevance score contributes to the final ranking along with other engagement predictions. This connects the new model back to the original product goal. Showing content that handles the search while also making sure whether people will find it the content worth interacting with.\n\n## The Evaluation of the Approach\n\nPinterest evaluates several parts of their new approach to understand which decisions have contributed to the improvement.\n\nOne measurement is 5-level accuracy, which checks whether the predicted category matches the evaluation label. This is a strict measure. If the model predicts L4 when the evaluation label is L5, they still count it as an error, even though both categories try to depict content that’s useful.\n\nThe Pinterest engineering team also reports AUROC, which measures how well model scores separate groups of examples. They evaluate this by using relevance cutoffs at levels 3, 4, and 5. For example, you might have a cutoff at L4 that asks how effectively the model distinguishes L4 and L5 examples from lower-relevance examples. This is quite important because you want the search ranking to find the strongest candidates.\n\nThe first experiment compares language models while keeping the Pin text features and maximum input length fixed. The SearchSAGE-only baseline achieves 50.3% accuracy, while the strongest tested model, Llama-3-8B, achieves 60.2%. This shows that the tested language model can extract additional relevance information beyond the embedding-based baseline.\n\nThe second experiment talks about the text supplied to the teacher. With the model and maximum text length held fixed, accuracy rises from 45.7% using synthetic captions alone to 58% using the full set of text features. Adding titles, descriptions, linked-page information, board titles, and historical query information improves the result.\n\nThis shows that better representations of Pins contribute to better judgments even when the underlying model stays the same.\n\nThe third experiment checks the amount of student training data. A student trained on roughly 300K human labels achieves 48.4% accuracy. Training with 30 million teacher-generated labels raises this to 54.8%.\n\nThe result is a great indicator of the practical value of distillation. A large collection of useful teacher model judgments can train a stronger production model than the available human labels alone.\n\n## Conclusion\n\nOffline experiments show that a model makes better predictions on an evaluation dataset.\n\nPinterest also needs to determine whether these predictions improve the search experience.\n\nTherefore, the Pinterest engineering team takes an online A/B experiment and evaluates search feeds produced with and without the new relevance model.\n\nOne evaluation uses nDCG@20. It tries to measure relevance across the first 20 results, which gives greater weight to results that appear nearer the top. A highly relevant Pin in the first position contributes more than the same Pin much farther down the list.\n\nThis is a great indicator of how users experience search. The ordering is super important because users encounter the first few results before deciding whether to continue checking things further.\n\nPinterest reports a 2.18% improvement in nDCG@20. This checks the quality of the ranked feed. It extends the evidence beyond whether a model assigns individual labels correctly.\n\nThe team also performed human relevance evaluations across countries. These evaluations reported improvements for the United States, Germany, France, and the United Kingdom.\n\nFinally, Pinterest measures search fulfillment, which tracks search sessions resulting in a high-significance user action. The reported improvements are 0.7% for US traffic and 2.0% for non-US traffic. This connects the relevance improvements to changes in user behaviour.\n\n**References:**", "url": "https://wpnews.pro/news/how-pinterest-built-llm-powered-search-in-20-languages-with-minimal-training", "canonical_source": "https://blog.bytebytego.com/p/how-pinterest-built-llm-powered-search", "published_at": "2026-12-01 16:30:38+00:00", "updated_at": "2026-12-01 16:48:49.395532+00:00", "lang": "en", "topics": ["large-language-models", "ai-products", "machine-learning", "natural-language-processing"], "entities": ["Pinterest", "ByteByteGo"], "also_reported_by": [], "takeaway": "Pinterest distills a large LLM's relevance judgments into a smaller model trained on LLM-generated labels, scoring results on a five-level scale (L5 highly relevant to L1 highly irrelevant) so live search stays fast and cheap across 20 languages.", "recommendation": {"advice": "Use a large LLM offline to label relevance training data, then train a smaller model to serve live queries, keeping per-search inference cheap while preserving LLM-quality judgments.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/how-pinterest-built-llm-powered-search-in-20-languages-with-minimal-training", "markdown": "https://wpnews.pro/news/how-pinterest-built-llm-powered-search-in-20-languages-with-minimal-training.md", "text": "https://wpnews.pro/news/how-pinterest-built-llm-powered-search-in-20-languages-with-minimal-training.txt", "jsonld": "https://wpnews.pro/news/how-pinterest-built-llm-powered-search-in-20-languages-with-minimal-training.jsonld"}}