Skip to content
← Back to Guides
LLMBeginner

Prompt Engineering Masterclass

30 min reading timeAuthor: Jordan Park

Prompt engineering is the quickest way to configure LLM outputs. This guide outlines structural patterns and techniques to ensure determinism and high performance.

1. System vs User Messages

Always separate behavioral instructions (System) from data payloads (User).

  • **System Prompts**: Establish identity, guardrails, response schema, and rules.
  • **User Prompts**: Contain the actual input variables, query, or document.
json
[
  {
    "role": "system",
    "content": "You are a compiler. Extract JSON from inputs. Schema: { 'entities': string[] }"
  },
  {
    "role": "human",
    "content": "The patient Sarah Smith was admitted on 12th July."
  }
]

---

2. Few-Shot Pattern (In-Context Learning)

Provide concrete examples of inputs and desired outputs. This is highly effective for custom formats or domain vocabularies.

markdown
Convert English slang to formal Spanish.

Example 1:
Input: That's fire!
Output: ¡Eso es fantástico!

Example 2:
Input: What's up, dude?
Output: ¿Cómo está usted, caballero?

Input: She's chill.
Output:

---

3. Chain-of-Thought (CoT)

Force the model to think step-by-step before answering. This significantly improves math, coding, and logical tasks.

markdown
Question: A farmer has 15 apples. He sells 5, buys 10, and eats 2. How many does he have?
Answer: Let's calculate step-by-step.
1. The farmer starts with 15 apples.
2. He sells 5 apples, so he has 15 - 5 = 10 apples remaining.
3. He buys 10 apples, so he now has 10 + 10 = 20 apples.
4. He eats 2 apples, so he has 20 - 2 = 18 apples.
Therefore, the farmer has 18 apples.
#Prompting#Patterns#Basics
Read more guides →