Skip to content
A natural language modeling framework based on PyTorch
Python
Branch: master
Clone or download
hudeven and facebook-github-bot auto resume from latest checkpoint for FBLearner retry job (#1046)
Summary:
Pull Request resolved: #1046

## Problem:
When a job fail at epoch X, FBLearner will retry it 3 times, from scratch(epoch1)
It wastes time and resources

## Solution:
1. The "retry" shares the same FBLearner job_id
2. we save all checkpoints at "manifold://pytext_training/tree/jobs/<JOB_ID>/checkpoint-<EPOCH>"
3. so there is a mapping (job_id --> latest checkpoint)
4. before training start, we check if there are already checkpoints saved for the current job_id.
Yes: load the latest checkpoint and resume training
No: start training from scratch
5. add config "auto_resume_from_snapshot" to turn this feature on/off.

Reviewed By: mwu1993

Differential Revision: D17874151

fbshipit-source-id: 9ace345f739f23a1a7c2994352dc5e364dcc18ad
Latest commit 8f93ce1 Oct 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Hide RNNG JIT till PyTorch 1.2 is ready (#686) Jun 12, 2019
.github Adding templates and changelog (#79) Dec 12, 2018
demo Add OSS integration tests: DocNN Oct 3, 2019
pytext auto resume from latest checkpoint for FBLearner retry job (#1046) Oct 17, 2019
tests Use SafeFileWrapper and TSV for processing Squad tsv files (#1045) Oct 16, 2019
.coveragerc Initial commit Dec 11, 2018
.gitignore Text lint all .gitignore files May 15, 2019
CHANGELOG.md EASY [PyText] fix OSS release (#909) Aug 15, 2019
CODE_OF_CONDUCT.md Adopt Contributor Covenant Aug 30, 2019
CONTRIBUTING.md Gets rid of all doc gen warnings for Python 3.7 (#188) Jan 8, 2019
LICENSE Initial commit Dec 11, 2018
README.md Make tutorial more trivial (add git clone) (#1037) Oct 8, 2019
activation_venv Refine doc index page (#102) Dec 14, 2018
activation_venv.bat Refine doc index page (#102) Dec 14, 2018
docs_requirements.txt ReadTheDocs OOM fix with CPU Torch (#1027) Oct 3, 2019
install_deps install_deps supports updates (#863) Aug 2, 2019
install_deps.bat Back out "EASY [PyText] use pip 18.1 to allow circleci tests to run" (#… Feb 20, 2019
pytest.ini Initial commit Dec 11, 2018
readthedocs.yml
requirements.txt set onnx==1.5.0 to fix CircleCI build temporarily (#1014) Oct 1, 2019
setup.py EASY [PyText] fix OSS release (#909) Aug 15, 2019

README.md

Overview

CircleCI

PyText is a deep-learning based NLP modeling framework built on PyTorch. PyText addresses the often-conflicting requirements of enabling rapid experimentation and of serving models at scale. It achieves this by providing simple and extensible interfaces and abstractions for model components, and by using PyTorch’s capabilities of exporting models for inference via the optimized Caffe2 execution engine. We are using PyText in Facebook to iterate quickly on new modeling ideas and then seamlessly ship them at scale.

Core PyText features:

Installing PyText

PyText requires Python 3.6.1 or above.

To get started on a Cloud VM, check out our guide.

Get the source code:

  $ git clone https://github.com/facebookresearch/pytext
  $ cd pytext

Create a virtualenv and install PyText:

  $ python3 -m venv pytext_venv
  $ source pytext_venv/bin/activate
  (pytext_venv) $ pip install pytext-nlp

Detailed instructions and more installation options can be found in our Documentation. If you encounter issues with missing dependencies during installation, please refer to OS Dependencies.

Train your first text classifier

For this first example, we'll train a CNN-based text-classifier that classifies text utterances, using the examples in tests/data/train_data_tiny.tsv. The data and configs files can be obtained either by cloning the repository or by downloading the files manually from GitHub.

  (pytext_venv) $ pytext train < demo/configs/docnn.json

By default, the model is created in /tmp/model.pt

Now you can export your model as a caffe2 net:

  (pytext_venv) $ pytext export < demo/configs/docnn.json

You can use the exported caffe2 model to predict the class of raw utterances like this:

  (pytext_venv) $ pytext --config-file demo/configs/docnn.json predict <<< '{"text": "create an alarm for 1:30 pm"}'

More examples and tutorials can be found in Full Documentation.

Join the community

License

PyText is BSD-licensed, as found in the LICENSE file.

You can’t perform that action at this time.