On the theoretic analyses on transforms, they mainly focus on the computability analysis, such the Turing-completeness of unbounded precision transformers, the advantage of parallelizability of unbounded precision transformers and the limitations of bounded precision transformers. This paper give transformers an algebra for reasoning, which relies heavily on the functional decomposition results of transformers. This algebra uses functional decompositions as atomic actions, includes sequential composition and parallel composition, recursion for feedback and abstraction for hidden layers. As we know, it is the first attempt to model transformers logically and can be used to verify the correctness of transformer based applications.
Figures & tables
Names
Functions
Types
α1
word embedding
Σ→Rd
α2
position embedding
N→Rd
α3
identity
Rd→Rd
α4
min/max
R2→R
α5
add/subtract
R2→R
α6
multiply by c
R→R
Table 1: Decomposition of Transformers
No.
Axioms
A1
x+y=y+x
A2
(x+y)+z=x+(y+z)
A3
x+x=x
A4
(x+y)∘z=x∘z+y∘z
A5
(x∘y)∘z=x∘(y∘z)
A6
x+0=x
Table 2: Axioms of BAT
No.
Rewriting rules
RA3
x+x→x
RA4
(x+y)∘z→x∘z+y∘z
RA5
(x∘y)∘z→x∘(y∘z)
RA6
x+0→x
RA7
0∘x→0
RA8
I∘x→x
Table 3: Rewriting rules of BAT
⟨I,s⟩→⟨√,s⟩
Table 4: Transition rules of BAT
x⊕y{∣α,α′∣}√xα√yα′√x⊕y{∣α,α′∣}x′xαx′yα′√
Table 5: Transition rules of APT
No.
Axioms
P1
α⊕(α′∘y)=(α⊕α′)∘y
P2
(α∘x)⊕α′=(α⊕α′)∘x
P3
(α∘x)⊕(α′∘y)=(α⊕α′)∘(x⊕y)
P4
(x+y)⊕z=(x⊕z)+(y⊕z)
P5
x⊕(y+z)=(x⊕y)+(x⊕z)
P6
0⊕x=0
Table 6: Axioms of APT
No.
Rewriting rules
RP1
α⊕(α′∘y)→(α⊕α′)∘y
RP2
(α∘x)⊕α′→(α⊕α′)∘x
RP3
(α∘x)⊕(α′∘y)→(α⊕α′)∘(x⊕y)
RP4
(x+y)⊕z→(x⊕z)+(y⊕z)
RP5
x⊕(y+z)→(x⊕y)+(x⊕z)
RP6
0⊕x→0
Table 7: Rewriting rules of APT
⟨Xi∣E⟩U√ti(⟨X1∣E⟩,⋯,⟨Xn∣E⟩)U√
Table 8: Transition rules of guarded recursion
No.
Axioms
RDP
⟨Xi∣E⟩=ti(⟨X1∣E⟩,⋯,⟨Xn∣E⟩)(i∈{1,⋯,n})
RSP
if yi=ti(y1,⋯,yn) for i∈{1,⋯,n} , then yi=⟨Xi∣E⟩(i∈{1,⋯,n})
end of Recursive definition and specification principle
Table 9: Recursive definition and specification principle