Transformers documentation

Axolotl

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Axolotl

Axolotl là một framework để fine-tuning và post-training cho các large language model. Nó hỗ trợ adapter-based tuning, ND-parallel distributed training, GRPO và QAT. Thông qua TRL, Axolotl cũng xử lý các workflow preference learning, reinforcement learning và reward modeling.

Định nghĩa phiên huấn luyện của bạn trong một tệp cấu hình YAML.

base_model: NousResearch/Nous-Hermes-llama-1b-v1
model_type: AutoModelForCausalLM
tokenizer_type: AutoTokenizer

datasets:
  - path: tatsu-lab/alpaca
    type: alpaca

output_dir: ./outputs
sequence_len: 512
micro_batch_size: 1
gradient_accumulation_steps: 1
num_epochs: 1
learning_rate: 2.0e-5

Khởi động huấn luyện bằng lệnh train.

axolotl train my_config.yml

Tích hợp Transformers

ModelLoader của Axolotl bao bọc quy trình tải của Transformers.

  • Cấu hình mô hình được xây dựng từ AutoConfig.from_pretrained(). Thiết lập tiền nạp cấu hình device map, quantization config và attention backend.

  • ModelLoader tự động chọn lớp AutoModel phù hợp (AutoModelForCausalLM, AutoModelForImageTextToText, AutoModelForSequenceClassification) hoặc một lớp cụ thể cho mô hình từ ánh xạ đa phương tiện. Trọng số được nạp bằng from_pretrained của bộ nạp đã chọn. Khi reinit_weights được đặt, Axolotl sử dụng from_config để khởi tạo ngẫu nhiên.

  • Axolotl sử dụng Transformers, PEFT và bitsandbytes để áp dụng các adapter sau khi khởi tạo mô hình khi các kỹ thuật dựa trên PEFT như LoRA và QLoRA được bật. Một trình quản lý vá (patch manager) sẽ áp dụng các tối ưu hóa bổ sung trước và sau khi tải mô hình.

  • AxolotlTrainer kế thừa Trainer, thêm các Axolotl mixins trong khi sử dụng vòng lặp huấn luyện và các API của Trainer.

Tài nguyên

Update on GitHub