> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-de/vergleiche/finetuning-comparison.md).

# Vergleich von Fine-Tuning-Tools

Wählen Sie das richtige Fine-Tuning-Framework für das Training von LLMs auf Clore.ai-GPU-Servern.

{% hint style="info" %}
**Feinabstimmung** passt ein vortrainiertes LLM an Ihre spezifische Aufgabe oder Domäne an. Dieser Leitfaden vergleicht die vier führenden Open-Source-Tools: Unsloth, Axolotl, LLaMA-Factory und TRL — und behandelt Geschwindigkeit, Speichereffizienz, unterstützte Modelle und Benutzerfreundlichkeit.
{% endhint %}

***

## Schnelle Entscheidungsübersicht

|                                  | Unsloth                                         | Axolotl                            | LLaMA-Factory      | TRL              |
| -------------------------------- | ----------------------------------------------- | ---------------------------------- | ------------------ | ---------------- |
| **Am besten für**                | Geschwindigkeit + Speicher                      | Konfigurationsgesteuertes Training | Anfängerfreundlich | Forschung + RLHF |
| **Geschwindigkeit vs. Baseline** | 2–5× schneller                                  | \~1× (Standard)                    | \~1× (Standard)    | \~1× (Standard)  |
| **Speicherreduzierung**          | 70–80 % weniger                                 | QLoRA-Standard                     | QLoRA-Standard     | Standard         |
| **RLHF/DPO/PPO**                 | Einfach                                         | ✅                                  | ✅                  | ✅ (nativ)        |
| **WebUI**                        | ❌                                               | ❌                                  | ✅                  | ❌                |
| **GitHub-Stars**                 | 23K+                                            | 9K+                                | 37K+               | 10K+             |
| **Lizenz**                       | LGPL (kostenlos für nicht-kommerzielle Nutzung) | Apache 2.0                         | Apache 2.0         | Apache 2.0       |

***

## Überblick

### Unsloth

Unsloth konzentriert sich laserfokussiert auf eines: Fine-Tuning so schnell und speichereffizient wie möglich zu machen. Es schreibt zentrale Operationen in Triton neu und optimiert CUDA-Kerne.

**Philosophie**: Maximale Geschwindigkeit, minimale VRAM-Nutzung — keine Kompromisse.

```python
from unsloth import FastLanguageModel
import torch

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="unsloth/Llama-3.2-8B-Instruct",
    max_seq_length=2048,
    load_in_4bit=True,  # 4-Bit-Quantisierung
)

model = FastLanguageModel.get_peft_model(
    model,
    r=16,              # LoRA-Rang
    target_modules=["q_proj", "k_proj", "v_proj", "up_proj", "down_proj"],
    lora_alpha=16,
    lora_dropout=0,
    bias="none",
    use_gradient_checkpointing="unsloth",  # ~30 % größere Batchgröße
    random_state=42,
)
```

### Axolotl

Axolotl verpackt Hugging Face Transformers mit einem YAML-basierten Konfigurationssystem. Es übernimmt die Komplexität des Trainings-Setups, damit Sie sich auf Daten und Hyperparameter konzentrieren können.

**Philosophie**: Alles in YAML, darunter volle Flexibilität.

```yaml
# config.yml
base_model: meta-llama/Meta-Llama-3-8B
model_type: LlamaForCausalLM
tokenizer_type: AutoTokenizer

datasets:
  - path: mhenrichsen/alpaca_data_cleaned
    type: alpaca

load_in_4bit: true
adapter: qlora

lora_r: 32
lora_alpha: 16
lora_target_modules:
  - q_proj
  - k_proj
  - v_proj
  - o_proj

num_epochs: 3
micro_batch_size: 2
gradient_accumulation_steps: 4
learning_rate: 2e-4
```

### LLaMA-Factory

LLaMA-Factory unterstützt die größte Bandbreite an Modellen (100+) und Trainingsmethoden, mit einer WebUI zur Konfiguration. Es ist die zugänglichste Option für Nicht-Forschende.

**Philosophie**: Alles funktioniert, für alle.

```bash
# Training über die Kommandozeile
llamafactory-cli train \
  --model_name_or_path meta-llama/Meta-Llama-3-8B \
  --stage sft \
  --do_train \
  --dataset alpaca_gpt4_en \
  --template llama3 \
  --finetuning_type lora \\
  --lora_rank 8 \
  --output_dir saves/llama3-8b-lora \
  --num_train_epochs 3.0 \
  --per_device_train_batch_size 2

# Oder WebUI verwenden
llamafactory-cli webui
```

