LoRA Rank Selection and Learning-Rate Scaling on Domain-Specific Corpora
Choosing adapter rank r and scaling factor alpha remains one of the most common sources of suboptimal fine-tuning runs. Increasing rank without adjusting weight decay or target modules frequently leads to overfitting on small instruction datasets.
Target All Linear Layers First
Adapting only q_proj and v_proj leaves significant capacity unused in feed-forward blocks. Applying LoRA across all attention and MLP projections (q, k, v, o, gate, up, down) at r=16 consistently outperforms q/v-only adapters at r=64 while using fewer trainable parameters.
lora_config = LoraConfig(
r=16,
lora_alpha=32,
lora_dropout=0.05,
target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
)
Preventing General-Capability Drift
Mixing 10–15% general instruction replay data alongside domain examples prevents format collapse and preserves tool-calling accuracy. Always track held-out schema compliance separately from training cross-entropy loss.