Beginner LM-Transformer tutorial: how to see text output?

Hi, I’ve very much enjoyed the beginner tutorial on tranformers, Language Translation with nn.Transformer and torchtext — PyTorch Tutorials 2.1.1+cu121 documentation, …up the point where it suddenly ends with only looking at scores, but never shows us any sample output text.

How do we get text? i.e. how do we go from a sequence of model-generated floating-point embedding values back to tokens, back to text? Is there a vocab function for that? (I’m just getting started with torchtext.)

For example, I’d love to be able to supply a prompt and see what it predicts for the next “n” tokens.
However, even just being able to see some sample generated text vs. target text during training or evaluation would be very helpful.

I failed to find any similar discussion questions on this topic (Sorry, they probably exist. Feel free to point me to one.)


I apparently missed the part where the tutorial says,

In this tutorial, we train a nn.TransformerEncoder model on a language modeling task. Please note that this tutorial does not cover the training of nn.TransformerDecoder, as depicted in the right half of the diagram above."

But given that the title and the opening text tell us we’ll be predicting words:

This is a tutorial on training a model to predict the next word in a sequence using the nn.Transformer module.

…I found the premature ending of the tutorial to be disappointing.

Is there a place where the decoder side is trained as well, so that we can see the words? (And could we add a link to that to the tutorial)?