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.3.tar.gz (5.9 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.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for boostedprob-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2a6796be5d115f95fa4c11c15938797a75f886e23cb36ae3cea2901fe1cbeaac
MD5 8afa02142457756c3ad7f08b0800f028
BLAKE2b-256 f2536ef6cc682ef894f674446dec2586b03e8e66290cb876f8fbbd94fb7f4517

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for boostedprob-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 706b0ab83261b78c6322bf720afae26a6f9e79486b74902479b6925bb06c78c3
MD5 853a8a97a73908c40161c0b59170ea45
BLAKE2b-256 c83ff3cde088b92beefe765c583cd8fd169d979ff57bb4427ff97abbce23cf68

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