Prompt engineering

making queries to systems with natural language

// updated 2025-12-11 18:30

A prompt refers to a query or request (written in the prompter's natural language such as English) to retrieve some information (i.e. process and generate text output), with the help of a trained system (known as a language model, or simply model, such as OpenAI ChatGPT or Google Gemini):

  • a prompt can consist of a:
    • vague suggestion
      • "tell me something about social media"
    • specific and contextual request
      • "write me a summary with six bullet points about social media's impact on the millennial generation, discussing positive and negative effects on their financial and social lives"

The more specific and descriptive the prompt, the more detailed and relevant the responses!

Specifics

  • format = how should we want the response to look like?
    • i.e. a list with bullet points? a chart with some number of columns? an image in the style of stop-motion animation?
  • context = what sub-topics do we want to explore in our prompt?
    • i.e. about a specific group of people in some place during some historical period?
  • role = what field of study or industry should the model look into?
    • i.e. should the model role-play a sports coach? a civil engineer? a poet? a web developer?
  • tone = what kind of voice should the output have?
    • e.g. professional / casual / humorous / dark humour-y?
  • length = how long of an output do we want?
    • i.e. specify the amount of lines or words or sentences
  • process = how should the model approach the prompt?
    • i.e. should the model do something before something else first?
  • examples = any similar scenarios with similar results for the model?
    • e.g. "if I want to learn web development, I should study HTML, CSS and JavaScript, so what should I study if I want to learn desktop application development?"

Not every prompt needs to consider all of the above; yet, some prompts might need to consider other things not listed up there! When creating prompts, the key takeaway lies in ensuring that the model understands the request:

  • avoid being "vague like the plague" and "being specific is terrific"
  • it should mimic the way we ask questions to people:
    • we try to ensure the other side understands us

If a prompt doesn't work the first time, it's not nearly as bad as an entire building collapsing; we simply just need to "rephrase" our request!

Prompting terminology

Prompting has different names for how specific we get:

  • zero-shot prompting = no examples given
    • used for straightforward queries with simple answers
      • e.g. "What is the capital of Canada?"
  • one-shot prompting = one example given
    • used to add context to something straightforward but could be mistaken for something else
      • e.g. (as in the AI agent example above) "if I want to learn web development, I should study HTML, CSS and JavaScript, so what should I study if I want to learn desktop application development?"
  • few-shot prompting = multiple examples given
    • used in order to train the model to detect a pattern so that it may use the pattern to generate a specific kind of output
      • e.g. "here are some samples of my movie reviews and their numeric ratings: (my review and rating samples), what would the rating be if my next review said 'I liked the storyline so much! I wanted to watch it again!'?"

Prompting also has other terms and strategies:

  • chain-of-thought prompting = output must show the model's "thought process"
    • just like how a math student must "show their work"
    • e.g. "I am going to take a trip that involves a flight, tell me what steps I need to or should take upon leaving my house up to the point of boarding, please include any optional steps as well"
  • "sub-prompting" = simply just breaking down what we want in smaller tasks and making prompts for those smaller tasks

The term "prompt engineering" can sound somewhat laughable (as the "engineering" part of it implies that it has to involve complex mathematics and computer programming!)

Perhaps "prompt refinement" or "prompt etiquette" might serve as better names for simply having better communication skills with the "generative pre-trained transformer" (aka the "large language model" or, as the common folk call it, the "AI")!

⬅️ older (in snippets)
🐙 Git ignore file
newer (in snippets) ➡️
Next.js — an introduction ➡️
⬅️ older (posts)
🐙 Git ignore file
newer (posts) ➡️
Next.js — an introduction ➡️