Sub topic 7
Filtering for integrity and quality
This chapter assumes you know the feed pipeline stages from earlier chapters: candidate generation, scoring, and re-ranking. It also assumes you can read short Python and treat a probability as a number between 0 and 1. The chapter covers how a feed removes or demotes posts for integrity and quality reasons, where those checks run, and how they fail.
What integrity and quality filtering means
A ranking model predicts which posts you will react to. It does not know whether a post is safe, honest, or worth your time. A scam post that gets clicks can score well. Integrity and quality filtering is the set of checks that keeps such posts out of the final feed or lowers their position.
Two terms need separating:
- Integrity covers harm and abuse: policy-violating content, spam, fake accounts, scams, coordinated manipulation, and content that is illegal in a given country.
- Quality covers posts that are allowed but low in value: clickbait headlines, engagement bait ("like if you agree"), recycled content, or pages that load slowly and are mostly ads.
The distinction matters because the response differs. Integrity violations are usually removed. Quality problems are usually demoted, so the post stays available but is shown less.
Where filtering sits in the pipeline
Filtering is not one step. Checks run at several points, and the cost of each check decides where it goes.
- At candidate generation. Cheap, rule-based checks remove posts that must never appear: content from blocked or muted accounts, posts removed by moderators, posts hidden by the viewer, and content restricted in the viewer's region or age group. Running these first means the expensive models never score posts that will be discarded.
- Alongside scoring. Classifier outputs, such as a predicted probability of spam, become extra features or separate scores. These can reduce a post's score directly.
- After scoring, during re-ranking. Final rules apply last, for example capping how many borderline posts appear on one screen. This stage connects to the re-ranking chapter.
Hard filters versus soft demotions
A hard filter removes a post. A soft demotion multiplies its score by a number below 1, so it can still appear if it scores very high. Platforms use both, and the choice follows from how certain the system is and how bad the harm would be.
| Situation | Typical response | Why |
|---|---|---|
| Viewer blocked the author | Hard filter | The user gave an explicit instruction. No model is needed. |
| Post removed by a moderator | Hard filter | A decision already exists. |
| Classifier is very sure the post breaks a rule | Hard filter or removal | High confidence and high harm. |
| Classifier is unsure but suspicious | Demote, and queue for human review | Removing a good post is costly, so reduce reach while a person checks. |
| Post is clickbait or engagement bait | Demote | It is allowed but low in value. |
| Post is legal in some regions only | Filter per viewer location | The rule depends on the viewer, not the post alone. |
Notice that explicit user choices and moderator decisions need no model at all. Only the uncertain middle needs thresholds.
Classifiers and thresholds
Most integrity checks that are not explicit rules come from classifiers. A classifier is a model that outputs the probability that a post belongs to a category, such as spam. You choose thresholds to turn that probability into an action.
Thresholds trade two kinds of error:
- A false positive removes or demotes a post that was fine. The author loses reach, and legitimate speech is suppressed.
- A false negative lets a harmful post through. Viewers see it, and it may spread.
Lowering a threshold catches more bad posts and wrongly catches more good ones. Raising it does the opposite. There is no setting that removes both errors. Platforms usually set stricter, lower thresholds for severe harms and looser, higher ones for subjective quality problems, and use demotion to soften errors in the middle.
Two practical points follow:
- Calibration matters. A threshold of 0.9 only means something if a score of 0.9 corresponds to roughly 90% of such posts really being violations. An uncalibrated model makes thresholds unreliable.
- Different categories need different thresholds. A single global cutoff would treat spam, graphic violence, and clickbait as if they had the same cost of error.
A worked example
The code below applies blocks, a removal threshold, and demotions to six candidates. The thresholds are illustrative, not any platform's real values.
from dataclasses import dataclass
@dataclass
class Candidate:
id: str
author: str
p_spam: float
p_violation: float
p_clickbait: float
base_score: float
REMOVE_VIOLATION = 0.90 # near-certain violation: drop
REVIEW_VIOLATION = 0.60 # suspicious: demote and send to review
REMOVE_SPAM = 0.95
CLICKBAIT_DEMOTE = 0.50
DEMOTION = 0.5 # multiply score by this when demoting
def apply_integrity(candidates, blocked_authors):
kept, dropped, review = [], [], []
for c in candidates:
if c.author in blocked_authors:
dropped.append((c.id, "blocked_author"))
continue
if c.p_violation >= REMOVE_VIOLATION:
dropped.append((c.id, "policy_violation"))
continue
if c.p_spam >= REMOVE_SPAM:
dropped.append((c.id, "likely_spam"))
continue
multiplier = 1.0
if c.p_clickbait >= CLICKBAIT_DEMOTE:
multiplier *= DEMOTION
if c.p_violation >= REVIEW_VIOLATION:
multiplier *= DEMOTION
review.append(c.id)
kept.append((c.id, c.base_score * multiplier))
kept.sort(key=lambda item: item[1], reverse=True)
return kept, dropped, review
candidates = [
Candidate("p1", "ana", 0.01, 0.02, 0.10, 3.0),
Candidate("p2", "ben", 0.02, 0.05, 0.80, 4.0),
Candidate("p3", "troll42", 0.01, 0.01, 0.10, 5.0),
Candidate("p4", "cy", 0.97, 0.01, 0.20, 3.5),
Candidate("p5", "dee", 0.05, 0.70, 0.10, 2.5),
Candidate("p6", "eli", 0.02, 0.95, 0.10, 2.0),
]
kept, dropped, review = apply_integrity(candidates, blocked_authors={"troll42"})
print("kept:", kept)
print("dropped:", dropped)
print("review:", review)Running it prints:
kept: [('p1', 3.0), ('p2', 2.0), ('p5', 1.25)]
dropped: [('p3', 'blocked_author'), ('p4', 'likely_spam'), ('p6', 'policy_violation')]
review: ['p5']Follow each post:
p3had the highest base score (5.0) but is dropped because the viewer blocked its author. A rule overrides any score.p2had the second-highest base score (4.0) but is demoted for clickbait, so it falls belowp1.p5stays in the feed at a low position and is queued for review, because 0.70 is suspicious but below the removal threshold.
The checks run in a deliberate order. Explicit rules come first because they are cheapest and most certain. Removals come before demotions so that a dropped post is never scored further.
Quality signals beyond classifiers
Quality filtering often relies on signals that are not about rule-breaking:
- Negative feedback. Hides, "not interested" taps, reports, and quick unfollows after seeing an author's posts. These are strong signals that a post or author is unwelcome.
- Source reputation. Past history of an account or domain, such as how often its posts were demoted or removed.
- Content patterns. Headlines that withhold the key fact, posts that ask for likes or shares, or text copied from other posts.
- Destination quality. For posts that link out, how the linked page behaves, including heavy ads or pages that users leave immediately.
Some of these overlap with engagement prediction. The predicted probability of a hide, which the scoring chapter gives a large negative weight, is itself a quality signal. Filtering and scoring are not cleanly separate. A hard filter is the part of the system where a rule overrides the score.
Common failure modes
- Over-removal. A classifier trained mostly on one language or culture mislabels posts from others. For example, slang or reclaimed words may look like abuse. Measure error rates per language and region, not only overall.
- Under-removal. Attackers change their behavior once they learn what gets caught: they misspell words, put text in images, or spread activity across many new accounts. Filters need regular retraining and new signals.
- Delayed labels. Ground truth for "was this spam?" often arrives hours or days later, through reports or review. The model is trained on old labels while attackers have moved on.
- Threshold drift. A model update can shift its score distribution. Without recalibration, an unchanged threshold removes more or fewer posts than intended.
- Cascading effects. Demoting a post reduces its engagement, which lowers its score in future rounds. A mistaken demotion can be self-reinforcing. The feedback-loops chapter covers this pattern.
- Review queue overload. If too many posts fall in the borderline band, human reviewers cannot keep up and decisions arrive after the post has already spread. Narrowing the band or prioritizing by predicted reach helps.
Transparency and appeals
Hard removals normally come with a notice to the author and a route to appeal. Demotions are often less visible. The author sees lower reach but may not know a demotion happened. Some platforms publish what kinds of content they demote, and some regulators require explanations for removals. This difference between visible and invisible actions is a recurring theme in the final chapter on user controls and transparency.
Summary
- Integrity filters protect people from harm. Quality filters protect their time. Both run alongside, and sometimes override, the engagement score.
- Cheap, explicit rules run first. Classifier-based decisions use thresholds and trade false positives against false negatives.
- Use hard removal when confidence and harm are high. Use demotion plus human review in the uncertain middle.
- Watch for miscalibration, language bias, adversaries who adapt, and demotions that feed back into lower engagement.
Exercise
In the worked example, post p2 has a base score of 4.0 but ends below p1 (base score 3.0). Explain why, then say what would happen to p5 if REVIEW_VIOLATION were raised from 0.60 to 0.75.
Show answer
p2 has a clickbait probability of 0.80, which is above the 0.50 threshold, so its score is multiplied by 0.5 and becomes 2.0. That is below p1's 3.0. If REVIEW_VIOLATION were 0.75, p5 (violation probability 0.70) would no longer qualify. It would keep its full score of 2.5, rank between p1 (3.0) and p2 (2.0), and would not be sent to the review queue. This shows the cost of a higher threshold: fewer false positives, but a suspicious post gets more reach and no human check.
Exercise
A platform lowers its removal threshold for spam from 0.95 to 0.70. Name one benefit and two risks, and describe one measurement you would check before shipping the change.
Show answer
Benefit: more spam is removed before viewers see it (fewer false negatives). Risks: more legitimate posts are wrongly removed (more false positives), and affected authors lose reach, which may be concentrated in particular languages or new accounts. Any two such risks are acceptable. A measurement to check: the false positive rate on a labeled sample, broken down by language or region, or the rate of successful appeals after removals, or user-reported spam before and after in an A/B test.