liveBook · Manning

Confidence

As explained in Hugging Face in Action

A confidence score is a numerical value expressing a model's estimated certainty in a prediction.

A confidence score expresses how strongly a model favors a prediction. Classification models expose class-specific values in logits, while object-detection models return scores for detected objects. section 3.2.3 section 4.2.1

Selecting a sentiment prediction

For the sentence “I loved the movie, it was fantastic!”, the model returns logits [-4.3428, 4.6955]. Applying torch.argmax selects class 1, producing the sentiment label “positive.” section 3.2.3

Confidence appears in several useful model outputs:

  • Classification logits contain one value for each class; the larger value indicates the favored class. section 3.2.3
  • Object detection returns a score for each detected object alongside its label and bounding box. section 4.2.1
  • A threshold can filter detections, such as retaining only predictions above 90 percent confidence. section 4.2.1
Figure 3.13 The confidence score for each class
A white square with black text

Description automatically generated

Use the class-score visualization to compare confidence values before selecting a prediction. section 3.2.3

How Hugging Face in Action covers it

How deep it goes
Explains class-logit shapes, score outputs, label selection, and threshold filtering without developing model internals.
Examples
Demonstrates sentiment logits and object-detection scores printed beside labels and drawn bounding boxes.
What it assumes
Uses token IDs, attention masks, and preprocessed image tensors as model inputs while demonstrating their preparation.
What you can do after
Apply it via PyTorch and Transformers to choose labels, filter detections, and report prediction scores.
How it connects
Connects confidence to logits, classification, object detection, labels, thresholds, and bounding boxes.

Also explained in

Compare how 13 books explain confidence →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hugging Face in Action. The section links point to the parts of the book it draws on.