An interesting topic, although still somewhat niche, is fine tuning a Large Language Model (LLM).
There are different reasons for fine tuning a model. For most companies interested in this technology, the goal is certainly not to improve the model in absolute terms, which would require enormous resources, but rather to adapt it to a specific context, teach it particular behaviors or domain knowledge, or change the style and structure of its answers.
This is also where we risk entering the realm of myth.
The reason is simple: everyone talks about Generative AI and LLMs, but far fewer people have had the opportunity to develop a concrete understanding of the underlying technologies and, more importantly, to experiment with how they actually work.
Where should you start?
For anyone seriously interested in the subject, perhaps because they are studying it at university, my first recommendation is to build a solid theoretical foundation.
There are excellent courses and specializations available on Coursera and DeepLearning.AI that can help you gradually understand the fundamental concepts.
But I would also like to add a few practical considerations, especially to encourage those who want to get their hands dirty and see what actually happens.
The first piece of good news is that, if you choose a sufficiently small model, somewhere around 1 to 2 billion parameters, you can run a fine tuning experiment entirely locally.
On a modern MacBook this is surprisingly accessible. Apple Silicon uses unified memory, and PyTorch supports MPS, Metal Performance Shaders, allowing applications to take advantage of the Mac GPU. The Hugging Face ecosystem also makes working with these models relatively straightforward.
There is another factor that significantly lowers the barrier to entry today.
If you use a coding agent, such as Codex or Claude Code, it can guide you through the choice of Python libraries, the preparation of scripts and notebooks, and the debugging of the many small problems you will inevitably encounter.
But this does not replace understanding.
Theory first, tools second
In my view, attempting an experiment like this without understanding the basics is of limited value.
You should have a reasonably clear idea of what fine tuning actually means, what Parameter Efficient Fine Tuning, PEFT, is, how LoRA, Low Rank Adaptation, works, how training and validation datasets should be built, and how to determine whether the model is actually learning something rather than simply memorizing your examples.
Do not be intimidated by the terminology.
If you have a solid mathematical background, roughly equivalent to the first couple of years of a scientific or engineering degree, you already have most of the tools needed to understand these concepts in depth. Probably even better than I do. I studied many of these things quite a few years ago, although fortunately I tend to remember the subjects I am passionate about.
Where is the difficult part?
Surprisingly, not so much in the code.
One of the areas that requires the most attention is preparing the datasets.
In this experiment we are doing Supervised Fine Tuning, SFT. We therefore need at least two datasets, one for training and another, separate one, for validation.
The records must follow the format expected by the model and, simplifying slightly, contain pairs of questions or instructions and their corresponding answers.
Understanding the format is relatively easy. The interesting part comes next.
These models have a remarkable ability to learn, and also to memorize, what we provide during training. But our goal is not simply to make the model answer one specific formulation of a question.
We want it to generalize.
If we want to teach the model a particular fact, we therefore need sufficiently varied examples so that it can recognize the different ways a person might ask for the same information.
This is where some real work is required.
Do not be discouraged if the first experiments do not behave as expected. It is worth spending a few hours improving the dataset, removing ambiguous examples and increasing the variety of formulations.
For a small educational experiment, if the number of facts or behaviors you want to teach is limited, say fewer than 50, a dataset of around 150 to 200 examples can already be enough to observe interesting results.
This is obviously not a general rule. It depends on the model, the task, the quality and variety of the examples, and the training parameters. But for learning and experimentation, it is a very reasonable starting point.
Why is this relatively easy today?
There is another important technological reason.
The fundamental architecture behind modern LLMs is still based on the Transformer, introduced in 2017 with the famous paper Attention Is All You Need. Many things have evolved since then, including architectures, training techniques, attention mechanisms, tokenizers, alignment and quantization, but that conceptual foundation remains.
At the same time, Hugging Face and the open source community have done an extraordinary job of providing high quality libraries covering almost the entire process, model loading, data preparation, training, PEFT and LoRA, evaluation and inference.
As a result, today we can spend much more time understanding what we are doing, instead of implementing every component from scratch.
The bottom line
I do not want to make this article too long, so here are the practical numbers.
For my experiment, I used a MacBook with Apple Silicon and 40 GB of unified memory.
The base model was Qwen3 1.7B.
With a relatively small dataset and parameter efficient fine tuning, training takes about 10 minutes on my machine. Immediately afterwards, I can load the adapted model and start testing inference.
So, you do not necessarily need a GPU cluster to understand what happens when you fine tune an LLM.
For an educational experiment, a modern laptop, a small open source model, Python, PyTorch, Hugging Face and a few hours of curiosity can be more than enough.
And, in my opinion, seeing a model that previously did not know something change its behavior after training is one of the best ways to turn seemingly abstract concepts into something concrete.
And yes, if by now you are thinking that I am a big Apple fan, I will not deny it.
Steve Jobs was, in my view, one of the relatively few geniuses who had an extraordinarily positive impact on the way we interact with technology.
All the code, scripts and specifications for my experiment are available here:
https://github.com/luigisaetta/llm-fine-tuning-on-mac
I hope they can be useful to anyone who wants to experiment, learn and, above all, better understand what actually happens when we fine tune an LLM.
For educational purposes, of course. 🙂