Aayaan Sahu
SEARCH
Tags
LINKS
LLMs, or Large Langage Models, are machine learning models based on the transformer architecture trained on vast arrays of text. The gist of an LLM is to give it some text and it will generate the next best words that it sees fits. This is done by understanding the relationships between words, so that it can idealize the next best output.
You've most definetely heard of ChatGPT, the first widely accessible large language model. But there are many more available LLMs, each with their own strengths and weaknesses.
Now that we know what LLMs are, we need to know how to take advantage of their capabilities. Prompt engineering encapsulates the idea of finding an effective method to communicate a task to an AI, such that it returns your desired output. We'll go over some of the most popular prompt engineering techniques.
The chain of thought prompting framework focuses on replicating how humans approach solving problems, namely through breaking up the problem into smaller parts. The model will then individually investigate these broken up parts until it arrives upon an answer. This paper investigates how using chain of thought can elicit reasoning within LLMs. Here's how chain of thought works.
Q: I have 20 apples in total. My customer buys 3 packs of apples. Every pack contains 4 apples. How many apples do I have left?
A: You start off with 20 apples. The customer buys 3 packs of 4 apples each which is equivalent to 3x4=12 apples. 20-12=8.
Q: I have 37 apples in total. My customer buys 4 packs of apples. Every pack contains 2 apples. How many apples do I have left?
A: You start off with 37 apples. The customer buys 4 packs of 2 apples each with is equivalent to 4x2=8 apples. 37-8=29.
Notice how within the input to the model, a Q&A structure was established using the Q: and A:. In addition, the input showed an example of breaking down the simple math problem into simpler steps in order to ensure that the LLM maintains accuracy and doesn't get lost in the way.
The tree of thought framework builds upon chain of thought. The gist is that there are multiple different trains of thought that form a tree, with the variety of thoughts leading to the finding of a better answer. There are four parts to the tree of thought prompting framework.
Here's an example prompt to get started.
Imagine three different experts are answering this question. They will brainstorm the answer step by step reasoning carefully and taking all facts into consideration. All experts will write down 1 step of their thinking, then share it with the group. They will each critique their response, and the all the responses of others. They will check their answer based on science and the laws of physics. Then all experts will go on to the next step and write down this step of their thinking. They will keep going through steps until they reach their conclusion taking into account the thoughts of the other experts. If at any time they realise that there is a flaw in their logic they will backtrack to where that flaw occurred . If any expert realises they're wrong at any point then they acknowledges this and start another train of thought. Each expert will assign a likelihood of their current assertion being correct. Continue until the experts agree on the single most likely location. The question is...
Zero-shot prompting is probably the prompting that you are familiar with. You write a question, it gives you an answer. Zero-shot prompting requires providing a model with a task without giving it any examples of the task being done, forcing the model to use solely pre-existing knowledge to generate a response. This is useful when testing how well a model performs from solely instructions. The following is an example of using zero-shot prompting.
Notice how the model isn't given any context and just has to rely on its pre-trained knowledge in order to answer the user's question.
Unlike zero-shot prompting, few-shot prompting provides the model with a few examples to understand how to perform a task before it is asked to generate a response to a similar input. This aids the model completing its task because it is given more context as to how the task needs to be completed from the examples provided. Here's how few-shot prompting works.
Translate the following English sentence to Spanish. Here are a couple examples.
=== Example 1 ===
English: I love coding.
Spanish: Me encanta codificar.
=== Example 2 ===
English: Machine learning is great.
Spanish: El aprendizaje automático es genial.
English: This post is informative.
Sure! Here is the translation:
=== Example ===
English: This post is informative.
Spanish: Esta publicación es informativa.
Notice how the model recognizes the format we would like our input and output, proving that the omdel grasped the structure and the requirements of the tasks through the provided examples.
Self-consistency prompting involves generating multiple responses to a given prmopt and selecting the oen that the majority agree with, or the one that is most consistent. This uses the idea that there is strength in numbers in order to democratize the best solution. By comparing different responses, self-consistency prompting filters anomalies and increases reliability of the model's output.
Since the model output is long, the example of self consistency prompting is attached here.