DML: 4 key ideas you must know to train an LLM successfully
My time series forecasting Python code was a disaster until I started using this package. 4 key ideas you must know to train an LLM successfully.
Hello there, I am Paul Iusztin ๐๐ผ
Within this newsletter, I will help you decode complex topics about ML & MLOps one week at a time ๐ฅ
This weekโs ML & MLOps topics:
My time series forecasting Python code was a disaster until I started using this package
4 key ideas you must know to train an LLM successfully
Extra: My favorite ML & MLOps newsletter
#1. My time series forecasting Python code was a disaster until I started using this package
Does building time series models sound more complicated than modeling standard tabular datasets?
Well... maybe it is... but that is precisely why you need to learn more about ๐๐ธ๐๐ถ๐บ๐ฒ!
When I first built forecasting models, I manually coded the required preprocessing and postprocessing steps. What a newbie I was...
How easy would my life have been if I had started from the beginning to use ๐๐ธ๐๐ถ๐บ๐ฒ?
.
๐๐ก๐๐ญ ๐ข๐ฌ ๐ฌ๐ค๐ญ๐ข๐ฆ๐?
๐๐ธ๐๐ถ๐บ๐ฒ is a Python package that adds time-series functionality over well-known packages such as statsmodels, fbprophet, scikit-learn, autoarima, xgboost, etc.
Thus, all of a sudden, all your beloved packages will support time series features such as:
- easily swap between different models (e.g., xgboost, lightgbm, decision trees, etc.)
- out-of-the-box windowing transformations & aggregations
- functionality for multivariate, panel, and hierarchical learning
- cross-validation adapted to time-series
- cool visualizations
and more...
โณ If you want to see ๐๐ธ๐๐ถ๐บ๐ฒ in action, check out my article: ๐ A Guide to Building Effective Training Pipelines for Maximum Results
#2. 4 key ideas you must know to train an LLM successfully
These are 4 key ideas you must know to train an LLM successfully
๐ ๐๐ผ๐ ๐ถ๐ ๐๐ต๐ฒ ๐บ๐ผ๐ฑ๐ฒ๐น ๐น๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด?
LLMs still leverage supervised learning.
A standard NLP task is to build a classifier.
For example, you have a sequence of tokens as inputs and, as output, a set of classes (e.g., negative and positive).
When training an LLM for text generation, you have as input a sequence of tokens, and its task is to predict the next token:
- Input: JavaScript is all you [...]
- Output: Need
This is known as an autoregressive process.
โ๏ธ ๐๐ผ๐ฟ๐ฑ๐ != ๐๐ผ๐ธ๐ฒ๐ป๐
Tokens are created based on the frequency of sequences of characters.
For example:
- In the sentence: "Learning new things is fun!" every work is a different token as each is frequently used.
- In the sentence: "Prompting is a ..." the word 'prompting' is divided into 3 tokens: 'prom', 'pt', and 'ing'
This is important because different LLMs have different limits for the input number of tokens.
๐ง ๐ง๐๐ฝ๐ฒ๐ ๐ผ๐ณ ๐๐๐ ๐
There are 3 primary types of LLMs:
- base LLM
- instruction tuned LLM
- RLHF tuned LLM
๐๐ต๐ฆ๐ฑ๐ด ๐ต๐ฐ ๐จ๐ฆ๐ต ๐ง๐ณ๐ฐ๐ฎ ๐ข ๐ฃ๐ข๐ด๐ฆ ๐ต๐ฐ ๐ข๐ฏ ๐ช๐ฏ๐ด๐ต๐ณ๐ถ๐ค๐ต๐ช๐ฐ๐ฏ-๐ต๐ถ๐ฏ๐ฆ๐ฅ ๐๐๐:
1. Train the Base LLM on a lot of data (trillions of tokens) - trained for months on massive GPU clusters
2. Fine-tune the Base LLM on a Q&A dataset (millions of tokens) - trained for hours or days on modest-size computational resources
3. [Optional] Fine-tune the LLM further on human ratings reflecting the quality of different LLM outputs, on criteria such as if the answer is helpful, honest and harmless using RLHF. This will increase the probability of generating a more highly rated output.
๐๏ธ ๐๐ผ๐ ๐๐ผ ๐ฏ๐๐ถ๐น๐ฑ ๐๐ต๐ฒ ๐ฝ๐ฟ๐ผ๐บ๐ฝ๐ ๐๐ผ ๐ณ๐ถ๐ป๐ฒ-๐๐๐ป๐ฒ ๐๐ต๐ฒ ๐๐๐ ๐ผ๐ป ๐ฎ ๐ค&๐ ๐ฑ๐ฎ๐๐ฎ๐๐ฒ๐
The most common approach consists of 4 steps:
1. A system message that sets the general tone & behavior.
2. The context that adds more information to help the model to answer (Optional).
3. The user's question.
4. The answer to the question.
Note that you need to know the answer to the question during training. You can intuitively see it as your label.
Extra: My favorite ML & MLOps newsletter
Do you want to learn ML & MLOps from real-world experience?
Then I suggest you join Pau Labarta Bajo's Real-World Machine Learning
weekly newsletter, along with another 8k+ ML developers.
Pau Labarta Bajo inspired me to start my weekly newsletter and is a great teacher who makes learning seamless โ
Thatโs it for today ๐พ
See you next Thursday at 9:00 a.m. CET.
Have a fantastic weekend!
Paul
Whenever youโre ready, here is how I can help you:
The Full Stack 7-Steps MLOps Framework: a 7-lesson FREE course that will walk you step-by-step through how to design, implement, train, deploy, and monitor an ML batch system using MLOps good practices. It contains the source code + 2.5 hours of reading & video materials on Medium.
Machine Learning & MLOps Blog: in-depth topics about designing and productionizing ML systems using MLOps.
Machine Learning & MLOps Hub: a place where all my work is aggregated in one place (courses, articles, webinars, podcasts, etc.).
Thanks for the shout out Paul. I love the content you share