微软 AI 入门课程

Training Skip-Gram Model

微软《AI for Beginners》 · 第 课 · 英文原版 · 本地镜像

Lab Assignment from AI for Beginners Curriculum.

Task

In this lab, you we challenge you to train Word2Vec model using Skip-Gram technique. Train a network with embedding to predict neighboring words in $N$-tokens-wide Skip-Gram window. You can use the code from this lesson, and slightly modify it.

The Dataset

You are welcome to use any book. You can find a lot of free texts at Project Gutenberg, for example, here is a direct link to Alice's Adventures in Wonderland) by Lewis Carroll. Or, you can use Shakespeare's plays, which you can get using the following code:

path_to_file = tf.keras.utils.get_file(
   'shakespeare.txt', 
   'https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt')
text = open(path_to_file, 'rb').read().decode(encoding='utf-8')

Explore!

If you have time and want to get deeper into the subject, try to explore several things: