Una mujer sonriente posa para una fotografía mientras alguien la está grabando con un teléfono móvil.

TikTok, Artificial Intelligence and Mathematical Probability

  • 13 May 2025
  • 6 minutos
  • Blog

TikTok is known for its hyper-personalised recommendation algorithm, capable of engaging millions of users. But beyond the viral dances and challenges, this platform hides a complex web of mathematics and artificial intelligence. Behind each suggested video, and also behind the security of the content that is published, there are mathematical models making decisions: what kind of scene is shown, does it break any rules, which viewers might be interested in it?

To do this, the most popular social network in recent years uses an Artificial Intelligence system that reviews millions of videos a day in real time, with the aim of making each user's wall a safe space, in which the content shown does not violate the rules of the community.

In this sense, mathematical foundations such as probability, statistics and linear algebra are key when it comes to automatically classifying video content, improving moderation within the platform and making automated decisions about what is shown, what is restricted and how the experience adapts to the user. Some of the processes that these algorithms carry out are as follows:

  • Scene recognition: they automatically identify what appears in a video (e.g., they determine whether a clip shows a beach, a familiar face, a pet, etc.).
  • Image classification: they then tag or categorise the frames of a video according to its visual content (e.g. whether it contains on-screen text, whether it is an animation or real video, the genre of activity it shows, etc.).
  • Automatic video moderation: at the same time, they detect inappropriate content (violence, nudity, hate speech, etc.) to block it or flag it for human review before it is massively disseminated.

Computer vision: understanding video content

In order to be able to recommend relevant videos or moderate them effectively, the first step is to know what is in each video that is uploaded to the platform (a recent study suggests that up to 117 million videos may be posted every day).

TikTok achieves this through computer vision techniques (a field of AI focused on image and video analysis). In essence, its algorithms examine the frames of a video and recognise visual patterns in them. These vision models are developed from deep neural networks trained on huge amounts of pre-labelled data, allowing  it to detect which objects and people are shown in a scene (for example, recognising a football or a familiar face), as well as identifying different actions (someone dancing is not the same as someone cooking) or the text overlaid on the video.

TikTok's algorithm goes so far that it can even infer the  predominantemotion in people' s facial expressions, which helps to contextualise the content. All this information is then used to classify and tag each post.

But TikTok does not only analyse the visual part: audio is also analysed with AI. To do this, natural language processing (NLP) algorithms transcribe and "understand" the audio of the videos (whether spoken dialogue or song lyrics), identifying keywords or the topic of the conversation. This complements the description of the content. Together with the metadata provided by the user (such as the title, description or hashtags), the algorithm builds a detailed profile of each piece. In this way, the platform "knows" to a large extent what a video is showing

Automatic moderation: AI as the guardian of the rules

The use of these intelligent algorithms greatly facilitates the moderation of content by humans, who are not forced to manually review millions of videos.

As we have seen, thanks to these computer vision and NLP capabilities, the system is able to detect any kind of explicit material, violence, dangerous behaviour or consumption of banned substances in the videos uploaded to the platform. At the same time, by "listening" to the audio, it can also detect in real time possible hate speech, harassment or other offensive expressions.

Moreover, the system goes further by reviewing subtitles, hashtags and text embedded in the video and even the metadata of the post itself, analysing suspicious patterns (for example, if an account uploads a large number of videos in a row, it may indicate an attempt at SPAM).

After this analysis, the AI estimates the likelihood that the video violates community standards and assigns it a risk level. If the detected risk is high, the content is immediately reported to human moderators, who are responsible for a second, more detailed review. In general, a video that has a high likelihood of showing violence or nudity will be sent for human review , while very low-risk content will remain on the platform without going through the moderation team. These detection models are constantly reinforced, so TikTok's algorithm is retrained with new data to adapt to both the latest trends and possible strategies employed by some users trying to circumvent these automatic filters.

A mathematical basis

But as mentioned earlier, to get this far, TikTok needs a solid mathematical foundation. First of all, linear algebra is essential for processing images and videos, since they are represented as numerical matrices. Neural networks perform complex mathematical operations (such as matrix multiplications) to extract relevant visual patterns, such as edges or shapes. These filters act as detectors that allow the system to identify objects and scenes in the content uploaded by users.

In addition, probability also plays an essential role in its AI models. Since predictions are not absolute certainties, the systems work with probabilistic estimates. For example, instead of asserting that a video contains a dog, they assign a probability to that hypothesis. This approach allows for more accurate moderation, as the system only acts if the content exceeds certain risk thresholds, such as being potentially harmful or inappropriate.

Finally, statistics and machine learning form the core of the training process. TikTok trains its algorithms by analysing millions of previously classified videos to find relationships between input signals (such as pixels or audio) and associated tags. Through mathematical optimisation techniques, the models adjust their parameters to minimise errors and improve their generalisability, making the platform increasingly effective in classifying and moderating content on a global scale.

For future students and technology enthusiasts, it can be really interesting to discover that the same tools they learn in the classroom are the ones that make the magic of applications like TikTok possible. Understanding how this mathematical gear works not only gives an appreciation of the engineering behind our favourite social networks, but also opens the door to innovating and building new smart systems. 

Read more about

5 reasons why you should study mathematics for software engineering.

What do I need to study mathematics?

The perfect tandem for your future: mathematics and software engineering.

Related Insights

Un joven sonriente se encuentra de pie en una sala de reuniones con paneles de vidrio.

UDIT alumnus develops AI tool to boost business cooperation

6 October 2025

One of the great challenges in today's technological ecosystems is to identify opportunities for collaboration between agents with different profiles. This need was the starting point for the Master's thesis of Yannick José Medina, a student of the Master's in Artificial Intelligence at UDIT, who developed an innovative solution for Secpho, a cluster of companies specialising in DeepTech. His proposal: a conversational recommendation system based on artificial intelligence that facilitates and speeds up the connection between partners.

Una jirafa camina por un paisaje natural.

More than ChatGPT: four projects unleashing the full power of Artificial Intelligence

8 September 2025

This article presents four projects that show how AI is already changing the way we live, care for ourselves and protect the planet. We talk about Google's revolutionary meteorological model capable of anticipating hurricanes with greater precision than official systems; GIRAFFE, a computer vision tool developed by Microsoft to save giraffes from extinction; the medical software implemented at the Clínica Universidad de Navarra, which improves the diagnosis of breast cancer; and a predictive system by Renfe that allows it to prevent graffiti on its trains in advance and efficiently.