incerto.llm.VarianceOfTokenProbs#

class incerto.llm.VarianceOfTokenProbs[source]#

Bases: object

Variance of token probabilities across the sequence.

Measures how consistent the model’s confidence is throughout the generation. Higher variance indicates varying uncertainty.

__init__()#

Methods

__init__()

compute(logits[, mask, dim])

Compute variance of max token probabilities.

static compute(logits, mask=None, dim=-1)[source]#

Compute variance of max token probabilities.

Parameters:
  • logits (Tensor) – Token logits of shape (batch, seq_len, vocab_size)

  • mask (Optional[Tensor]) – Optional mask for padding of shape (batch, seq_len)

  • dim (int) – Dimension to compute softmax over (default: -1)

Return type:

Tensor

Returns:

Variance of shape (batch,)