Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

DialoGPT

> 数据库
Open source

Large-scale pretraining for dialogue

2.4K stars0 likes2 views
WebsiteGitHub

About

Large-scale pretraining for dialogue

A State-of-the-Art Large-scale Pretrained Response Generation Model (DialoGPT)

This project page is no longer maintained as DialoGPT is superseded by GODEL, which outperforms DialoGPT according to the results of this paper. Unless you use DialoGPT for reproducibility reasons, we highly recommend you switch to GODEL.

This repository contains the source code and trained model for a large-scale pretrained dialogue response generation model. The human evaluation results indicate that the response generated from DialoGPT is comparable to human response quality under a single-turn conversation Turing test.

The repository is based on huggingface pytorch-transformer and OpenAI GPT-2, containing data extraction script, model training code and pretrained small (117M) medium (345M) and large (762M) model checkpoint.

The model is trained on 147M multi-turn dialogue from Reddit discussion thread. The largest model can be trained in several hours on a 8 V100 machines (however this is not required), with distributed training and FP16 option.

The include script can be used to reproduce the results of DSTC-7 grounded dialogue generation challenge and a 6k multi-reference dataset created from Reddit data.

Project webpage: https://www.microsoft.com/en-us/research/project/large-scale-pretraining-for-response-generation/

ArXiv paper: https://arxiv.org/abs/1911.00536

News

(Update 07/09/2022) Changes on the files.pushshift.io/reddit server caused our data generation pipeline to break. These problems have now been fixed, and the steps explained in the Data Preparation subsection below should work again. Data is generated in about 10 hours with 8 processes (-j 8), and 800GB of temporary disk space is needed.

(Update 06/23/2021) We have released a retrieval-augmented/grounded version of DialoGPT (RetGen), please check out the RetGen repo and RetGen paper

(Update 05/20/2021) An awesome video walkthrough on YouTube for DialoGPT by Prakhar Mishra

(Update 03/31/2021) A 3rd party demo by AK391 using Gradio web demo try it out

(Update 09/15/2020) A set of large-scale dialog ranking models has been released!

DialoGPT generation is improved by integrating with our latest dialog ranking models, DialogRPT

(Update 07/08/2020) The 6K multi-ref test set has been released!

To generate the data, pleaser run demo.py and set the data option to 'full', the generated 6k multi-ref test set will be located at

./data/test.refs.txt

(Update 03/10/2020) Model cards available in Huggingface Transformers!

Please check out our model cards in huggingface Transformers repository. With several lines of code it should be pretty straighforward to play with the DialoGPT interactively.

small model: https://huggingface.co/microsoft/DialoGPT-small

medium model: https://huggingface.co/microsoft/DialoGPT-medium

large model: https://huggingface.co/microsoft/DialoGPT-large

(New) Ranking model: https://huggingface.co/microsoft/DialogRPT-updown

(Update 01/06/2020) Some third-party decoding script implementations:

  • https://github.com/polakowo/gpt2bot GPT2Bot implementation based on telegram by polakowo, ref
  • https://colab.research.google.com/drive/1PslHE4Rl4RqSa20s7HEp0ZKITBir6ezE A colab interactive notebook by qywu,ref
  • https://github.com/andreamad8/DialoGPT2-Interact An interactive script featuring multiturn chatbot by andreamad8,ref
  • https://github.com/LHolten/DialoGTP-MMI-decoder An MMI implementation by LHolten,ref
  • https://colab.research.google.com/drive/1-_KjlAV3J1IVDw_9KogjKDCzgFY7Jp7E A colab interactive notebook by illuminascent@Reddit,ref
  • https://colab.research.google.com/drive/15wa925dj7jvdvrz8_z3vU7btqAFQLVlG A great tutorial of how to finetune DialoGPT to build a customized bot built by Rostyslav Neskorozhenyi. ref
  • https://gradio.app/g/AK391/DialoGPT A 3rd party demo by AK391 using Gradio web demo

Recommended Configuration

  • Linux Ubuntu 16.04
  • GPU with at least 12G memory

DialoGPT was developed entirely on Ubuntu 16.04, and -- depending on our availability -- we try to provide support if you experience difficulties running the code on the same configuration. However, we are unable to provide support for other distributions or operating systems. Portions of the code may run on other UNIX flavors (macOS, Windows subsystem for Linux, Cygwin, etc.), but it is recommended to use Ubuntu for the main training code.