### TRL (Transformer Reinforcement Learning)

TRL ist Hugging Faces offizielle RLHF-Bibliothek. Sie ist der Standard für PPO, DPO, ORPO und andere Alignment-Trainingsmethoden.

**Philosophie**: Forschungsorientiert, Alignment-Training nativ.

```python
from trl import SFTTrainer, SFTConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
from datasets import load_dataset

model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B")

training_args = SFTConfig(
    output_dir="./results",
    num_train_epochs=3,
    per_device_train_batch_size=2,
    gradient_accumulation_steps=4,
    learning_rate=2e-4,
    logging_steps=10,
)

trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    args=training_args,
    train_dataset=load_dataset("tatsu-lab/alpaca", split="train"),
)

trainer.train()
```

***

## Geschwindigkeits-Benchmarks

### Trainingsgeschwindigkeitsvergleich (Token/Sekunde)

Testaufbau: LLaMA 3.1 8B, LoRA r=16, 4-Bit-Quantisierung, Batchgröße 4, A100 80 GB

| Werkzeug                       | Tokens/Sek. | vs. Baseline | Speicher (VRAM) |
| ------------------------------ | ----------- | ------------ | --------------- |
| Unsloth (4-Bit)                | \~4,200     | **2,8×**     | \~8 GB          |
| Axolotl (QLoRA)                | \~1,500     | 1,0×         | \~16GB          |
| LLaMA-Factory (QLoRA)          | \~1,480     | \~1,0×       | \~16GB          |
| TRL (QLoRA)                    | \~1,450     | \~0,97×      | \~18 GB         |
| Unsloth (vollständiges 16-Bit) | \~2,800     | **1,9×**     | \~22GB          |

{% hint style="success" %}
**Der Vorteil von Unsloth ist real**: Die 2–5×-Geschwindigkeit kommt von benutzerdefinierten Triton-Kernels für Attention, Cross-Entropy, RoPE und LoRA. Nicht nur Marketing.
{% endhint %}

### Vergleich der VRAM-Nutzung

Training von LLaMA 3.1 8B, Sequenzlänge 2048:

| Methode                          | Unsloth  | Axolotl | LLaMA-Factory | TRL   |
| -------------------------------- | -------- | ------- | ------------- | ----- |
| Vollständiges Fine-Tuning (bf16) | 60 GB    | 70GB    | 72GB          | 74 GB |
| LoRA (bf16)                      | 18 GB    | 24 GB   | 25 GB         | 26GB  |
| QLoRA (4-Bit)                    | **8 GB** | 16 GB   | 16 GB         | 18 GB |
| QLoRA (4-Bit, langer Kontext)    | 12 GB    | 24 GB   | 24 GB         | 26GB  |

**Minimale GPU für 8B-Modell**:

* Unsloth: RTX 3080 (10 GB) ✅
* Andere: RTX 3090 (24 GB) erforderlich

***

## Unterstützte Modelle

### Modell-Unterstützungsmatrix

| Modellfamilie | Unsloth   | Axolotl   | LLaMA-Factory | TRL |
| ------------- | --------- | --------- | ------------- | --- |
| LLaMA 3.x     | ✅         | ✅         | ✅             | ✅   |
| LLaMA 2       | ✅         | ✅         | ✅             | ✅   |
| Mistral       | ✅         | ✅         | ✅             | ✅   |
| Mixtral MoE   | ✅         | ✅         | ✅             | ✅   |
| Gemma 2       | ✅         | ✅         | ✅             | ✅   |
| Phi-3/3.5     | ✅         | ✅         | ✅             | ✅   |
| Qwen 2.5      | ✅         | ✅         | ✅             | ✅   |
| DeepSeek      | ✅         | ✅         | ✅             | ✅   |
| Falcon        | ✅         | ✅         | ✅             | ✅   |
| GPT-NeoX      | Teilweise | ✅         | ✅             | ✅   |
| T5/FLAN       | ❌         | ✅         | ✅             | ✅   |
| BERT/RoBERTa  | ❌         | ✅         | ✅             | ✅   |
| Vision-LLMs   | Teilweise | Teilweise | ✅             | ✅   |

### Unterstützung für Trainingsmethoden

