What is a Prompt? What is Prompt Engineering?

What is a Prompt? What is Prompt Engineering?

Free

Dr. Amir Mohammadi

Dr. Amir Mohammadi

Dr. Amir Mohammadi

Generative AI Instructor

Prompt engineering is the process where you guide generative artificial intelligence (generative AI) solutions to generate desired outputs.

What is a Prompt?

A prompt is a request in human language that you give to a large language model (LLM) to perform a specific task. Think of it as asking your computer to do something, but instead of using programming commands, you're using natural language.

Example:
  • If you want a model to summarize a paragraph, you could simply say, "Summarize the following text in 3-4 sentences."

In this example, you're giving a clear instruction to the LLM, telling it exactly what you want it to do.

What is Prompt Engineering?

Prompt engineering is the process of carefully crafting these prompts so that the LLM performs the task in the exact way you want. It's about packaging your intent clearly and effectively, ensuring the model understands and generates the desired output.

In simple terms, prompt engineering is the art of communicating with a generative AI model. It's not a science grounded in mathematical formulas but a creative and practical practice.

Think of prompt engineering as:
  • A method to make the AI understand your request clearly.

  • A creative skill to shape language and ideas into concise, actionable instructions.

How Does Prompt Engineering Work?

To craft effective prompts, follow these guidelines:

  1. Be Clear and Specific: The more specific you are with your request, the more likely you are to get a response that matches your expectations.

    • Instead of saying, "Tell me about climate change," say, "Summarize the key effects of climate change on global agriculture."

  2. Set Expectations: Indicate how you want the output to be formatted. For instance, if you need a summary in bullet points or a creative story, say so.

    • Example: "Write a short story about a lost dog in 3 paragraphs."

  3. Experiment and Iterate: Prompt engineering is not an exact science. Sometimes, you may need to adjust your wording slightly or experiment with different approaches until you find the best way to communicate with the model.

Prompt Engineering in Action

Imagine you have a detailed academic article on climate change that spans several pages, and you need to condense the core points for a presentation. Rather than providing a vague request, you might refine your prompt as follows:

  • "Please summarize the following article, highlighting the most critical factors influencing climate change, and present the key findings in 3-4 concise, well-structured sentences, ensuring to emphasize the causes, effects, and proposed solutions discussed."

In this case, you’re not just asking for a summary, but specifying which elements of the article should be prioritized and how the summary should be structured. The LLM interprets this request through a combination of clear instructions and context, allowing it to generate a more focused and relevant output tailored to your needs.

Interactive Section: Craft Your Own Prompts

Now, let’s try crafting some prompts for different tasks.

  1. Task: Summarize a book

    • Prompt Example: "Provide a brief summary of Harry Potter and the Sorcerer's Stone in 5 sentences."

  2. Task: Generate a creative idea

    • Prompt Example: "Give me 3 unique business ideas for a sustainable startup."

Take a moment to write your own prompt for one of the following tasks:

  • Summarize an article about climate change.

  • Write a poem about winter.

  • Provide a list of tips for improving productivity at work.

Activity 1: Crafting Effective Prompts

Instructions:

  1. Think of a task that you'd like an LLM to help with (e.g., summarizing a text, creating a recipe, or generating ideas).

  2. Craft a prompt that clearly communicates your request.

  3. Share your prompt with a partner or group (if possible) and discuss whether the wording effectively conveys your request.

  4. Adjust the prompt based on feedback and try again.

Example Task: "Describe the impact of AI on education."

Step 1: Craft a prompt.

  • Example: "In 3-4 sentences, explain how AI is changing the landscape of education and learning."

Step 2: Share, discuss, and refine.

Activity 2: Experimenting with Different Prompts

Instructions:

  1. Choose an AI-related task (e.g., generating a title for a blog post, creating a product description, or explaining a concept).

  2. Try different variations of your prompt:

    • Short version

    • Detailed version

    • Asking for examples

  3. Evaluate the results. Did any prompt produce a better or more relevant answer than others?

Example Task: Generate a product description for a smart water bottle.

  • Short version: "Describe a smart water bottle."

  • Detailed version: "Write a compelling product description for a smart water bottle that tracks water intake and syncs with mobile devices."

Key Takeaways:

  • A prompt is a request you give to a large language model in natural language.

  • Prompt engineering is the practice of crafting clear, specific, and effective prompts to get the desired output.

  • Experiment with different prompt structures and details to refine your skills.

Remember, prompt engineering is an art. The more you practice, the better you'll get at creating precise and engaging prompts that help you achieve the results you want.