Experimental alpha. Expect breaking changes and major bugs. Your
feedback is much appreciated.
Head Splitter

Cuts each vector into H equal parts and gives the heads a dimension of their own, so the machines after it work on every head at once.

Shapes
[B×T×C] in, [B×H×T×(C/H)] out.
Settings
- Heads: 1, 2, 4 or 8. 4 by default.
Parameters
None.
In PyTorch
def split_heads(x, heads):B, T, C = x.shapereturn x.view(B, T, heads, C // heads).transpose(1, 2)
Notes
With a Head Splitter and a Head Merger you can build multi-head attention from parts: split the queries, keys and values the same way, and the Matrix Multipliers, Scaler, Causal Mask and Softmax all work on every head in parallel.
Making it
The Fabricator makes it with no mask. See The Bench and the Fabricator.

Residual