Prompt Engineering as an alternative to fine-tuning
This video describes how to use Prompt_Engineering_as_an_alternative_to_fine_tuning.ipynb
Prompt_Engineering_as_an_alternative_to_fine_tuning.ipynb was designed with ChatGPT as a Cobot(collaborative bot) on top of an implementation of ChatGPT. You can access Prompt_Engineering_as_an_alternative_to_fine_tuning.ipynb on GitHub:
So what will it be: Fine-tuning or prompt engineering OpenAI's models (davinci, ChatGPT, other)?
Let's dive into this:
Using large language models(LLM) provides better power if required.
However, it is not always possible or necessary to fine-tune a model to obtain exactly what we need.
Let's see what ChatGPT has to say:
a)ChatGPT on prompt engineering:
"Prompt engineering can be a useful technique for improving the performance of language models like GPT-3 on specific tasks or domains without fine-tuning. By carefully crafting prompts, you can guide the model to produce the desired output."
b)ChatGPT on fine-tuning when it's possible:
"However, prompt engineering is not a replacement for fine-tuning in all cases. Fine-tuning is still the best way to achieve high accuracy on a specific task when you have enough task-specific labeled data. Fine-tuning allows the model to learn from the task-specific data and adjust its weights accordingly, leading to better performance on that task."
For fine-tuning OpenAI GPT-3 models or subsequent models, read Chapter 7 of Transformers for NLP, 2nd Edition, and run the fine-tuning notebook of the chapter.
c)ChatGPT on prompt engineering when fine-tuning is challenging:
"In contrast, prompt engineering is useful when you don't have enough labeled data or when the task is not well-defined. For example, if you want to generate creative writing prompts or answer questions about a broad topic like history, prompt engineering can help guide the model to generate relevant and informative responses."
Working on this information, this notebook will focus on prompt engineering when:
you don't have enough labeled data
when the task is not well-defined as in open conversations, for example
when the cost of fine-tuning exceeds the benefit of your project
when the topic is broad
Prompt Engineering as described in the video and available in the notebook:
Advanced prompt engineering is not limited to entering a good prompt or question. This notebook will show you how to implement a transformer efficiently with advanced prompt engineering:
1. Building the Knowledge base(KB)
2. Parsing the user's prompt and accessing the KB
3. Generating ChatGPT content with a dialog function
4. Moderation, quality control
5. Summary and next steps
For more on the importance of prompt engineering, consult Transformers for NLP, 2nd edition starting chapter 1: