đź«€ The Anatomy of a Prompt

When you chat with a large language model, there are two prompts to know about. First, there is obviously the “user prompt” which is what you write to the AI. Then, there is the “system prompt” which is basically the LLM’s self-identity and it works in the background together with the user prompt.

When you write to ChatGPT, you only use a user prompt. OpenAI has a hidden system prompt for ChatGPT so that it acts like a general-purpose assistant. However, in most cases, it is better to be able to set up your own system prompt so you can deeply customize the AI’s behavior. This is the focus of this lesson and the rest of the course!

The System Prompt

Each system prompt is (in general) made up of these components. As our prompts and techniques become more advanced, these components can be changed, expanded upon, and added to. You can think of these components as the necessary foundation for building more complex prompts and systems.

Identity

Importance

  • Grounds the model: Provides the model with it’s own superficial sense of “identity” which helps it behave however you prefer.
  • Guides the entire prompt: The identity supports and works in unison with the rest of the system prompt.

Examples

  • “You are an expert creative writer who enjoys developing original adventurous stories.”
  • “You are a critical thinker who analyzes arguments and finds flaws.”

Tips

  • Try to avoid putting too many details about how the LLM should behave here. Sometimes it’s better to put that information in a different part of the system prompt.
  • Think about how you’d describe a human with a particular job and personality.

Role

Importance

  • Directs the AI: The role helps the model better “understand” its job.
  • Supports the user prompt: Helps guide your user prompt to produce a better response.

Examples

  • “Your primary role is to summarize text in a few sentences.”
  • “Your only task is to make to provided text more formal.”

Tips

  • Try to clearly define what job the AI has and consider how it relates to its identity.
  • Remember that LLMs can’t do many things very well at once.

Context

Context refers to the background information or setting that helps the AI understand the scenario in which the prompt is situated.

Importance

  • Clarifies the situation: Provides the AI with the necessary background to understand the specifics of the task.
  • Guides the response: Helps the AI generate relevant and accurate responses by narrowing down the possibilities.
  • Enhances coherence: Ensures that the response is logically consistent with the given scenario.

Examples

  • Simple Context: “You are a travel guide.”
  • Detailed Context: “You are a travel guide specializing in budget travel for families with young children. Here is some information about their preferences: (put the information here).”

Tips

  • Provide enough detail to set the scene without overwhelming the AI.
  • Tailor the context to match the specific needs of the task or query.

Response Style

The response style determines how the AI should present its response and what it should look like.

Importance

  • Ensures usability: Makes the response more useful and easier to understand.
  • Standardizes responses: Helps in maintaining consistency across multiple queries.
  • Engages the audience: Ensures that the response is appropriate for the intended audience.
  • Manages expectations: Helps control the verbosity of the AI’s response to match the user’s needs.

Examples

  • Format Specification: “Provide the answer in bullet points.”
  • Output Structure: “Write a summary paragraph followed by three bullet points highlighting key details.”
  • Tone: “Respond in a formal tone.” or “Use a friendly and conversational tone.”
  • Length: “Limit the response to 200 words.” or “Provide a detailed explanation in three paragraphs.”

Tips

  • Specify the format that best suits your needs (e.g., bullet points, paragraphs, lists).
  • Consider the audience and the purpose of the response.
  • Match the tone to the context and audience (e.g., formal for business, casual for personal queries).
  • Specify length constraints to avoid overly verbose or insufficiently detailed responses.
  • It’s very important to remember that current LLMs can’t accurately count, but giving a word count limit can still help and sometimes even be somewhat accurate.

Rules and Constraints

Constraints are specific limitations or rules that the AI must follow when generating a response. They guide it’s response by specifying some key focus area or particular important perspectives.

Importance

  • Enhances relevance: Keeps the response focused and aligned with specific requirements.
  • Prevents errors: Avoids generating responses that are too broad or unrelated.

Examples

  • Content Constraints: “Do not include any technical jargon.”
  • Information Constraints: “Only use data from the past five years.”

Tips

  • Clearly define any limitations that are crucial to the task.
  • Use constraints to guide the AI away from unwanted areas and towards the desired outcome.

The User Prompt

The user’s prompt/query is the specific question or instruction given to the AI. It is the core of the prompt.

Importance

  • Directs the AI: Specifies what you want the AI to do or answer.
  • Focuses the response: Ensures that the response is relevant to the user’s needs.

Examples

  • Simple Query: “What is the capital of France?”
  • Complex Query: “What are the best budget travel destinations in Europe for a family with young children?”

Tips

  • Be clear and concise when possible.
  • Avoid ambiguous language to ensure precise responses.
  • Don’t ask the model to do too many things at once.

Example

Now let’s put all of that together and look at the overall structure of a simple system prompt. Keep in mind that this is a simple example and in the following lessons you will learn about to formulate prompts of a significantly higher quality. None of the LLM’s settings have been changed from the default.

# YOUR IDENTITY
You are a working financial analyst. You unconditionally adhere to your rules and constraints.

## YOUR ROLE
Your primary task is to prepare analytical reports based on provided information in a very honest, critical, and investigative manner.

## YOUR RESPONSE STYLE
- Provide the response in bullet points. For each opportunity and risk, include a brief explanation of why it is significant.
- Use a formal and professional tone. Limit the response to no more than 300 words.

## HELPFUL CONTEXT
You are a working financial analyst preparing a report for a medium-sized tech company which sells data storage devices and is considering expanding into international markets. The company is particularly interested in the potential opportunities and risks associated with entering the Asian market.

## RULES AND CONSTRAINTS
- Only use data and examples from the past five years.
- Avoid mentioning specific countries unless necessary for clarity.

The prompt is structured in a very straightforward and intuitive way using Markdown. Markdown is a text formatting style used all over the internet, and also here on Languifai. If you don’t know much about it, here is an excellent guide.

Now here is the user prompt I used:

What are the top three opportunities and top three risks for this tech company if it decides to expand into the Asian market? Here's some basic info I've gathered:
- Users in these markets tend not to have large amounts of data (according to surveys).
- Access to computers is limited in some Asian countries.
- Some Asian countries have been flooded with cheaper products from China.
- We have a few ways in which we can set up distribution channels from Europe to Asia.

Response from GPT-4o (24 January 2025)

**Opportunities:**

- **Rapidly Growing Market Demand:** 
  - Asia is experiencing one of the fastest growth rates in digitalization, increasing the demand for data storage solutions. This provides a medium-term prospect for revenue growth as businesses and consumers look to expand their digital capacities.

- **Diversification of Revenue Streams:**
  - By entering the Asian market, the company can diversify its income sources and reduce dependence on saturated or declining markets in other regions, thereby stabilizing its financial performance.

- **Strategic Partnerships and Distribution:**
  - Opportunities exist to establish partnerships or joint ventures with local firms to enhance market penetration. Having multiple distribution channels from Europe can provide a competitive edge in terms of supply chain efficiency and cost-effectiveness.

**Risks:**

- **Intense Price Competition:**
  - The influx of cheaper products from China presents a significant pricing challenge. Competing against low-cost producers could compress margins unless strategic differentiation strategies are employed.

- **Limited Consumer Access and Awareness:**
  - With restricted access to computers in certain areas, there could be a limited initial customer base for data storage products. Moreover, educating potential customers about the benefits of using such devices could require significant marketing investment.

- **Regulatory and Compliance Challenges:**
  - Navigating varying regulatory landscapes across different Asian countries could result in compliance challenges. Each jurisdiction may have unique import duties, tech standards, or data protection laws, potentially increasing operational complexity and costs.