# Introduction to Prompting Techniques for Large Language Models
Large language models (LLMs) like GPT-4 are a specific type of AI that have shown impressive capabilities in generating natural language. However, they still need some guidance and instructions from us to perform well on many tasks. This is where prompting comes in!
Prompting involves providing the LLM with some additional context, instructions, examples etc. to steer it towards generating the desired output. Let's go through some prompting techniques with examples:
## 1. Basic Prompting
* The simplest way to prompt an LLM is to just provide an instruction.
Prompt:
`How can I find a good work-life balance?`
Output: Make sure to set boundaries between your work and personal life. Don't check work emails outside of work hours. Take regular vacations to recharge. Prioritize self-care activities like exercise, meditation, hobbies. Communicate your needs to your employer.
## 2. Providing Context
* Giving some context can help the LLM generate more relevant responses.
Prompt:
`I'm a doctor working long and stressful hours. What are some ways I can nurture relationships with my colleagues and patients?`
Output: As a doctor working long hours, nurturing relationships may be challenging but is important. Set aside dedicated time each week to check in personally with colleagues and patients. Send brief personal notes or texts to show you care. Schedule social events outside work when possible. Make time to actively listen and show empathy during appointments. Small gestures go a long way in healthcare.
## 3. Giving Examples
* Providing a few examples to demonstrate the desired output is a great technique called few-shot prompting.
Prompt:
`Match the job titles with their respective industries Example:`
`Surgeon = Hospital and Healthcare`
`Software Developer = Information Technology`
`Chef = Culinary and Hospitality`
`What does Architect = ?`
Output: Architect = Construction and Engineering
## 4. Ask for Formatting
* Framing the prompt in a specific format leads to clearer responses.
Prompt:
`Hello, can you provide me with 3 tips for building strong relationships with colleagues and clients in my role as a sales manager? Generate the list in this format`
`1.`
`2.`
`3.`
Output: Here are 3 tips for building strong work relationships as a sales manager:
1. Schedule regular 1-on-1 meetings to provide support and mentorship
2. Actively listen and validate others' perspectives, even in disagreement
3. Send personalized notes or small gifts to recognize achievements
## 5. Positive Instruction Over Negative
* Rather than asking for what you don't want, ask for what you want.
❌ Prompt:
`List several skills or qualities that would not be useful in a teaching career`
Output: impatience, disorganization, poor communication skills, arrogance, lack of empathy, social anxiety, resistance to change, overly serious demeanor, unwillingness to collaborate
âś… Prompt:
`List several skills or qualities that would be useful in a teaching career`
Output: patience, organization, communication, creativity, empathy, leadership, adaptability, sense of humor, problem-solving, collaboration.
## 6. Be clear in description
*Being clear helps the LLM understand what you want
Prompt:
`What are 5 examples of jobs that allow flexibility and remote work options?`
Output: Here are 5 examples of jobs that allow flexibility and remote work options:
Software Developer - Can work remotely writing code and collaborating with teams through video chat. Flexible hours.
Graphic Designer - Design visual content for clients remotely. Set own schedule.
Tutor - Teach students online via video chat. Choose your own hours.
Virtual Assistant - Provide admin support to clients by email, phone, video. Flexible schedule.
Writer/Editor - Write, edit or copyedit documents for clients. Telecommute with flexible hours.
## 7. Putting it all together
*Copy this template
Prompt:
`Role: In this role, you will assume the position of [describe the specific role or character]. Respond in a [tone of voice] manner.`
`Instruction: Your primary objective is to [explain the main task the user wants to accomplish, give clear, well-defined goals].`
`Context: To set the scene and provide relevant background information, here's some context for your role and instruction. [Provide any necessary context, background details, or relevant information. Could be any file too txt, pdf, csv, etc... make sure to reference the file by name]`
`Example: To illustrate what's expected, here's an example response that aligns with your role and instruction. [Provide a sample response that demonstrates how the output should look like. This can serve as a format for the llm to understand the desired outcome.]`
These are just a few simple prompting techniques to get you started! Prompting well takes experimentation - keep trying different prompts and you'll get better results from LLMs.
This guide was inspired by the awesome website at
https://www.promptingguide.ai/