o
    	Ti                  	   @   s@  d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
mZmZmZ edkreeee
fZe \ZZZejejejdZejejejdZejejejdZejdu rXeje_ejdu rdeee\ZZeejejdZe	eeeeej  ej!d	kr~eej" ndeeed
Z#e#$  e#%ej& ej're#j'ejd dS dS dS )a;  
Run the KTO training script with the commands below. In general, the optimal configuration for KTO will be similar to that of DPO.

# Full training:
python trl/scripts/kto.py     --dataset_name trl-lib/kto-mix-14k     --model_name_or_path=trl-lib/qwen1.5-1.8b-sft     --per_device_train_batch_size 16     --num_train_epochs 1     --learning_rate 5e-7     --lr_scheduler_type=cosine     --gradient_accumulation_steps 1     --eval_steps 500     --output_dir=kto-aligned-model     --warmup_ratio 0.1     --report_to wandb     --bf16     --logging_first_step

# QLoRA:
python trl/scripts/kto.py     --dataset_name trl-lib/kto-mix-14k     --model_name_or_path=trl-lib/qwen1.5-1.8b-sft     --per_device_train_batch_size 8     --num_train_epochs 1     --learning_rate 5e-7     --lr_scheduler_type=cosine     --gradient_accumulation_steps 1     --eval_steps 500     --output_dir=kto-aligned-model-lora     --warmup_ratio 0.1     --report_to wandb     --bf16     --logging_first_step     --use_peft     --load_in_4bit     --lora_target_modules=all-linear     --lora_r=16     --lora_alpha=16
    )load_dataset)AutoModelForCausalLMAutoTokenizerHfArgumentParser)	KTOConfig
KTOTrainerModelConfigScriptArgumentsget_peft_configsetup_chat_format__main__)trust_remote_codeN)nameno)argstrain_dataseteval_datasetprocessing_classpeft_config)dataset_name)(__doc__datasetsr   transformersr   r   r   trlr   r   r   r	   r
   r   __name__parserparse_args_into_dataclassesscript_argstraining_args
model_argsfrom_pretrainedmodel_name_or_pathr   model	ref_model	tokenizer	pad_token	eos_tokenchat_templater   dataset_configdatasetdataset_train_spliteval_strategydataset_test_splittrainertrain
save_model
output_dirpush_to_hub r2   r2   H/home/ubuntu/.local/lib/python3.10/site-packages/examples/scripts/kto.py<module>   sH   ) 


)