Sub topic 1
Why Feeds Are Ranked Instead of Sorted by Time
Prerequisites
This chapter assumes three things:
- You have used a social media app and have seen a home feed.
- You understand probability as a number between 0 and 1.
- You can read short Python programs.
You do not need any machine learning background. Later chapters cover the models in detail. This chapter explains why ranking exists at all and what problem it solves.
The two basic designs
A feed is the ordered list of posts that an app shows when you open it. Two designs dominate.
A chronological feed shows posts from accounts you follow, newest first. The rule is one line: sort by timestamp, descending.
A ranked feed (also called an algorithmic feed) gives each candidate post a score and sorts by that score. The score estimates how valuable the post is to you at this moment. Time is one input among many, not the only one.
| Property | Chronological feed | Ranked feed |
|---|---|---|
| Sort key | Post timestamp | Computed score |
| Candidate source | Accounts you follow | Followed accounts, plus recommendations |
| Predictability | High: you can predict the order | Lower: order depends on models and your history |
| Handles high volume | Poorly | Better |
| Needs behavioral data | No | Yes |
| Easy to audit | Yes | Harder |
Neither design is simply better. They make different trade-offs, and the rest of this chapter explains where each one breaks down.
What goes wrong with pure time sorting
Chronological ordering works well when you follow a small number of accounts that post at a modest rate. Three things break it as usage grows.
Volume outruns attention
Suppose you follow 800 accounts and together they publish 400 posts a day. If you open the app twice a day for five minutes each, you might see 40 posts. A chronological feed shows you the newest 40 of the 400 you could have seen. The other 360 are skipped, and the choice of which ones is decided only by when you happened to open the app.
Ranking changes which 40 you see. Instead of "whatever was posted most recently", the feed tries to show "the 40 you are most likely to find worth your time".
Posting frequency decides who is heard
In a time-sorted feed, an account that posts 30 times a day takes up 30 slots. A friend who posts once a week appears once, and is buried under newer posts within minutes. The feed rewards volume, not quality or closeness. A feed dominated by high-frequency accounts is a common complaint about chronological timelines.
The timing of your visit matters too much
If a close friend posts at 3 a.m. and you open the app at 9 a.m., the post may already be far down the list. A chronological feed has no way to say "this one matters more than the ten that came after it."
The following diagram shows the volume problem.
What ranking changes
Ranking replaces one sort key with a computed one. It also changes three other things.
- The candidate pool can grow. A chronological feed is limited to accounts you follow. A ranked feed can add posts from accounts you do not follow if the system predicts you will like them. This is how recommendation sections come to sit inside home feeds.
- Old posts can beat new ones. A highly relevant post from yesterday can outrank a dull post from five minutes ago.
- Different people see different feeds. Two users who follow the same accounts can see different orders, because each score depends on that user's history.
A minimal scoring example
Here is a small program that scores posts using predicted reaction probabilities and a freshness decay. The weights are illustrative, not any real platform's values.
from dataclasses import dataclass
@dataclass
class Post:
id: str
author: str
age_hours: float
p_like: float
p_comment: float
p_hide: float
# Illustrative weights, not any real platform's values.
WEIGHTS = {"like": 1.0, "comment": 4.0, "hide": -10.0}
def score(post: Post) -> float:
value = (
WEIGHTS["like"] * post.p_like
+ WEIGHTS["comment"] * post.p_comment
+ WEIGHTS["hide"] * post.p_hide
)
freshness = 0.5 ** (post.age_hours / 6) # halves every 6 hours
return value * freshness
posts = [
Post("a", "ana", 1, 0.30, 0.02, 0.01),
Post("b", "ben", 12, 0.60, 0.10, 0.01),
Post("c", "cy", 2, 0.10, 0.01, 0.05),
]
for p in sorted(posts, key=score, reverse=True):
print(p.id, round(score(p), 3))Running it prints the posts in score order. Post a is the newest relevant one and ranks first. Post b is twelve hours old and has strong predicted reactions, but its freshness factor is 0.25, which pulls it below a. Post c is newer than b but has a 5% predicted chance of being hidden, and the weight of -10 makes its value negative.
A chronological feed would show a, c, b by age (1, 2, then 12 hours). The ranked feed shows a different order because it uses predicted reactions and not only age.
Notice that p_like, p_comment, and p_hide are predictions, not facts. Where they come from is the subject of later chapters. For now, treat them as numbers a model supplies.
Why platforms prefer ranking
Platforms give several reasons, and some are better supported than others.
- Relevance under overload. When there are more posts than time, some selection is unavoidable. Ranking makes that selection deliberate.
- Engagement. Platforms measure that ranked feeds usually increase time spent and interactions compared with chronological ones. This is a business motive, and it is also a place where interests can diverge from the user's.
- Creator and advertiser needs. A feed that mixes in new content gives new creators a path to an audience. Advertisers also need a feed that holds attention.
- Safety and quality. Ranking is a place to demote spam, bait, and content that breaks policy. A pure time sort has no such hook, so every spam post gets full placement as long as it is new.
The last point is easy to miss. Even a platform that wanted a purely chronological feed would still need filters for spam and abuse. Ranking gives those filters a natural place to live.
What ranking costs
Ranking is not free, and the costs are the reason chronological options still exist in many apps.
Opacity
With a time sort, you can explain why a post is where it is. With ranking, the honest answer is "a model gave it a high score based on many inputs." Users often cannot tell why something appeared, which makes the feed feel arbitrary or manipulative.
Optimization targets can drift
A ranker optimizes whatever it is told to optimize. If the target is predicted engagement, content that provokes strong reactions can score well even when users would not choose it on reflection. Choosing the target is a product decision, covered in the next chapter.
Feedback effects
Ranking uses your past behavior to decide what to show next, and what you are shown shapes what you do next. This can narrow the content you see over time. The chapter on feedback loops examines this in detail.
Infrastructure and complexity
A chronological feed is a database query with an ORDER BY. A ranked feed needs feature storage, model serving, low latency, and experimentation tooling. It is also harder to debug, because a bad result may come from data, a model, a weight, or a rule.
Hybrid designs in practice
Most large platforms do not choose one design. Common patterns include:
- A default ranked feed with a separate "following" or "latest" tab that is chronological.
- A ranked feed with a toggle that lets the user switch.
- A chronological feed of followed accounts with ranked recommendations inserted at certain positions.
- Ranking applied only to notifications or to a "top posts" digest, not the main list.
Even a "chronological" tab is often not purely so. It may still drop spam, hide muted accounts, or collapse repeated posts. So the real question is rarely "ranked or not" but "how much does the system reorder and filter, and who controls it?"
Where this fits in the pipeline
The rest of this tutorial follows the order of a feed pipeline. Ranking is only one stage.
The pipeline exists because scoring every post for every user is too expensive. A cheap first stage cuts millions of posts to a few hundred. Then an expensive model scores only those. Chronological sorting skips all of this, which is why it is cheap, and why it cannot do any of the things the pipeline is built for.
Common misunderstandings
- "The algorithm" is one program. In practice it is many models, rules, and filters. Different surfaces (home feed, search, notifications) often use different ones.
- Ranking means hiding posts. In most designs nothing is deleted. Posts are ordered, and low-ranked ones are simply less likely to be seen. Some filters do remove content, which is a separate step.
- Chronological means neutral. It still favors frequent posters and users who are online at the right time. It is predictable, but it is not neutral.
- Ranking is only about engagement. Engagement is a major input, but quality, safety, diversity, and business rules also shape the order.
Summary
Feeds are ranked because the number of posts available to a person far exceeds the time they have. A time sort picks the newest slice. A ranked feed picks the slice it predicts is most valuable, and can include posts from outside your follows. The price is less predictability, more infrastructure, and the risk that the optimization target does not match what users want. The next chapter looks at that target: what a feed is trying to optimize.
Exercise
You follow 500 accounts. One posts 20 times a day. A close friend posts once a week. You open the app once a day and read about 30 posts. Explain what a chronological feed will probably show you, and name one change a ranked feed could make.
Show answer
A chronological feed shows the 30 newest posts at the moment you open the app. The account posting 20 times a day will likely fill many of those slots, and the friend's weekly post will usually be buried unless it was posted just before you opened the app. A ranked feed could raise the friend's post by using signals such as how often you interact with that friend, so it appears even though it is older. It could also lower some of the high-frequency account's posts.
Exercise
In the scoring example, post b has higher predicted like and comment probabilities than post a, but it ranks below a. Which part of the score causes this, and what would you change in the code to make older posts matter less?
Show answer
The freshness factor causes it. Post b is 12 hours old, so its factor is 0.5 (12 / 6) = 0.25, which cuts its value to a quarter. To make age matter less, increase the half-life, for example change the 6 in `0.5 (post.age_hours / 6)` to 24, so the score halves only every 24 hours.
Exercise
A teammate says "a chronological feed is neutral, so it needs no spam filter." Give two reasons this is wrong.
Show answer
First, a chronological feed still gives every new post full placement, so spam and abusive posts reach users just as easily as any other post, which means a filter is still needed. Second, chronological order is not neutral: it favors accounts that post often and users who happen to be online when posts are made. Filtering and ordering are separate concerns, and removing the ranker does not remove the need for filters.