# Örnekler

[`examples/`](https://github.com/huggingface/trl/tree/main/examples) dizini, TRL kütüphanesinin çeşitli uygulamalarda nasıl kullanılacağını gösteren, kendi içinde tamamlanmış örneklerin bir koleksiyonunu içerir. **Her örnek, gösterdiği yöntem ve görevle adlandırılmış kendi klasöründe bulunur** (ör. `grpo_wordle`, `sft_gpt_oss_chess`) ve örneğin ihtiyaç duyduğu her şeyi barındırır: betikler, defterler, istemler, sohbet şablonları ve değerlendirme kodu.

Temel tek-eğitmen eğitim betikleri örnekler değildir; [`trl/scripts`](https://github.com/huggingface/trl/tree/main/trl/scripts) içinde yer alır ve [komut satırı arayüzü](clis) (`trl sft`, `trl dpo`, `trl grpo`, …) üzerinden erişilebilir. Her eğitmenin dokümantasyon sayfası ayrıca tam olarak çalıştırılabilir bir kod parçası içerir.

Ortak kaynaklar `examples/` kökünde yer alır:

- [`examples/deepspeed_configs`](https://github.com/huggingface/trl/tree/main/examples/deepspeed_configs): `--deepspeed` ile geçirilen, birçok örnekte kullanılan DeepSpeed ZeRO yapılandırma dosyaları.
- [`examples/fsdp_configs`](https://github.com/huggingface/trl/tree/main/examples/fsdp_configs): FSDP yapılandırma dosyaları, `--fsdp --fsdp_config` ile geçirilir (komut satırında yalnızca `--fsdp` kullanmak için transformers 5.10 veya daha yeni bir sürüm gereklidir; eski sürümlerde eğitim yapılandırmasında `fsdp=True` olarak ayarlayın).
- [`examples/datasets`](https://github.com/huggingface/trl/tree/main/examples/datasets): örneklerde kullanılan `trl-lib` veri setlerini oluşturmak için kullanılan betikler.

**Yeniden Başlamak**

TRL ve ek bağımlılıkları aşağıdaki gibi yükleyin:

```bash
pip install --upgrade trl[quantization]
```

Ek isteğe bağlı bağımlılıkları [burada](https://github.com/huggingface/trl/blob/main/pyproject.toml) kontrol edin. Notebook tabanlı örnekler kendi kendine yeterlidir ve **ücretsiz Colab** üzerinde çalıştırılabilir; betik tabanlı örnekler ise tek GPU, çoklu GPU veya DeepSpeed kurulumlarında çalışır (aşağıdaki [Distributed Training](#distributed-training) bölümüne bakın).

## İçindekiler

| Örnek | Açıklama | Colab'da Aç |
| --- | --- | --- |
| [`async_distillation_math`](https://github.com/huggingface/trl/tree/main/examples/async_distillation_math) | GSM8K üzerinde [experimental.async_distillation.AsyncDistillationTrainer](/docs/trl/v1.18.2/tr/async_distillation_trainer#trl.experimental.async_distillation.AsyncDistillationTrainer) ile asenkron on-policy distillation: öğretmen, vLLM üzerinden HTTP ile sunulur. | |
| [`async_distillation_mopd`](https://github.com/huggingface/trl/tree/main/examples/async_distillation_mopd) | [experimental.async_distillation.AsyncDistillationTrainer](/docs/trl/v1.18.2/tr/async_distillation_trainer#trl.experimental.async_distillation.AsyncDistillationTrainer) ile çoklu öğretmenli on-policy distillation (MOPD): Open-MOPD'nin matematik, kod ve talimat takibi uzmanlarını SFT checkpoint'lerine birleştirir: 60 adımda AIME24'te 17,5'ten 24,2'ye ve IFEval'de 67,5'ten 73,0'a yükselme (script, Hugging Face Jobs launcher ve sonuçlarla README). | |
| [`async_grpo_harbor`](https://github.com/huggingface/trl/tree/main/examples/async_grpo_harbor) | [OpenEnv](openenv) üzerinden sunulan herhangi bir yüklü kodlama ajanı (`mini-swe-agent`, `opencode`, `claude-code`, ...) ile [Harbor](https://huggingface.co/docs/openenv/environments/harbor) görev setinde AsyncGRPO eğitimi: ajan, kum havuzunda kendi döngüsüne sahipken TRL, yakalama vekili tarafından kaydedilen token kimlikleri ve logprobs üzerinde eğitim yapar. | |
| [`async_grpo_math`](https://github.com/huggingface/trl/tree/main/examples/async_grpo_math) | GSM8K üzerinde [AsyncGRPOTrainer](/docs/trl/v1.18.2/tr/async_grpo_trainer#trl.AsyncGRPOTrainer) ile asenkron GRPO, üretimi (vLLM sunucusu) eğitimden ayırır ve yalnızca adaptörü vLLM sunucusuna senkronize eden bir LoRA varyantını içerir. | |
| [`dpo_reduce_hallucinations`](https://github.com/huggingface/trl/tree/main/examples/dpo_reduce_hallucinations) | [openbmb/RLAIF-V-Dataset](https://huggingface.co/datasets/openbmb/RLAIF-V-Dataset) veri setini kullanarak bir Görüntü Dil Modelinin DPO ile ince ayarını yapıp halüsinasyonları azaltma. | |
| [`gold_chatbot_arena`](https://github.com/huggingface/trl/tree/main/examples/gold_chatbot_arena) | Qwen2 öğretmeninden Llama 3.2 öğrencisine [experimental.gold.GOLDTrainer](/docs/trl/v1.18.2/tr/gold_trainer#trl.experimental.gold.GOLDTrainer) ile chatbot_arena_completions üzerinde çapraz tokenleştirici (cross-tokenizer) General Online Logit Distillation (GOLD), tam eğitim ve LoRA varyantlarıyla. | |
| [`gold_qwen3_vl`](https://github.com/huggingface/trl/tree/main/examples/gold_qwen3_vl) | Qwen3-VL-8B'nin [experimental.gold.GOLDTrainer](/docs/trl/v1.18.2/tr/gold_trainer#trl.experimental.gold.GOLDTrainer) ile daha küçük VLM öğrencilerine Genel Çevrimiçi Logit Distilleme (GOLD) yöntemiyle aktarımı; aynı aileden (JSD kaybı) ve farklı aileden (ULD kaybı) distillemeyi kapsar. | |
| [`grpo_2048`](https://github.com/huggingface/trl/tree/main/examples/grpo_2048) | Bir modelin 2048 oyununu oynamasını öğretmek için araç çağrısı ile GRPO. | |
| [`grpo_browsergym`](https://github.com/huggingface/trl/tree/main/examples/grpo_browsergym) | LLM ve VLM varyantlarıyla, BrowserGym [OpenEnv](openenv) ortamında GRPO. | |
| [`grpo_carla`](https://github.com/huggingface/trl/tree/main/examples/grpo_carla) | CARLA otonom sürüş [OpenEnv](openenv) ortamı ile GRPO, LLM ve VLM varyantları (çok modlu kamera görüntüsü araç yanıtları). | |
| [`grpo_catch`](https://github.com/huggingface/trl/tree/main/examples/grpo_catch) | GRPO, [OpenEnv](openenv) ortamı ile (OpenSpiel). | |
| [`grpo_continuous_batching`](https://github.com/huggingface/trl/tree/main/examples/grpo_continuous_batching) | Değişken tamamlama uzunluklarına sahip büyük partilerde daha hızlı üretim için transformers'ın sürekli toplama (continuous batching) motoruyla GRPO. | |
| [`grpo_echo`](https://github.com/huggingface/trl/tree/main/examples/grpo_echo) | Echo [OpenEnv](openenv) ortamında minimal GRPO eğitimi. | |
| [`grpo_harbor`](https://github.com/huggingface/trl/tree/main/examples/grpo_harbor) | Takılabilir bir temel ajan (`bash` / `jupyter` / `terminal_notes` iskeletleri) ile Harbor görev setine karşı GRPO eğitimi. [Harbor Entegrasyonu](harbor) kılavuzuna bakın. | |
| [`grpo_ministral3_vl`](https://github.com/huggingface/trl/tree/main/examples/grpo_ministral3_vl) | Ücretsiz Colab'da QLoRA ile GRPO Ministral 3. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/grpo_ministral3_vl/grpo_ministral3_vl.ipynb) |
| [`grpo_multi_env`](https://github.com/huggingface/trl/tree/main/examples/grpo_multi_env) | Çoklu ortam GRPO eğitimi: Wordle + Catch [OpenEnv](openenv) ortamlarını aynı eğitim çalışmasında kullanın. | |
| [`grpo_qlora`](https://github.com/huggingface/trl/tree/main/examples/grpo_qlora) | Ücretsiz Colab'da QLoRA ile GRPO. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/grpo_qlora/grpo_qlora.ipynb) |
| [`grpo_qwen3_vl`](https://github.com/huggingface/trl/tree/main/examples/grpo_qwen3_vl) | Ücretsiz Colab'da QLoRA ile GRPO Qwen3-VL. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/grpo_qwen3_vl/grpo_qwen3_vl.ipynb) |
| [`grpo_rnj_1_instruct`](https://github.com/huggingface/trl/tree/main/examples/grpo_rnj_1_instruct) | rnj-1-instruct üzerinde Colab'da QLoRA ile GRPO çalıştırarak akıl yürütme yetenekleri eklemek. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/grpo_rnj_1_instruct/grpo_rnj_1_instruct.ipynb) |
| [`grpo_seta`](https://github.com/huggingface/trl/tree/main/examples/grpo_seta) | Açık kaynaklı openreward.ai kataloğundaki SETA ORS ortamına karşı GRPO eğitimi. [OpenReward Entegrasyonu](openreward) kılavuzuna bakın. | |
| [`grpo_sql_agent`](https://github.com/huggingface/trl/tree/main/examples/grpo_sql_agent) | Bir SQL veritabanını sorgulayarak soruları yanıtlayan bir ajan eğitmek için GRPO (betik ve defter; OOM nedeniyle ücretsiz Colab'da çalıştırılamaz). | |
| [`grpo_sudoku`](https://github.com/huggingface/trl/tree/main/examples/grpo_sudoku) | Bir [OpenEnv](openenv) ortamında, SFT modelinden başlayarak Sudoku (TextArena) oynamak için GRPO: 26 boş hücrede temel, SFT ve SFT + GRPO modelleri sırasıyla 30 bulmacanın 0, 10 ve 22'sini çözdü (sonuçlarla birlikte script, notebook ve README). | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/grpo_sudoku/grpo_sudoku.ipynb) |
| [`grpo_visual_math`](https://github.com/huggingface/trl/tree/main/examples/grpo_visual_math) | [lmms-lab/multimodal-open-r1-8k-verified](https://huggingface.co/datasets/lmms-lab/multimodal-open-r1-8k-verified) veri setini kullanarak akıl yürütme için çok modlu bir modelin GRPO ile ince ayarı. | |
| [`grpo_wordle`](https://github.com/huggingface/trl/tree/main/examples/grpo_wordle) | Bir [OpenEnv](openenv) ortamında Wordle (TextArena) oynamak için GRPO (betik ve defter). | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/grpo_wordle/grpo_wordle.ipynb) |
| [`gspo_math`](https://github.com/huggingface/trl/tree/main/examples/gspo_math) | [AI-MO/NuminaMath-TIR](https://huggingface.co/datasets/AI-MO/NuminaMath-TIR) veri setinde matematiksel akıl yürütme için [GRPOTrainer](/docs/trl/v1.18.2/tr/grpo_trainer#trl.GRPOTrainer) ile GSPO. | |
| [`gspo_visual_math`](https://github.com/huggingface/trl/tree/main/examples/gspo_visual_math) | GSPO, [GRPOTrainer](/docs/trl/v1.18.2/tr/grpo_trainer#trl.GRPOTrainer) ile [lmms-lab/multimodal-open-r1-8k-verified](https://huggingface.co/datasets/lmms-lab/multimodal-open-r1-8k-verified) veri setini kullanarak akıl yürütme için çok modlu bir modelin ince ayarını yapmak. | |
| [`lfm2_5_moe_research_agent`](https://github.com/huggingface/trl/tree/main/examples/lfm2_5_moe_research_agent) | LiquidAI/LFM2.5-8B-A1B iki adımda: tek bir 8xH100 düğümünde, yüklenme sırasında transformers'ın `DistributedConfig` ile bölünmüş (token yönlendirmeli uzman paralelliği ve FSDP) xLAM fonksiyon çağrısı üzerinde [SFTTrainer](/docs/trl/v1.18.2/tr/sft_trainer#trl.SFTTrainer) ile tam SFT, ardından HotpotQA üzerinde [GRPOTrainer](/docs/trl/v1.18.2/tr/grpo_trainer#trl.GRPOTrainer) ve `environment_factory` (`search` / `read` araçları, tam eşleşme ödülü) ile çok turlu bir araştırma ajanının GRPO'su. | |
| [`mpo_visual_preferences`](https://github.com/huggingface/trl/tree/main/examples/mpo_visual_preferences) | [DPOTrainer](/docs/trl/v1.18.2/tr/dpo_trainer#trl.DPOTrainer) ile MPO, [HuggingFaceH4/rlaif-v_formatted](https://huggingface.co/datasets/HuggingFaceH4/rlaif-v_formatted) veri setini ve bir dizi kayıp ağırlığını kullanarak çok modlu bir modeli tercihler temelinde hizalamak için kullanılır. | |
| [`online_dpo_visual_math`](https://github.com/huggingface/trl/tree/main/examples/online_dpo_visual_math) | Bir Görsel Dil Modelinin [experimental.online_dpo.OnlineDPOTrainer](/docs/trl/v1.18.2/tr/online_dpo_trainer#trl.experimental.online_dpo.OnlineDPOTrainer) ile çevrimiçi DPO ince ayarı. | |
| [`rloo_math`](https://github.com/huggingface/trl/tree/main/examples/rloo_math) | vLLM ile [AI-MO/NuminaMath-TIR](https://huggingface.co/datasets/AI-MO/NuminaMath-TIR) veri setinde matematiksel akıl yürütme için [RLOOTrainer](/docs/trl/v1.18.2/tr/rloo_trainer#trl.RLOOTrainer) ile RLOO. | |
| [`rloo_visual_math`](https://github.com/huggingface/trl/tree/main/examples/rloo_visual_math) | [lmms-lab/multimodal-open-r1-8k-verified](https://huggingface.co/datasets/lmms-lab/multimodal-open-r1-8k-verified) veri setini kullanarak akıl yürütme için çok modlu bir modelin RLOO ile ince ayarı. | |
| [`sdft_privileged_context`](https://github.com/huggingface/trl/tree/main/examples/sdft_privileged_context) | [experimental.sdft.SDFTTrainer](/docs/trl/v1.18.2/tr/sdft_trainer#trl.experimental.sdft.SDFTTrainer) ile öz-distilasyon ince ayarı, ayrıcalıklı (sadece öğretmen) bağlamı modele damıtma. | |
| [`sdpo_math`](https://github.com/huggingface/trl/tree/main/examples/sdpo_math) | Doğrulanabilir matematik ödülleri ve [openai/gsm8k](https://huggingface.co/datasets/openai/gsm8k) üzerinde isteğe bağlı ortam geri bildirimi kullanarak [experimental.sdpo.SDPOTrainer](/docs/trl/v1.18.2/tr/sdpo_trainer#trl.experimental.sdpo.SDPOTrainer) ile SDPO. | |
| [`sft_agent_traces`](https://github.com/huggingface/trl/tree/main/examples/sft_agent_traces) | Qwen3.5-2B'nin ajan izleri üzerinde SFT'si: Qwen3.5-397B-A17B, Hugging Face Sandboxes içinde bir OpenCode ajanı olarak veri analizi [Harbor](harbor) görevlerini çözer; süreç [OpenEnv](openenv) tarafından kaydedilir ve öğrenci model, yalnızca asistan kayıplarıyla (assistant-only loss) çözülmüş konuşmalar üzerinde eğitilir. Verilerine hiçbir izin dokunmadığı görevlerde, yaklaşık 500 iz, performansı %7,6'dan %33,3'e çıkarır (rollout, veri seti ve eğitim betikleri ile sonuçları içeren README). | |
| [`sft_beam`](https://github.com/huggingface/trl/tree/main/examples/sft_beam) | [SFTTrainer](/docs/trl/v1.18.2/tr/sft_trainer#trl.SFTTrainer) ile tek bir 8xB300 düğümünde reflection/Beam-1.0-501B-A23B için LoRA SFT, yüklenme sırasında transformers'ın `DistributedConfig` ile parçalanmış (token dağıtımı ile uzman paralelliği). | |
| [`sft_diffusion_gemma`](https://github.com/huggingface/trl/tree/main/examples/sft_diffusion_gemma) | [SFTTrainer](/docs/trl/v1.18.2/tr/sft_trainer#trl.SFTTrainer)'ı blok-difüzyon hedefiyle genişleterek DiffusionGemma blok-difüzyon dil modelinin GSM8K üzerinde SFT'si. | |
| [`sft_gemma3`](https://github.com/huggingface/trl/tree/main/examples/sft_gemma3) | Codeforces COTS veri setinde Gemma 3'ün SFT'si. | |
| [`sft_gemma3_vision`](https://github.com/huggingface/trl/tree/main/examples/sft_gemma3_vision) | Gemma 3'ün görüden metne görevlerinde SFT'si. | |
| [`sft_gpt_oss_chess`](https://github.com/huggingface/trl/tree/main/examples/sft_gpt_oss_chess) | openai/gpt-oss-20b modelinin satranç bulmacaları üzerinde [SFTTrainer](/docs/trl/v1.18.2/tr/sft_trainer#trl.SFTTrainer) ile tam ince ayarı: TRL, MXFP4 uzmanlarını dekuantize edilmiş olarak yükler ve ince ayarı yapılan uzmanlar, orijinal gibi sunulmak üzere tekrar MXFP4'e kuantize edilir. | |
| [`sft_ministral3_vl`](https://github.com/huggingface/trl/tree/main/examples/sft_ministral3_vl) | Ücretsiz Colab üzerinde QLoRA ile SFT Ministral 3. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/sft_ministral3_vl/sft_ministral3_vl.ipynb) |
| [`sft_mistral_large_4`](https://github.com/huggingface/trl/tree/main/examples/sft_mistral_large_4) | 8xB300 düğümünde, FP8 ağırlıklarının üzerine, yüklenme sırasında transformers'ın `DistributedConfig` ile parçalanan (token yönlendirmeli uzman paralelliği) [SFTTrainer](/docs/trl/v1.18.2/tr/sft_trainer#trl.SFTTrainer) ile mistralai/Mistral-Large-4-1T-A52B'nin LoRA SFT'si. | |
| [`sft_nemotron_3`](https://github.com/huggingface/trl/tree/main/examples/sft_nemotron_3) | NVIDIA Nemotron 3 modellerinin SFT'si (betik ve LoRA defter). | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/sft_nemotron_3/sft_nemotron_3.ipynb) |
| [`sft_qlora`](https://github.com/huggingface/trl/tree/main/examples/sft_qlora) | Ücretsiz Colab'da QLoRA ile SFT. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/sft_qlora/sft_qlora.ipynb) |
| [`sft_qwen3_8b_1m_context`](https://github.com/huggingface/trl/tree/main/examples/sft_qwen3_8b_1m_context) | 8xH100'lu tek bir düğümde, bağlam paralelliği ile 1.048.576 jetonluk diziler üzerinde Qwen3-8B'nin SFT'si. | |
| [`sft_qwen3_vl`](https://github.com/huggingface/trl/tree/main/examples/sft_qwen3_vl) | Ücretsiz Colab'da QLoRA ile SFT Qwen3-VL. | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/sft_qwen3_vl/sft_qwen3_vl.ipynb) |
| [`tail_sft_gsm8k`](https://github.com/huggingface/trl/tree/main/examples/tail_sft_gsm8k) | Başlangıç politikası kaybı filtreleme ile [SFTTrainer](/docs/trl/v1.18.2/tr/sft_trainer#trl.SFTTrainer)'ı genişleterek GSM8K üzerinde TailSFT. | |
| [`sft_muse_spark_open`](https://github.com/huggingface/trl/tree/main/examples/sft_muse_spark_open) | meta-models/Muse-Spark-Open-816B-A42B modelinin 8 düğüm üzerinde [SFTTrainer](/docs/trl/v1.18.2/tr/sft_trainer#trl.SFTTrainer) ile LoRA SFT'si, yüklenme sırasında transformers'ın `DistributedConfig` ile parçalanır (token dağıtımı ile uzman paralelliği). | |
| [`sft_tool_calling`](https://github.com/huggingface/trl/tree/main/examples/sft_tool_calling) | QLoRA ile SFT kullanarak yerleşik araç çağırma desteği olmayan bir modele araç çağırma öğretme (betik, sohbet şablonu ve defter). | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/huggingface/trl/blob/main/examples/sft_tool_calling/sft_tool_calling.ipynb) |
| [`sft_visual_chat`](https://github.com/huggingface/trl/tree/main/examples/sft_visual_chat) | Bir sohbet ortamında Görsel Dil Modelinin SFT'si. Yalnızca [LLaVA 1.5](https://huggingface.co/llava-hf/llava-1.5-7b-hf), [LLaVA 1.6](https://huggingface.co/llava-hf/llava-v1.6-mistral-7b-hf) ve [Llama-3.2-11B-Vision-Instruct](https://huggingface.co/meta-llama/Llama-3.2-11B-Vision-Instruct) ile test edildi; kullanıcılar diğer model mimarilerinde beklenmedik davranışlarla karşılaşabilir. | |
| [`xtoken`](https://github.com/huggingface/trl/tree/main/examples/xtoken) | [experimental.gold.GOLDTrainer](/docs/trl/v1.18.2/tr/gold_trainer#trl.experimental.gold.GOLDTrainer) ile X-Token off-policy cross-tokenizer bilgi damıtması, projeksiyon matrisi hazırlığı dahil. | |

## Dağıtık Eğitim

Örnek betikleri, torchrun ile birden çok GPU üzerinde çalıştırabilirsiniz:

```shell
torchrun --nproc_per_node {NUM_GPUS} path_to_script.py --all_arguments_of_the_script
```

DeepSpeed ZeRO-{1,2,3} için:

```shell
torchrun --nproc_per_node {NUM_GPUS} path_to_script.py --deepspeed examples/deepspeed_configs/zero{1,2,3}.json --all_arguments_of_the_script
```

Gerektiği gibi `NUM_GPUS` ve `--all_arguments_of_the_script` değerlerini ayarlayın.

