Head Merger

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

Head Merger

Joins the heads back into one vector per position: the reverse of the Head Splitter.

Shapes

[B×H×T×d] in, [B×T×(H·d)] out.

Parameters

None.

In PyTorch

def merge_heads(x):
B, H, T, D = x.shape
return x.transpose(1, 2).reshape(B, T, H * D)

Notes

Follow it with a Linear Layer to mix what the heads found: that is the output projection, W_O.

Making it

The Fabricator makes it with no mask. See The Bench and the Fabricator.