How TikTok’s Algorithm Works: The Math Explained

Quick answer: TikTok’s recommendation algorithm predicts which videos you are most likely to enjoy from signals such as watch time, skips, likes, shares and video topics. Recommendation systems use vectors, probability models and collaborative filtering to find patterns and rank content. In a simple model, a video’s score is the dot product of your taste vector and the video’s vector. Real platforms use far larger machine-learning systems that learn from billions of interactions, test new content through exploration, and keep their exact ranking formulas private.

Facts checked November 22, 2026.

Open TikTok, YouTube or Netflix and the first thing you see was chosen for you by an algorithm, out of millions of options, in a fraction of a second. It can feel like mind reading. It is mostly linear algebra and probability: the same vectors and dot products you meet in a math class, applied at enormous scale. Here is how it works, with small examples you can compute.

Step 1: Turn Tastes Into Vectors

Imagine describing each video by two numbers: how much it is about math and how much it is about cooking. Your viewing history gives you a taste vector in the same two dimensions. Say you watch mostly math:

\[ \vec{u} = (4, 1). \]

Three candidate videos:

VideoVector (math, cooking)Dot product with \(\vec{u}\)Cosine similarity
A: Proof puzzle(5, 0)\(4 \cdot 5 + 1 \cdot 0 = 20\)0.97
B: Pasta recipe(1, 4)\(4 \cdot 1 + 1 \cdot 4 = 8\)0.47
C: Kitchen math(3, 3)\(4 \cdot 3 + 1 \cdot 3 = 15\)0.86

The dot product multiplies matching entries and adds. A bigger score means a better match, so the ranking is A, then C, then B. The score is a match strength, not a probability: 20 does not mean a 20% chance. Cosine similarity divides by the vectors’ lengths to compare direction only:

\[ \cos\theta = \frac{\vec{u} \cdot \vec{v}}{\|\vec{u}\|\,\|\vec{v}\|}: \quad \text{A: } \frac{20}{\sqrt{17} \cdot 5} \approx 0.970, \quad \text{B: } \frac{8}{\sqrt{17} \cdot \sqrt{17}} \approx 0.471, \quad \text{C: } \frac{15}{\sqrt{17} \cdot \sqrt{18}} \approx 0.857. \]

Real systems use vectors with hundreds of dimensions, and nobody labels them “math” or “cooking”; the dimensions are learned, just like word embeddings.

Step 2: Learn the Vectors From Everyone (Collaborative Filtering)

Where do the vectors come from? Collaborative filtering uses the behavior of millions of users: if people who liked what you liked also liked something new, you will probably like it too. Picture a giant table with a row for every user, a column for every movie and a rating in each cell you have filled in. Most cells are empty. Matrix factorization approximates the table as a product of two thin matrices:

\[ R \approx U V^{T}, \]

where each row of \(U\) is a user vector and each row of \(V\) is a movie vector. A predicted rating is a dot product. If your vector is \((2, 1)\) and a movie’s is \((1, 3)\), the prediction is \(2 \cdot 1 + 1 \cdot 3 = 5\). Training adjusts all the vectors, using gradient descent, until predictions match the known ratings as closely as possible. This is the same matrix multiplication that powers AI (see why AI runs on matrix multiplication).

Collaborative Filtering vs Content-Based Recommendations

MethodUsesExample
Content-based filteringThe item’s own features: topics, sounds, captionsYou watched an algebra video, so here is another algebra video
Collaborative filteringBehavior of users with similar tastesPeople who enjoyed video A also enjoyed video B
HybridBothMost large platforms combine topics with viewing patterns

Worked example: Alex and Sam both enjoyed videos A and B. Sam also enjoyed video C. A collaborative-filtering model may recommend C to Alex because their viewing patterns overlap. Two cautions: a missing rating is not a zero (Alex may simply never have seen C), and most platforms learn from implicit feedback, such as watches, skips and replays, rather than star ratings.

The Netflix Prize: A Million-Dollar Math Contest

From 2006 to 2009, Netflix offered 1 million dollars to anyone who could predict ratings 10% more accurately than its own system, measured by root-mean-square error. On September 21, 2009, the prize went to the team BellKor’s Pragmatic Chaos, with a 10.06% improvement (an error, RMSE, of about 0.8567). Matrix factorization was one of the central ideas behind the leading entries, and the contest made it a standard tool across the industry.

Step 3: Predict What You Will Do

Modern platforms do not just predict ratings; they predict actions. A ranking model estimates probabilities such as

  • the chance you watch a video to the end,
  • the chance you like, share or comment,
  • the chance you skip in the first second.

It combines them into one score. Here is a hypothetical teaching example, not any platform’s real formula: score \(= 0.6 \times P(\text{watch to end}) + 0.3 \times P(\text{like}) + 0.1 \times P(\text{share})\). If those probabilities are 0.8, 0.4 and 0.1:

\[ 0.6(0.8) + 0.3(0.4) + 0.1(0.1) = 0.48 + 0.12 + 0.01 = 0.61. \]

