by pjankiewicz · 2mo ago · 0 comments
You don't actually use the "next token" that the model chooses
That's what the author is doing in this part
token_ids = [model.tokenize(text=label.encode(), add_bos=False)[0] for label in labels]
choice_logits = numpy.asarray([logits[token_id] for token_id in token_ids])
logprobs = choice_logits - numpy.logaddexp.reduce(choice_logits)
probabilities = numpy.exp(logprobs)
This works because the model is always producing probabilities for all tokens