incerto.llm.SequenceLengthCalibration#

class incerto.llm.SequenceLengthCalibration(alpha=0.6)[source]#

Bases: object

Calibrate for length bias in sequence probabilities.

Longer sequences tend to have lower probabilities. This adjusts for that bias using length normalization.

Parameters:

alpha (float)

__init__(alpha=0.6)[source]#
Parameters:

alpha (float) – Length penalty factor (common range: 0.5-1.0)

Methods

__init__([alpha])

calibrate(seq_log_prob, seq_length)

Apply length normalization.

__init__(alpha=0.6)[source]#
Parameters:

alpha (float) – Length penalty factor (common range: 0.5-1.0)

calibrate(seq_log_prob, seq_length)[source]#

Apply length normalization.

Parameters:
  • seq_log_prob (Tensor) – Log probability of sequence (batch,)

  • seq_length (Tensor) – Length of sequence (batch,)

Return type:

Tensor

Returns:

Length-normalized scores