top of page

Register For Updates

Search

What is Prompt Engineering?

  • Writer: James Henry
    James Henry
  • Oct 1, 2023
  • 7 min read

You may have heard of prompt engineering in the context of using ChatGPT or similar; it sounds technical, but what is it? Note that I am focusing on the text-generating AIs, not the image models like Midjourney or Dall.e


Prompt engineering is simply how you ask a Large Language Model (LLM) AI such as ChatGPT, Bard or Claude, to do something.



Is Prompt Engineering Difficult?


No, or maybe Yes!


Oh! You can get an awful lot of value from these LLM AIs by simply asking your question as you might another person. But as with asking people to do things, how you express your question can influence the results.


So, where to start? Just start with a normal question. When you get a response, think of a question to expand or clarify the response—experiment but interact with the AI. Then we can try something more fun.


"Act like..."


Again, you may have heard of this technique for asking questions of these types of artificial intelligence. It may or may not be necessary, depending on the nature of the question or interaction. Try the following two examples, I suggest using ChatGPT, https://chat.openai.com/:

  • Act like William Shakespeare and write a 5 line poem about summer.

  • Act like [enter the name of a poet] and write a 5 line poem about summer.

I tried this for five poets: William Shakespeare, Confucious (ok, not a poet but a strong supporter), Walt Whitman, Oscar Wilde, and Rudyard Kipling. I then asked, "Contrast the styles of the above as you have constructed them," to which ChatGPT responded:


Certainly, the styles of the poems vary according to the poets they aim to emulate:

  1. William Shakespeare: Written in iambic pentameter, the poem uses a traditional structure often found in Shakespearean work. The language is slightly archaic, and it deals with universal themes like love and the fleeting nature of time ("Ah, summer's kiss, a fleeting, sweet esteem").

  2. Confucius: This poem aims for simplicity and wisdom, hallmarks of Confucian philosophy. It underscores the balance and harmony found in nature ("In every season, wisdom is the balm"), reflecting Confucius' emphasis on the natural order and ethical living.

  3. Walt Whitman: Emulating Whitman's free verse and celebration of nature and individualism, this poem exudes expansiveness and inclusivity ("Within your warmth, I find myself expand"). Whitman's style often embraces the 'common' elements of life as worthy of poetic exploration.

  4. Oscar Wilde: This poem plays on themes of vanity and societal norms, echoing Wilde's wit and his ability to question social constructs ("For beauty's sin is fading, not the sin"). The tone is a bit ironic and aims to be as clever as Wilde himself.

  5. Rudyard Kipling: Known for his storytelling and moral lessons, this poem tries to encapsulate Kipling's straightforward, instructive style ("In every season, let your courage hum"). It speaks to the human condition, offering advice on how to handle life's challenges.

Each poem aims to capture the essence of its respective poet's style, themes, and typical language choices.


To me, that is a fun example of the power of "Act like..." but let us see what the LLMs have to say on the topic.


ChatGPT and "Act like..."


Starting a prompt with "Act like..." can be useful when you want to guide the behavior or role of the person (or in this case, the AI) responding to the prompt. This phrasing sets a clear expectation for the style, tone, or formality of the response you're seeking. It can be particularly useful in the following scenarios:

  1. Role-playing: When you want the respondent to assume a particular role (e.g., "Act like you are Shakespeare and write a sonnet").

  2. Imitating a Style: If you're looking for a response in a particular style or from a particular perspective (e.g., "Act like a financial advisor and tell me how to invest my savings").

  3. Simulation: If you're interested in seeing how someone would respond in a given situation (e.g., "Act like you're a customer service agent dealing with a difficult customer").

  4. Setting Tone or Mood: When you want the response to capture a specific emotional tone (e.g., "Act like you're an excited tour guide describing a new attraction").

  5. Educational Exercises: If you're practicing a skill and want the respondent to play the role of a tutor or examiner (e.g., "Act like you're a professor grading my essay").

However, the "Act like..." phrasing is not always necessary. Often, a well-crafted prompt without "Act like..." can achieve the same goal. The choice to use it depends on how explicit you wish to be in guiding the response and whether you think the additional direction would yield a more accurate or useful answer.


So, if you have a specific vision for the type of response you'd like to see, starting your prompt with "Act like..." could be a good idea.


Bard and "Act like"


Starting a prompt with "Act like..." is important when you want the LLM to generate text in a specific style or persona. For example, if you want the LLM to generate text in the style of a Shakespearean play, you might start your prompt with "Act like William Shakespeare."


Starting a prompt with "Act like..." is also important when you want the LLM to generate text from the perspective of a specific character or group of people. For example, if you want the LLM to generate text from the perspective of a robot, you might start your prompt with "Act like a robot."


Here are some examples of situations where it might be important to start a prompt with "Act like...":

  • When you want the LLM to generate text in a specific style, such as the style of a Shakespearean play or a news article.

  • When you want the LLM to generate text from the perspective of a specific character or group of people, such as the perspective of a robot or a customer service representative.

  • When you want the LLM to generate text that is consistent with a specific brand or tone of voice.

