NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

How Do Transformers Align Tokens?

Hadi DaneshmandDiffCoALG @ NeurIPS 2025

Abstract

How can language models align words in translated sentences with different syntactic structures? Can they compute edit distances—or even sort arbitrary sequences? These tasks are examples of *assignment problems*. We prove a carefully engineered prompt enables a transformer to approximate the solution of assignment. This prompt induces attention layers to simulate gradient descent on the dual objective of assignment. We establish an **explicit approximation bound** that improves with transformer depth. A striking implication is that a single transformer can sort inputs of **arbitrary** length—proving a form of *out-of-distribution generalization*.
BibTeX
@inproceedings{daneshmand2025how,
  author = {Hadi Daneshmand},
  title = {{How Do Transformers Align Tokens?}},
  booktitle = {DiffCoALG @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=eulUHNBpmx},
}

Loading related content...

Figure