Understanding chat and instruct modes in LLMs
Understanding chat and instruct modes in Large Language Models
Large language models (LLMs) are a type of artificial intelligence (AI) that can generate and understand text. LLMs can operate in two modes: chat and instruct. Though the vanilla mode which comes with the model often termed as base model has ability to respond to user prompt, the responses are not intuitive. Hence we go for chat or instruct variants of LLMs.
LLMs can operate in two modes: chat and instruct.
Chat mode is designed for conversational contexts, where the LLM responds to the user's messages in a natural and engaging way.
Example prompts in for a model in Chat mode will be as follows:
- "Hello, how are you today?"
- "Tell me a joke."
- "Write me a poem about love."
- "What are your thoughts on the future of artificial intelligence?"
Instruct mode is designed for natural language processing tasks in specific domains, where the LLM follows the user's instructions and produces the desired output.
Example prompts in for a model in Instruct mode will be as follows:
- "Translate the following sentence into Spanish: I love you."
- "Summarize the article titled 'The Future of Work'."
- "Write a code snippet to calculate the factorial of a number."
- "Generate a list of 10 marketing ideas for my new product."
As we just understood the basic definitions, let's dive deep into few more details around these two modes.
When to use chat and instruct?
- Chat mode: Casual conversations, when you want the LLM to respond in a natural and engaging way.
- Instruct mode: Specific natural language processing tasks, when you want the LLM to follow your instructions and produce the desired output.
How to fine-tune a model to be in instruct?
- Provide the LLM with some examples of
instructions
and their corresponding outputs. - Consider the quality and quantity of the data, the learning rate and regularization, the freezing and unfreezing of layers, and the evaluation and validation.
How to fine-tune a model to be in chat?
- Provide the LLM with some examples of
dialogues
that you want the model to emulate. - Consider the quality and quantity of the data, the learning rate and regularization, the freezing and unfreezing of layers, and the evaluation and validation.
Difference between chat and instruct?
- Chat mode is designed for conversational contexts, while instruct mode is designed for natural language processing tasks in specific domains.
- Fine-tuning in chat mode helps the LLM do a better job on generating natural and coherent responses that are relevant and engaging to the user. Fine-tuning in instruct mode helps the LLM do a better job on following different types of instructions and generating outputs that are accurate and appropriate to the task.
Can I fine-tune a model to produce a model with both chat and instruct capabilities combined?
You can fine-tune a model to produce a model with both chat and instruct capabilities combined.
- Provide the LLM with some examples of dialogues that include both modes of interaction.
- You can use some pre-trained language models, such as ChatGPT and InstructGPT³, which are based on the GPT-3 architecture, as a starting point for your fine-tuning.
To fine-tune a model to have both chat and instruct capabilities, you need to provide it with some examples of dialogues that include both modes of interaction. For example, you can use the following dialogue as an example:
User: Hi, do you like movies?
Model: Yes, I do. I enjoy watching different genres and styles of movies.
User: What is your favorite movie genre?
Model: I like sci-fi movies the most. They are imaginative and exciting.
User: ### Instruction
Model: Okay, switching to instruct mode. What do you want me to do?
User: Write a summary of the movie Interstellar.
Model: Interstellar is a sci-fi movie directed by Christopher Nolan. It follows a group of astronauts who travel through a wormhole in search of a new home for humanity. Along the way, they face challenges such as time dilation, gravity anomalies, and moral dilemmas.
Some examples of LLMs that support chat and instruct modes are ChatGPT and InstructGPT, which are based on the GPT-3 architecture.
Another example of an LLM that supports both chat and instruct modes is WizardLM, which is a family of instruction-following LLMs that can execute small programs as part of a prompt. WizardLM can perform various skills, such as sorting, filtering, arithmetic, or logic. WizardLM is also based on the Transformer architecture, but it uses a different training data and objective than ChatGPT and InstructGPT.
Summary
In this blog post, we covered the following topics:
- The difference between chat and instruct modes in LLMs.
- When to use chat and instruct modes.
- How to fine-tune a model to be in instruct mode.
- How to fine-tune a model to be in chat mode.
- The difference between fine-tuning in chat and instruct mode.
- Whether or not it is possible to fine-tune a model to produce a model with both chat and instruct capabilities combined.