# T5 for a multi-classification task with returning probabilities \[0,1\]

**URL:** <https://discuss.huggingface.co/t/t5-for-a-multi-classification-task-with-returning-probabilities-0-1/104835>\
**Category:** 🤗Transformers\
**Created:** [September 1, 2024, 1:23pm UTC](https://discuss.huggingface.co/t/t5-for-a-multi-classification-task-with-returning-probabilities-0-1/104835 "2024-09-01T13:23:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pizzadyali](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@pizzadyali](https://discuss.huggingface.co/u/pizzadyali)\
**Post date:** [September 1, 2024, 1:23pm UTC](https://discuss.huggingface.co/t/t5-for-a-multi-classification-task-with-returning-probabilities-0-1/104835/1 "2024-09-01T13:23:14Z")

</div>

So I have this task to fine tune CodeT5 using a large dataset for translating a given natural language command to a cmd of my command system. I am using `beam_search = 3` as I want to have three output cmds, but I also want to return the probability associated with each output, I intend to set that beam score to exponential, but I expect the first positional output to be the one with the highest probability. How to approach this? Should I average in someway the token logits returned? I intend to use the function `compute_transition_scores`.

Basically I want something like this:

```auto
output_ids = model.generate( #max_new_tokens=5
            input_ids = ids,
            attention_mask = mask,
            max_length=200,
            num_beams=3,
            repetition_penalty=2.5,
            length_penalty=1.0,
            early_stopping=False,
            output_scores=True,
            return_dict_in_generate=True,
            )
        transition_scores = model.compute_transition_scores(output_ids.sequences, output_ids.scores, normalize_logits=True)

```

So that for example if I give this input sentence: `execute application Apx 4 times`  
I should have this type of result:

```auto
outputs = ["run Apx -t 4", "run Apx --times 4", "do Apx --times 4"] # imaginary
scores = [-0.04, -0.09, -1] # imaginary
confid = [0.0, 0.0, 0.0]
for i in scores:
    confid [i] = math.exp(scores[i])
confid = [0.9, 0.8, 0.1]

```

How best to calculate these beam scores `scores`?
