在使用输入平铺和 Flash Attention 2 时,掩码/张量形状不匹配

作者: marianrh-apa创建于 2026年9月24日更新于 2026年9月24日

你好, 自从升级了 Sentence Transformers 之后, 当尝试使用 CachedGISTEmbedLoss 和 Flash Attention 2 训练嵌入模型时, 我就收到了 `IndexError: The shape of the mask [32, 32] at index 0 does not match the shape of the indexed tensor [64, 2048] at index 0` 的错误。 我升级的版本 (在那个版本中一切仍然正常运行) 是 v5.3.0。

内容来源: huggingface/sentence-transformers