From the course: Hands-On AI: Build a Generative Language Model from Scratch

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Building your model

Building your model

- [Instructor] So we're just about ready to train the model that I've set up for you, and if you're following along in the exercise files, we're in 01, 01_3_begin, where right at the top, I bring in the random module, as well as punctuation from string, and that default dictionary from collections. Now, the kind of model that we're building is considered a type of what's called a Markov chain. And that's why on line seven, you'll notice that I define a class of Markov chain. Then, I initialize the class and give our model a default dictionary that produces lists as its graph, and that's going to hold our raffle possibilities for each token. Now, more advanced models have sophisticated ways of tokenizing. Our model is basically going to get rid of all punctuation in numbers and split things up, removing any spaces and new lines. Then, there's that train method, and this one, we're going to implement together in this…

Contents