Skip to Main Content

Artificial Intelligence

Welcome to this Zayed University Library guide, designed to assist you on your path through the realm of Artificial Intelligence.

Basic Prompting

The quality of generative AI output is heavily influenced by the instructions it receives (also known as the "prompt"). Tweaking these prompts, a skill known as "prompt engineering," can be used to improve the results significantly. According to some, the ability to interact with AI might even be the most important work skill of this century. Prompt engineering is an emerging field and the guidelines are still taking shape as users continue to explore different possibilities to improve outputs.

Prompt engineering is similar to building a search query for information retrieval. Just like using specific search terms or phrases in a search engine to get the desired results, prompt engineering also involves the selection of words or phrases to interact effectively with AI. When using search engines, a general search query often leads into many irrelevant results. Similarly, in the context of AI prompts, general instructions often lead into general or vague responses. Prompt engineering enhances the likelihood of getting relevant and useful outputs from the AI models. Here are some tips and examples to improve your prompt.

Step Example
1. Start by giving the AI a Persona or Role using the "act as" command. This defines how the AI should act or behave. Act as an experienced Professor of Marketing
2. Specify the Task or Verb. Here you specify what you want the AI to do. Create a presentation transcript about the 5 Ps of Marketing

3. Add additional instructions, such as...

 
Format A presentation transcript
Length The transcript shouldn't be longer than 1000 words
Objective The objective is to explain the basics of 5 Ps of Marketing to absolute beginners
Tone Professional / playful / humorous (see also 80 important Adjectives for ChatGPT)
Target Audience / Complexity level Target level is undergraduate students
Do's and Don'ts You may include some jokes but keep it professional
Example(s) of desired result(s)

Slide Title: What is Marketing?

Transcript: Before we dive into the 5 Ps, let's briefly touch on what marketing is. Marketing is not just about selling products; it's about creating value for both customers and the company. It's a dance between satisfying customer needs and achieving business goals.

You can compare the difference in ChatGPT yourself with these two prompts:

After the initial output, you can always give additional instructions and ask the AI to improve specific aspects of the output, for example:

  • Make it more casual but keep it academic
  • Add a new part about [topic X]
  • Don't talk about [topic X]
  • Shorten/Expand [section X]
  • Explain [topic X] in simple terms
  • Rewrite [section X]

See also AI Use Cases in this guide for other useful tips.

Advanced Prompting

Zero, One and Few-Shot prompting

Zero, One and Few-Shot prompting means giving zero, one or several examples to the AI to guide it towards the desired output. Usually giving examples improves the output significantly.

Zero Shot One Shot Few Shot
Determine the sentiment of this sentence: This basketball has a lot of weight.
 
Example sentence: This basketball is easy to carry.
Example answer: The sentiment of this sentence is positive.
Determine the sentiment of the sentence: This basketball has a lot of weight

 
Sentence: This basketball fits in my bag.
Sentiment: somewhat positive.
Sentence: This basketball deflates after just one game!
Sentiment: extremely negative.
Sentence: This basketball is orange.
Sentiment: neutral.
Sentence: This basketball’s feel is a bit better than I am used to.
Sentiment:

 
The sentiment of the sentence "This basketball has a lot of weight" is neutral. It does not convey a positive or negative sentiment; rather, it is a straightforward statement about the basketball's weight. The sentiment of the sentence "This basketball has a lot of weight" is negative. It suggests that the basketball is heavy, which is generally considered undesirable for a basketball, as lighter basketballs are typically easier to handle and play with. The sentiment of the sentence "This basketball’s feel is a bit better than I am used to" is somewhat positive. It indicates that the speaker finds the feel of the basketball to be better than what they are accustomed to, which suggests a positive impression, although it's not overwhelmingly positive.

 Source: Prompt Engineering 101: Zero, One, and Few-Shot Prompting

Chain-of-Thought (CoT)

Chain-of-thought (CoT) prompting enables the AI to simulate reasoning capabilities through intermediate steps. This gives the model more time to "think" and correct possible mistakes before reaching the final answer. You can combine this with one or few shot examples that include the intermediate steps.

You can also try "Zero-Shot CoT" by adding the phrase "Let’s think step by step" to your prompt. For example: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each an has 3 tennis balls. How many tennis balls does he have now? Let’s think step by step.

