fairseq README

The project's README from github.com/facebookresearch/fairseq. As one markdown file: README.md.



Support Ukraine MIT License Latest Release Build Status Documentation Status CicleCI 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:

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

git clone https://github.com/pytorch/fairseq
cd fairseq
pip install --editable ./

# on MacOS:
# CFLAGS="-stdlib=libc++" pip install --editable ./

# to install the latest stable release (0.10.x)
# pip install fairseq
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" ./

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},
}

fairseq (facebookresearch/fairseq)

Searching Database…

32.2K ·GitHub
archived
这是什么?Fairseq 是 Facebook AI Research 推出的序列建模工具包,基于 PyTorch,用于训练翻译、摘要、语言建模及其他文本生成任务的自定义模型。
这是现成的应用,还是需要我在它的基础上开发的工具包?它是建立在 PyTorch 之上的 Python 研究工具包/库,可以通过命令行的训练和生成工具使用,也可以注册你自己的模型、损失准则、任务和优化器。
我该如何安装并让模型跑起来?克隆仓库,然后用 pip 在本地安装(可编辑安装),再使用提供的 torch.hub 接口,或者使用为翻译和语言建模列出的预训练模型。
训练模型之前我需要准备什么?你需要 PyTorch 1.10.0 及以上版本和 Python 3.8 及以上版本;如果要训练新模型,还需要带 NCCL 的 NVIDIA GPU;处理大型数据集时,还可以选择安装 NVIDIA 的 apex 库或 PyArrow。
这个项目还在积极维护吗?不再维护了。仓库已归档,意味着它只读,不再接收更新,但代码、论文和预训练模型仍可供使用。
使用它一定需要 NVIDIA GPU 吗?训练新模型需要(要求 NVIDIA GPU 加 NCCL),不过生成任务也可以在 CPU 上运行;在 NVIDIA 张量核心上使用混合精度训练,还能进一步提速。
fairseq 的模型能处理哪些任务?翻译、语言建模、摘要、语音识别(通过 wav2vec),以及其他文本和语音生成任务,每项都附有参考实现。
哪些知名模型最早是通过 fairseq 发布的?RoBERTa、BART、mBART、wav2vec/wav2vec 2.0、XLM-R,以及基于 Transformer 的 WMT 翻译模型,都以 fairseq 参考实现的形式发布。
我可以直接使用预训练模型,而不用自己训练吗?可以,fairseq 提供预训练的翻译和语言建模检查点,可以通过便捷的 torch.hub 接口获取。
生成功能支持哪些搜索/解码策略?内置束搜索(Beam Search)、多样化束搜索(Diverse Beam Search)、无约束/top-k/top-p 采样,以及词汇约束解码,可在 CPU 或 GPU 上快速生成。
Size
25.5 MB
Stars
32.2K
Age
9y
Commits · 90 Days