maziao/Huggingface-PaddlePaddle

Convert HuggingFace code and pretrained models to a PaddlePaddle supported format.

21

stars

25

commits

Python

primary language

Jun 25, 2024

updated

README

Huggingface-PaddlePaddle

Convert HuggingFace code and pretrained models to a PaddlePaddle supported format.

Supported models

IDFamilyConverted CheckpointsArticle
1GPT2gpt2Language Models are Unsupervised Multitask Learners
2GPT-NeoEleutherAI/gpt-neo-125mGPT-NeoX-20B: An Open-Source Autoregressive Language Model
3OPTfacebook/opt-125mOPT: Open Pre-trained Transformer Language Models
4BLOOMYeungNLP/bloom-396m-zhBLOOM: A 176B-Parameter Open-Access Multilingual Language Model
5LLaMaTinyLlama/TinyLlama-1.1B-intermediate-step-1195k-token-2.5TLLaMA: Open and Efficient Foundation Language Models
6DITTOFinetunedLearning to Break the Loop: Analyzing and Mitigating Repetitions for Neural Text Generation
7ScaleGradFinetunedStraight to the Gradient: Learning to Use Novel Tokens for Neural Text Generation
8SimCTGFinetunedA Contrastive Framework for Neural Text Generation
9Unlikelihood-TokenFinetunedNeural Text Generation with Unlikelihood Training
10Unlikelihood-SeqFinetunedNeural Text Generation with Unlikelihood Training
11Qwen-1.5Qwen/Qwen1.5-0.5BQwen Technical Report
12GPT-SW3AI-Sweden-Models/gpt-sw3-126mGPT-SW3: An Autoregressive Language Model for the Nordic Languages
13Galacticafacebook/galactica-125mGalactica: A Large Language Model for Science
14DeepSeek LLMdeepseek-ai/deepseek-coder-1.3b-baseDeepSeek LLM: Scaling Open-Source Language Models with Longtermism
15InternLM2internlm/internlm2-1_8bInternLM - GitHub Repo
16PythiaEleutherAI/pythia-70mPythia: A Suite for Analyzing Large Language Models Across Training and Scaling
17Phi-1.5microsoft/phi-1_5Textbooks Are All You Need II: phi-1.5 technical report

Procedures

Step 1. Download HuggingFace model checkpoints

huggingface-cli download --resume-download PRETRAINED_MODEL_NAME --cache-dir CACHE_DIR

Step 2. Transform HuggingFace checkpoints (PyTorch) to PaddlePaddle

python transform_checkpoint/transform_xxx.py --hf-repo CACHE_DIR --pd-repo TARGET_DIR

[Optional] Step 3. Check correctness of transformation

python check_correctness.py --hf-repo CACHE_DIR --pd-repo TARGET_DIR

Step 4. Generate new config file

python generate_config.py --src-config PATH_TO_SRC_CONFIG --mode-name MODEL_NAME --tgt-dir TARGET_DIR

Step 5. Continue training from pretrained checkpoints

CUDA_VISIBLE_DEVICES={x} python train.py \
    --model-config MODEL_CONFIG \
    --model-name MODEL_NAME \
    --tokenizer TOKENIZER \
    --dataset DATASET \
    --criterion CRITERION \
    --pretrained-model-path TARGET_DIR \
    --save-dir SAVE_DIR

Step 6. Evaluation

CUDA_VISIBLE_DEVICES={x} python test.py --dataset DATASET --pretrained-model-path SAVE_DIR

Contributors

maziao

25 commits

maziao/Huggingface-PaddlePaddle

Convert HuggingFace code and pretrained models to a PaddlePaddle supported format.

21

stars

25

commits

Python

primary language

Jun 25, 2024

updated

README

Huggingface-PaddlePaddle

Convert HuggingFace code and pretrained models to a PaddlePaddle supported format.

Supported models

IDFamilyConverted CheckpointsArticle
1GPT2gpt2Language Models are Unsupervised Multitask Learners
2GPT-NeoEleutherAI/gpt-neo-125mGPT-NeoX-20B: An Open-Source Autoregressive Language Model
3OPTfacebook/opt-125mOPT: Open Pre-trained Transformer Language Models
4BLOOMYeungNLP/bloom-396m-zhBLOOM: A 176B-Parameter Open-Access Multilingual Language Model
5LLaMaTinyLlama/TinyLlama-1.1B-intermediate-step-1195k-token-2.5TLLaMA: Open and Efficient Foundation Language Models
6DITTOFinetunedLearning to Break the Loop: Analyzing and Mitigating Repetitions for Neural Text Generation
7ScaleGradFinetunedStraight to the Gradient: Learning to Use Novel Tokens for Neural Text Generation
8SimCTGFinetunedA Contrastive Framework for Neural Text Generation
9Unlikelihood-TokenFinetunedNeural Text Generation with Unlikelihood Training
10Unlikelihood-SeqFinetunedNeural Text Generation with Unlikelihood Training
11Qwen-1.5Qwen/Qwen1.5-0.5BQwen Technical Report
12GPT-SW3AI-Sweden-Models/gpt-sw3-126mGPT-SW3: An Autoregressive Language Model for the Nordic Languages
13Galacticafacebook/galactica-125mGalactica: A Large Language Model for Science
14DeepSeek LLMdeepseek-ai/deepseek-coder-1.3b-baseDeepSeek LLM: Scaling Open-Source Language Models with Longtermism
15InternLM2internlm/internlm2-1_8bInternLM - GitHub Repo
16PythiaEleutherAI/pythia-70mPythia: A Suite for Analyzing Large Language Models Across Training and Scaling
17Phi-1.5microsoft/phi-1_5Textbooks Are All You Need II: phi-1.5 technical report

Procedures

Step 1. Download HuggingFace model checkpoints

huggingface-cli download --resume-download PRETRAINED_MODEL_NAME --cache-dir CACHE_DIR

Step 2. Transform HuggingFace checkpoints (PyTorch) to PaddlePaddle

python transform_checkpoint/transform_xxx.py --hf-repo CACHE_DIR --pd-repo TARGET_DIR

[Optional] Step 3. Check correctness of transformation

python check_correctness.py --hf-repo CACHE_DIR --pd-repo TARGET_DIR

Step 4. Generate new config file

python generate_config.py --src-config PATH_TO_SRC_CONFIG --mode-name MODEL_NAME --tgt-dir TARGET_DIR

Step 5. Continue training from pretrained checkpoints

CUDA_VISIBLE_DEVICES={x} python train.py \
    --model-config MODEL_CONFIG \
    --model-name MODEL_NAME \
    --tokenizer TOKENIZER \
    --dataset DATASET \
    --criterion CRITERION \
    --pretrained-model-path TARGET_DIR \
    --save-dir SAVE_DIR

Step 6. Evaluation

CUDA_VISIBLE_DEVICES={x} python test.py --dataset DATASET --pretrained-model-path SAVE_DIR

Contributors

maziao

25 commits

Languages

Python

95.2%

Shell

4.8%