Add per token confidence to each segment. #991
Draft
+67
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As it seems to be useful for some user, I implemented a way to obtain the per token confidence of the model.
The
tokens_probs
will be added to the dictionary of eachsegment
the same waytokens
is. Eachtokens_probs
item's position in the list exactly matches each item's position in thetokens
list. The confidence of each token can easily be retrieved because the positions of the elements in the two lists match.As it is difficult to produce a general method to append the tokens which represent a word together depending on the language, I solely focused on producing the token level confidence. I am aware that there is work in progress about a word level timestamp which deals with regrouping tokens per word when possible: word-level timestamps in transcribe() #869
More specifically the split_tokens_on_spaces function.
So we could eventually use this to merge confidences of the tokens when the language used allows us to do so.
I would like to know if I would be necessary to set the tokens_probs results in each segment as optional and if so what would be the expectations about the structure of the implementation of it.