All Projects → huggingface → Naacl_transfer_learning_tutorial

huggingface / Naacl_transfer_learning_tutorial

Licence: mit
Repository of code for the tutorial on Transfer Learning in NLP held at NAACL 2019 in Minneapolis, MN, USA

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Naacl transfer learning tutorial

Sru Deeplearning Workshop
دوره 12 ساعته یادگیری عمیق با چارچوب Keras
Stars: ✭ 66 (-90.39%)
Mutual labels:  tutorial, transfer-learning
Getting Things Done With Pytorch
Jupyter Notebook tutorials on solving real-world problems with Machine Learning & Deep Learning using PyTorch. Topics: Face detection with Detectron 2, Time Series anomaly detection with LSTM Autoencoders, Object Detection with YOLO v5, Build your first Neural Network, Time Series forecasting for Coronavirus daily cases, Sentiment Analysis with BERT.
Stars: ✭ 738 (+7.42%)
Mutual labels:  tutorial, transfer-learning
Learnapollo
👩🏻‍🏫 Learn Apollo - A hands-on tutorial for Apollo GraphQL Client (created by Graphcool)
Stars: ✭ 5,274 (+667.69%)
Mutual labels:  tutorial
Exploit me
Very vulnerable ARM/AARCH64 application (CTF style exploitation tutorial with 14 vulnerability techniques)
Stars: ✭ 665 (-3.2%)
Mutual labels:  tutorial
Awesome Federated Learning
Federated Learning Library: https://fedml.ai
Stars: ✭ 624 (-9.17%)
Mutual labels:  transfer-learning
Hypervisor From Scratch
Source code of a multiple series of tutorials about the hypervisor. Available at: https://rayanfam.com/tutorials
Stars: ✭ 623 (-9.32%)
Mutual labels:  tutorial
Makeiconswithsketch
Simple tutorials about how to make icons with Sketch.
Stars: ✭ 643 (-6.4%)
Mutual labels:  tutorial
Eliasdb
EliasDB a graph-based database.
Stars: ✭ 611 (-11.06%)
Mutual labels:  tutorial
Flutter planets tutorial
The Flutter Planets app tutorial with commits per lesson
Stars: ✭ 682 (-0.73%)
Mutual labels:  tutorial
Lc3 Vm
Write your own virtual machine for the LC-3 computer!
Stars: ✭ 631 (-8.15%)
Mutual labels:  tutorial
Javascripttraining
Training course repository for JavaScript
Stars: ✭ 658 (-4.22%)
Mutual labels:  tutorial
Django Rest Framework Tutorial
Django-REST-framework 基本教學 - 從無到有 DRF-Beginners-Guide 📝
Stars: ✭ 630 (-8.3%)
Mutual labels:  tutorial
Dasarpemrogramangolang
📖 Source Code E-book Dasar Pemrograman Golang
Stars: ✭ 625 (-9.02%)
Mutual labels:  tutorial
Tensorflow 101
TensorFlow 101: Introduction to Deep Learning for Python Within TensorFlow
Stars: ✭ 642 (-6.55%)
Mutual labels:  transfer-learning
Blcmods
This is a repository for Community Mods made for the Borderlands series
Stars: ✭ 615 (-10.48%)
Mutual labels:  tutorial
Deno Tutorial
:sauropod: 长期更新的《Deno 钻研之术》!循序渐进学 Deno & 先易后难补 Node & 面向未来的 Deno Web 应用开发
Stars: ✭ 667 (-2.91%)
Mutual labels:  tutorial
Early Stopping Pytorch
Early stopping for PyTorch
Stars: ✭ 612 (-10.92%)
Mutual labels:  tutorial
Deepdrive
Deepdrive is a simulator that allows anyone with a PC to push the state-of-the-art in self-driving
Stars: ✭ 628 (-8.59%)
Mutual labels:  transfer-learning
Node Blog
🚀《Node.js从入门到上线》A blog build with Koa2.
Stars: ✭ 640 (-6.84%)
Mutual labels:  tutorial
Gentle Intro
A gentle Rust tutorial
Stars: ✭ 682 (-0.73%)
Mutual labels:  tutorial

Code repository accompanying NAACL 2019 tutorial on "Transfer Learning in Natural Language Processing"

