Pro(mpt) engineering: Suprisingly complicated

Prompt engineering expands interaction with AI tools beyond simple commands. It utilizes natural language to fully leverage the capabilities of AI. This type of communication is intuitive and democratizes access to AI, as it does not require specialized programming knowledge.

illustration eines mannes der mit einem chatbot kommuniziert

Fundamental Understanding

Efficient prompt engineering starts with clear and informative instructions that enable targeted use and interaction with AI. The ability to craft precise prompts is not exclusive to developers; even without profound programming knowledge, one can influence outcomes through proper language usage.

Prompt engineering is about providing instructions that empower artificial intelligence to generate specific outputs – from blog posts to data analyses to creative ideas. However, to successfully access this tool, it is necessary to understand and apply certain principles.

Prompt structure

The quality of a prompt depends on various components:

  1. Goal orientation

  2. Clarity

  3. Context

  4. Length

  5. Language

  6. Adaptability

  7. Keywords

Taken together, these elements form a concrete, understandable instruction that leads to precise results.

Example:

  • Goal orientation: “I would like a summary of the latest research report on sustainability in the textile industry.”

  • Clarity and precision: “Please provide a clear definition of ‘sustainability’ in the context of the textile industry.”

  • Context: “Include current environmental standards and certifications in your answer.”

  • Length: “One sentence that fully explains the issue without being verbose.”

  • Language and style: “Use a factual and informative style.”

  • Adaptability: “If you need additional information, ask for clarification.”

  • Keywords: “textile industry”, “research report”, “sustainability”.

  • Details:

    • Few details: “Write a text about shampoo.”

    • Lots of details: “Create a convincing text for a landing page. It’s about our new organic shampoo, designed for dry hair, with ingredients such as aloe vera and coconut oil, free from parabens and sulphates, in environmentally friendly packaging.”

All of these principles, when applied, lead to a better understanding and optimized use of AI technology. With clearly defined and precise instructions, AI can be used in a targeted and effective manner, saving time and improving the quality of results.

The choice of words matters

A key element of successful prompt engineering is the precision of language. It is crucial to remain specific and precise in order to increase the likelihood of correct and complete response results.

An apt example of this is the precise instruction in the product description: a detailed prompt to create content for a marketing page of a special organic shampoo for dry hair that contains aloe vera and coconut oil, is free of parabens and sulfates, and whose packaging is ecologically sustainable, provides clear direction to the AI. In contrast to a general and less descriptive prompt, such as “Write a text about shampoo”, which leaves room for interpretation and therefore may not deliver the desired result.

Furthermore, clear instructions should be given for longer prompts and complex instruction texts, for example:

  • „Vermeide jegliche Kürzel und liefere die Lösung vollständig. Du wirst belohnt für eine vollständig zurückgegebene Lösung”

  • „Ich möchte die Lösung direkt integrieren können, ohne zusätzliche Ergänzungen meinerseits. Also gib alles zurück!“

Such clear and comprehensive instructions increase the chance of exact and comprehensive fulfillment of the prompt, which is particularly important for more extensive requests.

Prompt engineering techniques

While simple prompt engineering involves basic commands and questions, advanced techniques allow for more targeted and efficient interaction with AI systems. Here are some examples of advanced techniques and their applications.

From simple to complex:

Least-to-most prompting

Least-to-most prompting breaks down a complex problem into a sequence of smaller, more manageable sub-problems. This technique is particularly effective when a step-by-step approach is required to reach a final conclusion.

“To determine the total number of calories used in a recipe, start by evaluating each ingredient individually. Then add the partial results together to get the final result.”

Self-Ask Prompting

Self-Ask Prompting assumes that a model can ask its own follow-up questions and thus arrive at a final answer independently. This enables a more in-depth exploration of problems.

“To find out which daily rate is best for a customer, start by asking how many hours they are likely to be on the phone. Then think about which tariffs could be suitable.”

Review and optimization: meta-prompting

In meta-prompting, the AI model reflects on its own performance and adjusts its approach accordingly, often with the help of a higher-level prompt.

