flan alpaca lora
1.0.0
repo นี้ฝึกอบรม Google/Flan-T5 บนชุดข้อมูล Alpaca ด้วยวิธีการฝึกอบรมการปรับตัวต่ำ มันลดหน่วยความจำ GPU ที่จำเป็นและเร่งการฝึกอบรม
17 มิ.ย. 2023: เพิ่มสมุดบันทึก คุณสามารถลอง Flan-Alpaca-Lora ด้วยตอนนี้
3 พฤษภาคม 2023: รถไฟ FLAN-T5-XL โดยใช้ชุดข้อมูล AlpACA-GPT4
13 เม.ย. 2023: รถไฟ FLAN-T5-XL โดยใช้ชุดข้อมูล GPTEACHER (คำแนะนำและบทบาท) ซึ่งดูเหมือนว่าจะทำงานได้ดี
5 เม.ย. 2023: รถไฟ FLAN-T5-XXL โดยใช้ 8 บิตปริมาณ โมเดลสามารถติดตั้งเป็น 3090 GPU เดียว ทุกรุ่นสามารถพบได้ใน HuggingFace
| แบบอย่าง | Adapter_params | ข้อมูล | GPU | เวลา |
|---|---|---|---|---|
| Flan-Alpaca-Lora-base | 0.9m | ทำความสะอาด Alpaca | 3090 | 20 นาที |
| Flan-alpaca-lora-large | 2.4m | ทำความสะอาด Alpaca | 3090 | 50 นาที |
| Flan-alpaca-lora-xl | 4.7m | ทำความสะอาด Alpaca | 3090 | 2.5 ชั่วโมง |
| Flan-alpaca-lora-xxl | 9.4m | ทำความสะอาด Alpaca | 3090 | 10 ชั่วโมง |
| Flan-Gpteacher-Lora-xl | 4.7m | ผู้เข้าร่วม | 3090 | 80 นาที |
| Flan-Alpaca-GPT4-LORA-XL | 4.7m | Alpaca-GPT4 | 3090 | 3.25hrs |
torch == 1.13.1
transformers == 4.29.1
peft == 0.3.0
bitsandbytes==0.38.1
accelerate==0.19.0
แพ็คเกจรุ่นใหม่ล่าสุดควรทำงานได้ดี
คำสั่งต่อไปนี้ finetune flan-t5-base เพียง 20 นาทีใน 3090 gpu เดียว
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 ))