Skip to content
Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
Python Cuda Other
Branch: master
Clone or download

Latest commit

theweiho and facebook-github-bot Apply black formatter to fairseq_cli/train.py
Differential Revision: D22125634

fbshipit-source-id: a05f483ac4b564f5d7a21f5ae3605615e7fcd263
Latest commit d617c29 Jun 18, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github fix Windows build (#1007) Jan 24, 2020
docs add vq-wav2vec (#1029) Mar 1, 2020
examples add random sequence truncation (#1173) Jun 5, 2020
fairseq Gradually releasing the restrictions on data-buffer-size Jun 18, 2020
fairseq_cli Apply black formatter to fairseq_cli/train.py Jun 19, 2020
scripts Updates div sometimes performing floor division to explicitly perform… Jun 5, 2020
tests Support residual connections in LSTM models (#1103) Jun 5, 2020
.gitignore REFACTOR: NAT Implementation (#925) Dec 4, 2019
.gitmodules adding model parallel multihead attention module (#1088) Mar 18, 2020
CODE_OF_CONDUCT.md Update CODE_OF_CONDUCT.md (#1759) Mar 4, 2020
CONTRIBUTING.md Relicense fairseq under MIT license (#786) Jul 30, 2019
LICENSE Relicense fairseq under MIT license (#786) Jul 30, 2019
README.md Several small fixes (incl. set default --data-buffer-size=10) (#2163) May 26, 2020
eval_lm.py Fix binaries in root dir (#995) Jan 17, 2020
fairseq.gif Initial commit Sep 15, 2017
fairseq_logo.png Fixes (#442) Jan 14, 2019
generate.py Fix binaries in root dir (#995) Jan 17, 2020
hubconf.py Build Cython components when loading hub (#1386) Nov 18, 2019
interactive.py Fix binaries in root dir (#995) Jan 17, 2020
preprocess.py Fix binaries in root dir (#995) Jan 17, 2020
pyproject.toml fetch pyproject.toml for building cython codes without pre-installati… Feb 16, 2020
score.py Fix binaries in root dir (#995) Jan 17, 2020
setup.py Fix binaries in root dir (#995) Jan 17, 2020
train.py Fix binaries in root dir (#995) Jan 17, 2020
validate.py Fix binaries in root dir (#995) Jan 17, 2020

README.md



MIT License Latest Release Build Status Documentation Status


Fairseq(-py) is a sequence modeling toolkit that allows researchers and developers to train custom models for translation, summarization, language modeling and other text generation tasks. We provide reference implementations of various sequence modeling papers:

List of implemented papers

What's New:

Previous updates

Features:

  • multi-GPU training on one machine or across multiple machines (data and model parallel)
  • fast generation on both CPU and GPU with multiple search algorithms implemented:
  • large mini-batch training even on a single GPU via delayed updates
  • mixed precision training (trains faster with less GPU memory on NVIDIA tensor cores)
  • extensible: easily register new models, criterions, tasks, optimizers and learning rate schedulers

We also provide pre-trained models for translation and language modeling with a convenient torch.hub interface:

en2de = torch.hub.load('pytorch/fairseq', 'transformer.wmt19.en-de.single_model')
en2de.translate('Hello world', beam=5)
# 'Hallo Welt'

See the PyTorch Hub tutorials for translation and RoBERTa for more examples.

Requirements and Installation

  • PyTorch version >= 1.4.0
  • Python version >= 3.6
  • For training new models, you'll also need an NVIDIA GPU and NCCL
  • To install fairseq and develop locally:
git clone https://github.com/pytorch/fairseq
cd fairseq
pip install --editable ./

# on MacOS:
# CFLAGS="-stdlib=libc++" pip install --editable ./
  • For faster training install NVIDIA's apex library:
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" \
  --global-option="--deprecated_fused_adam" --global-option="--xentropy" \
  --global-option="--fast_multihead_attn" ./
  • For large datasets install PyArrow: pip install pyarrow
  • If you use Docker make sure to increase the shared memory size either with --ipc=host or --shm-size as command line options to nvidia-docker run.

Getting Started

The full documentation contains instructions for getting started, training new models and extending fairseq with new model types and tasks.

Pre-trained models and examples

We provide pre-trained models and pre-processed, binarized test sets for several tasks listed below, as well as example training and evaluation commands.

We also have more detailed READMEs to reproduce results from specific papers:

Join the fairseq community

License

fairseq(-py) is MIT-licensed. The license applies to the pre-trained models as well.

Citation

Please cite as:

@inproceedings{ott2019fairseq,
  title = {fairseq: A Fast, Extensible Toolkit for Sequence Modeling},
  author = {Myle Ott and Sergey Edunov and Alexei Baevski and Angela Fan and Sam Gross and Nathan Ng and David Grangier and Michael Auli},
  booktitle = {Proceedings of NAACL-HLT 2019: Demonstrations},
  year = {2019},
}
You can’t perform that action at this time.