Example

Example of Generating Text with RNNLMScratch

To demonstrate the text generation process, the predict method can be invoked on a trained language model instance. For example, if a model is provided with the prefix 'it has' and tasked with generating 2020 additional characters, it first processes the prefix to build context during its warm-up period. It then sequentially predicts each subsequent character. In practice, calling the method with these parameters might yield an output sequence such as 'it has in the the the the ', illustrating both the mechanics of autoregressive generation and the characteristic repetition often observed in basic models.

0

1

Updated 2026-05-14

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L