← All AI Engineer talks

AI Engineer World's Fair 2025

What We Learned from Using LLMs in Pinterest

About this talk

Pinterest Search engineers Han Wang and Mukuntha Narayanan explain how they improve search relevance using fine-tuned LLM cross-encoders that classify query-Pin relevance, enriched by vision-language-model captions and user signals. An 8-billion-parameter Llama 3 model is reported to outperform multilingual BERT by 12% and SearchSage by 20%. To serve the approach efficiently at scale, they distill a multilingual teacher into a production student model, selectively refresh embeddings, and reuse relevance-tuned representations across languages and downstream tasks. Audience questions cover model selection, ranking integration, earlier search architectures, multimodality, and multilingual results.

Chapters

  1. 0:00Presenters, Pinterest Search, and multilingual scale
  2. 1:52Search architecture, cross-encoder relevance, and model benchmarks
  3. 5:04Vision-language annotations and production-scale distillation
  4. 12:10Reusable relevance-tuned semantic representations
  5. 14:03Audience questions on models, ranking, multimodality, and languages

Talk transcript

  1. 0:00

    [on-hold electronic music] Yeah, hi, everyone.

  2. 0:15

    Um, thanks for joining the talk today. Um, we are super excited to be here and to share some of the learnings we, um, we have from integrating the LLM into Pinterest Search.

  3. 0:27

    My name's Han, and today I'll be presenting with Mukuntha, and we are both machine learning engineers from Search Relevance team at Pinterest.

  4. 0:36

    So start with a brief introduction to Pinterest. Um, Pinterest is a visual discovery platform where Pinners can come to find inspiration to create a life they love. And there are three main discovery surfaces on Pinterest, the home feed, the related pins, and search.

  5. 0:54

    In today's talk, we'll be focusing on search and, um, where the user can type in their queries and, um, find useful, inspiring content based on their information need. And we'll share, um, how we leverage LLM to improve the search relevance.

  6. 1:13

    Um, here are some key statistics for Pinterest Search. Every month, we handle over six billion searches with billions of pins to search from, covering topics from recipe, home decor, travel, fashion, and beyond.

  7. 1:29

    And at Pinterest, search is remarkably global and multilingual. We support over forty-five languages and are reaching Pinners in more than one hundred countries. These numbers highlight the importance of search at Pinterest and why we are investing, um, in search relevance to improving the search experience.

  8. 1:52

    So, um, this is an overview of how Pinterest Search work at the back end. So it's similar to, um, many recommendation system at industry. It has query understanding, retrieval, reranking, and the blending stage, and finally produce, um, relevant and engagement search feeds.

  9. 2:12

    And, um, in today's go- talk, we'll be focusing on the semantic relevance modeling that happen at the reranking stage and share about how we use LLM to improve, um, the search relevance on the search.

  10. 2:29

    Okay, so, um, here's our search relevance model, which, um, is essentially a classification model. Given a search query and a pin, the model will predict how much the pin is relevant to the search query.

  11. 2:44

    And to measure this, we use a five-point scale, um, ranging from the most relevant to most irrelevant.

  12. 2:53

    All right. Um, now we are gonna share some key learnings we have from using the LLM to improve search, Pinterest search relevance. And here are four main takeaways that we would like to, um, go into more details.

  13. 3:11

    Lesson one, LLMs are good at relevance prediction.

  14. 3:17

    Um, so before I present, um, the result, let me first give a quick overview of the model architecture that we are using. Um, we concatenate the query and the pin text together and pass them into a LLM to get a, um, embedding.

  15. 3:35

    So this is called, um, Cross-encoder structure, we- we-- where we can better capture the interaction between the query and the pin. And then we feed the, um, embedding from LLM into NLP layer to produce a five-dimensional vector which correspond to the, um, five relevance levels.

  16. 3:55

    And during training, we fine-tune some open source LLM using Pinterest internal data and to better adapt the model to our Pinterest content.

  17. 4:07

    And here, um, I'd like to share some results, um, to demonstrate that the usefulness of LLM. And as a baseline, we use SearchSage, which is a Pinterest in-house content and the query embedding.

  18. 4:24

    And, um, so if you look at the table, you can see that the LLM has substantially, um, improved the performance of the relevance prediction. And as we use more advanced LLMs and increase the model size, the performance keeps improving.

  19. 4:42

    And for example, um, the eight billion Llama three model gives, um, twelve percent of improvement over the multilingual BERT base model and twenty percent of improvement over the SearchSage embedding model.

  20. 4:55

    So, um, the lesson here is that, um, LLMs, they are quite good at relevance prediction.

  21. 5:04

    Um, lesson two, the vision language model generated captions and the user actions can be quite useful for content annotations.

  22. 5:16

    So to use LLM for search, uh, for relevance prediction, we need to build a text representation of each pin. And here I listed several features that we used in our model.

  23. 5:30

    Besides the, um, the title of description of the pin, we also include, um, the VLM-generated synthetic image caption to directly extract information from the image itself. And besides that, we add some, um, user engagement-based feature like the board titles, um, for the user-curated board that the pin has been saved to,

  24. 5:55

    or, um, the queries that led to the highest engagement with this pin on search surface So these two user action-based features, um, serves as additional annotation for the content.

  25. 6:09

    And, um, here the five source of feature together helps to build a more, um, robust and comprehensive text representation for each pin.

  26. 6:22

    Uh, we... To understand the, um, importance of t-each vortex feature, we also did some ablation studies. We used the, um, VLM generated image caption as a baseline. And, um, as you can see, itself already pro-um, provide a very solid baseline.

  27. 6:42

    And as we sequentially add more vortex feature, we keep seeing performance improvement. And this indicate that enriching the vortex feature is quite useful for relevance prediction. And notably, um, the last two rows of the table shows the performance gain we have by adding these user action-based features.

  28. 7:04

    So these features turned out to be quite useful content annotation that help model better understand the content.

  29. 7:14

    All right. Um, next, I will hand over to Mukuntha to talk about how we used knowledge distillation to productionize this model.

  30. 7:22

    Right. Yeah. Uh, so now we have a good relevance model, which is good at predicting search relevance. Uh, but how do we actually scale this up without bankrupting Pinterest?

  31. 7:33

    Uh, usually the answer is knowledge distillation into smaller models. Um, and this is the production served relevance student model that we distilled from the teacher model using semi-supervised learning.

  32. 7:45

    Uh, the student model is trained to predict five-scale relevance scores too. Uh, it trains using the five, uh, scale soft scores pro-produced by the teacher model. Um, and we produce data for this using a semi-supervised learning setup that, uh, I'll show in the next slide.

  33. 8:03

    So the LLM teacher model is trained on a small set of human labeled data that we get from human annotators who are trained in very specific segments. Uh, we fine-tune, and this is a multilingual language model which uses pretty generic features which scale across a lot of different domains, et cetera.

  34. 8:22

    Um, and the way we get training data for the student, uh, is through, uh, sampling from daily search logs, which is, um, all the searches, uh, people make on Pinterest.

  35. 8:34

    Uh, and since we sample daily, uh, this includes any trending queries, all the latest, freshest pins on Pinterest. And this is also remarkably go-global, like we mentioned, and only a small subset of this comes from the US, where most of our human labeled data comes from.

  36. 8:52

    Um, we sample from this, and we label using the teacher, and we scale it up pretty much 100X, uh, across different domains, languages, countries where, uh, the LLM teacher model produces pretty good labels.

  37. 9:05

    We train the student model, and this is the model that actually gets served online. Um,

  38. 9:12

    and, uh, zooming into the student model, uh, also-- this also has language models in it. Uh, but unlike the teacher model, it's not a cross-encoder. It, uh, is a bi-encoder, uh, which essentially means we don't have cross interactions between the pin and the query, uh, representations.

  39. 9:30

    Um, the pin gets embedded separately, query gets embedded separately, and it also uses a lot of other features like, um, SearchSage that we previously mentioned for both embedding the query and the pin.

  40. 9:41

    Uh, we have GraphSAGE embeddings, which Pinterest has published papers on, um, and OmniSage and a lot of other embedding features for query and pin. But we also use, uh, a lot of pin query text match statistics like BM25, which we've seen historically perform really well for predicting search relevance.

  41. 9:59

    Um, and the reason this scales well is the bi-encoder. Uh, bi-encoder large language models can scale really well, uh, when we, uh, use offline inference and caching. Uh, the pin embedding here is entirely offline inferred on billions of pins.

  42. 10:17

    Uh, it uses predominantly the same text features that we mentioned on the teacher, uh, which helps distill efficiently. Um, and, uh, we only, uh, re-infer, uh, these embeddings every time that these inputs meaningfully change, uh, meaning that, uh, every time that we, uh, need new embeddings, um, it's only going to run on a few set of new

  43. 10:40

    pins. Um, and, uh, this is offline inferred, so none of this is happening online when a user issues a search query. Uh, and the query embedding is pretty much, uh, real-time inferred online.

  44. 10:52

    Uh, and search queries are pretty short. Um, they don't occupy too many tokens, which means, uh, we can keep the latencies for the query embedding up to like a few milliseconds.

  45. 11:02

    Um, and we also cache this, uh, because search queries get repeated a lot, and we get around an eighty-five percent cache hit rate. Um, and yeah, this scales really well, uh, to actually serve Pinterest traffic.

  46. 11:17

    Um, the online results here, uh, the first four numbers are relevance, uh, measurements, nDCG, uh, precision at eight, uh, measured on the US, Germany, France, uh, specific segments that we zoomed into.

  47. 11:31

    Uh, we can actually see that we get relevance gains international, uh, internationally even though we started with a very limited set of US data for this particular experiment. Um, and, uh, we also see that search fulfillment, which measures engagement on search, um, fulfilling actions, um, also goes up, um, also on non-US even though our, uh, starting data

  48. 11:56

    was predominantly US. And, uh, yeah, uh, large language models are very good at, uh, expanding across many different domains, countries, uh, even though, uh, they have-- weren't explicitly trained for this.

  49. 12:10

    Um, and, uh, this is a bonus. Uh, we also found that relevance-tuned large language models produce really good rich, uh, semantic representations, which are very good general purpose. Uh, this is the same production relevance student model that I shared on the previous slide.

  50. 12:27

    Uh, and, uh, the Pin embedding and the query embedding, uh, are basically free representations that we get from these models, uh, which can be used across Pinterest for representing Pins and search queries.

  51. 12:41

    Um, we, we also use this to represent boards using the titles, et cetera. Um, and we found that using these embeddings, especially since they've been distilled from a large language model teacher and also have large, uh, language models in them, uh, they are very good at semantic content representations.

  52. 13:01

    Uh, and yeah, they perform pretty well across, uh, related Pins, home feed, and a lot of other surfaces where we've seen, uh, representations improve by adding these things. Um, so let me go over the key takeaways again.

  53. 13:18

    Um, I think lesson one, we found that LLMs are really good at relevance prediction. Uh, lesson two, we found that visual language model captions are good, uh, ex- good ways to imbue them with, uh, image representations, and, uh, user actions are very good content annotations.

  54. 13:36

    Um, three, uh, we found that knowledge distillation is a very good way to scale, uh, and efficiently serve models, uh, online. And, uh, lesson four, uh, relevance tuning produces pretty rich representations, uh, that embed semantic representations for content fairly well.

  55. 13:56

    Thank you. Um, I wonder if there are any questions from the audience. Please come up to the mics.

  56. 14:03

    How did you decide which open source LLMs to fine-tune?

  57. 14:09

    Yeah, that's a... Yeah, that's a very good question. So we did a lot of experiment trying different language models. And, um, in the previous slide, we also share some, um, performance for different language model.

  58. 14:22

    Yeah. So we did a lot of experiment and find the one that gives us the best performance. Yeah.

  59. 14:29

    Uh, if you could just walk us through somebody typing a search prompt. The confusion that I have is you have, like, LLMs, uh, building some sort of matching. Is it just being used for the label to be distilled, or how did you shim that into the bi-encoder?

  60. 14:46

    It wasn't really clear on the two-tower, uh, flying airline and how the LLM search kind of influenced that.

  61. 14:55

    We use LLMs to distill into a student model which predicts search relevance specifically and produces five scale relevance scores. Um, and it's served at the end of the search pipeline.

  62. 15:06

    It's, uh, the re-ranking stage. Um, like every recommendation system, we have a lot of, uh, CGs, which are candidate generators. We have early stage ranking, and this is one of the things that sits further down the pipeline, which actually predicts search relevance scores and, uh, is used

  63. 15:24

    right before blending to actually produce a feed. So I think it's very similar to most recommender systems.

  64. 15:34

    So, uh, I have a... Excuse me. Uh, I have a question on how you evolved into this architecture. Like, I'm sure Pinterest has pre-LLM era search as well. Like, what limitations did you see in those systems that this new architecture solved for?

  65. 15:56

    So, um, if I'm understanding correctly your question is about what's the difference between the new system with the-

  66. 16:02

    Yeah

  67. 16:02

    ... from the-

  68. 16:03

    What, what was the, what was the driver to adapt, adapting LLMs, uh, for, for in, in your search pipeline? Did the type... Did it support new features, or is it...

  69. 16:13

    Does it improve on the existing features where you had limitations?

  70. 16:19

    I think they definitely improve, uh, especially with visual language model captions. I think we were es- very effectively able to expand beyond limited markets for actually measuring relevance data and getting relevance data.

  71. 16:34

    And yeah, these multilingual models are very good at, uh, getting s- synthetic data for different markets for, uh, relevancy.

  72. 16:47

    Hey. Um, g-great, great talk. Um, I was wondering why, uh, or if, if the embedding model is inherently multimodal, um, because you have text, which is, uh, the, the query, and then you're matching against, um, either text links or images.

  73. 17:03

    And so how do you think about mo- multimodality?

  74. 17:07

    It's definitely something we're exploring, but then, uh, on a lot of applications, I think we found, uh, visual captions are very good at ca- uh, capturing what the image has.

  75. 17:17

    Um, and we have some very good captioning models in-house, which, uh, yeah, help us.

  76. 17:24

    Great. Thanks.

  77. 17:27

    What was the improvement-

  78. 17:28

    Great talk. Uh, yeah, just a quick question. You mentioned that you saw improvements in other language as well. Did you start with the common baseline model for all languages, or did you have to sort of...

  79. 17:40

    And just change the features for each language, or did you actually also start with separate l- models for individual languages?

  80. 17:49

    Yeah, that's a-

  81. 17:49

    Just curious how you actually saw the improvements manifest everywhere.

  82. 17:54

    Yeah. Um, so we s- we used the, um, same model for all languages, and we... Because we u- we are using the multilingual mo- um, LM, so we believe it can have transfer to other languages. [outro music]