Large Language Models for Search Relevance at Scale

pinterest · Tech · year n/a · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Search relevance ranking at global scale

Pinterest needed better semantic relevance prediction for search across billions of pins, billions of monthly searches, dozens of languages, and many countries. Cross-encoder LLMs improved relevance but were too expensive to serve directly in the high-throughput search ranking pipeline.

Constraints:

Architecture

Pinterest first fine-tunes multilingual open-source LLM cross-encoders on internal human-labeled relevance data. The teacher concatenates query and pin text, including title, description, visual-language-model synthetic image captions, board titles, and high-engagement search queries, then predicts a five-level relevance score. To productionize it, Pinterest uses semi-supervised distillation: daily search logs are sampled across domains, languages, countries, and fresh pins; the LLM teacher labels them; and a bi-encoder student learns five-scale soft relevance scores. Pin embeddings are inferred offline on billions of pins and refreshed only when inputs meaningfully change, while query embeddings run online in a few milliseconds with about 85% cache hit rate. The resulting relevance-tuned embeddings are reused across related pins, home feed, boards, and other Pinterest surfaces.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  Search_query["Search query"] --> Query_understanding["Query understanding"]
  Query_understanding --> Retrieval_candidate_generators["Retrieval candidate generators"]
  Retrieval_candidate_generators --> Early_ranking["Early ranking"]
  Early_ranking --> Production_relevance_student["Production relevance student"]
  Pin_text_features["Pin text features"] --> LLM_cross_encoder_teacher["LLM cross-encoder teacher"]
  Human_relevance_labels["Human relevance labels"] --> LLM_cross_encoder_teacher
  Daily_search_log_sampler["Daily search log sampler"] --> LLM_cross_encoder_teacher
  LLM_cross_encoder_teacher --> Teacher_soft_labels["Teacher soft labels"]
  Teacher_soft_labels --> Production_relevance_student
  Pin_text_features --> Offline_pin_embedding["Offline pin embedding"]
  Offline_pin_embedding --> Production_relevance_student
  Search_query --> Online_query_embedding["Online query embedding"]
  Online_query_embedding --> Query_cache["Query cache"]
  Online_query_embedding --> Production_relevance_student
  BM25_and_graph_features["BM25 and graph features"] --> Production_relevance_student
  Production_relevance_student --> Blending_stage["Blending stage"]
  Offline_pin_embedding --> Reusable_semantic_embeddings["Reusable semantic embeddings"]
  Online_query_embedding --> Reusable_semantic_embeddings
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Search query User search text that needs relevant pin results. Query understanding, Online query embedding
Query understanding Early search pipeline stage that interprets query intent. Search query, Retrieval candidate generators
Retrieval candidate generators Generate candidate pins before ranking. Query understanding, Early ranking, Production relevance student
Early ranking Initial ranking before late-stage relevance reranking. Retrieval candidate generators, Production relevance student
Pin text features Title, description, VLM captions, board titles, and engaged queries used to represent a pin. LLM cross-encoder teacher, Offline pin embedding
Human relevance labels Small set of trained annotator labels for initial teacher fine-tuning. LLM cross-encoder teacher
LLM cross-encoder teacher Fine-tuned multilingual LLM that sees query and pin together and predicts five-scale relevance. Pin text features, Human relevance labels, Daily search log sampler, Teacher soft labels
Daily search log sampler Samples fresh queries, pins, languages, countries, and domains from daily Pinterest search logs. LLM cross-encoder teacher
Teacher soft labels Five-scale relevance scores produced by the teacher for semi-supervised student training. Production relevance student
Offline pin embedding Bi-encoder pin representation inferred offline and cached for billions of pins. Pin text features, Production relevance student
Online query embedding Realtime query embedding with cache reuse for repeated short search queries. Search query, Production relevance student, Query cache
Query cache Caches repeated online query embeddings. Online query embedding
Production relevance student Bi-encoder model served online to predict search relevance from query/pin features. Offline pin embedding, Online query embedding, Teacher soft labels, BM25 and graph features, Blending stage
BM25 and graph features Additional query-pin text match, Sage, GraphSage, OmniS, and embedding features. Production relevance student
Blending stage Late search pipeline stage producing the final search feed. Production relevance student
Reusable semantic embeddings Pin, query, and board embeddings reused across related pins, home feed, and other Pinterest surfaces. Offline pin embedding, Online query embedding

