Skip to main content
All CollectionsAi Assistants
Basic prompt configuration
Basic prompt configuration

Learn how to create effective prompts for your AI assistants in Ubby

Tlohi Bilel avatar
Written by Tlohi Bilel
Updated this week

Introduction

Creating effective prompts is essential for getting the best results from your AI assistants. This guide will walk you through the basics of prompt configuration, including the structure of a good prompt, basic principles, and tips for optimizing your prompts.

Structure of a Good Prompt

Key Elements

  1. Be Clear and Precise: Provide specific instructions to avoid ambiguity.

  2. Define the Role and Context: Set the context and role of the assistant to guide its responses.

  3. Specify the Desired Response Format: Indicate the format in which you want the response.

  4. Include Examples: Provide examples to illustrate the desired outcome.

  5. Mention Limits or Behaviors to Avoid: Specify any constraints or behaviors to avoid.

  6. Adapt Tone and Style: Adjust the tone and style according to your needs.

Basic Principles in Prompting

Basic Prompts

You can achieve a lot with simple prompts, but the quality of the results depends on the amount of information you provide and the clarity of the formulation. A prompt can include instructions or questions, context, inputs, or examples to guide the model for better results.

Example of a Basic Prompt

Prompt:

The sky is

Output:

blue The sky is blue on a clear day. On cloudy days, the sky can be gray or white.

This example shows that the language model generates a sequence of characters that make sense in the context of "The sky is." However, the output may be unexpected or not aligned with the task we want to accomplish.

Improving the Prompt

Prompt:

Complete the sentence: The sky is

Output:

so beautiful today.

By asking the model to complete the sentence, the result is more aligned with the instruction. This approach of designing optimal prompts to guide the model in performing a task is known as prompt engineering.

Formatting Prompts

A standard prompt can be formatted as follows:

<Question>?

or

<Instruction>

For example, a question-answer (QA) format:

<Question>? A:

This is called zero-shot prompting, where you ask the model for a response without any examples or demonstrations of the task. Some large language models (LLMs) can handle zero-shot prompting, but it depends on the complexity and knowledge of the task.

Few-Shot Prompting

Few-shot prompting involves providing examples (demonstrations) to guide the model:

<Question>? 
<Answer>
<Question>?
<Answer>
<Question>?
<Answer>
<Question>?

For example:

Q: What is the capital of France? 
A: Paris
Q: What is the capital of Germany?
A: Berlin
Q: What is the capital of Italy?
A: Rome
Q: What is the capital of Spain?
A:

Few-shot prompts enable the model to learn tasks based on a few demonstrations.

Elements of a Prompt

Key Components

A prompt can include the following elements:

  1. Instruction: A specific task or instruction for the model.

  2. Context: External information or additional context to guide the model.

  3. Input Data: The input or question for which you seek an answer.

  4. Output Indicator: The type or format of the desired output.

Not all components are necessary for a prompt, and the format depends on the task. We will cover concrete examples in upcoming guides.

General Tips for Prompt Design

Start Simple

Begin with simple prompts and add more elements and context as you seek better results. Modify your prompt iteratively to optimize it for your application.

The Instruction

Use commands like "Write," "Classify," "Summarize," "Translate," "Order," etc., to indicate what you want the model to do. Experiment with different instructions, keywords, contexts, and data to find what works best for your use case.

Specificity

Be very specific about the instruction and task. The more descriptive and detailed the prompt, the better the results. Providing examples in the prompt is very effective for achieving the desired outcomes.

Avoiding Ambiguity

Avoid being too clever or vague. Be precise and direct. For example:

Explain the concept of prompt engineering in 2-3 sentences to a high school student.

Do's and Don'ts

Focus on what to do rather than what not to do. For example:

The following is an agent recommending movies to a customer. The agent should recommend a movie from the trending global movies list. Avoid asking for user preferences or personal information. If no movie is available, respond with "Sorry, I couldn't find a movie to recommend today." Customer: Recommend a movie based on my interests. Agent:

Output:

Sorry, I don't have information on your preferences. However, here are some of the most popular movies worldwide right now: [list of movies]. I hope you find something you like!

Conclusion

Creating effective prompts is an iterative process that requires experimentation. By following the principles and tips outlined in this guide, you can design prompts that yield better results and optimize the performance of your AI assistants.

Did this answer your question?