A natural language modeling framework based on PyTorch
Clone or download
arbabu123 and facebook-github-bot Refactor optimizer similar to other components. (#8)
Summary:
This diff achieves the following objectives:
- We will have a cleaner way of specifying optimizers. Only exact expected arguments can be provided for a particular optimizer. Giving momentum argument for Adam will throw exception.
- It makes it easier to add new optimizers. By replacing the if-else-style create_optimizer(), optimizers can be defined from different files.
- We remove support for multiple optimizers as this feature was not being used anywhere else and it was creating unnecessary complexity.

Pull Request resolved: #8

Reviewed By: hikushalhere

Differential Revision: D13227927

fbshipit-source-id: 2da3a1f8f456e6c4561375f62efa6596715a2880
Latest commit 57f11b7 Jan 18, 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.

We recommend using a virtualenv:

  $ 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.

  (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:

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

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

  (venv) $ pytext --config-file demo/configs/docnn.json predict <<< '{"raw_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.