In NLG, a Transformer is trained on large corpora of text to learn the statistical patterns and relationships between words. It then generates text by sampling from this learned distribution of words based on given input or context. The Transformer's self-attention mechanism helps it capture long-range dependencies and generate coherent and contextually relevant output.