Gladly!
As mentioned in this post, the goal here is to just generate the angles for the positional encoding, not the encoding.
One property of the angles is that they are identical for each even and odd index pair (in that order and assuming 0 is even) i.e. for 16 indices starting with 0, (0, 1) have the same angle, (2, 3) have the same angle but different from all past angle values and so on till we reach (14, 15) pair.
We just calculate the angles for each even-odd indices by
angle = pos / (10000^(2*i / d))
where “pos” is changed with each position, “d” is kind of a constant and “i” needs only to change for different even-odd pairs and the same within the pair (think of what python integer operations could achieve this).
Also you need to get the correct value for “d” along with its correct data type (casting it if you need to).