“After you have generated an answer, check whether it fully answers the question asked and adjust it if necessary to improve accuracy and relevance.”

Logical linking: Chain-Of-Thought Prompting

Chain-Of-Thought Prompting promotes the development of sophisticated thinking skills with large language models. Specific examples are used as a guide to create a chain of thought.

“To determine a company’s profitability, start by analyzing revenues and expenses and how they have changed over the course of the fiscal year. Use this information to identify trends and potential for future profits.”

ReAct: Merging thinking and acting

ReAct combines the two concepts of thinking and acting.Through this synthesis, a model can formulate, track and update action plans and collect additional information from external sources through actions.

“Design a plan to improve customer service.Start with an analysis of current customer feedback and identify key areas that need to be optimized. Then develop concrete measures for implementation.”

For advanced users: Markdown, JSON Schema and Mermaid

'It´s all about the technique!'

Markdown for structured documentation

In communication, especially in the creation of technical documentation, markup language such as Markdown is used to ensure structure and clarity. For example, Markdown can be used to clearly define and visually highlight headings, lists and links. This makes it easier to present complex information in an understandable way.

				
					# Behaviour
You´re a writer which writes article for online content.
Always use the provided informations from the Knowledge Base or updated files, like abstracts/file from/with documentation or other sources for fact checking
Infos within this knowledge base/files always overwrite your internal infos. 

## Target audience
Content is written for linkedin:
- Dev
- Product Owners
- Managers

## Writing Guidelines
- readablity
- if a specific word appears to often within the text and recommend alternatives.
- if auxiliary verbs are used too often
- approachable/inclusive tone
- That Apposition/insert are not too long, max 6 words
- Never copy text from docs directly about use them as inspiration and rephrase it

## User Input
- Article name, required
- Text length, required
- Language, required
- Notes, required
Only return this format when the user has provided all necessary infos, if not ask for it!
If you don´t know sth or aren´t confident, say it, be as precise/pedantic as possible!
Don´t abbreviation or shorten known infos, always return them in full!
You will be rewarded for matching all requirements!
				
			

JSON schema for data structures

When it comes to defining and validating data structures, JSON schemas are extremely useful. They specify which data is required in which form, thereby reducing the possibility of errors and simplifying the exchange of information between different systems or between humans and AI.

				
					# Behaviour
You are an api and can only response with valid, directly parsable json.

## Output
Your Output-JSON must be baseed on this jsonschema:
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "title": "Todo Task",
  "required": ["task", "description"],
  "properties": {
    "task": {
      "type": "string",
      "description": "The title of the task"
    },
    "description": {
      "type": "string",
      "description": "Additional details about the task"
    }
  }
}
Return it directly without any explanations and code snippet formating!
				
			

Mermaid for the visualization of database structures

Mermaid is a text-based diagramming tool that is often used in technical documentation to visualize data structures such as database schemas. It provides a standardized method to visualize complex relationships clearly and supports clarity of communication in development processes. For example, a mermaid diagram can be used to clearly represent the relationship between authors, books and orders in a database.

An example of a simple entity-relationship diagram in Mermaid could look like this:

				
					erDiagram
    Autorin ||--o{ Buch : schreibt
    Buch ||--o{ Bestellung : inbegriffen_in

    Autorin {
        int id PK
        string name
        date geburtsdatum
    }

    Buch {
        int id PK
        string titel
        float preis
        int autorin_id FK
    }

    Bestellung {
        int id PK
        int buch_id FK
        date bestelldatum
    }
				
			

These advanced techniques make it possible to get more out of interactions with AI models and solve complex problems more efficiently.

By applying these techniques, answers can be achieved that are closer to human thinking and reduce errors, making them more natural/nuanced and increasing productivity.

This list does not include every technique, as not all of them can be used in all situations.

Links & further reading:

Picture of Alptuğ Dingil

Alptuğ Dingil

Alptuğ joined Inspired in 2022 as a software engineer. Besides his customer projects he's always looking for a new challenge. So lately he got engaged with Kubernetes and the configuration of a DIY cluste and got certified as a Google professional cloud architect.

Recent Posts