However, it is not always necessary to start a prompt with "Act like...". For example, if you want the LLM to answer a question in a comprehensive and informative way, you can simply start your prompt with "Answer the following question:".


Ultimately, the best way to decide whether or not to start a prompt with "Act like..." is to think about the specific output you want to generate and the best way to achieve that output.


Here are some additional tips for using "Act like..." in prompts:

  • Be specific about the style or persona you want the LLM to adopt. For example, instead of saying, "Act like a writer," say, "Act like a creative writer who specializes in science fiction."

  • Provide the LLM with examples of text you like, written in the style or persona you want it to adopt.

  • Experiment with different prompts to see what works best.

Claude and "Act like..."


Using "Act like..." at the start of a prompt can be very important and useful in certain situations when requesting something from an AI assistant. Here are some key points on when and why it's important to start a prompt with "Act like...":

  • It signals to the AI that you want it to actively roleplay and respond from a specific perspective, rather than just providing information. This cues the AI to mimic a target personality/character.

  • Starting with "Act like..." is crucial when you want the AI to speak or write with a particular tone, attitude, opinion, or emotional disposition in mind.

  • It's important to use when asking the AI to generate creative writing, dialogue, or any response that involves conveying a distinct voice or viewpoint.

  • The instruction tells the AI to take on an active, participatory role in its response, not just answer passively. This elicits more dynamic and involved responses.

  • It prompts the AI to interpret the remainder of the prompt through a directed, subjective lens rather than answering objectively.

  • You should use “Act like...” when you want the AI to respond in-character rather than just as itself. This makes interactions more immersive.

In summary, "Act like..." is very useful for framing subjective, in-character requests and steering the AI into a particular mindset or persona. Without this clear instruction, prompts can often be interpreted literally rather than as a creative roleplaying opportunity.


But Wait, There's More!


Since the release of ChatGPT on Nov 30, 2022, there has been significant experimentation and development in prompt engineering methods. Here is a current list courtesy of the LLMs. There are brief explanations, and I suggest if you want to delve into any of them that you ask an LLM to guide you:


Basic Techniques

  • Specificity: Make the prompt specific to guide the model.

  • Contextualization: Provide additional context for better accuracy.

  • Question Decomposition: Break down complex queries into simpler questions.

  • Instructional Prompts: Use explicit task-based instructions.

  • Constrained Output: Limit the output's length or format.

  • Completeness: Be complete in your prompts, provide all the information needed.

  • Clarity: Prompts should be clear and easy to understand. Avoid jargon or overly complex language.

Intermediate Techniques

  • Multiple Prompts: Ask the question in multiple ways for clarity.

  • Placeholder Techniques: Use templates where the model fills in the blanks.

  • Iterative Refinement: Continuously refine prompts based on outputs.

  • Role-play or Directive Prompts: Use "Act as..." for style or tone.

  • Counterfactuals: Employ "What would happen if..." for nuanced answers.

  • Meta-Prompts: Instruct the model to think step-by-step or debate pros and cons.

  • Prompt Examples: Provide examples of text that you like, as well as examples of prompts that have worked well in the past.

Advanced Techniques

  • Clarification Prompts: The model asks questions to the user for more context.

  • Negative Constraints: Specify what you don't want in the answer.

  • Confidence Indicators: Ask the model to state its confidence level.

  • Cascading Prompts: Use a series of prompts for complex tasks.

  • Error Correction: Ask the model to revise or correct a given text.

  • Prompt Chains: Prompt chains are a series of prompts that guide the LLM to generate the desired output.

Specialized Techniques

  • Generative vs. Discriminative Prompts: Use generative prompts for creation and discriminative ones for evaluation.

  • Parallel Prompts: Disambiguate complex queries by asking them in parallel ways.

  • Conditional Prompts: Use conditions like "If X, then Y."

  • Prospective or Retrospective Prompting: Ask the model to consider the future or the past.

  • A/B Testing: Experiment with different prompts to see which works best.

  • Ethical or Safety Guidelines: Include ethical or safety constraints in the prompt.

  • Expert-Level Querying: Use specialized jargon for expert-level tasks.

  • Creative Constraints: Constrain the LLM only to use certain words or phrases or to write in a specific style.

  • Human-in-the-loop Prompting: A technique where the human user provides feedback to the LLM on its output.

Prompt engineering is both an art and a science, requiring a blend of creativity, empirical testing, and ongoing refinement to get the most out of the model.


Try:


 
 
 

Komentáře


Join our mailing list

Thanks for subscribing!

noun-nanotechnology-2182707 a copy.png

Older People and Artificial Intelligence

Thanks for subscribing!

  • Instagram
  • Facebook
  • Twitter

© 2023 Older.AI

bottom of page