Concepts / Parameter-Efficient Fine-Tuning with LoRA

Parameter-Efficient Fine-Tuning with LoRA

The source gives four strategies for improving LLM performance: adjusting hyperparameters, increasing and diversifying the training dataset, experimenting with prompts, and using a larger pretrained model.

  • Programming

When a Test Score Disappoints

Imagine you have built a language model, pretrained it, and fine-tuned it for a specific task. The test scores come back lower than you hoped. Where do you look next? This is the moment this article addresses. It collects practical strategies for improving an LLM's performance after the basic development steps are complete.

The chapter this material comes from closes a full cycle: implementing an architecture, pretraining the model, and fine-tuning it for specific tasks. The strategies covered here are the next things to investigate once that cycle is done. Each one is a lever you can pull, and each one needs to be judged by a measured score rather than by intuition.

Four Levers for Better Performance

The source names four strategies that can improve model performance. Each one acts on a different part of the problem, so it helps to keep them separate in your head before you decide which one to try first. Adjusting hyperparameters changes how the training run itself behaves. Changing the training data changes what the model learns from. Experimenting with prompts changes how you ask the model to respond. Choosing a larger pretrained model changes the starting point from which fine-tuning begins.

Improving LLMperformanceHyperparametershow the training runbehavesDataset size anddiversitywhat the model learns fromPromptshow you ask the model torespondLarger pretrainedmodelthe starting point forfine-tuningstrategystrategystrategystrategy
Which four strategies sit at the same level, and which part of the training or inference setup does each one change?

The four strategies are not interchangeable. A change to the training run can alter how the model fits the data, a change to the data can alter what there is to fit, a change to the prompt alters only the input at the moment of asking, and a change to the starting model alters the foundation everything else is built on. Knowing which lever you are pulling tells you what kind of result to expect and how to test it.

Tracing One Change Against a Baseline

A hyperparameter change is easiest to understand as a short, repeatable sequence. You begin with a baseline configuration and a measured test score. You change one setting, retrain, and then measure again on the same test set. Only that comparison tells you whether the change helped. A score on its own means little until it is set against the baseline.

BaselineconfigurationBaseline test scoreChange one settingRetrainNew test score onsame test setBetter than baseline?Keep the changeTry another settingmeasureadjustrunevaluatecompareyesno
What happens in order when one setting is changed, and how the new score is compared against the baseline to decide whether the change helped?

Notice that the loop always returns to the same measurement step. Every configuration is judged on the same yardstick, which is the fixed test set and the baseline score. The source lists learning rate, batch size, and number of epochs as examples of settings to adjust, and the same sequence applies to any of them.

Worked example

Judging one learning-rate change

A baseline run scores 71.0 on the test set. You change only the learning rate and retrain. The new run scores 68.5 on the same test set. Did the change help? (These numbers are illustrative and are not taken from the source.)

  1. 1
    Record the baseline

    The baseline configuration and its measured score of 71.0 are the reference point for every later comparison.

  2. 2
    Isolate the change

    Only the learning rate was changed. Batch size, epochs, data, and prompt stayed the same, so any score difference can be traced to this one setting.

  3. 3
    Measure on the same test set

    The new run is evaluated on the identical test set, so the comparison is fair.

  4. 4
    Compare the two scores

    The difference is 68.5 minus 71.0, which is $-2.5$. The new score is lower than the baseline.

  5. 5
    Decide

    The change did not help on this test set. The next step is to revert it and try another setting.

Result

The learning-rate change lowered the score by 2.5 points, so it is not kept.

Changing the Data and the Prompt

The two strategies in this part leave the model's starting point alone. One changes what the model learns from, and the other changes how you ask it to respond. Both can be compared with the same discipline used for training settings.

Reading the Base and Instruct Gap

The fourth strategy is to start from a larger pretrained model. The source explains the reasoning: a larger model may have greater capacity to capture complex patterns and generate more accurate responses. The source does not provide a size-versus-score table, so its evidence for this strategy is indirect. The clearest numbers it gives compare two versions of the same Llama 3 8B model.