The training code can be run on CPU, but it can be slow. We would recommend to use GPU to train and finetune all models. There is no minimal limit of the number of GPUs. However, if using distributed train for multiple GPUs configuration, the speed-up vs the number of GPUs is roughly sub-linear. To simulate the same batchsize when using less GPUs, please use a larger gradient_accumulation_steps in model training.

The 117M and 345M model can be loaded in a single GPU with 12G memory. The 762M model would require a single GPU that has greater than 16G memory for efficient training. The training speed on a benchmark data with 50M training instances and V100 GPUs:

n_gpu epoch time (h) token/sec
1 118 10847
2 62 20645
4 34 37647
8 18 71356

Fine-tuning from our pretrained model on a new dataset typically requires 1-2 epochs.

Setup & Installation (TL;DR)

We created a demo script demo.py to ease the difficulty of the deployment of this system. The demo.py contains a pipeline of model downloading, data extraction, data preprocessing and model training over a dummy dataset within one commandline.

Train model with Conda Environment

Please use the below commandlines to clone, install the requirements and load the Conda environment (Note that the Nvidia CUDA 10.0 developer toolkit is required):

bash
sudo apt-get install -y make wget gzip bzip2 xz-utils zstd sed
bash
git clone https://github.com/microsoft/DialoGPT.git
cd DialoGPT
conda env create -f LSP-linux.yml -n LSP
conda activate LSP

If you run this on an architecture other than Linux, please use LSP-generic.yml instead of LSP-linux.yml but please note that the generic one is not tested in all platform, so the stablity can not be gauranteed. To use fp16 training, please install apex by using commands below

bash
conda activate LSP
git clone https://github.com/NVIDIA/apex
cd apex
git reset --hard 3d01e4a0a188cc8df54bc6e44cf5eb40ff6b4cc5
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" .
python3.6 demo.py

Train model with Docker environment

To start, first install the docker and Nvidia-docker from their official repos. The image environment for running the code can be loaded as below:

Nvidia-docker v2.*

bash
$ docker run --gpus all --ipc=host --rm -it -v $PWD:/workspace --network=host icaruszyz/large-scale-training:dialogpt bash

Nvidia-docker v1.*

bash
$ nvidia-docker --rm -it -v $PWD:/workspace --network=host icaruszyz/large-scale-training:dialogpt bash

Inside the docker container, run

bash
python demo.py

Pipeline details

This section explains all components in the demo.py.

Data loading

Before running demo.py, you can set DATA_FOLDER (default value ./models) in demo.py as the place you want to download all the data and pretrained/fine-tuned models. Then simply run

bash
python demo.py

to

  • automatically download models and data,
  • prepare raw data into db that is ready to use for the program,
  • generate a training scripts.

Note that by default the demo.py will use a dummy data, please specify the Reddit training data by using option --data. Three options are available:dummy,small and full.

bash
python demo.py --data small
python demo.py --data full

The small Reddit data is around 140MB and the full Reddit data is more than 27GB. You can prepare a cup of coffee when processing with the full Reddit data because it takes a long time!

To generate the 6k multi-ref test set data, pleaser run demo.py and set the data option to 'full', the generation will be located at

./data/test.refs.txt

Pretrained model

The pretrained and fine-tuned models are available on azure blobstorage. Please run/see demo.py for more details about how to download/use those models. Or you could download directly by using the links in demo_utils.py.

Preparing data

First, use the prepare4db.sh to convert a tsv data file into the correct format that the following script can recognize. The trainig data need to be then processed into a database file with below commandline:

bash
python prepro.py --corpus $DATA_PATH

Using the training script

The training script can be used in single GPU or multiple GPU settings (distributed training across multiple GPUs within a single node):

bash
python ./LSP_train.py  # Single GPU training
python -m torch.distributed.launch --nproc_per_node=8 ./LSP_train.py  # Training on 8 GPUs

The training script accept several arguments to tweak the training:

Argument Type Default value Description
max_seq_length int 128 Maximum number of tokens for each training instance.
train_input_file str "" Path of the training dataset in a .db format
eval_input_file str "" Path of the validation set in a tsv format
continue_from int 0 Resuming the training after a specified number of steps
fp16 boolean True Whether to use 16-bits floating point for model training.
train_batch_size int 4 Batch size for training
valid_batch_size int 4 Batch size for validation
gradient_accumulation_steps int 2 Accumulate gradients on several steps
learning_rate float 1e-5 Learning rate
lr_schedule str `n

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythondata-processingdialogptdialoguegpt-2

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库