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

Instruction Tuning & Efficient Fine-Tuning3 / 6

Chapter 113 / 6

Instruction Tuning & Efficient Fine-Tuning

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)

Complete the starter code in the editor. Any correct approach is accepted.

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