Project Creation: Part Three
Explore how to generate text by sampling from a Markov chain model using a fixed-length context. Understand the role of context length and probability sampling to predict the next character in a sequence. Gain practical experience implementing text generation and recognize the limitations of syntactic models compared to advanced methods like LSTM.
We'll cover the following...
Sampling the text
We already created our Markov model in the previous lesson. Now we need to sample the text and generate some new text based on this sampling.
Explanation:
-
The function,
sample_next(ctx,model,k), accepts three parameters: the context, the model, and the value ofK. -
The
contextis nothing but the text that will be used to generate some new text. However, only the lastKcharacters from the context will be used by the model to predict the next character in the sequence. -
For example, we passed the value of context ...