How does Pinterest use machine learning (ML)?
Tags: machinelearning, ai, ranking, recommendation
Published: 2022-03-10 19:28:43

## TLDR
Deploying methods of deep learning, AI, and ML, Pinterest is able to customize every user experience, maintaining their high user engagement and retention.

## Outline
* Intro
* Deep learning for image search
* Recommendation system
* Ranking
* Conclusion

## Intro
Founded in 2010, Pinterest is a platform where users can bookmark images to create folders which act as make-shift blogs. Accumulating 431 million active users, Pinterest sets itself apart from other web-based photo sites like Google photos by allowing user interaction, and ensuring photos shared to the site are high-quality images. To make sure images are high-quality and relevant to individual users, various artificial intelligence (AI) and machine learning (ML) algorithms are used.

## Deep learning for image search
Pinterest’s platform lends itself to generating millions of daily image uploads. The way users engage with the platform is by searching a word or phrase, and being presented with thousands of images that correspond to the search. Deploying an AI algorithm which can understand and categorize photos is extremely important to maintaining the efficiency of the platform.

When a photo is uploaded to Pinterest, it may have misleading or no corresponding tags that would give meaning to that image. To properly label all photos uploaded, Pinterest deploys an AI algorithm that categorizes and sorts all photos. This makes it easier for images to be more efficiently ranked and recommended later in the process.

Unlike other social media platforms, whose images are primarily taken and posted using a mobile phone, images on Pinterest are made up of high-quality, professional photography. This makes it much easier for Pinterest’s algorithm to extract the embeddings within the image.

Pinterest uses [representation learning](https://blog.fastforwardlabs.com/2020/11/15/representation-learning-101-for-software-engineers.html), a deep learning algorithm related to neural networks, to label and categorize the billions of photos that are uploaded to their site. Representation learning algorithms have become successful because they are able to extract very specific information from images.

<center>![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6gkczo33x325t95j0d4n.png)_Source: Fastforwardlabs_</center>

Images at Pinterest are applied to the representation learning model, which extracts pixels to make up a smaller, more compressed representation of the photo. Images are then compared to 1 another, and grouped based on similar qualities. With more data and time the model runs, its performance is able to get extremely niche and complex in image identification. This allows for more accurate recommendations and ranking. Thus, this model lays the foundation for other AI and ML algorithms within Pinterest to operate.

## Recommendation system
In the early stages of Pinterest, the platform saw high engagement with the recommended images shown when a user clicked on a similar photo. Images weren’t an exact match and weren’t always accurate to what the user was searching for. This sparked the idea to create the image search algorithm explained above to categorize photos.

Implementing image search solved the problem of identifying similar photos. Pinterest still had to solve for getting those photos to their users. To do this, a recommendation model was created to provide relevant photos to users as they scroll through their feed.

Pinterest’s platform benefits from users saving and grouping photos into labeled folders. This provides Pinterest with a labeled dataset of the user’s individual interest and preference. When a user pins a photo, it tells the algorithm to serve them similar pins so they can add to their boards. Pins are also recommended across board categories. Meaning that pins from 1 board can influence another’s pin recommendations.

As an example, say a user saves a photo of a standard pair of jeans. Using data extracted from boards and past pins, the recommendation algorithm gains insight into the style preferences of the user. If a user’s past pins contained lots of western wear, the algorithm narrows down the recommendations provided to photos of jeans related to western wear.

## Ranking
Even with pins being filtered down using a recommendation model, thousands, if not millions, of photos exist for every niche interest. Pinterest built a ranking algorithm to sort their photos so users get the more accurate recommendations.

Pinterest’s ranking model takes into account 4 factors:
* Domain quality
* Pin quality
* Pinner quality
* Topic relevance.

Pinterest’s **domain quality** factors in how well photos from a website perform on the app. More weight is given to pins that come from higher performing websites, boosting their ranking on user home pages.

**Pin quality** accounts for how well a photo performed based on user interactions: repins, comments, and click throughs. Similar to [TikTok](https://www.mage.ai/blog/how-does-tiktok-use-machine-learning), Pinterest will assess how well a pin does with the pinner’s own followers first. If the pin shows a high level of engagement, it will be shown to a larger audience. Pins showing more engagement will be ranked higher.

Pinterest ranks **pinner quality** as a factor in how much weight a pin receives. This takes into account the engagement rate, quality of posted pins, and how much engagement a user provides to others. Additionally, the quality of your re-pinned photos is given weight, giving more to higher-quality, high performing pins.

The final factor to Pinterest’s ranking system is topic relevance. By analyzing user preferences through their data, and content embeddings on pins, Pinterest is able to rank the most relevant content to display on a user’s feed.

Using these 4 factors to rank their content, Pinterest is able to provide their users high-quality, relevant content on their homepages every time they search.

## Conclusion
Pinterest’s use of AI and ML models: representation learning, recommendation system, and ranking, allow them to customize each dashboard to provide high-quality, relevant content to their users. These optimizations have undoubtedly contributed to Pinterest’s high engagement rate.

Want to build your own ranking model? [Start building](https://mage.ai/) for free!