Implement sequence packing with a block-diagonal attention mask so packed samples can't at

SFT, Instruction Tuning & PEFT3 / 6

Chapter 113 / 6

SFT, Instruction Tuning & PEFT

Implement sequence packing with a block-diagonal attention mask so packed samples can't at

Hard

Implement sequence packing with a block-diagonal attention mask so packed samples can't attend across boundaries.

Target interface
pack(samples, max_len, pad_id=0)

Implement the function/class skeleton in the editor. Any correct approach is accepted.

Hints0 / 2
Reference solution
Your own code stays in the editor.