GithubHelp home page GithubHelp logo

minhnguyent546 / pre-training-gpt2 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 519 KB

A GPT-2 implementation which works on multi-GPUs and XLA devices.

Python 99.05% Shell 0.19% Makefile 0.76%
gpt-2 text-generation tpu

pre-training-gpt2's Introduction

GPT-2 from scratch

This is a very simple implementation of the GPT-2 model using PyTorch. Some of the ideas and codes are derived from OpenAI's GPT-2 implementation and nanoGPT.

Getting started

Start by cloning the repository and installing the requirements:

git clone https://github.com/minhnguyent546/gpt2-from-scratch.git
cd gpt2-from-scratch
pip install -r requirements.txt

The configuration file can be found at config/config.yaml.

To preprocess the data, simply run the following command:

python gpt2/preprocess.py --config config/config.yaml

After that, we can start training the model:

python gpt2/train.py --config config/config.yaml

Experiment

The model was trained on corpus.viwiki (50MB of text extracted from this), the training process took around 4 hours with 40K training steps on Kaggle's P100 GPU.

Training loss

Here are some generated text from the model:

python gpt2/generate.py \
    --model ./checkpoints/gpt2-40000.pt \
    --tokenizer ./checkpoints/tokenizer.json \
    --seed 42 \
    --max-new-tokens 120 \
    --temperature 1

result:

>> Nghiên cứu là một quá
Nghiên cứu là một quá trình tạo ra các chất hút điện ngoài sự vật chất . Có hai lĩnh vực điện xuất nhằm tạo ra các loại nguyên tử tự nhiên thù của các kim loại - kim loại . Gốc vụ có thể có các loại kim loại như hiđrua liti , Gd và các loại sulfua kim loại khác . Các chất phóng xạ khác gồm các đồng ( 90 %), 1 %, ") [ 25 ] 6H2O ( 20 % tương đương với 66 %.
Các hợp chất ở dạng O2 là hyđrô sulfit ở nhiệt độ thấp , là một trong các điều kiện quan trọng cho sự cháy cháy . Các chất này là nguồn
python gpt2/generate.py \
    --model ./checkpoints/gpt2-40000.pt \
    --tokenizer ./checkpoints/tokenizer.json \
    --seed 42 \
    --max-new-tokens 40 \
    --temperature 0.5

result:

>> Đầu năm 2021
Đầu năm 2021 , một nhóm hội nghị quốc tế đã được thành lập tại Paris năm 1973 , và cuộc họp này đã được tổ chức bởi các đảng hợp nhất . Năm 1999 , Hội nghị thượng đỉnh thứ nhất được

pre-training-gpt2's People

Contributors

minhnguyent546 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.