The tutorial was given on June 2 at NAACL 2019 in Minneapolis, MN, USA by Sebastian Ruder, Matthew Peters, Swabha Swayamdipta and Thomas Wolf.

Here is the webpage of NAACL tutorials for more information.

The slides for the tutorial can be found here: https://tinyurl.com/NAACLTransfer.

A Google Colab notebook with all the code for the tutorial can be found here: https://tinyurl.com/NAACLTransferColab.

The present repository can also be accessed with the following short url: https://tinyurl.com/NAACLTransferCode

Abstract

The classic supervised machine learning paradigm is based on learning in isolation a single predictive model for a task using a single dataset. This approach requires a large number of training examples and performs best for well-defined and narrow tasks. Transfer learning refers to a set of methods that extend this approach by leveraging data from additional domains or tasks to train a model with better generalization properties.

Over the last two years, the field of Natural Language Processing (NLP) has witnessed the emergence of several transfer learning methods and architectures, which significantly improved upon the state-of-the-art on a wide range of NLP tasks.

These improvements together with the wide availability and ease of integration of these methods are reminiscent of the factors that led to the success of pretrained word embeddings and ImageNet pretraining in computer vision, and indicate that these methods will likely become a common tool in the NLP landscape as well as an important research direction.

We will present an overview of modern transfer learning methods in NLP, how models are pre-trained, what information the representations they learn capture, and review examples and case studies on how these models can be integrated and adapted in downstream NLP tasks.

Overview

This codebase tries to present in the simplest and most compact way a few of the major Transfer Learning techniques, which have emerged over the past years. The code in this repository does not attempt to be state-of-the-art. However, effort has been made to achieve reasonable performance and with some modifications to be competitive with the current state of the art.

Special effort has been made to

  • ensure the present code can be used as easily as possible, in particular by hosting pretrained models and datasets;
  • keep the present codebase as compact and self-contained as possible to make it easy to manipulate and understand.

Currently the codebase comprises:

  • pretraining_model.py: a transformer model with a GPT-2-like architecture as the basic pretrained model;
  • pretraining_train.py: a pretraining script to train this model with a language modeling objective on a selection of large datasets (WikiText-103, SimpleBooks-92) using distributed training if available;
  • finetuning_model.py: several architectures based on the transformer model for fine-tuning (with a classification head on top, with adapters);
  • finetuning_train.py: a fine-tuning script to fine-tune these architectures on a classification task (IMDb).

Installation

To use this codebase, simply clone the Github repository and install the requirements like this:

git clone https://github.com/huggingface/naacl_transfer_learning_tutorial
cd naacl_transfer_learning_tutorial
pip install -r requirements.txt

Pre-training

To pre-train the transformer, run the pretraining_train.py script like this:

python ./pretraining_train.py

or using distributed training like this (for a 8 GPU server):

python -m torch.distributed.launch --nproc_per_node 8 ./pretraining_train.py

The pre-training script will:

  • download wikitext-103 for pre-training (default),
  • instantiate a 50M parameters transformer model and train it for 50 epochs,
  • log the experiements in Tensorboard and in a folder under ./runs,
  • save checkpoints in the log folder.

Pretraining to a validation perplexity of ~29 on WikiText-103 will take about 15h on 8 V100 GPUs (can be stopped earlier). If you are interested in SOTA, there are a few reasons the validation perplexity is a bit higher than the equivalent Transformer-XL perplexity (around 24). The main reason is the use of an open vocabulary (sub-words for Bert tokenizer) instead of a closed vocabulary (see this blog post by Sebastian Mielke for some explanation)

Various pre-training options are available, you can list them with:

python ./pretraining_train.py --help

Fine-tuning

To fine-tune the pre-trained transformer, run the finetuning_train.py script like this:

python ./finetuning_train.py --model_checkpoint PATH-TO-YOUR-PRETRAINED-MODEL-FOLDER

PATH-TO-YOUR-PRETRAINED-MODEL-FOLDER can be for instance ./runs/May17_17-47-12_my_big_server

or using distributed training like this (for a 8 GPU server):

python -m torch.distributed.launch --nproc_per_node 8 ./finetuning_train.py  --model_checkpoint PATH-TO-YOUR-PRETRAINED-MODEL-FOLDER

Various fine-tuning options are available, you can list them with:

python ./finetuning_train.py --help
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].