Skip to main content

models.TokenAttention

Attention from [CLS] to each feature token in the last block, per

Usage

Source

models.TokenAttention()

row and head, from AttentionCannFit.attention.

Attributes

Name Description
heads Number of heads.
rows Number of rows.
tokens Feature tokens, in column order.

heads

Number of heads.

heads: int


rows

Number of rows.

rows: int


tokens

Feature tokens, in column order.

tokens: list[str]

Methods

Name Description
get() Weight of token token (an index into tokens) for row
mean() Mean weight per token over the rows and heads, or over rows

get()

Weight of token token (an index into tokens) for row

Usage

Source

get(row, head, token)

and head. Per row and head the weights over the feature tokens and [CLS] itself sum to 1.


mean()

Mean weight per token over the rows and heads, or over rows

Usage

Source

mean(rows=None)

only: what the model attends to in a segment.

Parameters
rows: list of int = None
Returns
list of float