Blogs / Why Padding Is the Usual Way and Packing the Alternative

Why Padding Is the Usual Way and Packing the Alternative

What a Hugging Face post says padding input sequences in mini-batches is and what packing examples without padding is.

  • Learning
  • 1 min read

For: Learners who know what a training batch is.

What padding is

Padding input sequences in mini-batches is a usual method to collate inputs during training.[1]

What packing is

Packing examples without padding, and using the token position information, is a more efficient alternative.[1]

Padding inputsequences inmini-batchesa usual method to collateinputs during trainingPacking exampleswithout paddingusing the token positioninformationA more efficientalternativeas the post puts italternative:is
How do the two ways differ?

Sources

  1. Packing with Flash Attention 2 (huggingface.co · checked )

More articles