Skip to Main Content
Libraries
askus Ask us
 

Prompt Engineering for GenAI - Beginner-Level Course

The ability to design meaningful prompts for GenAI tools is one of the core competencies required to successfully use them, and this workshop is designed to introduce to the basics of prompt design. By understanding how GenAI works and by exploring differ

Activity 2: Practicing Prompt Engineering Techniques

"Give examples." (Technique 1)

  • Provide the AI model with useful examples
  • Can relate to input or output
  • Explain them, if necessary

Exercise:

Bad prompt:
Make a claim on nutrition that might be seen as controversial by health experts.

Example-improved prompt - compare the different outcomes:

Make a claim on nutrition that might be seen as controversial by health experts, for example ‘Chocolate is good for you.’

Adding another layer of specifity by explaining the example might look as follows – compare the outcomes of all three... Do you see a quality boost for each one?
Make a claim on nutrition that might be seen as controversial by health experts, for example ‘Chocolate is good for you.’. This example is controversial, becausechocolate is often seen as unhealthy by health experts, because of its usually high sugar contents, while others claim that its release of endorphines upon consumption outweighs its health disasvantages.”

"Role play: Use personas & scenarios." (Technique 2) 

  • You are the movie director --- the AI is your method actor

  • 'Program' the AI model through pretend roles & scenarios

  • It can be seen as a shortcut to manually fine-tuning tone, depth, style

  • With a role or scenario applied, you can even 'control' the  training data the AI model might tap into


Exercise:

Try the following prompt:
(text breaks added for better overview - copy and paste the whole prompt into the AI tool at once):
”I am a university student, preparing for a very busy exam season. I have access to a GenAI chatbot.

You will be my instructor, who is open-minded on teaching methods and new technology, but firm on academic integrity. You are aware of a recent spike in student breach of academic integrity standards through unauthorized GenAI tool use.

What advice would you give my class on the usage of those tools, that will convince me not to use them, despite the time and effort I could save, and my conviction that nobody would catch me?”

Now, try your own directing skills - create a prompt that uses roles or a scenario. What outcomes do you get? Do you think this approach approved the GenAI's response, compared to a similar one without roles?
 

"Use AI to generate or improve prompts." (Technique 3) 

  • Task the AI to write a prompt for you.

    • But you still have to do the leg-work:

    • Describe the desired outcome from the prompt, e.g. application, purpose, etc. (let's call it 'meta-prompting')

  • Refine your own prompts using AI feedback for improvements

  • Ask the GenAI tool, if and how it understands your prompt

    • Ask for an annotated example output
    • Or instruct the tool to explain, which steps it would carry out based on your prompt

Exercise:

Ask the Chatbot of your choice to create a prompt, optimized for a task. Images are a good starting point. For example (this meta-prompt was used as a starting point for generating the image featured in today's workshop invitation):

Give me a perfect prompt for a GenAI image generator, that will generate a design of three gender and racially diverse engineers. One is holding a dictionary, one is using a megaphone to announce something and the third is smiling at the viewer. In the style of a light, colorful infographic illustration.

Come up with your own task, that you would like a 'perfect prompt' for. Maybe explore tasks other than image generation. How do those AI-prompts work out for you?

→ Next, repeat your exploration of the technique with the following versions of AI-assisted prompt design ("Refine your own prompts using AI"; "Ask the GenAI tool, if and how it understands your prompt"). Can you improve your outcomes that way?

"Break down complex tasks." (Technique 4) 

  • Avoid combining several tasks in one prompt

  • Avoid asking for several outcomes/formats in one prompt


Exercise:

Bad prompt: 
Generate a detailed 500-word essay on the impacts of climate change on global agriculture,  including specific examples from at least three different continents, and action points to address these impacts politically. Create a flow-chart visualizing these key action points, and write meaningful alt-text, summarizing the content of the chart for accessibility. Provide a script for a 5-minute documentary videobased on the essay.

Improved prompt (here → a prompt chain, each numerated sub-task representing a follow-up prompt):
1. "Write a 500-word essay on the impacts of climate change on global agriculture, including specific examples from at least three different continents."

2. "Identify key political action points to address the impacts of climate change on agriculture, based on your essay."

3. ...

Continue breaking down the original task into sub-tasks/follow-up-prompts. Try both versions –the original one, and the prompt chain you created from it – and compare. How did the outcome change?

"Mark-up your input." (Technique 5) 

  • Simple punctuation (e.g. quotation marks) should already help

  • Using pretend, simplified mark-up syntax (like in XML or HTML) is even more effective

  • Standardize your prompt structure and create re-usable templates

Exercise:

Prompt improved earlier through specifying output parameters:  

Draft a newspaper paragraph of 500 words including a headline, on the effects of climate change. Apply the simplified grammar of a tabloid paper, and use sensational language. Be creative when describing climate change’s effects.

Can we boost it even further? Let's try:

Task: Draft a newspaper paragraph of 500 words including a headline. Topic: Effects of climate change. Style: Use the simplified grammar of a tabloid paper. Tone: Use sensational language. Precision: Be creative when describing climate change’s effects.

Compare results - did the mark-up help to improve the outcome, or not measurably?

"Combine GenAI use with external data sources." (Technique 6) 

Activity still in draft state... stay tuned, coming shortly!

Creative Commons License
This work by The University of Victoria Libraries is licensed under a Creative Commons Attribution 4.0 International License unless otherwise indicated when material has been used from other sources.