| Methode                         | Unsloth | Axolotl | LLaMA-Factory | TRL       |
| ------------------------------- | ------- | ------- | ------------- | --------- |
| Vollständige Feinabstimmung     | ✅       | ✅       | ✅             | ✅         |
| LoRA                            | ✅       | ✅       | ✅             | ✅         |
| QLoRA                           | ✅       | ✅       | ✅             | ✅         |
| DoRA                            | ✅       | ✅       | ✅             | ❌         |
| PEFT                            | ✅       | ✅       | ✅             | ✅         |
| SFT                             | ✅       | ✅       | ✅             | ✅ (nativ) |
| DPO                             | ✅       | ✅       | ✅             | ✅ (nativ) |
| PPO                             | ❌       | ✅       | ✅             | ✅ (nativ) |
| ORPO                            | ✅       | ✅       | ✅             | ✅         |
| KTO                             | ❌       | ✅       | ✅             | ✅ (nativ) |
| GRPO                            | ✅       | ❌       | ✅             | ✅         |
| CPT (fortgesetztes Pretraining) | ✅       | ✅       | ✅             | ✅         |

***

## Unsloth: Tiefer Einblick

### Was es schnell macht

1. **Triton-Kerne**: Schreibt Flash Attention, Cross-Entropy-Loss und LoRA in Triton neu
2. **Verschmolzene Operationen**: Kombiniert mehrere CUDA-Operationen zu einem Kernel
3. **Intelligentes Gradient Checkpointing**: Der Modus "unsloth" spart \~30 % mehr Speicher
4. **Effiziente Backprop**: Vermeidet das Materialisieren großer Zwischen-Tensoren

### Installation auf Clore.ai

```bash
# CUDA 12.8
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --no-deps trl peft accelerate bitsandbytes

# Oder mit conda
conda create --name unsloth_env python=3.11
conda activate unsloth_env
conda install pytorch-cuda=12.1 pytorch cudatoolkit xformers -c pytorch -c nvidia -c xformers -y
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --no-deps trl peft accelerate bitsandbytes
```

### Vollständiges Trainingsskript

```python
from unsloth import FastLanguageModel
from trl import SFTTrainer
from transformers import TrainingArguments
from datasets import load_dataset
import torch

# 1. Modell mit Unsloth-Optimierung laden
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="unsloth/Meta-Llama-3.1-8B-Instruct",
    max_seq_length=2048,
    dtype=None,        # Automatisch erkennen
    load_in_4bit=True,
)

# 2. LoRA-Adapter hinzufügen
model = FastLanguageModel.get_peft_model(
    model,
    r=16,
    target_modules=["q_proj", "k_proj", "v_proj", "o_proj",
                    "gate_proj", "up_proj", "down_proj"],
    lora_alpha=16,
    lora_dropout=0,
    bias="none",
    use_gradient_checkpointing="unsloth",
    random_state=3407,
)

# 3. Datensatz laden und formatieren
dataset = load_dataset("tatsu-lab/alpaca", split="train")

def format_prompt(example):
    return {"text": f"### Anweisung:\n{example['instruction']}\n\n### Antwort:\n{example['output']}"}

dataset = dataset.map(format_prompt)

# 4. Trainieren
trainer = SFTTrainer(
    model=model,
    tokenizer=tokenizer,
    train_dataset=dataset,
    dataset_text_field="text",
    max_seq_length=2048,
    args=TrainingArguments(
        per_device_train_batch_size=2,
        gradient_accumulation_steps=4,
        warmup_steps=5,
        num_train_epochs=1,
        learning_rate=2e-4,
        fp16=not torch.cuda.is_bf16_supported(),
        bf16=torch.cuda.is_bf16_supported(),
        logging_steps=1,
        optim="adamw_8bit",
        weight_decay=0.01,
        lr_scheduler_type="linear",
        seed=3407,
        output_dir="outputs",
    ),
)
trainer.train()

# 5. Speichern
model.save_pretrained("lora_model")
model.save_pretrained_gguf("model_gguf", tokenizer, quantization_method="q4_k_m")
```

**Schwächen**: Kein PPO, beschränkt auf unterstützte Modellliste, LGPL-Lizenz (für kommerzielle Nutzung prüfen)

***

## Axolotl: Tiefer Einblick

### Konfigurations-First-Ansatz

Axolotl glänzt, wenn Sie reproduzierbare, versionskontrollierte Trainingskonfigurationen wünschen:

