flan alpaca lora
1.0.0
此存储库通过低级适应训练方法在羊驼数据集上训练Google/Flan-T5 。它减少了所需的GPU内存并加快训练的速度。
2023年6月17日:添加笔记本。您现在可以尝试使用Flan-Alpaca-Lora。
2023年5月3日:使用羊Alpaca-GPT4数据集训练Flan-T5-XL。
2023年4月13日:使用GPTEACHER数据集(指示和角色扮演)训练Flan-T5-XL,表现良好。
2023年4月5日:使用8位量化列车flan-t5-xxl。该模型可以安装到单个3090 GPU中。所有模型都可以在HuggingFace中找到。
| 模型 | adapter_params | 数据 | GPU | 时间 |
|---|---|---|---|---|
| Flan-Alpaca-lora碱 | 0.9m | 羊驼清洁 | 3090 | 20分钟 |
| Flan-alpaca-lora-large | 2.4m | 羊驼清洁 | 3090 | 50分钟 |
| flan-alpaca-lora-xl | 4.7m | 羊驼清洁 | 3090 | 2.5小时 |
| Flan-Alpaca-lora-XXL | 94m | 羊驼清洁 | 3090 | 10小时 |
| Flan-Gpteacher-Lora-Xl | 4.7m | GPTEACHER | 3090 | 80分钟 |
| Flan-Alpaca-gpt4-lora-Xl | 4.7m | 羊驼gpt4 | 3090 | 3.25小时 |
torch == 1.13.1
transformers == 4.29.1
peft == 0.3.0
bitsandbytes==0.38.1
accelerate==0.19.0
这些软件包的最新版本应该很好。
以下命令Finetune Flan-T5碱基仅在单个3090 GPU上使用20分钟
python train.py
--model_name_or_path google/flan-t5-base
--data_path ./alpaca_data_cleaned.json
--bf16 True
--output_dir ./ckpts/
--num_train_epochs 3
--per_device_train_batch_size 8
--gradient_accumulation_steps 8
--evaluation_strategy " no "
--save_strategy " no "
--learning_rate 5e-4
--weight_decay 0.
--warmup_ratio 0.03
--lr_scheduler_type " cosine "
--logging_steps 50
--tf32 True示例用法:
import transformers
from peft import PeftModel
# Where peft_model_id should be the saving directory or huggingface model id
model_name = "google/flan-t5-large" ; peft_model_id = "reasonwang/flan-alpaca-lora-large"
tokenizer = transformers . AutoTokenizer . from_pretrained ( model_name )
base_model = transformers . AutoModelForSeq2SeqLM . from_pretrained ( model_name )
peft_model = PeftModel . from_pretrained ( base_model , peft_model_id )
# Input an instruction or any other questions.
inputs = tokenizer ( "List a few tips to get good scores in math." , return_tensors = "pt" )
outputs = peft_model . generate ( ** inputs , max_length = 128 , do_sample = True )
print ( tokenizer . batch_decode ( outputs , skip_special_tokens = True ))