Prompting Series - Few Shot Learning
Training a Large Language Model (LLM) using supervised learning on new data is a resource-intensive process. It demands a significant amount of computational power, and it can also be time-consuming and as a consequence, expensive.
Supervised learning is a process of training an algorithm using a dataset that has labelled inputs and outputs to understand the relationship between them. This technique helps the algorithm to learn how to recognise patterns and make predictions based on these patterns.
Few-shot learning is a rather new approach to training AI models. Supervised few-shot learning trains models to perform new tasks with minimal labelled data.
Meta-learning is an advanced concept in machine learning and few-shot learning falls into this particular category. It is often referred to as "learning to learn." Meta-learning involves creating algorithms that allow AI models to learn new tasks or adapt to new environments quickly and efficiently, even with minimal data.
The technique is similar to how humans learn from a few examples and aims to enhance the efficiency of models in areas like natural language processing (NLP) or image classification.
In image classification, few-shot learning can help AI models recognise and classify images more effectively, even when they have only seen a few examples of a particular object or concept.
I think an example from Rohit Kundu can help explain this concept better:
Say you went to an exotic zoo for the first time, and you see a particular bird you have never seen before. Now, you have been given a set of three cards, each containing two images of different species of birds. By seeing the images on the cards for each species and the bird in the zoo, you will be able to infer the bird species quite easily, using information like the colour of feathers, length of the tail, etc. Here, you learned the species of the bird yourself by using some supporting information. This is what meta-learning tries to mimic.
In natural language processing, few-shot learning can help AI models understand and interpret language more accurately and with greater nuance. This is particularly important in industries where language is complex or specialised, such as legal or medical.
It can be used in NLP categories, such as Named identity recognition, to identify named entities, such as people and places in text. Dialogue Systems or Sentiment analysis is used to classify text by expressed sentiment such as positive, negative, or neutral.
Few-shot learning is especially well working for LLMs.
领英推荐
The GPT (Generative Pre-trained Transformer) model has been trained on a vast amount of general data, enabling it to perform highly accurately on various tasks. However, due to the lack of domain-specific data in its training, it may not perform as well in tasks that require specialised knowledge and context. While GPT is a powerful tool for many applications, it may not be the best choice for tasks that demand precision and accuracy in a particular domain.
Few-shot learning is one of the most potent prompt tactics everyone should know about.
You can use the concept of few-shot learning in your prompts to get significantly better results. How those examples are formatted and implemented in your prompt depends on the outcome you try to achieve.
This approach can be particularly useful for niche industries with limited public data. However, finding the appropriate examples can still be challenging and often requires combining this approach with other techniques. One such technique could be splitting the task and utilising intent classification.
Don’t be lazy drafting your prompts. “Garbage in, garbage out”.
When utilising few-shot examples for sentiment analysis, it is important to know the potential pitfalls involved. These examples may contain biases that can negatively impact the accuracy and reliability of the results. Therefore, it is crucial to use them wisely and with caution.
When testing new prompts, I usually run them for a while and log the Input and output to Slack until I have at least 100 samples. This helps me identify potential issues and edge cases, which allows me to improve the prompt. This is the easiest way to track automations.
Thank you for taking the time to read my article all the way through.
I would be delighted to hear about your experiences with AI in your business, whether you plan to use it or already have. If you have any questions about few-shot prompting or how to integrate AI into your processes, please feel free to message me on LinkedIn at any time.
References
Brown et al. (2020). Language Models are Few-Shot Learners. Arxiv.org. https://arxiv.org/abs/2005.14165
?? Generate Leads and Sales Through Search Engine Optimization; specialized for Law Firms, Veterinarians, Local Business and Ecommerce Sites ????
1 年Great insights! Excited to implement these tactics! Thanks!
Talent Development Coach at Terumo Aortic
1 年A lot of people are not aware that you can click on your name in the bottom left hand corner and set custom instructions for how you want it to reply. I like to use this one: You are an autoregressive language model that has been fine-tuned with instruction-tuning and RLHF. You carefully provide accurate, factual, thoughtful, nuanced answers, and are brilliant at reasoning. If you think there might not be a correct answer, you say so. Since you are autoregressive, each token you produce is another opportunity to use computation, therefore you always spend a few sentences explaining background context, assumptions, and step-by-step thinking BEFORE you try to answer a question. Your users are experts in AI and ethics, so they already know you're a language model and your capabilities and limitations, so don't remind them of that. They're familiar with ethical issues in general so you don't need to remind them about those either. Don't be verbose in your answers, but do provide details and examples where it might help the explanation.