emmi.modules.attention.anchor_attention.self_anchor_attention

Classes

SelfAnchorAttention

Anchor attention within branches: each configured branch attends to its own anchors independently.

Module Contents

class emmi.modules.attention.anchor_attention.self_anchor_attention.SelfAnchorAttention(config)

Bases: emmi.modules.attention.anchor_attention.multi_branch_anchor_attention.MultiBranchAnchorAttention

Anchor attention within branches: each configured branch attends to its own anchors independently.

For a list of branches (e.g., A, B, C), this creates a pattern where A tokens attend to A_anchors, B tokens attend to B_anchors, and C tokens attend to C_anchors. It requires all configured branches and their anchors to be present in the input.

Example: surface tokens attend to surface_anchors and volume tokens attend to volume_anchors. This is achieved via the following attention patterns:

AttentionPattern(query_tokens=[“surface_anchors”, “surface_queries”], key_value_tokens=[“surface_anchors”]) AttentionPattern(query_tokens=[“volume_anchors”, “volume_queries”], key_value_tokens=[“volume_anchors”])

Parameters:
  • dim – Model dimension.

  • num_heads – Number of attention heads.

  • use_rope – Whether to use rotary position embeddings.

  • bias – Whether to use bias in the linear projections.

  • init_weights – Weight initialization method.

  • branches – A sequence of all participating branch names.

  • anchor_suffix – Suffix identifying anchor tokens.

  • config (emmi.schemas.modules.attention.AttentionConfig)

Initialize internal Module state, shared by both nn.Module and ScriptModule.