```yaml
# axolotl_config.yml — vollständiges Beispiel
base_model: meta-llama/Meta-Llama-3-8B-Instruct
model_type: LlamaForCausalLM
tokenizer_type: AutoTokenizer

# Daten
datasets:
  - path: tatsu-lab/alpaca
    type: alpaca
  - path: ./my_custom_data.jsonl
    type: sharegpt
dataset_prepared_path: ./prepared_data
val_set_size: 0.01

# Quantisierung
load_in_4bit: true
adapter: qlora
bf16: true
tf32: true

# LoRA
lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_modules:
  - q_proj
  - v_proj
  - k_proj
  - o_proj
  - gate_proj
  - up_proj
  - down_proj

# Training
sequence_len: 4096
sample_packing: true  # Packt kurze Sequenzen zur Effizienz
pad_to_sequence_len: true
micro_batch_size: 2
gradient_accumulation_steps: 4
num_epochs: 3
learning_rate: 0.0002
optimizer: adamw_bnb_8bit
lr_scheduler: cosine

# Protokollierung
logging_steps: 10
eval_steps: 100
save_steps: 100
output_dir: ./outputs/my-model

# wandb
wandb_project: my-fine-tune
wandb_run_id: run-001
```

```bash
# Installieren und ausführen
pip install axolotl[flash-attn,deepspeed]
axolotl train axolotl_config.yml
```

**Am besten für**: Teams, die reproduzierbare, konfigurationsversionierte Trainingsläufe wollen

***

## LLaMA-Factory: Tiefer Einblick

### WebUI-Rundgang

```bash
# Installieren
pip install llamafactory

# WebUI starten
llamafactory-cli webui
# http://localhost:7860 öffnen
```

WebUI-Tabs:

1. **Train** — Basis-Modell, Datensatz, Methode konfigurieren
2. **Auswerten** — MMLU-, CMMLU-Benchmarks ausführen
3. **Chat** — interaktive Inferenz
4. **Exportieren** — LoRA zusammenführen, zu GGUF quantisieren

### CLI-Trainingsbeispiel

```bash
# Überwachtes Fine-Tuning
llamafactory-cli train \
  --stage sft \
  --model_name_or_path meta-llama/Meta-Llama-3-8B \
  --dataset alpaca_gpt4_en,glaive_toolcall_en \
  --template llama3 \
  --finetuning_type lora \\
  --lora_rank 8 \
  --lora_alpha 16 \
  --lora_target all \
  --output_dir saves/llama3-lora \
  --num_train_epochs 3 \
  --per_device_train_batch_size 2 \
  --gradient_accumulation_steps 4 \
  --learning_rate 2e-4 \
  --quantization_bit 4 \
  --flash_attn fa2

# DPO-Training
llamafactory-cli train \
  --stage dpo \
  --model_name_or_path meta-llama/Meta-Llama-3-8B \
  --dataset dpo_mix_en \
  --template llama3 \
  --finetuning_type lora \\
  --output_dir saves/llama3-dpo
```

**Am besten für**: Anfänger, Teams, die WebUI wollen, DPO/RLHF ohne tiefes Forschungswissen

***

## TRL: Tiefer Einblick

### Beispiel einer RLHF-Pipeline

TRL ist die erste Wahl für Alignment-Training:

```python
from trl import PPOTrainer, PPOConfig, AutoModelForCausalLMWithValueHead
from trl import DPOTrainer, DPOConfig
from datasets import load_dataset

# DPO (Direct Preference Optimization) — die gebräuchlichste Alignment-Methode
model_name = "meta-llama/Meta-Llama-3-8B-Instruct"

dpo_config = DPOConfig(
    model_name_or_path=model_name,
    output_dir="dpo_outputs",
    num_train_epochs=1,
    per_device_train_batch_size=2,
    beta=0.1,             # KL-Strafkoeffizient
    loss_type="sigmoid",  # oder "hinge", "ipo", "kto_pair"
    learning_rate=5e-7,
)

# Präferenzdatensatz laden (Prompt + ausgewählt + abgelehnt)
dataset = load_dataset("Anthropic/hh-rlhf", split="train")

trainer = DPOTrainer(
    model=model_name,
    args=dpo_config,
    train_dataset=dataset,
)
trainer.train()
```

**Am besten für**: Implementierungen für Alignment-Forschung, RLHF, DPO, PPO, ORPO

