Hacker News
Understanding Positional Embeddings in Modern LLMs
programjames
|next
[-]
1. Rotary positional embeddings are representations of the translation group. The n-dimensional translation group ℝⁿ is abelian, so its irreducible representations are all one-dimensional ρ: ℝⁿ → ℂ, specified by a momentum vector m: ρₘ(x) = exp(i⟨m, x⟩). You can get a multi-dimensional representation by choosing several m, which are your learnable parameters.
2. If you wanted RoPE embeddings to also preserve rotation (perhaps you have scenes viewed at arbitrary angles), you are looking for representations of the special Euclidean group. The irreducible representations in four dimensions are your familiar particles: electrons, protons, etc., and in general are parameterized by a momentum vector and a discrete spin vector. You would have to do some kind of annealing process to train the spin vector (or you could just make it constant).
3. If you want to do attention on quadtrees, well, what is the group? Suppose every node in the quadtree has local coordinates scaled to [0, 1]. Moving up/down/to a neighbor in the quadtree requires an affine transformation of the local coordinates, which compose, so we can label every node by its affine transformation to the root (x, d): y → x + 2⁻ᵈy, where x is the node's translation in the image and d is its depth in the tree. The finite-dimensional irreducible representations are parameterized by momentum vectors m as well as a modulus M and basis vectors {e₁, e₂, ..., eₖ} where k = ord₂(M) and look like ρₘ,ₑ(x, d) = DPᵈ where D is the diagonal matrix with entries Dⱼⱼ = exp(2πi⟨2ʲm, x⟩ / M) and P permutes the basis vectors.
nlitened
|root
|parent
|next
[-]
From what I usually see, ML researches just throw everything at the wall and see what sticks. Whatever approach turns out to work better, gets used more often, and sometimes theoretical background is developed for why it works. RoPE works not because it’s good math, just it turned out to work better than some other equally arbitrary approaches at some point, and then other approaches have also been developed that work better than RoPE.
Mabusto
|root
|parent
|next
[-]
programjames
|root
|parent
[-]
A few ML researchers do actually have a lot of this theoretical knowledge. You can see this in papers like Variational Diffusion Models, Continuous Normalizing Flows, <?> Delta Attention. These papers are usually also better written, because the authors understand why things work so they can deprioritize irrelevant details.
nsagent
|root
|parent
[-]
https://youtube.com/watch?v=x7psGHgatGM
I presume your comment is in reference to this speech, as he famously states: "Machine Learning has become alchemy" in it. For anyone who has some time and hasn't watched it, I'd highly recommend it.
fc417fc802
|root
|parent
|next
|previous
[-]
esafak
|root
|parent
|next
|previous
[-]
mathisfun123
|root
|parent
|previous
[-]
It's always like this because people can't admit ML is just spray and pray. So they superimpose theory.
programjames
|root
|parent
[-]
ankkalinna
|root
|parent
|next
|previous
[-]
LudwigNagasena
|root
|parent
|next
|previous
[-]
tsimionescu
|root
|parent
|next
|previous
[-]
Can you explain more what you mean here? What do electrons (elementary particles) have to do with protons (complex composite particles) and with general principles of four-dimensional spatial transformation? The electrical force is not a direct consequence of space-time geometry, and even less so the specific particles we happen to find in our universe.
programjames
|root
|parent
[-]
tsimionescu
|root
|parent
[-]
Plus, calling the particles that you get out of such a theory "the electron" or "the quark" is profoundly misleading. If you only start with a space-time related symmetry, you don't get "electrons", you maybe get particles with the spin and mass of an electron. But it doesn't have charge, nor color nor weak hypercharge. It doesn't decay and doesn't absorb photons nor do anything else that an electron does - it's not an electron. You need to combine this with a lot more symmetry groups to start getting the actual particles, and even then you still need to add the experimentally discovered values to match physics - the math allows for infinite numbers of various particles with properties similar to the ones our universe actually contains.
I'd also note that apparently the Euclidean group doesn't have anything to do with particles anyway, it's the Poincarre group whose irreducible symmetries lead to the (mass, spin) description of particles.
programjames
|root
|parent
[-]
tsimionescu
|root
|parent
[-]
augment_me
|root
|parent
|next
|previous
[-]
However would be good to add that the solution can be structural(like in NoPE), then you dont need explicit representations and it just falls out of your architecture.
programjames
|root
|parent
[-]
Also, I expect the target audience of the blog is ML researchers, since he goes into some of the math, and umm... the kind of ML researcher that is not at least aware of the basics of abstract algebra is closer to an alchemist than a researcher.
empiricus
|root
|parent
|next
|previous
[-]
fractorial
|root
|parent
|next
|previous
[-]
mathisfun123
|root
|parent
|previous
[-]
programjames
|root
|parent
[-]
The reason you want to know the general theory behind positional embeddings is it lets you work with other kinds of relative positions. For example, quad/octtrees are useful for faster attention on large images/videos, or a Gaussian splat might want 3D translation + rotation invariance.
I believe you can also go further and start adding in gauge groups and whatnot, but I just thought about that off the top of my head.