Top 10 Prompt Engineering Dos and Don’ts

Prompt engineering is a brand new discipline for writing and optimizing prompts to efficiently use large language models (LLMs) for many applications and research topics. Prompt engineering aims to structure the prompt text you send to the LLM so that it is correctly interpreted and understood. Well-crafted prompts direct the LLM to produce accurate, relevant, and contextually appropriate responses.

These prompt engineering dos and don’ts will help you improve your generative AI work.

Be specific

Be as specific, descriptive and detailed as possible about your question or information request. The more specific you can be, the better the LLM can understand your prompt.

For example, ‘What makes Siamese cats appealing to many cat lovers?’

Conversely, avoid creating vague or general descriptions and over-complicating your prompts. That produces unpredictable results.

For example, ‘Tell me more about cats.’

Describe context

Describe your desired context, outcome, length, format, and style as part of your prompt.

For example, ‘Describe what makes Siamese cats appealing to many cat lovers in prose in approximately 100 words.’

Conversely, the absence of context will likely produce a reasonable response that doesn’t align with your unstated goal.

For example, ‘Tell me something interesting about Siamese cats.’

Be brief

Keep your prompts as short and focused as possible. You may think this point contradicts many other points in this article. Instead, this point illustrates that most of the guidance in this article requires you to make judgments and trade-offs.

For example, ‘Describe the coloration of Siamese cats in approximately 50 words.’

Conversely, don’t ramble on.

For example, ‘Notwithstanding intra-species variation and various breeder attempts to produce exotic fur colors, describe the typical coloration of Siamese cats in approximately 50 words.’

Separate instructions from context

Start your prompts with instructions followed by your context. Separate the two using double quotes. The single quotes are not part of the prompt. They’re here for clarity.

For example, ‘Describe what makes Siamese cats appealing to many cat lovers “in prose in approximately 100 words.”’

Less effectively, ‘Describe in prose what makes Siamese cats appealing to many cat lovers in approximately 100 words.’

Use explicit constraints

Adding constraints to your prompt helps narrow down the LLM response. Specifying a geographic area, time period, or language will narrow your response.

For example, ‘What is the population of Siamese cats owned by English-speaking citizens in Brooklyn?’

While no constraints will still produce a response, you will view it with low confidence.

For example, ‘What is the population of Siamese cats?’

Verify response accuracy

Verify the accuracy of responses by independently checking LLM responses against other sources. This task is essential because LLMs, even with all their power, still make mistakes that are termed hallucinations.

By verifying, you avoid possible embarrassment from mistakes or inadvertently misleading your audience.

An example of a hallucinatory LLM response to the prompt, ‘What do Siamese cats like to eat?’ might be, ‘Many Siamese cats like eating raw carrots.’

Avoid information overload

While it’s tempting to include as much detail as possible in your prompt, too much information can be counterproductive and might overload or confuse your LLM.

For example, ‘Describe what makes under-weight Siamese cats with black tails appealing to many left-handed cat lovers in Brooklyn who live on the third floor of brownstone condo buildings near dilapidated subway stations.’

Conversely, sufficient detail is more likely to produce an appropriate response.

For example, ‘Describe what makes Siamese cats appealing to many cat lovers in Brooklyn.’

Avoid leading and open-ended questions

Leading questions in your prompt can bias your LLM response.

A biased example, ‘Do you think black citizens prefer Siamese cats?’

Open-ended questions will produce a broad or generic LLM response that’s useless.

An open-ended example, ‘What do you think of Siamese cats?’

Employ iteration and fine-tuning

Even a thoughtfully crafted prompt will sometimes produce an off-target LLM response. Iterate and fine-tune your prompt to improve the quality and appropriateness of the LLM response.

For example, ‘Are Siamese cats happy?’ could be iterated to ‘What are the indicators that Siamese cats are happy?’

Regardless of your prompt technique, iterative prompting and fine-tuning are often necessary to arrive at the desired LLM response.

Avoid the word ‘not’

State what you want the LLM to do in your prompt. Don’t discuss what not to do.

Poor example: ‘What is the population of Brooklyn cats that are not Siamese?’

Better example: ‘What is the population of Brooklyn cats?’ or ‘How many cats in Brooklyn are Siamese?’

 

Applying these prompt engineering dos and don’ts will help you improve your generative AI work regardless of the LLM you are using or the topic you are researching.

 

What ideas can you contribute to help improve LLM responses through better prompt engineering? We’d love to hear your opinion. You can share that with us below. Select the checkmark for agreement or the X for disagreement. In either case, you’ll be asked if you also want to send your comments directly to our editorial team.

Would you recommend this article?

Share

Thanks for taking the time to let us know what you think of this article!
We'd love to hear your opinion about this or any other story you read in our publication.


Jim Love, Chief Content Officer, IT World Canada
Yogi Schulz
Yogi Schulzhttp://www.corvelle.com
Yogi Schulz has over 40 years of Information Technology experience in various industries. Yogi works extensively in the petroleum industry to select and implement financial, production revenue accounting, land & contracts, and geotechnical systems. He manages projects that arise from changes in business requirements, from the need to leverage technology opportunities and from mergers. His specialties include IT strategy, web strategy, and systems project management.

Featured Download

IT World Canada in your inbox

Our experienced team of journalists and bloggers bring you engaging in-depth interviews, videos and content targeted to IT professionals and line-of-business executives.

Latest Blogs

Senior Contributor Spotlight