Data flow

A user query enters Pinterest search and candidate generators retrieve pins. At the reranking stage, the production relevance student predicts five-scale relevance scores before blending. The teacher path builds training labels by feeding query+pin text features into a multilingual LLM cross-encoder. Daily search logs provide fresh unlabeled examples; the teacher produces soft relevance labels at 100x scale. The student path embeds pins offline from the same text features, computes query embeddings online, combines bi-encoder embeddings with existing features such as Sage, GraphSage, OmniS, and BM25 statistics, and serves relevance predictions online.

4 supporting quotes
“search work and the back end. So it's similar to um many recommendation system and industry. It has query understanding retrieval ranking and the blending stage”transcript, stated
“the model will predict how much the ping is relevant to this search query. And to measure this, we use a fivepoint scale”transcript, stated
“we sample from this and we label using the teacher and we scale it up pretty much 100x”transcript, stated
“the pin embedding here is entirely offline inferred on billions of pins”transcript, stated

Why this architecture

Pinterest uses a cross-encoder LLM teacher because it can model rich query-pin interactions and improve relevance prediction, but serves a bi-encoder student because pin embeddings can be inferred offline, query embeddings are short and cacheable, and the production model can scale to Pinterest traffic. VLM captions and user-action features expand image and engagement context, while multilingual teacher labels let a limited human-label set generalize across markets.

3 supporting quotes
“cross encoder structure we where we can better capture the interaction between the query and the ping”transcript, stated
“this also has language models in it. uh but unlike the teacher model it's not a cross encoder it uh is a by encoder”transcript, stated
“the reason this scales well is the by encoder uh benccoder large language models can scale really well”transcript, stated

Models used: fine-tuned open-source LLMs · 8B Llama model · multilingual BERT-based model · SearchSage · bi-encoder student model · visual language model captions · GraphSage · OmniS · BM25

Scale

Alternatives considered (roads not taken)

Serve the cross-encoder LLM teacher directly online

Rejected because: The production system uses a distilled bi-encoder student because cross-encoder interaction is too expensive for online scale.

“how do we actually scale this up without bankrupting Pinfest? Uh usually the answer is call this resolution into smaller models.”transcript, stated

Train only on human-labeled relevance data

Rejected because: Human labels are small and market-limited, so the team samples daily logs and uses the teacher to scale labels across domains/languages/countries.

“trained on a small set of human label data that we get from human annotators”transcript, stated
“we scale it up pretty much 100x uh across different domains, languages, countries”transcript, stated

Use only text title and description features

Rejected because: VLM captions and user engagement features add useful content annotations for image-heavy pins.

“we also include um the VM generated synthetic image caption to directly extract information from the image itself.”transcript, stated
“user action based features um serves as additional annotation for the content”transcript, stated

Use separate models for each language

Rejected because: Pinterest used the same multilingual model across languages to transfer improvements internationally.

“we use the um same model for all languages and we because we we are using the multilingual um LM”transcript, stated

Patterns

fine-tuning-adaptation (model-training)

Pinterest fine-tunes multilingual open-source LLMs on internal relevance data to adapt them to Pinterest content.

“during training we fine-tune some open source LM using tin internal data and to better adapt the model to our Pinterest content”transcript, stated

retrieval-ranking (ranking)

The distilled student model predicts five-scale search relevance scores at the reranking stage before blending.

“this is one of the things that sits further down the pipeline which actually predicts search relevant scores and uh is used right before blending”transcript, stated

synthetic-data-generation (training-data)

The LLM teacher produces soft labels over sampled daily logs to scale training data roughly 100x across markets.

“the LLM teacher model produces pretty good labels. We train the student model and this is the model that actually gets served online.”transcript, stated

batch-offline-processing (serving)

Pin embeddings are inferred offline on billions of pins and refreshed only when input features meaningfully change.

“the pin embedding here is entirely offline inferred on billions of pins”transcript, stated
“we only uh reinfer uh these embeddings every time that these inputs meaningfully change.”transcript, stated

cost-aware-routing (serving)

Pinterest distills the expensive teacher into a scalable student, caches query embeddings, and separates offline pin inference from online query inference.

“knowledge distillation is a very good way to scale uh and efficiently serve models uh online”transcript, stated
“we also cache this u because search queries get repeated a lot and we get around an 85% cash hit rate.”transcript, stated

Tradeoffs

