F
fine-tuning-with-trl
Fine-tune LLMs using reinforcement learning with TRL - SFT for instruction tuning, DPO for preference alignment, PPO/GRPO for reward optimization, and reward model training. Use when need RLHF, align model with preferences, or train from human feedback. Works with HuggingFace
Installation
Pick a client and clone the repository into its skills directory.
Installation
About this skill
Fine-tune LLMs using reinforcement learning with TRL - SFT for instruction tuning, DPO for preference alignment, PPO/GRPO for reward optimization, and reward model training. Use when need RLHF, align model with preferences, or train from human feedback. Works with HuggingFace Transformers.
How to use
- Zainstaluj wymagane pakiety: pip install trl transformers datasets peft accelerate. 2. Przygotuj swoje dane treningowe – dla SFT potrzebujesz par prompt-completion, dla DPO par chosen/rejected. 3. Załaduj model bazowy, np. Qwen/Qwen2.5-0.5B, używając AutoModelForCausalLM z biblioteki transformers. 4. Dla nadzorowanego dostrajania (SFT) utwórz SFTTrainer, przekaż model, dataset i uruchom trainer.train(). 5. Jeśli chcesz wyrównać model z preferencjami, użyj DPOTrainer z DPOConfig, ustaw preference_dataset z parami chosen/rejected i trenuj. 6. Po dostrojeniu ewaluuj model na testowych danych, aby sprawdzić jakość wyrównania z ludzkimi preferencjami.