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.

Solution: Semantic similarity

Solution: Semantic similarity

(upbeat music) - [Instructor] So the goal of the challenge was to modify the similar words function, so that it goes by semantic similarity as opposed to just length. And the way I would do this is by changing the length here for the sort key to co-sign similarity, which we worked on in an earlier video. So let's do co-sign si-mi-la-rity and we need two arguments. And the first one is to look up the vector of X. So X is the word and we look up what vector it's mapping to. And we'll also do a lookup for the word and that's the input word. For this one it's tree by default. Now let's go ahead and run this and see what happens. And we have tree, plant, wood, saw, and farm, and you see that as we progress, the words get less and less similar. And you can check this out with any of the words that are in this dictionary to see what comes up. Now if you want to take this a bit further you can explore the different…

Contents