Sentence Transformers packed position IDs wrong for RoBERTa models under flash attention

tomaarsen · x · 2026-07-23

Since v5.5.0, Sentence Transformers has packed text-only batches into a single sequence when flashattention2 is enabled.

The bug was that packed positionids restarted at 0 for each text, but RoBERTa-family models expect paddingidx + 1. That shifted every token's position embedding, causing silent quality degradation rather than a crash.

Related event: Flash Attention Causes Performance Drops in BGE-M3 and Other Models(2 posts)→

Original post →

More from Research

Research channel →