I think this blog post in particular might be helpful here https://sebastianraschka.com/blog/2023/self-attention-from-s...