diff --git a/docs/index.rst b/docs/index.rst index 1ea01d6aa6..c6da2cd832 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,9 +12,10 @@ models. This toolkit offers four main features: 4. Community supports -This toolkit assume users has basic knowledges about deep learning and -NLP. Otherwise, please refer to introduction course such as `Stanford -CS224n `_. +This toolkit assumes that users have basic knowledge about deep learning and +NLP. Otherwise, please refer to an introduction course such as +`Deep Learning---The Straight Dope `_ or +`Stanford CS224n `_. .. note:: @@ -26,7 +27,7 @@ Installation GluonNLP relies on the recent version of MXNet. The easiest way to install MXNet is through `pip `_. The following -command installs a nightly build CPU version of MXNet. +command installs a nightly built CPU version of MXNet. .. code-block:: bash @@ -34,11 +35,11 @@ command installs a nightly build CPU version of MXNet. .. note:: - There are other pre-build MXNet packages that enables GPU supports and + There are other pre-build MXNet packages that enable GPU supports and accelerate CPU performance, please refer to `this tutorial `_ for details. Some training scripts are recommended to run on GPUs, if you don't have a GPU - machine at hands, you may consider to `run on AWS + machine at hands, you may consider `running on AWS `_. @@ -52,8 +53,8 @@ Then install the GluonNLP toolkit by A Quick Example ---------------- -Here is a quick example that download and create a word embedding model and then -compare the similarity between two words. +Here is a quick example that downloads and creates a word embedding model and then +computes the cosine similarity between two words. .. (You can click the go button on the @@ -76,10 +77,13 @@ compare the similarity between two words. import mxnet as mx import gluonnlp as nlp - glove = nlp.embedding.create('glove', source='glove.6B.50d.txt') + # Create a GloVe word embedding. + glove = nlp.embedding.create('glove', source='glove.6B.50d') + # Obtain vectors for 'baby' and 'infant' in the GloVe word embedding. baby, infant = glove['baby'], glove['infant'] def cos_similarity(vec1, vec2): + # Normalize the dot product of two vectors with the L2-norm product. return mx.nd.dot(vec1, vec2) / (vec1.norm() * vec2.norm()) print(cos_similarity(baby, infant))