Skip to main content

Utilities to identify dominant tokens and compute boosted model probabilities for Quality Estimation.

Project description

BoostedProb

Implementation of Boosted Model Probability (BoostedProb) for Quality Estimation introduced in the paper: Are Generative Models Underconfident? Better Quality Estimation with Boosted Model Probability (EMNLP 2025 Main).

We provide 2 functions:

  • find_dominant(log_probs)
    Identifies the indices of tokens that have dominant probability values within each distribution.
  • calculate_boostedprob(log_probs, target)
    Computes the BoostedProb for each output token ID specified in target:
    • If the token is dominant: returns the sum of probabilities of all dominant tokens
    • If the token is not dominant: returns the probability of that token itself.

Toy example:

import torch
import boostedprob

log_probs = torch.log(torch.tensor([
    [0.5, 0.4, 0.05, 0.05],
    [0.5, 0.4, 0.05, 0.05],
]))  # shape [nr_tokens, vocab_size]

target = torch.tensor([2, 1])  # shape [nr_tokens, 1]

# Find dominant tokens
print(boostedprob.find_dominant(log_probs))
# Output
# tensor([[ 0,  1, -1, -1],  tokens at position 0 and 1 are dominant
#         [ 0,  1, -1, -1]])   tokens at position 0 and 1 are dominant
# -1 are dummy values to be ignored.

# Calculate boosted prob (find_dominant() runs internally)
print(boostedprob.calculate_boostedprob(log_probs, target))   # shape [nr_tokens, 1]
# Output
# tensor([0.0500, 0.9000])

Install

From PyPI (recommended):

pip install boostedprob

From GitHub (latest development version):

pip install "git+https://github.com/TuAnh23/boostedprob.git"

Or install locally in editable mode:

git clone https://github.com/TuAnh23/boostedprob.git
cd boostedprob
pip install -e .

Examples

See the examples/ folder for integration with Hugging Face models.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boostedprob-0.1.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boostedprob-0.1.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file boostedprob-0.1.2.tar.gz.

File metadata

  • Download URL: boostedprob-0.1.2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for boostedprob-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7d49ade97c70d13e5e8c9f2395397915e6df278073da2d6b68c47a5395171837
MD5 e467ad9cb86183e7c56bff509d6fe8d0
BLAKE2b-256 7dc5cd73b6d326ef758d84263bdf2ec23dfe7ad4678df1c0f108d26dbbe46a1c

See more details on using hashes here.

File details

Details for the file boostedprob-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: boostedprob-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for boostedprob-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d001f1464743f32ea29f747e6560f68103f0f234874c61269dce3896b0eb7ca4
MD5 651af4b6b27040b10001a01c543ba98f
BLAKE2b-256 694b32543f5bdfa27e3a04ebc2a4835d565f0922a0f63fb5503f5817923d61ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page