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 ))