01 What are Large Language Models (LLMs)?
Large Language Models are AI models that can understand and generate human-like language. These models are trained on massive amounts of text data and can be used for a variety of tasks, including language translation, text completion, and question-answering. In essence, these models are trained to predict the next word given a sequence of words.
Large Language Models like OpenAI's GPT-4 and Google's Bard are increasingly becoming popular owing to their success in generating smart responses. However, these smart responses are elicited only when the instructions are clear and contain keywords that trigger the model to respond in that way. This is what prompt engineering aims to achieve — writing good prompts for eliciting good responses.
02 Four Paradigms of NLP Progress
Natural Language Processing has gone through four phases of development. None of these are obsolete — each paradigm built on the last.
03 What is a Prompt?
Basic Elements of a Prompt
04 What is Prompt Engineering?
Prompt engineering is needed because Large Language Models generate text based on the input they receive. If the input is vague, unclear, or incomplete, the generated output will also be vague, unclear, or incomplete. By engineering a good prompt, you can improve the quality of the generated output.
Prompt engineering requires:
05 Best Practices for Writing Prompts
A clear and specific prompt helps the model understand what is required. Avoid vague or ambiguous prompts.
Use the context of the task to craft the prompt — including the topic, target audience, and purpose.
Functions defined in the prompt that the model is explicitly instructed to use — for example, a calc() function to compute results inline.
Bullet points, headings, and subheadings help the model understand the structure of the prompt.
Provide few-shot examples to illustrate the desired output format and help the model understand the requirements.
Limit the scope of output — specify length, language type, or format to keep responses on target.
Test the prompt with the model and refine based on the output. Identify issues and improve iteratively — prompt engineering is not a one-shot task.
06 Prompt Examples
Encourage AI models to be factually correct by following a series of steps in their reasoning.
Ask the model to ground answers in reliable sources and make them cite those sources explicitly.
Ask the model to continue from a specific point using the special token that signals the end of the instruction block.
Language models do not always react well to nice, friendly language. If you really want them to follow some instructions, you might want to use forceful language. All caps and exclamation marks work.
If your model is giving you a hard time following instructions, use:
Ask the model to audit an article or piece of text for factual inaccuracies.
Make sure to include the person's name in ALL CAPS to ask the model to remember the character they are supposed to be.
07 Conclusion
Prompt engineering is a critical component of using Large Language Models effectively. By crafting clear, specific, and well-structured prompts, you can improve the quality and relevance of the generated output.
By following the best practices for writing prompts, you can ensure that your prompts are effective and efficient in generating the desired output.