LLM Prompt

Large Language Model Prompt

Providing information to an LLM and requesting an action

What is a Prompt?

A prompt is a piece of text and your way of communicating with LLMs, to provide information and request an action. While this communication is done in natural language form, not all communications achieve the same success level.

Even though LLMs have made significant advancements, there are still limitations to their capabilities. One critical factor for successful use of an LLM is a good prompt. This page summarizes tips on how to create effective prompts.

Tips on Writing a Good Prompt (Prompt Engineering)

1. Provide Necessary Information at the Top

If the LLM needs information to perform a task, provide the information at the beginning of the prompt. Use keywords such as “Context” to specify what the information represents.

Example:

Context: The user is asking about the weather forecast.
Task: Provide a detailed weather forecast for the next three days.

2. Keep Instructions Short and Precise

Specify what exactly needs to be done in the bare minimum number of words required.

Example:

Summarize the following text in one paragraph.

3. Note Expectations Clearly

State what you expect rather than what you don’t want.

Example:

Answer should be informative and useful.

4. Include Formatting Instructions

When necessary, specify the format or structure you want for the output.

Example:

List the items in bullet points:
- Item 1
- Item 2

5. Specify the Scope Using Identifiers

Use characters such as ", """, or similar identifiers to clearly demarcate the scope of the data provided within the prompt.

Example:

"""
The quick brown fox jumps over the lazy dog.
"""
Summarize the text above.

6. Explicitly Note Constraints and Goals

For complex prompts, categorize information into sections like Constraints and Goals. Mention goals after the constraints.

Example:

Constraints: Use no more than 200 words.
Goals: Provide a comprehensive overview of the topic.

7. Place Important Instructions Near the End for Large Prompts

For larger prompts, place goals and important instructions as close as possible to the end of the prompt.

Example:

Context: Detailed explanation of a complex topic.
...
Goals: Summarize the key points in a concise manner.

8. Stick to One Term for the Same Concept

Use consistent terminology throughout the prompt to avoid confusion.

Example:

Use "customer" throughout the prompt instead of alternating with "client" or "user".

9. Include Examples Specific to Your Data Context

Providing examples can significantly enhance the LLM's performance.

Example:

Example: "The cat sat on the mat."
Rewrite in passive voice: "The mat was sat on by the cat."

By following these tips, you can create effective prompts that guide LLMs to produce accurate and useful responses.

Last updated