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:
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:
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
?