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

[MRG] Benchmark models for 4.0 #2982

Merged
merged 3 commits into from
Oct 18, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion gensim/models/word2vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ def _log_train_end(self, raw_word_count, trained_word_count, total_elapsed, job_

"""
logger.info(
"training on a %i raw words (%i effective words) took %.1fs, %.0f effective words/s",
"training on %i raw words (%i effective words) took %.1fs, %.0f effective words/s",
raw_word_count, trained_word_count, total_elapsed, trained_word_count / total_elapsed
)

Expand Down
35 changes: 35 additions & 0 deletions gensim/scripts/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020 Radim Rehurek <[email protected]>

"""
Help script (template) for benchmarking. Run with:

/usr/bin/time --format "%E elapsed\n%Mk max mem" python -m gensim.scripts.benchmark ~/gensim-data/text9/text9.txt

"""

import logging
import sys

from gensim.models.word2vec import Text8Corpus, LineSentence # noqa: F401
from gensim.models import FastText, Word2Vec, Doc2Vec, Phrases # noqa: F401
from gensim import __version__

logger = logging.getLogger(__name__)


if __name__ == "__main__":
logging.basicConfig(
format='%(asctime)s [%(processName)s/%(process)d] [%(levelname)s] %(name)s:%(lineno)d: %(message)s',
level=logging.INFO,
)

if len(sys.argv) < 2:
print(globals()['__doc__'] % locals())
sys.exit(1)

corpus = Text8Corpus(sys.argv[1]) # text8/text9 format from http://mattmahoney.net/dc/textdata.html
cls = FastText
cls(corpus, workers=12, epochs=1).save(f'/tmp/{cls.__name__}.gensim{__version__}')
2 changes: 1 addition & 1 deletion gensim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def _smart_save(self, fname, separately=None, sep_limit=10 * 1024**2, ignore=fro
in separate files. The automatic check is not performed in this case.

"""
logger.info("saving %s object under %s, separately %s", self.__class__.__name__, fname, separately)
logger.info("saving %s under %s, separately %s", self, fname, separately)

compress, subname = SaveLoad._adapt_by_suffix(fname)

Expand Down