Skip to Main Content

AI LibGuide: Prompt Engineering - How to prompt an AI tool

Prompt Engineering - What is an AI prompt?

Prompt Engineering is a technique used to interact effectively with an AI system, like ChatGPT, to get the best possible answers or outputs. Think of it as crafting the "perfect question" or instruction to guide the AI in giving you the right response.

What is an AI prompt?

An artificial intelligence (AI) prompt is a mode of interaction between a human and a large language model that lets the model generate the intended output. This interaction can be in the form of a question, text, code, snippets or examples.

Here are some tips on how to get started.

What is Prompt Engineering?

Imagine you're asking a friend for help. If ou give vague instructions, they might not know exactly what you need. For example:

  • Vague: "Tell me something about AI."
  • Specific: "Explain the difference between supervised and unsupervised learning in AI, with examples."

Prompt engineering works the same way with AI. The way you phrase your question or instruction affects the AI's answer. Therefore, be specific!

Why is it important?

  1. Clarity: A well-crafted prompt avoids confusion.
  2. Efficiency: It saves time by reducing back-an-forth clarifications.
  3. Better results: The AI provides more accurate and relevant responses.

Tips on Prompt Engineering

Why you should learn Prompt Engineering?

It is important to note the following:

  1. Research skills: helps you get better answers from AI tools when writing essays, solving problems, or studying.
  2. Time-Saving: reduces the time spent rephrasing questions or searching for answers.
  3. Criting Thinking: encourages you to think about what you need and how to ask for it.

Examples for students:

Let's say you're researching climate change. Compare these two prompts:

Simple: "Tell me about climate change."

Output: A generic overview.

Improved: "Explain how climate change affects marine life, focusing on corla reefs and fish populations."

Output: Detailed, focused, and relevant.

Be aware of "hallucinations"

What are AI "hallucinations"?

AI hallucinations occur when a generative AI model produces outputs that are incorrect, fabricated, or non-sensical while appearing plausible or confident in the output. These outputs are not based on the training data or logical reasoning.

Causes:

  1. Lack of specific training data: The AI fills gaps with guesses.
  2. Overgeneralisation: The model applies patterns from unrelated contexts.
  3. Model architecture limitations: AI models predict text probability without understanding.

AI Hallucinations explained

Key Techniques in Prompt Engineering

  1. Be Specific: Provide clear instructions and include necessary details. 
    • Example: Instead of saying "Write about AI," try "Write a 300-word essay on how AI is used in healthcare."
  2. Set the Context: Tell the AI who it should "act like" or what style to use.
    • Example: "Act as a historian and explain the signficance of the Renaissance."
  3. Use Constraints: Limit or structure the response.
    • Example: "List five ethical concerns about AI in bullet ponts."
  4. Ask follow-up quesions: If the first response isn't perfect, refine your prompt based on the answer.
    • Example: "Expand on the sectond point with are real-world example."
  5. Test and iterate: Experiment with different wordings to see which gives the best response.

Examples of AI "Hallucinations"

It has been found that an AI tool can make up historical events or scientific facts. AI tools can fabricate details about a topic it was queried on.

Implications:

  • Misinformation: users might believe the false outputs.
  • Trust issues: reduces the credibility of the AI tools.
  • Critical thinking dependency: requires users to fact-check and provide creative and critical thinking in research.

Example of a "hallucination":

If asked for sources on "neural networks", the AI might generate:

Smith, J., & Doe, A. (2015). Advances in Neural Networks. Journal of Computational Science, 45(7), 234-245.

Check the authors. Article title might exist. Journal title does exist. Reference completely incorrect and fabricated!

Correct reference:

Smith, JL. (2020). Advances in Neural Networks and potential for their application to steel metallurgy. Materials Science and Technology, 36(17): 1805-1819.