Classic design · Senior
Personalized news feed
Classic interview design. Key points: multi-task engagement, weighted score, and freshness and diversity.
Short answer
Classic interview design. Key points: multi-task engagement, weighted score, and freshness and diversity. Facebook News Feed ranking decides, for each person, which posts appear first. Meta's engineering post describes the challenge of designing personalized ranking for more than two billion people, each with different interests.
01 · CONTEXT
Deciding what each person sees first
Facebook News Feed ranking decides, for each person, which posts appear first. Meta's engineering post describes the challenge of designing personalized ranking for more than two billion people, each with different interests. The company says it uses machine learning to predict which content will be most important to each person.
Without machine learning, the feed could be flooded with content the person does not find relevant or interesting, including overly promotional content or content from acquaintances who post frequently, which can bury content from the people they are closest to.
Scale complicates the problem: the available posts must be scored for more than two billion people, with more than a thousand posts per person per day on average. In addition, the system needs to know whether an article received many likes even if it was published minutes earlier.
02 · THE OBJECTIVE
From a like to many signals
The starting point is an observable signal of value: the person clicking like. The prediction uses features of the post, such as its type or the relationship between the viewer and the poster. The algorithm ranks higher the item with the highest predicted probability that the person will like it.
Liking is not the only way to express preference. There are several values, such as likes, comments, and shares, that must be aggregated into a single value per post. Sometimes the models disagree, and the weight of each prediction is based on the actions people say, in surveys, are most meaningful.
The overall goal is long-term value. To evaluate it, the post argues for choosing metrics aligned with what people say is important to them, and the company surveys people about how meaningful an interaction was or whether a post is worth the time.
03 · ARCHITECTURE
From the request to the ranked feed
When someone opens Facebook, on any interface, the request goes to a Web/PHP layer, which queries the feed aggregator. The aggregator collects the relevant information about each post and analyzes its attributes to predict the post's value to the person and compute the final score, aggregating all the predictions.
The diagram starts with the client, whether an iPhone, an Android, or a browser, which sends the request to the Web/PHP layer.
The Web/PHP layer queries the feed aggregator.
The aggregator fetches actions and objects, with an object summary, from the feed's leaf databases.
The models run over all candidate stories in parallel, across many machines called predictors.
The aggregator returns the list of ranked stories to the front end, which renders it for the person.
04 · CANDIDATES AND PASSES
Inventory, funnel, and diversity
The eligible inventory includes any non-deleted post shared by a friend, group, or page the person is connected to, made since the last login. There is also resurfacing logic: new posts the person has not seen but that were ranked in earlier sessions become eligible again, and already-seen posts that generated an interesting conversation among friends can become eligible again as a comment-boosted post.
Scoring happens in several passes, needed to save computing power and to apply rules, such as diversity of content types, that depend on an initial score. Before them, integrity processes are applied to each post.
The diagram starts with the eligible inventory, which gathers the posts since the last login and those that become eligible again.
Integrity processes are applied to each post before the scoring passes.
A lightweight model selects about five hundred of the most relevant posts among the eligible ones.
In the main pass, each story is scored independently and the eligible ones are sorted by score.
Rules such as diversity of content types come in during the contextual pass.
| Passada | What it does | Why it exists |
|---|---|---|
| Leve | Uses a lightweight model to select the most relevant posts among the eligible ones | Allows ranking fewer stories, with high recall, and using more powerful neural networks in the following passes |
| Principal | Scores each story independently and sorts the eligible ones by score | This is where most of the personalization happens |
| Contextual | Adds contextual features, such as content-type diversity rules | Prevents the person from seeing redundant content types, such as several videos in a row |
05 · THE SCORE
From multitask predictions to a linear combination
Each post is scored with multitask neural networks. The features include the post type, embeddings, that is, representations generated by deep learning models, and what the person usually interacts with. For each person, there are thousands of signals to evaluate.
The diagram starts with the features that feed the model: post type, embeddings, and what the person usually interacts with.
The multitask neural network receives the features and scores the post.
The system generates several predictions for the person, such as like, comment, and share.
The predictions are combined linearly into a single value per post.
A rare action, with a prediction close to zero, plays a minimal role in the result.
For simplicity and tractability, the predictions are combined linearly. For some people, the score may be higher for likes than for comments, because some people express themselves more by liking. One advantage of the format is that an action the person rarely engages in, such as a like prediction very close to zero, automatically plays a minimal role in the ranking.
06 · FRESHNESS AND LIMITS
Freshness, diversity, and what to take into the interview
Freshness shows up in more than one place. The system needs to know, in real time, whether an article received many likes even though it was published minutes earlier, and also whether the person liked a lot of content a minute earlier, in order to use that in ranking. The resurfacing logic makes not-yet-seen posts get reconsidered.
Diversity, in turn, comes in at the contextual pass, because rules such as content-type variety depend on an initial score.
The post also cites offline learning systems among the techniques behind the meaningful interactions and content quality models.
Frequently asked questions
What is Personalized news feed?
Classic interview design. Key points: multi-task engagement, weighted score, and freshness and diversity.
What does the Personalized news feed design cover?
It is organized in these sections: Deciding what each person sees first, From a like to many signals, From the request to the ranked feed, Inventory, funnel, and diversity, From multitask predictions to a linear combination, and Freshness, diversity, and what to take into the interview.
How long is Personalized news feed and what level is it?
It takes about 16 minutes to read and is rated Senior level.
Now design it yourself
Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.