Sources: Prompt Engineering Guide: CoT, Wei et al. (2022) and Kojima et al. (2022)

ReAct (Reason + Act)

ReAct prompting enables the AI to simulate thinking patterns and required actions. By specifying an example pattern, the AI can mimic it in another task. In the example below, the pattern includes an example question, thought, action and observation. The model then uses this pattern to answer the final question. This type of prompting works best with Retrieval Augmented Generation (RAG), where the AI uses external information (e.g. Wikipedia) to check the facts.

Prompt Response
Use the following template to answer the question:
-----
Question: Actor Tom Hanks has worked with the director of E.T. in which iconic film?
Thought: I need to identify the director of E.T. and then find out which iconic film Tom Hanks worked on with this director.
Action: Search for the director of the movie E.T.
Observation: The director of E.T. is Steven Spielberg.
Thought: Now that I know the director is Steven Spielberg, I need to find out which iconic film Tom Hanks worked on with Steven Spielberg.
Action: Search for the iconic film that Tom Hanks and Steven Spielberg collaborated on.
Observation: Tom Hanks and Steven Spielberg collaborated on the iconic film "Saving Private Ryan."
Final Answer: Tom Hanks worked with the director of E.T., Steven Spielberg, in the iconic film "Saving Private Ryan."
-----
Question: Who was the president of Finland when UAE became independent?

Thought: I need to determine the year when the UAE became independent and then find out who was the president of Finland during that time.
Action: Search for the year when the UAE became independent.
Observation: The United Arab Emirates (UAE) became independent from the United Kingdom on December 2, 1971.
Action: Find out who the president of Finland was in 1971.
Observation: In 1971, the President of Finland was Urho Kekkonen.
Final Answer: The president of Finland when the UAE became independent in 1971 was Urho Kekkonen.

Source: Prompt Engineering Guide: ReAct, Yao et al. (2022)

Self-ask prompting

Self-asking enables the AI to ask itself if follow up questions are needed to reach the final answer. This helps the AI to evaluate the information it has and provide more relevant answers.

Prompt Response

Use the following template to answer the question:
-----
Question: Who lived longer, Elvis Presley or John Lennon?
Are follow up questions needed here? Yes.
Follow up: How old was Elvis Presley when he died?
Intermediate answer: Elvis Presley was 42 years old when he died.
Follow up: How old was John Lennon when he died?
Intermediate answer: John Lennon was 40 years old when he died.
So the final answer is: Elvis Presley
-----

Question: Who lived longer, Urho Kekkonen or Sheikh Zayed?

Question: Who lived longer, Urho Kekkonen or Sheikh Zayed?
Are follow up questions needed here? Yes.
Follow up: How old was Urho Kekkonen when he died?
Intermediate answer: Urho Kekkonen was 85 years old when he died.
Follow up: How old was Sheikh Zayed when he died?
Intermediate answer: Sheikh Zayed was 86 years old when he died.
So the final answer is: Sheikh Zayed

Source: Press et al. (2022)

Symbolic Reasoning

In symbolic reasoning, the AI can be instructed to convert parts of the prompt into symbols for easier processing. This can be done by simply adding the phrase "use symbolic reasoning" into the prompt.

Prompt Response
I have a chair, two potatoes, a cauliflower, a lettuce head, two tables, a cabbage, two onions and three fridges. How many vegetables do I have? Use symbolic reasoning

Let's use symbolic reasoning to determine how many vegetables you have. We'll assign symbols to each item:
Chair (C), Potatoes (P), Cauliflower (CF), Lettuce head (L), Tables (T), Cabbage (CB), Onions (O), Fridges (F)

Now, let's count the vegetables: Potatoes (2P), Cauliflower (1CF), Lettuce head (1L), Cabbage (1CB), Onions (2O)

To find the total number of vegetables, we'll add up the quantities of each vegetable:
2P + 1CF + 1L + 1CB + 2O =

2 potatoes + 1 cauliflower + 1 lettuce head + 1 cabbage + 2 onions = 7 vegetables.

Source: Gao et al. (2022)

Other Prompting Techniques

Since Large Language Models enable you to use natural language to interact with the model, there's much room for experimentation. We strongly encourage you to experiment and try different ways of reaching the desired results. Here are some additional emerging and experimental prompting techniques:

Image source: Cobus Greyling: 12 Prompt Engineering Techniques