> 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/training/axolotl-training.md).

# Axolotl universelles Fine-Tuning

Axolotl fasst HuggingFace Transformers, PEFT, TRL und DeepSpeed in einer einzigen YAML-gesteuerten Schnittstelle zusammen. Sie definieren Ihr Modell, Dataset, die Trainingsmethode und Hyperparameter in einer Konfigurationsdatei — und starten dann mit einem einzigen Befehl. Für Standard-Workflows ist kein Python-Scripting erforderlich.

{% hint style="success" %}
Alle Beispiele laufen auf GPU-Servern, die über die [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

## Hauptmerkmale

* **Nur YAML-Konfiguration** — alles in einer Datei definieren, kein Python nötig
* **Alle Trainingsmethoden** — LoRA, QLoRA, vollständiges Fine-Tuning, DPO, ORPO, KTO, RLHF
* **Multi-GPU sofort einsatzbereit** — DeepSpeed ZeRO 1/2/3 und FSDP mit einer Option
* **Sample-Packing** — kurze Beispiele aneinandersetzen, um die Sequenzlänge zu füllen, 3–5× Durchsatzsteigerung
* **Flash Attention 2** — automatische VRAM-Einsparungen auf unterstützter Hardware
* **Breite Modellunterstützung** — Llama 3.x, Mistral, Qwen 2.5, Gemma 2, Phi-4, DeepSeek, Falcon
* **Eingebaute Datensatzformate** — alpaca, sharegpt, chat\_template, completion und benutzerdefiniert

## Anforderungen

| Komponente | Minimum        | Empfohlen            |
| ---------- | -------------- | -------------------- |
| GPU        | RTX 3060 12 GB | RTX 4090 24 GB (×2+) |
| VRAM       | 12 GB          | 24+ GB               |
| RAM        | 16 GB          | 64 GB                |
| Festplatte | 50 GB          | 100 GB               |
| CUDA       | 11.8           | 12.1+                |
| Python     | 3.10           | 3.11                 |

**Clore.ai-Preise:** RTX 4090 ≈ $0.5–2/Tag · RTX 3090 ≈ $0.3–1/Tag · RTX 3060 ≈ $0.15–0.3/Tag

## Schnellstart

### 1. Axolotl installieren

```bash
# Klonen und installieren
git clone https://github.com/OpenAccess-AI-Collective/axolotl.git
cd axolotl

pip install packaging ninja
pip install -e '.[flash-attn,deepspeed]'
```

Oder verwenden Sie das Docker-Image (für Reproduzierbarkeit empfohlen):

```bash
docker run --gpus all -it --rm \
  -v /workspace:/workspace \
  winglian/axolotl:main-latest
```

### 2. Eine Konfigurationsdatei erstellen

Speichern Sie dies als `config.yml`:

```yaml
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
model_type: LlamaForCausalLM
tokenizer_type: AutoTokenizer

load_in_4bit: true
adapter: qlora
lora_r: 32
lora_alpha: 16
lora_dropout: 0.05
lora_target_linear: true

datasets:
  - path: yahma/alpaca-cleaned
    type: alpaca

sequence_len: 2048
sample_packing: true
pad_to_sequence_len: true

wandb_project: axolotl-clore
wandb_name: llama3-qlora

output_dir: /workspace/axolotl-output

gradient_accumulation_steps: 4
micro_batch_size: 2
num_epochs: 1
learning_rate: 2e-4
optimizer: adamw_bnb_8bit
lr_scheduler: cosine
warmup_steps: 10

bf16: auto
flash_attention: true
gradient_checkpointing: true

logging_steps: 10
save_strategy: steps
save_steps: 500
eval_steps: 500

evals_per_epoch:
val_set_size: 0.02
```

### 3. Training starten

```bash
# Einzelne GPU
accelerate launch -m axolotl.cli.train config.yml

# Multi-GPU (alle verfügbaren GPUs)
accelerate launch --multi_gpu -m axolotl.cli.train config.yml
```

Trainingsfortschrittsprotokolle werden an stdout und optional an Weights & Biases ausgegeben.

## Konfigurations-Deep-Dive

### Datensatzformate

Axolotl unterstützt nativ mehrere Eingabeformate:

```yaml
# Alpaca-Stil (instruction / input / output)
datasets:
  - path: yahma/alpaca-cleaned
    type: alpaca

# ShareGPT Multi-Turn-Chat
datasets:
  - path: anon8231489123/ShareGPT_Vicuna_unfiltered
    type: sharegpt
    conversation: chatml

# Chat-Vorlage (automatische Erkennung durch Tokenizer)
datasets:
  - path: HuggingFaceH4/ultrachat_200k
    type: chat_template
    field_messages: messages
    message_field_role: role
    message_field_content: content

# Lokale JSONL-Datei
datasets:
  - path: /workspace/data/my_dataset.jsonl
    type: alpaca
    ds_type: json
```

### Multi-GPU mit DeepSpeed

Erstelle `deepspeed_zero2.json`:

```json
{
  "bf16": { "enabled": true },
  "zero_optimization": {
    "stage": 2,
    "offload_optimizer": { "device": "cpu" },
    "allgather_partitions": true,
    "allgather_bucket_size": 5e8,
    "reduce_scatter": true,
    "reduce_bucket_size": 5e8,
    "overlap_comm": true,
    "contiguous_gradients": true
  },
  "train_micro_batch_size_per_gpu": "auto",
  "gradient_accumulation_steps": "auto",
  "gradient_clipping": 1.0
}
```

Fügen Sie Ihrer Konfiguration hinzu:

```yaml
deepspeed: deepspeed_zero2.json
```

Dann starten:

```bash
accelerate launch --num_processes 4 -m axolotl.cli.train config.yml
```

### DPO / ORPO Ausrichtung

```yaml
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
rl: dpo
# oder: rl: orpo

datasets:
  - path: argilla/ultrafeedback-binarized-preferences
    type: chat_template.default
    field_messages: chosen
    field_chosen: chosen
    field_rejected: rejected

dpo_beta: 0.1
```

### Vollständiges Fine-Tuning (kein LoRA)

```yaml
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct

# Kein Adapter, keine Quantisierung
adapter:
load_in_4bit: false
load_in_8bit: false

learning_rate: 5e-6
micro_batch_size: 1
gradient_accumulation_steps: 8
gradient_checkpointing: true
flash_attention: true
bf16: auto

deepspeed: deepspeed_zero3.json  # erforderlich für vollständiges Fine-Tuning bei 8B+
```

## Beispielanwendungen

### Inference nach dem Training

```bash
# Interaktive Inferenz starten
accelerate launch -m axolotl.cli.inference config.yml \
  --lora_model_dir /workspace/axolotl-output
```

### LoRA in Basismodell mergen

```bash
accelerate launch -m axolotl.cli.merge_lora config.yml \
  --lora_model_dir /workspace/axolotl-output \
  --output_dir /workspace/merged-model
```

### Datensatz vorverarbeiten (vor dem Training validieren)

```bash
python -m axolotl.cli.preprocess config.yml
```

Dies tokenisiert und validiert den Datensatz. Nützlich, um Formatfehler vor einem langen Traininglauf zu erkennen.

## VRAM-Nutzungsreferenz

| Modell        | Methode     | GPUs | VRAM/GPU | Konfiguration            |
| ------------- | ----------- | ---- | -------- | ------------------------ |
| Llama 3.1 8B  | QLoRA 4bit  | 1    | \~12 GB  | r=32, seq\_len=2048      |
| Llama 3.1 8B  | LoRA 16bit  | 1    | \~20 GB  | r=16, seq\_len=2048      |
| Llama 3.1 8B  | Vollständig | 2    | \~22 GB  | DeepSpeed ZeRO-3         |
| Qwen 2.5 14B  | QLoRA 4bit  | 1    | \~16 GB  | r=16, seq\_len=2048      |
| Llama 3.3 70B | QLoRA 4bit  | 2    | \~22 GB  | r=16, seq\_len=2048      |
| Llama 3.3 70B | Vollständig | 4    | \~40 GB  | DeepSpeed ZeRO-3+Offload |

## Tipps

* **Immer aktivieren `sample_packing: true`** — größte einzelne Durchsatzverbesserung (3–5× bei kurzen Datensätzen)
* **Verwenden Sie `flash_attention: true`** auf Ampere+-GPUs für 20–40% VRAM-Einsparungen
* **Beginnen Sie mit QLoRA** für Experimente; auf vollständiges Fine-Tuning wechseln Sie nur, wenn die LoRA-Qualität stagniert
* **Setze `val_set_size: 0.02`** um Überanpassung während des Trainings zu überwachen
* **Zuerst vorverarbeiten** — führen Sie aus `axolotl.cli.preprocess` um die Datenformatierung zu validieren, bevor Sie sich auf einen langen Lauf festlegen
* **Verwenden Sie das Docker-Image** für reproduzierbare Umgebungen — vermeidet Abhängigkeitskonflikte
* **`lora_target_linear: true`** wendet LoRA auf alle linearen Schichten an, im Allgemeinen besser als nur die Aufmerksamkeit zu adressieren

## Fehlerbehebung

| Problem                                       | Lösung                                                                                          |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `OutOfMemoryError`                            | Niedriger `micro_batch_size` auf 1, aktivieren Sie `gradient_checkpointing`                     |
| Datensatzformatfehler                         | Ausführen `python -m axolotl.cli.preprocess config.yml` zum Debuggen                            |
| `sample_packing` langsam in der ersten Epoche | Normal — die anfängliche Packing-Berechnung ist einmalig                                        |
| Multi-GPU-Training hängt                      | Überprüfen Sie NCCL: `export NCCL_DEBUG=INFO`, stellen Sie sicher, dass alle GPUs sichtbar sind |
| `flash_attention` Importfehler                | Installieren: `pip install flash-attn --no-build-isolation`                                     |
| Loss fällt nicht ab                           | LR auf 1e-4 senken, Warmup erhöhen, Datensatzqualität prüfen                                    |
| WandB-Verbindungsfehler                       | Ausführen `wandb login` oder setzen Sie `wandb_project:` auf leeren String                      |

## Ressourcen

* [Axolotl GitHub](https://github.com/OpenAccess-AI-Collective/axolotl)
* [Beispielkonfigurationen](https://github.com/OpenAccess-AI-Collective/axolotl/tree/main/examples)
* [CLORE.AI Marketplace](https://clore.ai/marketplace)


---

# 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:

```
GET https://docs.clore.ai/guides/guides_v2-de/training/axolotl-training.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
