My understanding is that MAX_LENGTH is used to initialize the size of the attention matrix. You make it as long as the longest sequence you have so that you have room to put any sequence in. So you have a max_len x max_len matrix, and if your input is less than that, it’ll simply have 0’s in the extra space, and it’ll get ignored. You need a hard number because it’s part of the architecture, kinda like how you use hard numbers in CNN’s. Does that help?