dolly icon indicating copy to clipboard operation
dolly copied to clipboard

[Feature] Logprobs

Open xingdi-eric-yuan opened this issue 2 years ago • 2 comments

Hi, thanks for sharing the code and models! May I ask what's an easy way to obtain the logprobs of each chosen tokens (not necessarily the entire vocab) during generation? Thanks!

xingdi-eric-yuan avatar May 03 '23 13:05 xingdi-eric-yuan

I haven't tried this, but I think you can just use compute_transition_scores for this in the transformers API, like at https://huggingface.co/docs/transformers/main_classes/text_generation#transformers.GenerationMixin.compute_transition_scores.example

srowen avatar May 03 '23 15:05 srowen

Thank you @srowen , I will try and report back.

xingdi-eric-yuan avatar May 03 '23 17:05 xingdi-eric-yuan

Just to report back, compute_transition_scores is exactly what I needed. Thanks for the suggestion. One thing worth mentioning is that, when locating logprobs per token (rather than strings that we can strip), one needs to change this to response_pos + 2 because there is an extra \n after the response token (as defined here).

xingdi-eric-yuan avatar May 04 '23 18:05 xingdi-eric-yuan

Just to report back, compute_transition_scores is exactly what I needed. Thanks for the suggestion. One thing worth mentioning is that, when locating logprobs per token (rather than strings that we can strip), one needs to change this to response_pos + 2 because there is an extra \n after the response token (as defined here).

@xingdi-eric-yuan, would you help share how you achieve the change to return the scores for each token?

wangyubo111 avatar May 11 '23 07:05 wangyubo111