Skip to content

A Brief Overview on Prompting!

Published: at 03:05 PM

(TL;DR)

Prompting is crucial in harnessing the power of LLMs.

This writeup goes through the workflow & some approaches such as Few-Shot Prompting & Chain of Thought Prompting, along with a brief overview on various strategies used in Prompt Engineering.

Table of contents

Open Table of contents

Prompting Workflows

The prompting of a LLM can be compartmentalised into three main blocks as shown below.

image

Illustration created by me.

Filling Up a Prompt Template

In a template, there are usually three main roles which are concatenated together to generate a token string that is passed to the model for computation.

image

Image taken from CMU's 11-711 ANLP course.

Here is an example of how the token string that is sent to a model looks like.

Answer Generation & Post-Processing

For the output, you can;

There are various methods for extraction:

A key rule of thumb is to use identifiers that occur frequently in the dataset that the model was trained on (e.g. using the scale of “Very Good - Bad” instead of “1 - 5”).

Few-Shot Prompting

This is done by providing a few examples of the task together with the initial instruction. In contrast, Zero-Shot Prompting is the same but no examples are provided. Below is an example of such a prompt.

image

Image taken from CMU's 11-711 ANLP course.

Some studies have show that the model’s accuracy is sensitive to;

Chain of Thought Prompting

This is done by getting the model to explain its reasoning before making an answer. By doing this the model is able to;

Below is an example of such a prompt.

image

Image taken from CMU's 11-711 ANLP course.

It was found that simply adding the text “Let’s think step by step” led to a noticeable increase in accuracy.

Structuring Output as Programs

This is done by getting the model to output its answer in a programming language such as Python or format its response .json. This improves accuracy as;

Below is an example of such a prompt.

image

Image taken from CMU's 11-711 ANLP course.

Such an approach is especially useful for numeric questions.

Prompt Engineering

There are two main ways in designing prompts;

Manual

image

Image taken from CMU's 11-711 ANLP course.

By removing ’:’ and the ‘\n’ in the prompt led to an increase in accuracy.

Automated

image

Image taken from CMU's 11-711 ANLP course.

By using a Paraphrasing Model to iteratively test other candidates, an optimal prompt can be created.

Conclusion

In summary, prompting is a crucial aspect in the use of large language models.

As these models continue to become more powerful, it then becomes equally important to utilise these techniques to harness the full potential of this tool.