liveBook · Manning

SFTConfig

As explained in Rearchitecting LLMs

SFTConfig is a configuration class for supervised fine-tuning settings such as epochs, learning rate, scheduling, and numerical precision.

SFTConfig centralizes the settings for supervised fine-tuning. In a QLoRA workflow, it sets training duration, batch size, learning-rate scheduling and warmup, numerical precision, and the dataset field consumed by SFTTrainer. section 7.3.3

Listing 7.11 Configuring and training QLoRA
from trl import SFTTrainer, SFTConfig #1
 
training_args = SFTConfig( 
    output_dir="./qlora_output",
    num_train_epochs=3, #2
    per_device_train_batch_size=8,
    gradient_accumulation_steps=1,
    learning_rate=2e-4, #3
    lr_scheduler_type="cosine", #4
    warmup_steps=7, #5
    fp16=False,
    bf16=True, #6
    logging_steps=10,
    save_strategy="no",
    max_length=MAX_SEQ_LENGTH,         
    dataset_text_field="text", #7
    report_to="none",
)
 
trainer = SFTTrainer(
    model=model,
    train_dataset=train_dataset,
    args=training_args,
)
trainer.train()
 

The configuration and SFTTrainer call show how the settings are applied to launch training. section 7.3.3

How Rearchitecting LLMs covers it

How deep it goes
Explains training settings and selected rationales, but not SFTConfig internals.
Examples
Uses three epochs, batch size eight, learning rate 2e-4, seven warmup steps, and bf16 precision.
What it assumes
Assumes initialized adapters and training examples formatted into a text field.
What you can do after
Operate/configure SFTTrainer to launch training with a dataset text field and specified optimization settings.
How it connects
Connects SFTTrainer settings with QLoRA, learning-rate scheduling, warmup, and numerical precision.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rearchitecting LLMs. The section links point to the parts of the book it draws on.