How to Write Better Prompts with 7 Techniques

12.6K views
•
January 31, 2024
by
Skill Leap AI
YouTube video player
How to Write Better Prompts with 7 Techniques

TL;DR

Better chatbot results come from specifying the desired style, format, restrictions, role, examples, and reasoning process. Use zero-shot prompting for direct requests, few-shot prompting when examples can guide the output, self-consistency for comparing several candidate answers, and retrieval-augmented generation when current or external information is required.

Transcript

there's a brand new prompting guide from meta the company behind Facebook and Instagram and there's seven prompting techniques in there that I think are going to be really useful if you use any kind of a chatbot so if you use chat GPT Claude co-pilot this is written for meta So Meta has a large language model called llama 2 but this applies across ... Read More

Key Insights

  • Explicit instructions are detailed directions that define what the response should contain and how it should be presented. Specifying the style, audience, length, terminology, and purpose gives the language model clearer guidance than an open-ended request.
  • Formatting requirements are instructions that shape the response into a useful structure. A user can request bullet points, a JSON object, fewer technical terms, or a response under a particular word count so the result fits its intended use.
  • Restrictions are boundaries that tell the model what sources or behaviors to avoid. Examples include using only academic papers, excluding sources older than 2020, and admitting when the answer is unknown instead of inventing unsupported information.
  • Zero-shot prompting is a request made without any previous example of the desired output. The model responds using only the task instructions, making the technique simple but less capable of reproducing a particular writing style or format.
  • Few-shot prompting is a technique that supplies examples before asking for a new result. Those examples show the model the preferred tone, structure, and style, giving it a concrete pattern to replicate when completing the requested task.
  • Role prompting is the assignment of a specific identity or area of expertise before the main instruction. A role such as machine learning expert, social media influencer, or successful entrepreneur provides context about the perspective and level of detail expected.
  • Chain-of-thought prompting is the addition of wording that asks the model to work through a problem carefully and step by step. The technique is presented as particularly useful for prompts involving logic, calculations, or other forms of complex reasoning.
  • Self-consistency is a method that generates several answers to the same question and then identifies the strongest or most commonly supported answer. Retrieval-augmented generation complements this approach by bringing external, more current sources into tasks where internal model knowledge may be insufficient.

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How can I write more effective AI prompts?

Write explicit instructions that define the desired audience, style, format, length, terminology, and restrictions. For example, request bullet points or a JSON object, set a word limit, ask for less technical language, identify acceptable sources, and tell the model to admit uncertainty. These details reduce ambiguity and give the chatbot clearer standards for constructing its response.

Q: What is the difference between zero-shot and few-shot prompting?

Zero-shot prompting gives the model a task without showing any previous examples, so the response is based only on the instruction. Few-shot prompting provides one or more examples of the desired output before presenting the new task. Those examples help communicate the expected writing style, tone, structure, and format, making the resulting response more consistent with the user's preferences.

Q: When should I use few-shot prompting?

Use few-shot prompting when you want the chatbot to reproduce a particular style, format, or type of response. Provide relevant examples, such as earlier articles that demonstrate the desired voice and organization, and then state the new assignment. The examples act as context or prompt priming, giving the model a pattern to follow instead of making it decide every presentation detail itself.

Q: How does role prompting improve chatbot responses?

Role prompting improves consistency by telling the model what perspective or expertise should guide the response. Place the role before the main request, such as asking the model to act as a machine learning expert advising senior engineers or as an entrepreneur sharing productivity strategies. The assigned role clarifies the expected audience, technical level, priorities, and style of advice.

Q: How do I use step-by-step reasoning in a prompt?

Add a phrase asking the model to think through the problem carefully and step by step. The presenter recommends this wording for questions that involve logic, mathematics, calculations, or other complex reasoning. The additional instruction encourages the model to work through the relevant stages of the problem instead of immediately producing a conclusion, which can improve the resulting response.

Q: What is self-consistency prompting?

Self-consistency prompting asks the model to produce several candidate answers to the same question and then choose the best-supported result. The presenter compares it to consulting a panel of experts and selecting the answer on which most of them agree. This method is intended to improve accuracy because the final response is based on comparison rather than a single initial generation.

Q: What is retrieval-augmented generation in prompting?

Retrieval-augmented generation, called RAG in the transcript, combines a language model with external information sources. It is useful when a question requires current, factual, or directly applicable knowledge that may not exist in the model's internal training data. By researching an outside source, the model can ground its response in information beyond its existing knowledge base and reduce unsupported answers.

Q: Can multiple prompting techniques be combined?

Multiple prompting techniques can be combined within one prompt or used across a sequence of prompts. For example, a user can assign a role, provide few-shot examples, require bullet-point formatting, establish source restrictions, and request step-by-step reasoning in the same task. Combining them lets each technique control a different part of the output, including perspective, style, evidence, structure, and reasoning.

Summary & Key Takeaways

  • Explicit instructions improve responses by defining the desired style, format, and restrictions. A prompt can request simple language, bullet points, a JSON object, a specific word limit, recent sources, or an admission of uncertainty. These details reduce ambiguity and give the language model clearer criteria for producing a useful answer.

  • Zero-shot prompting provides only an instruction, while few-shot prompting adds examples of the desired output. Examples can demonstrate writing style, structure, tone, and content expectations before the model completes the new task. The presenter favors few-shot prompting because the added context gives the model a pattern it can follow.

  • Role prompting establishes a relevant perspective, while chain-of-thought wording encourages careful step-by-step reasoning. Self-consistency compares several generated answers and selects the strongest or most commonly supported result. Retrieval-augmented generation adds external sources, helping the model answer questions that require factual, applicable, or more current information than its internal knowledge contains.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from Skill Leap AI 📚