Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "generator" language in word2vec docs #2935

Merged
merged 4 commits into from
Sep 16, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions gensim/models/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@

.. sourcecode:: pycon

>>> from gensim.test.utils import common_texts, get_tmpfile
>>> from gensim.test.utils import common_texts
>>> from gensim.models import Word2Vec
>>>
>>> path = get_tmpfile("word2vec.model")
>>>
>>> model = Word2Vec(common_texts, size=100, window=5, min_count=1, workers=4)
>>> model.save("word2vec.model")

The training is streamed, meaning `sentences` can be a generator, reading input data
from disk on-the-fly, without loading the entire corpus into RAM.

It also means you can continue training the model later:
The training is streamed, so `sentences` can be an iterable, reading input data
mpenkov marked this conversation as resolved.
Show resolved Hide resolved
from disk on-the-fly. This lets you avoid loading the entire corpus into RAM.
However, note that because the iterable must be re-startable, `sentences` must
not be a generator. For an example of an appropriate iterator see
:class:`~gensim.models.word2vec.BrownCorpus`,
:class:`~gensim.models.word2vec.Text8Corpus` or
:class:`~gensim.models.word2vec.LineSentence`.

If you save the model you can continue training it later:

.. sourcecode:: pycon

Expand Down