Use a cross-encoder LLM as the teacher.

Chose query and pin concatenated into one LLM input over independent query/pin embeddings for the teacher.

Rationale: The cross-encoder better captures query-pin interactions for relevance labeling.

“we contain the query and the ping text together and pass them into a ln to get a um embedding.”transcript, stated
“where we can better capture the interaction between the query and the ping”transcript, stated

Serve a bi-encoder student online.

Chose offline pin embeddings plus online query embeddings over serving the cross-encoder directly.

Rationale: The bi-encoder scales better because expensive pin embeddings can be precomputed and query embeddings are short/cacheable.

“unlike the teacher model it's not a cross encoder it uh is a by encoder”transcript, stated
“this scales really well. uh to actually serve Pinterest traffic.”transcript, stated

Use semi-supervised teacher labeling.

Chose daily logs labeled by LLM teacher over expanding human labels manually.

Rationale: Teacher labels scale training data across countries, languages, domains, trending queries, and fresh pins.

“we sample from this and we label using the teacher and we scale it up pretty much 100x”transcript, stated

Use one multilingual model across languages.

Chose same multilingual LM for all languages over separate language-specific models.

Rationale: The multilingual model transfers relevance improvements to non-US/international segments.

“we get relevance gains international uh internationally even though we started with a very limited set of US data”transcript, stated
“we use the um same model for all languages and we because we we are using the multilingual um LM”transcript, stated

Gotchas (what bit them)

Cross-encoder relevance quality does not automatically make a production-search model.

Root cause: Cross-encoders capture query-pin interaction but are too expensive for Pinterest traffic.

Resolution: Use the cross-encoder as teacher and distill into a bi-encoder student with offline and cached embeddings.

“the student model is trained to predict five scale relevant scores too. Uh it trains using the five uh scale soft scores produced by the teacher model.”transcript, stated

Human relevance labels may not cover global markets and fresh content.

Root cause: Most human labels for the experiment came from the US while Pinterest search is multilingual and global.

Resolution: Sample daily search logs and let the multilingual LLM teacher label fresh data across domains, languages, and countries.

“only a small subset of this comes from the US where most of our human label data comes from.”transcript, stated
“this includes any trending queries, all the latest freshest pins on Pinterest”transcript, stated

Image-heavy search needs richer textual representations than title and description.

Root cause: Pins are visual content, and title/description alone may miss the image semantics and user-curated context.

Resolution: Add VLM-generated captions, board titles, and high-engagement search queries as content annotations.

“the five source of feature together helps to build a more um robust and comprehensive text representation for each pin.”transcript, stated

Online pin embedding would be too expensive at search scale.

Root cause: There are billions of pins, but most pin text features do not change on every query.

Resolution: Infer pin embeddings offline and only refresh changed inputs; infer short query embeddings online and cache repeated queries.

“none of this is happening online when a user issues a search query.”transcript, stated
“search queries are pretty short. Um they don't occupy too many tokens which means u we can keep the latencies for the query embedding up to like a few milliseconds.”transcript, stated

Evaluation

Pinterest evaluates the teacher against existing SearchSage and multilingual BERT baselines, performs ablation studies over text features, measures student online relevance and engagement metrics across US/Germany/France/non-US segments, and checks whether relevance-tuned embeddings improve other surfaces.

Metrics: five-level relevance prediction · 12% improvement over multilingual BERT-based model · 20% improvement over SearchSage embedding model · NDCG · precision@8 · search fulfillment · query embedding latency in a few milliseconds · 85% query cache hit rate

3 supporting quotes
“the 8 billion lama mastery model gives um 12% of improvement over the multilingual birdbased model”transcript, stated
“the 8 billion lama mastery model gives um 12% of improvement over the multilingual birdbased model and 20% of improvement over the search stage embedding model.”transcript, stated
“to understand the um importance of t each vortex feature we also did some oblation studies.”transcript, stated

Outcomes

Pinterest search handles over 6 billion monthly searches, billions of pins, over 45 languages, and more than 100 countries. The production student uses offline inference over billions of pins and online cached query embeddings to scale.

3 supporting quotes
“We support over 45 languages and reaching pingers in more than 100 countries.”transcript, stated
“relevance tuned large language models produce really good rich uh sematic representations which are very good general purpose.”transcript, stated
“they perform pretty well across uh, related pins, home feed, and a lot of other surfaces”transcript, stated