Pretrained Large Language Models (LLMs)
A pretrained Large Language Model (LLM) serves as a crucial foundation for various advanced tasks, including instruction fine-tuning. This process is essential for developing applications such as chatbots, personal assistants, and other conversational systems. The focus here is on a medium-sized GPT model with 355 million parameters, which is preferred over smaller models due to its enhanced capacity to learn and retain complex patterns necessary for high-quality instruction-following tasks.
Overview of Pretrained LLMs
Pretrained LLMs are initially developed through a comprehensive pretraining phase, where the model learns from vast amounts of text data. This phase equips the model with a broad understanding of language, which can then be fine-tuned for specific tasks. The fine-tuning process involves adjusting the pretrained model to perform particular tasks more effectively, such as following human instructions or classifying text.
Fine-Tuning for Instruction Following
The process of fine-tuning a pretrained LLM to follow human instructions is a multi-stage endeavor. As depicted in Figure 7.1, this process is part of the broader task of coding an LLM, specifically focusing on step 9 of stage 3. This step involves using an instruction dataset to refine the model's ability to understand and execute human instructions accurately.
Figure 7.1 The three main stages of coding an LLM. This chapter focuses on step 9 of stage 3: fine-tuning a pretrained LLM to follow human instructions.
Loading a Pretrained LLM
Before beginning the instruction fine-tuning process, it is essential to load a pretrained GPT model. Figure 7.15 illustrates the three-stage process for instruction fine-tuning, starting with loading a pretrained LLM. This step is foundational for subsequent training phases. The medium-sized model with 355 million parameters is chosen over the smaller 124-million-parameter model due to its superior capacity to learn intricate patterns and nuanced behaviors required for effective instruction-following.
Figure 7.15 The three-stage process for instruction fine-tuning an LLM. After the dataset preparation, the process of fine-tuning an LLM for instruction-following begins with loading a pretrained LLM, which serves as the foundation for subsequent training.
The code for loading pretrained models remains consistent with previous tasks, such as pretraining and classification fine-tuning, with the primary difference being the specification of the model size, "gpt2-medium (355M)", instead of "gpt2-small (124M)". This choice ensures that the model has the necessary capacity to achieve satisfactory results in instruction-following tasks.