Understanding Transformers: A Step-by-Step Math Example ??? Part 1

I understand that the transformer architecture may seem scary, and you might have encountered various explanations on YouTube or in blogs. However, in my blog, I will make an effort to clarify it by providing a comprehensive numerical example. By doing so, I hope to simplify the understanding of the transformer architecture.

Shoutout to HeduAI for providing clear explanations that have helped clarify my own concepts!

Let’s get Started!

Inputs and Positional Encoding

Let’s solve the initial part where we will determine our inputs and calculate positional encoding for them.

Step 1 (Defining the data)

The initial step is to define our dataset (corpus).

In our dataset, there are 3 sentences (dialogues) taken from the Game of Thrones TV show. Although this dataset may seem small, its size actually helps us in finding the results using the upcoming mathematical equations.

Visit Now