The video with the highest score goes first. Another common target is expected watch time, roughly \(P(\text{click}) \times \text{expected minutes watched}\). A 2016 Google paper on YouTube’s deep learning recommender described a two-stage design (the published 2016 architecture, not necessarily today’s system): a fast candidate generation step narrows millions of videos to a few hundred, then a ranking model, trained to predict expected watch time, orders them. For a refresher on combining probabilities, see the probability behind AI.

How TikTok’s For You Feed Learns So Fast

TikTok has said its For You feed is driven by user interactions (videos you like, share, comment on or watch fully), video information (sounds, hashtags, captions) and, with less weight, device and account settings. Its speed comes from real-time learning: ByteDance’s 2022 Monolith paper describes a system that updates its model within minutes of new user actions, rather than retraining once a day. Every swipe is a data point, and a short video produces many data points per minute. The paper shows ByteDance’s technology; TikTok has not said its feed uses exactly this system.

What about a brand-new account with no history? That is the cold-start problem. TikTok may start from interests you select and broadly popular videos, then update quickly from your first reactions. You can also steer it: long-press a video and tap “Not interested,” or use “Why this video” to see some of the reasons a video was shown.

Step 4: Explore vs Exploit

If the algorithm only showed what it already knows you like, it would never learn your new interests, and new creators would never get seen. So recommenders reserve a slice of the feed for exploration: content outside your usual pattern. This is the multi-armed bandit problem from reinforcement learning. A simple hypothetical version shows the best-scoring video 90% of the time and something new 10% of the time (no platform publishes its exact split); smarter methods explore more when they are uncertain.

This is also why a brand-new account’s feed changes so quickly: with little data, uncertainty is high, so the system explores and learns from each reaction.

The Downside: Feedback Loops

Recommendation math optimizes the target it is given. If the target is watch time, the system learns to show whatever keeps people watching, which is not always what is best for them. Feedback loops can narrow what you see, sometimes called a filter bubble, because you can only react to what you are shown. Platforms counter this with diversity rules, and some regulations, such as the European Union’s Digital Services Act, require very large platforms to offer at least one recommendation option not based on profiling (Article 38).

Common Misconceptions

“The app listens to your conversations.” There is no need: viewing behavior alone gives a strong signal, and the math above explains how.

“The algorithm understands your personality.” It finds patterns in numbers. A dot product has no idea what “math” or “cooking” mean.

“Going viral is random.” There is randomness from exploration, but videos that hold attention earn more exposure in later rounds of testing.

Watch: How Recommendation Algorithms Work

If you learn better by watching, these videos are worth your time.

How does Netflix recommend movies? Matrix Factorization (Luis Serrano Academy). A friendly, visual walkthrough of matrix factorization with small numbers.
The Math Behind Recommender Systems (Art of the Problem). How taste vectors and similarity scores drive recommendations.
How TikTok’s Algorithm Figures You Out | WSJ (The Wall Street Journal). A 2021 investigation using test accounts to see how fast the feed adapts.

Check Your Understanding

Five quick questions to see how much of this has stuck. Pick an answer and press Submit; you will see a short explanation either way.

Answer each question and press Submit to see your result right away.

1. What is the dot product of (4, 1) and (1, 4)?
Found a bug? Let us know!
2. Which video best matches the taste vector (4, 1)?
Found a bug? Let us know!
3. A user vector is (2, 1) and a movie vector is (1, 3). What rating is predicted?
Found a bug? Let us know!
4. A teaching formula scores 0.6 × 0.8 + 0.3 × 0.4 + 0.1 × 0.1. What is the score?
Found a bug? Let us know!
5. Why do recommenders show some content outside your usual interests?
Found a bug? Let us know!

Frequently Asked Questions

How do recommendation algorithms work?

They represent users and items as vectors of numbers, score matches with dot products, learn the vectors from many users’ behavior (collaborative filtering), predict actions such as watch time, and mix in some exploration.

What math is used in recommendation systems?

Linear algebra (vectors, dot products, matrix factorization), probability for predicting clicks and watch time, optimization such as gradient descent, and bandit methods for exploration.

How does the TikTok algorithm work?

TikTok says its For You feed weighs user interactions most, then video information such as sounds and hashtags, and device settings least. ByteDance’s Monolith system updates its model in near real time from new interactions.

What is the cold-start problem?

Recommending well for a new user or new video with no history. Platforms use selected interests, popular content and fast learning from the first interactions.

What is collaborative filtering?

A method that recommends items liked by people with similar tastes. Matrix factorization, which approximates the user-item ratings table as a product of two smaller matrices, is a common way to do it.

What was the Netflix Prize?

A 2006–2009 competition offering 1 million dollars for a 10% improvement in Netflix’s rating predictions. BellKor’s Pragmatic Chaos won in September 2009 with 10.06%.

Why does my feed show things I never searched for?

Recommenders deliberately explore content outside your usual pattern so they can discover new interests and test new videos.

Keep Exploring

Sources and Further Reading

Related to This Article

What people say about "How TikTok’s Algorithm Works: The Math Explained - Effortless Math"?

No one replied yet.

Leave a Reply