ai-cookbook / src /llms /prompting.qmd
Sébastien De Greef
chore: Update colorFrom in README.md and index.qmd
e3bf489
raw
history blame contribute delete
No virus
3.96 kB
# Prompting LLM's
## **I. Clarity and Specificity**
1. **Be clear and concise**: Use simple, straightforward language to convey your request.
* Good sample: "Write a short story about a character who discovers a hidden treasure."
* Bad sample: "Create a narrative that revolves around an individual who stumbles upon a concealed riches repository."
2. **Define specific tasks**: Clearly outline what you want the model to do.
* Good sample: "Summarize the main points of the article in 50 words."
* Bad sample: "Do something with the article, maybe summarize it or something."
3. **Avoid ambiguity**: Use specific terms and phrases to avoid confusion.
* Good sample: "Generate a recipe for vegan chocolate cake."
* Bad sample: "Make a dessert that's healthy and yummy."
## **II. Context and Framing**
1. **Provide context**: Give the model a clear understanding of the topic, tone, and style you're aiming for.
* Good sample: "Write a humorous article about the benefits of procrastination, in the style of The Onion."
* Bad sample: "Write something funny about procrastination."
2. **Frame the task**: Use language that sets the tone and direction for the response.
* Good sample: "Imagine you're a travel blogger, write a review of a fictional restaurant in Paris."
* Bad sample: "Write a review of a restaurant."
## **III. Tone and Style**
1. **Specify tone and style**: Use adjectives to describe the tone and style you're aiming for.
* Good sample: "Write a formal, technical report on the benefits of AI in healthcare."
* Bad sample: "Write something about AI in healthcare."
2. **Use emotional cues**: Incorporate emotional language to evoke a specific tone or atmosphere.
* Good sample: "Write a heartfelt letter to a friend who's going through a tough time."
* Bad sample: "Write a letter to a friend."
## **IV. Constraints and Guidelines**
1. **Set constraints**: Provide specific guidelines on format, length, or structure.
* Good sample: "Write a sonnet about the beauty of nature, with a specific rhyme scheme and 14 lines."
* Bad sample: "Write a poem about nature."
2. **Specify formats and structures**: Use specific formats, such as lists or tables, to guide the response.
* Good sample: "Create a table comparing the features of three different smartphones."
* Bad sample: "Write something about smartphones."
## **V. Avoiding Bias and Assumptions**
1. **Avoid leading language**: Phrases that imply a specific answer or perspective can influence the model's response.
* Good sample: "What are the benefits and drawbacks of using AI in healthcare?"
* Bad sample: "Why is AI the best thing to happen to healthcare?"
2. **Use neutral language**: Avoid language that implies a particular perspective or bias.
* Good sample: "Discuss the impact of climate change on global ecosystems."
* Bad sample: "Explain why climate change is a hoax."
## **VI. Providing Examples and References**
1. **Provide examples**: Offer concrete examples to illustrate the desired output.
* Good sample: "Write a product description in the style of this example: [insert example]."
* Bad sample: "Write a product description."
2. **Reference external sources**: Include references to external sources, such as books or articles, to provide context and guidance.
* Good sample: "Summarize the main points of 'The Hitchhiker's Guide to the Galaxy' in 100 words."
* Bad sample: "Write a summary of a book."
## **VII. Feedback and Iteration**
1. **Provide feedback**: Give the model feedback on its responses to improve future output.
* Good sample: "The previous response was too formal, can you make it more conversational?"
* Bad sample: "That was bad, try again."
2. **Iterate and refine**: Refine your prompts based on the model's responses to achieve the desired outcome.
* Good sample: "Let's try rewriting the prompt to focus on a specific aspect of the topic."
* Bad sample: "Just try again, maybe it'll work this time."