What do you think happens?

Before you look at the numbers: the base model has no instruction fine-tuning, and the instruct model was fine-tuned on a general instruction-following dataset. Which one do you expect to score higher on the test set, and roughly how large a gap do you expect?

Reveal answer
Answer:

The instruct model scores higher. The base model averages 58.51 and the instruct model averages 82.6, a gap of about 24.09 points.

The source attributes the gap to instruction fine-tuning. Because both scores come from the same test set, the difference can be read directly as the effect of that added fine-tuning step.

Model variantFine-tuning statusAverage test score
Llama 3 8B baseNo fine-tuning58.51
Llama 3 8B instructFine-tuned on a general instruction-following dataset82.6

Llama 3 8B base versus instruct on the test set

The gap is the difference between the two averages: $82.6 - 58.51 = 24.09$. The instruct variant is about 24.09 points higher. The direction matters: the instruct model is the higher-scoring one, and the source attributes the gap to instruction fine-tuning rather than to any other difference between the two versions.

Cutting Cost with LoRA

The last item is a different kind of strategy. Rather than promising a direct score gain, it addresses cost. The source introduces parameter-efficient fine-tuning with LoRA, which stands for low-rank adaptation. The chapter states that LoRA can be used for parameter-efficient fine-tuning and points to an appendix for the method itself.

This article does not describe LoRA's internal mechanics, because the source does not explain them in this section. What the chapter does set up is an experiment: take the instruction fine-tuning code from the chapter, switch it to LoRA, and then compare the training run time and the model performance against the standard approach.

AspectStandard fine-tuning runLoRA run
Starting codeInstruction fine-tuning code from the chapterThe same code, switched to LoRA
Quantity comparedTraining run time and model performanceTraining run time and model performance
How to judge the resultMeasured against the standard run on the same test setMeasured against the standard run on the same test set

Setting up a fair comparison between a standard run and a LoRA run

Mistakes When Comparing Runs

  • Common mistake

    Judging a change by its score alone

    What it looks like

    A run scores 68.5 and is called a success without checking what the baseline scored.

    Why it fails

    A score has meaning only relative to a measured baseline on the same test set.

    Do this instead

    Record the baseline first, then compare each new run against it.

  • Common mistake

    Changing several settings at once

    What it looks like

    The learning rate, batch size, and epochs are all changed in one retrain.

    Why it fails

    If the score moves, you cannot tell which setting caused the change.

    Do this instead

    Change one thing at a time so that a score change can be traced to a specific setting.

  • Common mistake

    Changing the test set while varying the prompt

    Why it fails

    A different test set produces a different yardstick, so the comparison is no longer fair.

    Do this instead

    Hold the test set fixed while you experiment with prompts.

  • Common mistake

    Treating a bigger dataset as automatically better

    Why it fails

    A larger dataset that repeats the same topics and style may add little new to learn.

    Do this instead

    Consider both size and diversity of the examples.

Planning a Fair Comparison

MEDIUM

You have a baseline fine-tuning run that scores 74.0 on a fixed test set. You want to test whether switching to LoRA changes training run time and performance. Describe what you would keep identical between the two runs, what you would measure, and how you would decide whether the LoRA run helped.

Hints
  • Start from the chapter's setup: the same instruction fine-tuning code, with only the method switched.
  • Both runs should be judged on the same test set.
  • Think about what two numbers the source names for comparison.

Key Takeaways

  • The source gives four strategies for improving LLM performance: adjusting hyperparameters, increasing and diversifying the training data, experimenting with prompts, and starting from a larger pretrained model. Each one changes a different part of the setup.
  • Every change should be judged against a measured baseline on the same test set. Changing one setting at a time makes it possible to trace a score change to its cause.
  • The Llama 3 8B base model averages 58.51 and the instruct model averages 82.6, a gap of about 24.09 points that the source attributes to instruction fine-tuning.
  • LoRA (low-rank adaptation) is introduced as a parameter-efficient fine-tuning method. The chapter's experiment compares a LoRA run against the standard approach on training run time and model performance.

Related concepts

More concepts starting with P