***

## Das richtige Tool wählen

### Entscheidungsfluss

```
Benötigen Sie maximale Geschwindigkeit/minimales VRAM?
  → JA → Unsloth (2–5× schneller, passt auf kleinere GPUs)

Benötigen Sie Alignment-Training (DPO/PPO/RLHF)?
  → JA → TRL oder LLaMA-Factory
  → Forschung/angepasst → TRL
  → Produktion/einfach → LLaMA-Factory

Benötigen Sie Konfigurationszuerst-Reproduzierbarkeit?
  → JA → Axolotl

Nicht-technisches Team oder WebUI gewünscht?
  → JA → LLaMA-Factory

Sie möchten einfach schnell anfangen?
  → LLaMA-Factory oder Unsloth
```

### Nach Teamtyp

| Team               | Empfehlung    | Grund                                   |
| ------------------ | ------------- | --------------------------------------- |
| Einzelner Forscher | Unsloth       | Geschwindigkeit + Jupyter-Notebooks     |
| ML-Ingenieur       | Axolotl       | Konfigurationsgetrieben, reproduzierbar |
| Produktteam        | LLaMA-Factory | WebUI, breite Modellunterstützung       |
| Alignment-Team     | TRL           | Native RLHF-Primitiven                  |
| Startup            | Unsloth + TRL | Geschwindigkeit + Alignment, wenn nötig |

***

## GPU-Empfehlungen für Clore.ai

{% hint style="warning" %}
**Multi-GPU-Rigs der 80GB-Klasse sind auf dem Clore.ai-Marktplatz nicht gelistet.** Die größten heute gelisteten Systeme sind 4× RTX PRO 6000 Blackwell (je 96 GB, 380 GB gesamt) und 8–11× RTX 5090 (je 32 GB). Kapazitäten für A100 / H200 / B200 werden als [Bare Metal](https://clore.ai/bare-metal) auf Anfrage verkauft. Prüfe [GPU-Preise & Verfügbarkeit](/guides/guides_v2-de/erste-schritte/pricing.md) bevor du eine Bereitstellung dimensionierst.
{% endhint %}

| Aufgabe             | Min. GPU         | Empfohlen     | Werkzeug        |
| ------------------- | ---------------- | ------------- | --------------- |
| 7–8B LoRA (QLoRA)   | RTX 3080 (10 GB) | RTX 3090      | Unsloth         |
| 13B LoRA            | RTX 3090 (24 GB) | A6000 (48 GB) | Unsloth/Axolotl |
| 70B LoRA            | A100 (80 GB)     | 2×A100        | Axolotl/TRL     |
| 8B vollständiges FT | A100 (40 GB)     | A100 (80 GB)  | Beliebig        |
| DPO/PPO 7B          | RTX 4090 (24 GB) | A6000 (48 GB) | TRL             |

***

## Nützliche Links

* [Unsloth GitHub](https://github.com/unslothai/unsloth) — 23K+ Sterne
* [Axolotl GitHub](https://github.com/axolotl-ai-cloud/axolotl) — 9K+ Sterne
* [LLaMA-Factory GitHub](https://github.com/hiyouga/LLaMA-Factory) — 37K+ Sterne
* [TRL GitHub](https://github.com/huggingface/trl) — 10K+ Sterne
* [Hugging Face PEFT-Dokumentation](https://huggingface.co/docs/peft)

***

## Zusammenfassung

| Werkzeug          | Am besten für                                    | Wichtigster Vorteil               |
| ----------------- | ------------------------------------------------ | --------------------------------- |
| **Unsloth**       | Geschwindigkeitskritisches Training, kleine GPUs | 2–5× schneller, 70 % weniger VRAM |
| **Axolotl**       | Konfigurationsgesteuerte, reproduzierbare Läufe  | YAML-zuerst, viele Datenformate   |
| **LLaMA-Factory** | 100+ Modelle, WebUI, Anfänger                    | Meiste Modellunterstützung, GUI   |
| **TRL**           | RLHF, DPO, Alignment-Forschung                   | Native Alignment-Trainings        |

Für die meisten Clore.ai-Anwendungsfälle: beginnen Sie mit **Unsloth** (Geschwindigkeit + Speichereffizienz), fügen Sie **TRL** hinzu, wenn Sie DPO- oder PPO-Alignment-Training benötigen.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/vergleiche/finetuning-comparison.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
