Axolotl 微调配置工具
Axolotl 用 YAML 配置驱动大模型微调,封装了 Transformers、PEFT、DeepSpeed、FlashAttention 等组件。适合需要可复现配置的 LoRA/QLoRA/全量微调。
核心配置:base model、dataset、adapter、training、deepSpeed、wandb。
安装:
git clone https://github.com/axolotl-ai-cloud/axolotl.git
cd axolotl
pip install -e .
准备配置:
cat > config.yml <<'EOF'
base_model: Qwen/Qwen2.5-7B-Instruct
model_type: AutoModelForCausalLM
tokenizer_type: AutoTokenizer
load_in_4bit: true
adapter: qlora
lora_r: 16
lora_alpha: 32
datasets:
- path: data/train.jsonl
type: alpaca
output_dir: ./out
num_epochs: 3
micro_batch_size: 2
gradient_accumulation_steps: 8
learning_rate: 2e-4
启动训练:
accelerate launch -m axolotl.cli.train config.yml
合并 LoRA:
python -m axolotl.cli.merge_lora config.yml
type 与 JSONL 字段不匹配,解析失败。load_in_4bit 但 adapter 仍设为 lora,显存不足。lora_r/lora_alpha 与 target modules 不匹配,效果差。trust_remote_code,配置里没有开启。accelerate config,只在一张卡上运行。