Theory of sequence-to-sequence models