เทรนด้วย LoRA
คุณต้องการเริ่ม fine-tuning ด้วย RLHF แต่เจอข้อผิดพลาด out-of-memory อยู่เรื่อย แม้จะเปลี่ยนไปโหลดโมเดลในความแม่นยำ 8 บิตแล้ว ข้อผิดพลาดก็ยังคงเกิดขึ้น จึงตัดสินใจก้าวไปอีกขั้นด้วยการนำ LoRA มาใช้เพื่อให้การ fine-tuning มีประสิทธิภาพมากขึ้น
สิ่งต่อไปนี้ถูก import ไว้ล่วงหน้าแล้ว:
- โมเดลที่โหลดในความแม่นยำ 8 บิต ในชื่อ
pretrained_model_8bit LoraConfigและget_peft_modelจากpeftAutoModelForCausalLMWithValueHeadจากtrl
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Reinforcement Learning from Human Feedback (RLHF)
คำแนะนำการฝึกหัด
- กำหนดค่า LoRA dropout เป็น
0.1และตั้งประเภท bias ให้เป็นแบบ lora-only - เพิ่มการกำหนดค่า LoRA เข้าไปในโมเดล
- ตั้งค่าโมเดลพร้อม value head สำหรับการเทรนด้วย PPO
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Set the configuration parameters
config = LoraConfig(
r=32,
lora_alpha=32,
lora_dropout=____,
bias=____)
# Apply the LoRA configuration to the 8-bit model
lora_model = get_peft_model(pretrained_model_8bit, ____)
# Set up the tokenizer and model with a value head for PPO training
model = ____.from_pretrained(____)