huggingface / trl

Train transformer language models with reinforcement learning.
http://hf.co/docs/trl
Apache License 2.0
10k stars 1.27k forks source link

Error in finetuning gemma #1346

Closed yoshitomo-matsubara closed 8 months ago

yoshitomo-matsubara commented 8 months ago

Thank you for demonstrating gemma fine-tuning! https://huggingface.co/blog/gemma

I was trying to run the script to fine-tune gemma, following the HF's blog post

but there are some parse errors

pip install -U transformers
pip install git+https://github.com/huggingface/trl
git clone https://github.com/huggingface/trl
cd trl

Same command as the blog post, but I needed to add --output_dir to the command to run the script

accelerate launch --config_file examples/accelerate_configs/multi_gpu.yaml --num_processes=1 \
    examples/scripts/sft.py \
    --model_name google/gemma-7b \
    --dataset_name OpenAssistant/oasst_top1_2023-08-25 \
    --batch_size 2 \
    --gradient_accumulation_steps 1 \
    --learning_rate 2e-4 \
    --save_steps 20_000 \
    --use_peft \
    --peft_lora_r 16 --peft_lora_alpha 32 \
    --target_modules q_proj k_proj v_proj o_proj \
    --load_in_4bit \
    --output_dir output/

Parser Error. Some of the arguments are not expected

Traceback (most recent call last):                                                                                                          
  File "/home/yoshitomo/workspace/trl/examples/scripts/sft.py", line 68, in <module>                                                        
    args, training_args, model_config = parser.parse_args_into_dataclasses()                                                                
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^              
  File "/home/yoshitomo/anaconda3/envs/gemma/lib/python3.12/site-packages/transformers/hf_argparser.py", line 347, in parse_args_into_datacl
asses                                                                 
    raise ValueError(f"Some specified arguments are not used by the HfArgumentParser: {remaining_args}")
ValueError: Some specified arguments are not used by the HfArgumentParser: ['--batch_size', '2', '--peft_lora_r', '16', '--peft_lora_alpha',
 '32', '--target_modules', 'q_proj', 'k_proj', 'v_proj', 'o_proj']

Am I missing something important to run the script or using a wrong version?

storuky commented 8 months ago

@yoshitomo-matsubara Yes, there were a lot of changes to arg names. You can check it out here In short:

batch_size => per_device_train_batch_size
peft_lora_r => lora_r
peft_lora_alpha => lora_alpha
target_modules => lora_target_modules
younesbelkada commented 8 months ago

Thanks everyone for reporting ! I just updated the instructions on the blogpost ! 🤗 Let me know if you face into more issues

yoshitomo-matsubara commented 8 months ago

Thank you for the quick fix!