Prompt Engineering: How to Get better results

In the world of natural language processing and artificial intelligence, prompt engineering has become an essential tool for enhancing and refining language model outputs. The ability to formulate questions or commands effectively can make the difference between obtaining accurate answers and confusing results.

In this article, we will explore best practices in prompt engineering to optimize your interactions with language models, focusing particularly on the context of GPT (Generative Pre-trained Transformer) and techniques applicable to similar architectures.

Photo by Mojahid Mottakin on Unsplash

Improve Your Instructions

Clear and specific instructions form the foundation of a good interaction with language models. Here are some ways to improve your instructions:

  • Be Specific: Instead of vague instructions, provide specific details about what you expect in the response.

Example:

Instead of: "Generate a response about artificial intelligence."

Use:

"Provide a detailed summary of how artificial intelligence is impacting healthcare."
  • Add Context: Provide background information to contextualize the task. This helps the model better understand the context of your request.

Example:

Instead of: "Write about sustainability."

Use:

"Imagine you're writing a blog entry on sustainability."

Provide specific data on how renewable energies are positively impacting the environment.

Other things you can do to improve your instructions include:

  • Instruct the model to act like a person.
  • Use delimiters to distinguish parts of your input.
  • Specify steps if your task is complex.

Add Reference Texts

Providing specific examples or reference texts can significantly enhance the quality of responses. This helps the model better understand the tone, style, and content you are seeking.

Example:

Write a persuasive paragraph about the importance of space exploration. Include information from the following two reference texts: 
Text 1: first paragraph...
Text 2: second paragraph...

You can also instruct the model to respond using quotes from a reference text, such as a website or a book.

Break Complex Tasks into Smaller Tasks

When facing a complex task, consider breaking it into smaller, more manageable tasks. This allows the model to focus on specific aspects and produce more accurate responses.

Example:

Instead of: "Describe all features of an operating system."
Bestseller No. 1
Pwshymi Printhead Printers Head Replacement for R1390 L1800 Printhead R390 R270 R1430 1400 for Home Office Printhead Replacement Part Officeproducts Componentes de electrodomésti
  • Function Test: Only printer printheads that have...
  • Stable Performance: With stable printing...
  • Durable ABS Material: Our printheads are made of...
  • Easy Installation: No complicated assembly...
  • Wide Compatibility: Our print head replacement is...
Bestseller No. 2
United States Travel Map Pin Board | USA Wall Map on Canvas (43 x 30) [office_product]
  • PIN YOUR ADVENTURES: Turn your travels into wall...
  • MADE FOR TRAVELERS: USA push pin travel map...
  • DISPLAY AS WALL ART: Becoming a focal point of any...
  • OUTSTANDING QUALITY: We guarantee the long-lasting...
  • INCLUDED: Every sustainable US map with pins comes...

Use:

"List and explain three key features of a modern operating system: security, multitasking, and file management."

Other techniques you can use include creating document summaries by providing excerpts rather than asking for the entire document and classifying the query type first, using that classification to determine which instructions are needed.

Give the Model Time to Think and Analyze Responses

Language models like GPT-3.5 can benefit from additional time to process and generate more elaborate responses. Don’t hesitate to adjust time parameters according to your needs.

Example:

Instead of: "Find the solution to the following differential equation: …"

Use:

"Find the solution to the following differential equation: …, use a calculator, perform checks, and provide the result once you've verified that the solution is correct."

Use External Tools

Integrating external tools can improve the quality and diversity of responses. You can use APIs from other platforms to obtain additional information or perform specific tasks.

Example:

You can write and execute Python code by enclosing it in triple quotes.

```python
import message
message.write(to="John Doe", message="Hey, want to meetup after work?")
```

Systematically Test Your Changes

New
ABYstyle - Call of Duty Toiletry Bag Search and Destroy, Black, 26 x 14 x 8.5 cm, Handle on pencil case for easy carrying, Black, 26 x 14 x 8.5 cm, Handle on pencil case for easy carrying
  • 100% official
  • Very practical with multiple pockets
  • Handle on pencil case for easy carrying
  • Material: Polyester
  • Dimensions: 26 x 14 x 8.5 cm
New
1890 Wing Angel Goddess Hobo Morgan Coin Pendant - US Challenge Coin Liberty Eagle Novel Coin Adult Toy Funny Sexy Coin Lucky Coin Pendant Storage Bag for Festival Party
  • FUNNY COIN&BAG: You will get a coin and jewelry...
  • NOVELTY DESIGN: Perfect copy the original coins,...
  • LUCKY POUCH: The feel of the flannelette bag is...
  • SIZE: Fine quality and beautiful packing. Coin...
  • PERFECT GIFT: 1*Coin with Exquisite Jewelry Bag....
New
Panther red Fleece Beanie
  • German (Publication Language)

Systematically test your instructions and parameters. Observe how responses change when modifying certain aspects and adjust accordingly. Make several requests with different configurations and compare the responses.

Final Summary and Recommendations

Prompt engineering is a skill that improves with practice. Experiment with various strategies, adjust based on results, and continually refine your approach. By consistently improving your instructions and techniques, you will maximize the effectiveness of language models like GPT-3.5 in your applications. Remember to consult OpenAI’s documentation for in-depth strategies.

Keep in mind that each task may require a unique approach, so maintain flexibility and creativity in your prompt engineering process. Get the most out of your interactions with GPT through effective prompt engineering!

Original Postrompt-engineering-how-to-get-better-results-b4a14b511599" target="_blank" data-width="840" data-border="1" data-collapsed="">View at Medium.com