Please enable JavaScript to use CodeHS

Responsible AI & Safety

How Do Recommendation Algorithms Work?

Ever wonder why your "For You" feed feels like it can read your mind? It's not magic — it's math, built from data about what you (and people like you) have clicked before. Let's open it up.

Responsible AI ~9 min Beginner friendly
The Big Idea

The big idea

Open a video app and scroll to your "For You" feed. Open a music app and hit "autoplay." Open a shopping site and scroll down to "you might also like." In every one of those moments, something has already happened behind the scenes: an algorithm — a set of step-by-step rules a computer follows to make a decision — has looked at millions of possible videos, songs, or products and picked the handful it thinks you're most likely to engage with: watch, like, comment on, or buy.

Simple definition: a recommendation algorithm is software trained on data about what you and people like you have done before, used to predict what you'll do next.

Here's the part that surprises people: "recommendation algorithm" isn't one single trick. It's not one magic formula every app uses. It's a whole category of techniques, and most real apps mix several of them together. But almost all of them boil down to the same job: rank a giant pile of content, and put the stuff you're most likely to react to near the top.


How It Decides

Two big approaches, explained simply

Most recommendation systems lean on two core ideas. Real platforms combine both (plus a lot of other signals), but understanding these two on their own will let you see through almost any "For You" feed you meet.

Content-based filtering

Recommend things that are similar in content to what you already liked — based on tags, category, or creator.

Example: you watch a lot of skateboarding videos. The app notices the tags "skateboarding," "tricks," and "skate park" show up again and again in what you watch, so it shows you more videos with those same tags — even from creators you've never seen.

Collaborative filtering

Recommend things that other people with similar taste to you liked — even if the content looks nothing alike on the surface.

Example: people who liked the same skateboarding videos as you also happened to love a cooking channel. You've never shown any interest in cooking, but you get that cooking channel recommended anyway, just because your "taste twins" liked it.

Content-based filtering asks, "What is this thing similar to?" Collaborative filtering asks, "What did people who act like you also enjoy?" Neither one understands the content the way a human does — both are just finding patterns in data about clicks, watches, and likes.


Interactive

Try it yourself: build your own "For You" feed

Below is a simplified, simulated video feed with six categories. Click on ("watch") a few videos and see what happens: a live interest score tracks which categories you engage with, and your feed reshuffles to show you more of whatever you've been clicking. This is a simplified, honest simulation — the scoring rule is just "+1 to that category every time you click" — but it demonstrates the exact same feedback mechanism real platforms use, just without the complexity.

"For You" Feed Simulator

Simulation only. Made-up videos, a simple scoring rule you can see below — not a real recommendation engine.

Click a video below to "watch" it, and watch your feed adapt in real time.

Your interest score

Rises every time you watch that category. The feed above skews toward your highest bars.

Notice how fast this happens. It usually only takes three or four clicks before the feed visibly leans toward one or two categories. Real platforms have far more signals than a single click — watch time, rewatches, comments, shares, how fast you scrolled past something — but the core loop is exactly what you just did: your behavior becomes the training data for what you see next.


The Catch

Why this creates a feedback loop

Play the simulator above out over months instead of minutes, and you can see the problem. It works like this:

  • You interact with one kind of content.
  • The algorithm shows you more of that kind of content.
  • Because you're seeing more of it, you get more chances to interact with it.
  • Every interaction teaches the algorithm even more that this is "you."

That loop can keep narrowing what you see over time, into what's often called a filter bubble or echo chamber — a feed so tightly tuned to your early clicks that you stop seeing perspectives, topics, or kinds of content you never happened to click on in the first place. It's not that the algorithm is hiding things from you on purpose. It's that it's confidently, mechanically doing exactly what it was built to do: show you more of what you already engage with.

Connecting the dots: a feed that narrows because of a training feedback loop is a specific example of a bigger idea — that an AI system's behavior is only as balanced as the data (and the feedback) that shapes it. Our tutorial on AI Bias and Fairness goes deeper on how skewed data leads to skewed outcomes; a recommendation feedback loop is that same mechanism playing out one click at a time.


The Real Goal

What the algorithm is actually optimizing for

Here's the part worth knowing plainly: most recommendation algorithms on free, ad-supported apps are built to maximize engagement — time spent, clicks, watches, comments. That's the metric, because more engagement means more ads shown, which means more revenue for the platform. Engagement is not the same thing as "what's best for you," "most educational," or even "most true." A platform can be maximizing engagement perfectly while showing you content that wastes your time or gets facts wrong.

One fact worth filing away, without panicking about it: content that's emotionally intense, surprising, or dramatic tends to reliably grab attention — so it often gets recommended more, whether or not it's actually the most useful or accurate thing on the topic. That's not a conspiracy. It's just what happens when a system is optimized to maximize how long you stay and how often you react.

Media-literacy fact: if a video or post made you feel a strong emotional jolt, that's exactly the kind of content a feedback-loop-driven algorithm learns to serve more of — not necessarily because it's important, but because it works.


Take Control

Being an intentional feed user

None of this means you're powerless. Once you know the mechanism, you can push back on it:

Use "Not interested"

Deliberately clicking "Not interested" or hiding a video sends a real signal, the same way a "watch" does — just in the opposite direction.

Follow on purpose

Intentionally following a wider variety of creators and topics gives the algorithm more categories to draw from, which broadens what it recommends.

Clear your history

If the platform allows it, periodically clearing your watch or search history resets some of the signal it's been building about you.

Know the mechanism

Just knowing a feedback loop exists is a big step. It turns "the app just knows me" into "I can see why it's showing me this" — and that awareness is what lets you use a feed instead of it quietly using you.


Your Turn

Check your understanding

Two friends use the exact same app, but their feeds look completely different. Using the vocabulary from this tutorial — content-based filtering and collaborative filtering — explain why that happens.

Your answer:

Sample answer: each friend has clicked, watched, and liked different things, so content-based filtering shows each of them more of whatever categories and tags their own history contains. On top of that, collaborative filtering compares each friend to different groups of "taste twins" — other users whose behavior matches theirs — and those groups probably liked totally different things. Since both approaches are personalized to each person's individual data, two accounts on the same app can end up with almost no overlap in their feeds.


Check Yourself

Quick quiz

1. What's the key difference between content-based filtering and collaborative filtering?

2. What actually causes a "filter bubble" to form?

3. Most recommendation algorithms on free, ad-supported platforms are primarily built to maximize what?

Keep learning about responsible AI

Now that you can see how a feed learns from your own clicks, the next tutorial looks at a different question: as AI-written text gets more common, can AI actually tell the difference between something a human wrote and something a machine wrote?

Part of the "Responsible AI & Safety" tutorial series.