How to convert model output logits into string sentences during training to check what the model is outputting?

It seems to me that these are the outputs of the base model. To get token predictions, you need the output of the LMHead (often a linear projection of hidden_dim → vocab_size). If you have the logits of shape bs, seqlen, vocab_size, you can simply do a softmax on that last dimension, select top1, and decode. This is not as much manual work as you may expect, but you do need the outputs of the LMHead.

As you said, you’d typically generate with generate, so I am not sure whether I understand your use case.

1 Like