AttentionExplanation<T>

Models & Types · AiDotNet.Interpretability.Explainers

Represents the result of an Attention Visualization analysis.

Constructors

Constructor Summary
AttentionExplanation()

Properties

Property Summary
List<Matrix<T>> AverageAttentionPerLayer { get; set; } Gets or sets average attention per layer (across heads) [layer][query, key].
List<Tensor<T>> LayerAttention { get; set; } Gets or sets attention weights for each layer [layer][head, query, key].
Matrix<T> AttentionRollout { get; set; } Gets or sets the attention rollout matrix [query, key].
T[] TokenImportance { get; set; } Gets or sets the overall token importance (derived from rollout).
int NumHeads { get; set; } Gets or sets the number of attention heads.
int NumLayers { get; set; } Gets or sets the number of layers.
int SequenceLength { get; set; } Gets or sets the sequence length.
string[] TokenLabels { get; set; } Gets or sets labels for tokens/positions.

Methods

Method Summary
List<ValueTuple<int, string, T>> GetSortedTokenImportance() Gets tokens sorted by importance.
string ToString() Returns a human-readable summary.