Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

HuggingFace's Transformers: State-of-the-art Natural Language Processing

Transformers is an open-source library that packages pretrained NLP models behind one API

  • Problem Once pretraining became widespread, users still had to distribute, fine-tune, deploy and compress each pretrained Transformer model themselves.
  • Method Transformers splits each model into a tokenizer, a transformer and a task head behind one API. Because the head is separate, one pretrained core can be paired with different heads.
  • Results The Model Hub now holds 2,097 user models shared by the community.

Why pretrained models are hard to reuse

Transformers have become the dominant architecture for NLP, beating convolutional and recurrent networks on both understanding and generation. Pretraining on generic text lets one model be adapted to many specific tasks. Once pretraining is widespread, the practical work shifts to distributing, fine-tuning, deploying and compressing the core models.

The authors argue this calls for systems that train, analyze, scale and augment these models on many platforms.

The authors answer with an open-source library and a centralized hub, where users compare models through the same minimal API. The library is released under the Apache 2.0 license and has over 400 external contributors.

Three parts make up every model

The key idea is to cut every model into three parts that can each be reused or replaced. The tokenizer converts raw text into sparse index encodings. The transformer turns those indices into contextual embeddings, and the head uses the embeddings to make a task-specific prediction. Because the head is separate, one pretrained core can be paired with different heads for different tasks.

Architectures differ in positional representations, masking, padding and whether they use a sequence-to-sequence design, but they share a multi-headed attention core. Each model's base class builds the computation from an embedding projection through the self-attention layers to the final encoder hidden states. Most models sit in a single file, which keeps them easy to extend.

Auto classes read the pretrained model's configuration and instantiate the right class, so switching models needs little change in code.

Tokenizers store the vocabulary as a token-to-index map and encode and decode text the way each model expects. Users can add tokens, special tokens and resize the vocabulary, and truncation accounts for the special tokens a model adds. Python-based tokenization is often too slow on very large datasets, so the most recent release uses a Rust tokenization library by default.

Heads are wrapper classes that add an output layer and an optional loss on top of the transformer's contextual embeddings. Their names follow a pattern such as XXXForSequenceClassification, where XXX is the model name. Some heads, such as conditional generation, also support sampling and beam search. For pretrained models, the heads used during pretraining are released as well, so users can continue with the pretraining objectives.

Sharing and loading models through the Model Hub

DistilBERT, which was developed for the library, is now widely downloaded by the community. The hub stores the model under a canonical name, so anyone can download, cache and run it in two lines of code. The FlauBERT example loads both parts with AutoTokenizer.from_pretrained and AutoModel.from_pretrained on flaubert/flaubert_base_uncased.

Each uploaded model gets a landing page and an optional model card that lists training details, datasets, a citation and known biases. Because the hub only holds transformer models, a model page can run live inference on user text. Model pages also link to tools such as exBERT for visualizing the model.

What three community groups built on the hub

The authors group the users into architects, trainers and end-users, following Strobelt et al. (2017). AllenAI trained SciBERT on PubMed data as a masked language model for biomedical extraction, then distributed it through the hub.

NYU used the Transformers API as a generic front-end for its Jiant framework and fine-tuned many models. That work led to research on the structure of BERT. Plot.ly needed document summarization without any training, so it searched the hub and found DistilBART. It ran and deployed that model directly from the hub with no research or ML expertise.

Paths from training to production

Models are available in both PyTorch and TensorFlow, and a model saved in one framework can be reloaded in the other. This lets users switch frameworks at any point in the model lifetime, from training to serving.

In PyTorch, TorchScript gives an intermediate form that runs efficiently from Python or in a C++ environment. Fine-tuned models can then be served through TorchServing, and TensorFlow offers its own serving options.

The library also exports models to ONNX, a standard interoperable format. In experiments run with the ONNX team on BERT, RoBERTa and GPT-2, ONNX reached nearly a 4x speedup. The text does not break that speedup down by model.

The team is also testing JAX/XLA and TVM as intermediate formats. For phones, models can be converted to CoreML weights with adapters and embedded in an iOS application. The authors note that similar methods can apply to Android, but they report no results for it.

Limitations

The report focuses on the core modeling specifications and leaves out training and development tools. Its only speed experiment is the ONNX run on BERT, RoBERTa and GPT-2.

The three community cases describe how the library was used, not how well the models performed on the users' tasks. The CoreML and Android paths are described without experiments.

Paper info

Authors
Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, Alexander M. Rush
Venue
arXiv · Preprint
First published
2019-10-9
Added
2026-11-11
Updated
2020-7-14
Version
v5
arXiv
1910.03771
Category
cs.CL
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame et al. (2019). HuggingFace's Transformers: State-of-the-art Natural Language Processing. arXiv:1910.03771v5. https://arxiv.org/abs/1910.03771v5

BibTeX
@misc{wolf2019huggingface,
  title = {{HuggingFace's Transformers: State-of-the-art Natural Language Processing}},
  author = {Thomas Wolf and Lysandre Debut and Victor Sanh and Julien Chaumond and Clement Delangue and Anthony Moi and Pierric Cistac and Tim Rault and Rémi Louf and Morgan Funtowicz and Joe Davison and Sam Shleifer and Patrick von Platen and Clara Ma and Yacine Jernite and Julien Plu and Canwen Xu and Teven Le Scao and Sylvain Gugger and Mariama Drame and Quentin Lhoest and Alexander M. Rush},
  year = {2019},
  eprint = {1910.03771},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.03771v5}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up