I'm currently using the T5 model to solve a text classification task as text generation. Specifically, I'm using the T5ForConditionalGeneration model from the HuggingFace Transformers library.

What I'm wondering is, is there a way that we can use the concept of "confidence" for this kind of setting? I'm asking because some samples I'm using are either mislabeled or don't have enough information to effectively make a classification decision. I was hypothesizing that the model's "confidence" for such samples would be relatively lower, and we could use such a measure to prevent the model from making predictions on those samples or something.

I don't think that the concept of "confidence" would apply to text generation, but was wondering if there's any other way we could make such decisions. Thanks!

  • $\begingroup$ I'm not familiar with T5, but maybe you can get a measure of uncertainty for the prediction by using bootstrap? $\endgroup$
    – mariob6
    Oct 13, 2022 at 6:05
  • $\begingroup$ What do you mean by 'the concept of confidence'. You mean like the idea of a confidence interval? What sort of estimates are you making with a T5 model? $\endgroup$ Oct 13, 2022 at 13:40
  • $\begingroup$ For code, you can read: discuss.huggingface.co/t/… This code is based on huggingface/transformers $\endgroup$ May 24, 2023 at 8:42

2 Answers 2


I didn't know what T5 was so I started to ask the question to an online AI question and answer generator (akshara.ai). I asked them

"Does the concept of "confidence" apply to text generation tasks?"

And I got 9 answers. The first answer is positive

The concept of "confidence" can definitely be applied to text generation tasks. When generating text, it's important to have confidence in your choices - whether that means trusting your own judgement or relying on the suggestions of a tool. With enough practice, you'll get better at knowing when and how to use different sources of information to create text that sounds natural and believable.

It is however not conclusive. This is the second answer

There is some debate about whether the term "confidence" applies to tasks such as text generation. Some people argue that the term should only be used when there is a clear measure of accuracy, while others believe that the term can be used more broadly to refer to a feeling of assurance or self-assurance. In general, though, it seems that having confidence in one's ability to generate text can lead to better results.

I am not sure whether the AI completely understands that the question was about the statistical concept of confidence. So I started ask the question in a different way.

"Does the concept of "confidence intervals" apply to text generation tasks?"

And I got

confidence intervals are a way of estimating how likely it is that a given value falls within a given range. When applied to text generation tasks, this means that the algorithm can estimate how likely it is that any particular sentence or paragraph generated by the algorithm will be rated as "good" by human evaluators.

I believe that this makes some sense. It should be possible to have a text to text generator provide an additional estimate for the 'confidence', a value for how likely it is that the answer/estimate is right.

More specific in relation to intervals

In text generation tasks, we can think about the confidence interval as a range of likely outcomes for the text being generated.

In the case of text generation intervals might not be so useful but for a single text output one could imagine something as a probability being estimated/computed, that provides a probability that the text is a sufficient answer.


such a probability is more like a Bayesian credibility than a frequentist confidence.

In everyday language we might consider it as confidence but in statistics it has a more specific meaning. (In a same way as 'significance' has a more narrow meaning in statistics than in everyday language).

Confidence relates to parametric models and data created by it. It relates to a hypothesised parameter value and the potential data that can be generated with that parameter value. Confidence expresses the following probability: If the output/estimate is correct, how likely would it have generated the observed data?


The statistical concept of "confidence" arises in the context of confidence intervals, which arises when we want to estimate an unknown parameter in statistical analysis. This can certainly occur in a text classification task so long as there is some unknown parameter in your model that you want to make an inference about.

Several of the things you say in your question suggest that you are not thinking about the meaning of a confidence interval in the correct way. It is not a model or a sample that has a level of "confidence" --- the level of confidence is something that applies to a confidence interval for an inference about a parameter in the model. In order to proceed sensibly, you need to step back and first ask yourself: (1) what is the form of my model; (2) what are the unknown parameters in my model; (3) what is an appropriate method to form a confidence interval for one or more of the parameters of interest; (4) what level of confidence do I wish to set for the formation of a confidence interval I wish to produce.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.