Skip to main content

build_segment_isolated_attention_mask

Function build_segment_isolated_attention_mask 

Source
pub fn build_segment_isolated_attention_mask(
    segments: &[SegmentType],
    config: &AttentionIsolationConfig,
) -> Vec<Vec<f32>>
Expand description

系列長 $L$ のセグメント割り当てに基づいて 2 次元のアテンションマスク $(L, L)$ を生成する。

行 $i$ (Query) から列 $j$ (Key) へのアテンション重みを決定する。

§引数

  • segments: 各トークン位置のセグメント種別スライス。
  • config: アテンション分離設定。

§戻り値

サイズ $(L, L)$ のフラット化されたベクトルまたは 2 次元ベクトル。