Generative AI

Prompt Engineering

Interactions between users and generative AI tools--whether it be in the form of questions, sentences, data, etc.--are known as prompts. Prompts require human intuition and creativity in order to formulate the right query and combination of elements needed to activate an AI tool's prompt logic.

Prompts are explicit instructions that enable an AI tool to produce the desired output. Additionally, Role Prompting assigns AI a role to act as a certain person (i.e. "You are my teacher", "You are a food critic", "You are a brilliant physicist who can solve any problem in the world", etc), which can improve accuracy and typically modifies how the AI tool will generate output.

Below are things to keep in mind when writing AI Prompts.

CLEAR Framework

 

Concise, Logical, Explicit, Adaptive, and Reflective

 

USE THIS

(Good)

INSTEAD OF THIS

(Not so good)

CONCISE: brevity and clarity in prompts

Remove unnecessary words, give clear instructions, be specific.

"Explain the process of collecting data"  "Can you provide me with a detailed explanation of the process of collecting data and its significance?"

LOGICAL: structured and coherent prompts

Provide information that follows a natural progression and ensure the relationships between concepts are evident.

“Describe the steps in searching databases, starting with choosing a topic and including basic search functions"   "How do I research a topic?"

EXPLICIT: clear output specifications

Provide precise instructions for desired output format, content, or scope.

"Provide an historical overview of the Naval Postgraduate School, emphasizing when it was relocated to Monterey, CA" "Tell me about the Naval Postgraduate School"

So you've made your initial prompts, what's next? Keep going!

ADAPTIVE: flexibility and customization in prompts

Experiment with different prompt formulations and phrasings; be flexible.

Initial Prompt: "Discuss the impact of having pets"

Answer: (includes "physical health")

Prompt Two: What are the physical health benefits to having a pet dog?

 

REFLECTIVE: continuous evaluation and improvement prompts

Evaluate the performance of your AI tool and adjust accordingly. Does the answer it gave make inuitive sense? Is the answer complete?

After recieving AI-generated list of research strategies, evaluate the relevance and applicability. Who is the target audience? Use this information and tailor your next prompts to be more specific to what you are researching.

Lo, L. S. (2023). The CLEAR path: A framework for enhancing information literacy through prompt engineering. The Journal of Academic Librarianship, 49(4), 102720–. https://doi.org/10.1016/j.acalib.2023.102720 

Prompt Engineering Examples

Source: Google Developers--Maching Learning Glossary: Generative AI

Prompts are any text entered as input to a large language model to condition the model to behave in a certain way. Prompts can be as short as a phrase or arbitrarily long (for example, the entire text of a novel). Prompts fall into multiple categories, including those shown in the following table:

 

Prompt Category Example Notes
Question How fast can a pigeon fly?
Instruction Write a funny poem about arbitrage. A prompt that asks the large language model to do something.
Example Translate Markdown code to HTML. For example:
Markdown: * list item
HTML: <ul> <li>list item</li> </ul>
The first sentence in this example prompt is an instruction. The remainder of the prompt is the example.
Role Explain why gradient descent is used in machine learning training to a PhD in Physics. The first part of the sentence is an instruction; the phrase "to a PhD in Physics" is the role portion.
Partial input for the model to complete The Prime Minister of the United Kingdom lives at A partial input prompt can either end abruptly (as this example does) or end with an underscore.

 

A generative AI model can respond to a prompt with text, code, images, embeddings, videos…almost anything.

Verify Citations!

If the generative AI tool you are using gives you a reference, it is your responsibility to verify it actually exists.

Some ways to do this are by:

  1. Do a Library Search for the title and author.
  2. Copy and paste the citation into Google Scholar. Or do a Google search for the lead author to see their publications.
  3. Search the library's journal list and go straight to the source.

If you verify the source is real, read the source/summary to confirm it includes what the generative AI sources says it does.

 

Evaluating the Output

Consider these criteria before using generative AI results:

CRAAP test from Bluford Library at North Carolina State University

Currency: the timeliness of the information

  • When was the information published or posted?
  • Has the information been revised or updated?
  • Is the information current or out-of-date for your topic?
  • Are the links functional?

Relevance: the importance of the information for your needs

  • Does the information relate to your topic or answer your question?
  • Who is the intended audience?
  • Is the information at an appropriate level (i.e. not too elementary or advanced for your needs)?
  • Have you looked at a variety of sources before determining this is one you will use?
  • Would you be comfortable using this source for a research paper?

Authority: the source of the information

  • Who is the author/publisher/source/sponsor?
  • Are the author's credentials or organizational affiliations given?
  • What are the author's credentials or organizational affiliations given?
  • What are the author's qualifications to write on the topic?
  • Is there contact information, such as a publisher or e-mail address?
  • Does the URL reveal anything about the author or source? Examples: .com (commercial), .edu (educational), .gov (U.S. government), .org (nonprofit organization), or .net (network)

Accuracy: the reliability, truthfulness, and correctness of the content, and

  • Where does the information come from?
  • Is the information supported by evidence?
  • Has the information been reviewed or refereed?
  • Can you verify any of the information in another source or from personal knowledge?
  • Does the language or tone seem biased and free of emotion?
  • Are there spelling, grammar, or other typographical errors?

Purpose: the reason the information exists

  • What is the purpose of the information? to inform? teach? sell? entertain? persuade?
  • Do the authors/sponsors make their intentions or purpose clear?
  • Is the information fact? opinion? propaganda?
  • Does the point of view appear objective and impartial?
  • Are there political, ideological, cultural, religious, institutional, or personal biases?

By scoring each category on a scale from 1 to 10 (1 = worst, 10=best possible) you can give each site a grade on a 50 point scale for how high-quality it is!

45 - 50 Excellent | 40 - 44 Good | 35 - 39 Average | 30 - 34 Borderline Acceptable | Below 30  Unacceptable

Types of Prompts

Source: Google Developers: Prompt Engineering for Generative AI

  • Direct prompting (Zero-shot): Direct prompting (also known as Zero-shot) is the simplest type of prompt. It provides no examples to the model, just the instruction.

 

  • Prompting with examples (One-, few-, and multi-shot): One-shot prompting shows the model one clear, descriptive example of what you'd like it to imitate. 

 

  • Chain-of-thought prompting: Chain of Thought (CoT) prompting encourages the LLM to explain its reasoning. Combine it with few-shot prompting to get better results on more complex tasks that require reasoning before a response.

 

  • Zero-shot CoT: Recalling the zero-shot prompting from earlier, this approach takes a zero-shot prompt and adds an instruction: "Let's think step by step." The LLM is able to generate a chain of thought from this instruction, and usually a more accurate answer as well. This is a great approach to getting LLMs to generate correct answers for things like word problems.

 

Prompt iteration strategies
Learn to love the reality of rewriting prompts several (possibly dozens) of times. Here are a few ideas for refining prompts if you get stuck:

Note: These strategies may become less useful or necessary over time as models improve.

  1. Repeat key words, phrases, or ideas
  2. Specify your desired output format (CSV, JSON, etc.)
  3. Use all caps to stress important points or instructions. You can also try exaggerations or hyperbolic language; for example: "Your explanation should be absolutely impossible to misinterpret. Every single word must ooze clarity!"
  4. Use synonyms or alternate phrasing (e.g., instead of "Summarize," try appending "tldr" to some input text). Swap in different words or phrases and document which ones work better and which are worse.
  5. Try the sandwich technique with long prompts: Add the same statement in different places.
  6. Use a prompt library for inspiration. Prompt Hero and this prompt gallery are two good places to start.

Further Reading