> ## Documentation Index
> Fetch the complete documentation index at: https://prompt.university/llms.txt
> Use this file to discover all available pages before exploring further.

# Lesson 1.4: Core Prompting Principles

> Master the four fundamental principles that make prompts effective

<Info>
  **Duration:** 60 minutes
</Info>

## Introduction

Master craftspeople follow principles that guide their work. Similarly, effective prompters follow proven strategies that consistently produce better results. In this lesson, you'll learn the fundamental principles that separate mediocre prompts from exceptional ones.

## The Four Core Principles

<CardGroup cols={2}>
  <Card title="Principle 1: Clarity & Specificity" icon="bullseye">
    Narrow the possibility space with precise instructions
  </Card>

  <Card title="Principle 2: Guide Reasoning" icon="route">
    Direct the model's thinking process step-by-step
  </Card>

  <Card title="Principle 3: Provide Context" icon="circle-info">
    Ground responses with relevant background information
  </Card>

  <Card title="Principle 4: Format Matters" icon="align-left">
    Structure influences how models interpret your intent
  </Card>
</CardGroup>

***

## Principle 1: Clarity and Specificity

### The Problem with Vague Prompts

LLMs can interpret vague prompts in countless ways. Specificity narrows the possibility space, guiding the model toward your intended outcome.

### Examples: Vague vs. Specific

<Tabs>
  <Tab title="❌ Vague">
    ```
    Tell me about climate change.
    ```

    **Problems:**

    * Too broad - could cover any aspect
    * No scope defined
    * Unclear audience level
    * No format specified
  </Tab>

  <Tab title="✅ Specific">
    ```
    Provide a detailed explanation of the causes and effects of climate change, 
    including impacts on global temperatures, weather patterns, and sea levels. 
    Also discuss possible solutions and mitigation actions. 

    Requirements:
    - Keep it under 500 words
    - Suitable for a 10-year-old child
    - Use simple language and concrete examples
    - Include 3 main causes and 3 main effects
    ```

    **Why it works:**

    * Clear scope (causes, effects, solutions)
    * Defined constraints (length, audience)
    * Specific requirements (structure, examples)
    * Measurable criteria (3 causes, 3 effects)
  </Tab>
</Tabs>

### Specificity Checklist

When crafting prompts, ask yourself:

<AccordionGroup>
  <Accordion title="What exactly do I want?">
    * Define the core task clearly
    * Specify the type of output (explanation, list, code, etc.)
    * State the purpose or goal
  </Accordion>

  <Accordion title="Who is the audience?">
    * Technical level (beginner, intermediate, expert)
    * Age group or background
    * Prior knowledge assumptions
  </Accordion>

  <Accordion title="What constraints apply?">
    * Length (word count, character limit)
    * Format (bullet points, paragraphs, JSON)
    * Tone (formal, casual, professional)
    * Style (technical, conversational, academic)
  </Accordion>

  <Accordion title="What should be included/excluded?">
    * Required elements
    * Topics to avoid
    * Specific examples needed
    * Level of detail
  </Accordion>
</AccordionGroup>

### Practice: Making Prompts Specific

<Tabs>
  <Tab title="Exercise 1">
    **Vague:** "Write about dogs."

    **Your turn:** Make this specific by defining:

    * What aspect of dogs?
    * What format?
    * What audience?
    * What length?

    <Accordion title="Sample Solution">
      ```
      Write a 300-word informative article about dog training basics 
      for first-time dog owners. Cover:

      1. House training fundamentals
      2. Basic commands (sit, stay, come)
      3. Positive reinforcement techniques

      Use an encouraging, supportive tone and include practical tips 
      that can be implemented immediately.
      ```
    </Accordion>
  </Tab>

  <Tab title="Exercise 2">
    **Vague:** "Help me with my code."

    **Your turn:** Make this specific by including:

    * What programming language?
    * What's the problem?
    * What have you tried?
    * What's the desired outcome?

    <Accordion title="Sample Solution">
      I'm writing a Python function to calculate the factorial of a number,
      but I'm getting a RecursionError for large inputs.

      Current code:

      ```python theme={null}
      def factorial(n):
          return n * factorial(n-1)
      ```

      Please help me:

      1. Identify the bug
      2. Fix the recursion issue
      3. Add input validation for negative numbers
      4. Suggest an iterative alternative for better performance
    </Accordion>
  </Tab>
</Tabs>

***

## Principle 2: Guide the Reasoning Process

### Why Reasoning Guidance Matters

LLMs can jump to conclusions. Explicit reasoning guidance activates deeper thinking and improves accuracy, especially for complex tasks.

### The "Let's Think Step-by-Step" Phenomenon

Research shows that simply adding this phrase significantly improves LLM performance on reasoning tasks.

<Tabs>
  <Tab title="Without Guidance">
    ```
    You are a mathematician. Solve this problem.

    Problem: What is 15% of 240?
    ```

    **Output:**

    ```
    The answer is 36.
    ```

    ✅ Correct, but no reasoning shown
  </Tab>

  <Tab title="With Reasoning Guidance">
    ```
    You are a mathematician. Follow these steps:

    Step 1: Interpret the problem carefully
    Step 2: Choose the most effective strategy
    Step 3: Perform calculations step-by-step
    Step 4: Review for accuracy and explain your solution

    Problem: What is 15% of 240?
    ```

    **Output:**

    ```
    Step 1: I need to find 15% of 240
    Step 2: I'll convert the percentage to a decimal and multiply
    Step 3: 
      - 15% = 0.15
      - 0.15 × 240 = 36
    Step 4: Verification: 36 is 15% of 240 because 36/240 = 0.15 = 15%

    The answer is 36.
    ```

    ✅ Correct with transparent reasoning
  </Tab>
</Tabs>

### Reasoning Patterns

<CardGroup cols={2}>
  <Card title="Sequential Steps" icon="list-ol">
    ```
    Step 1: [First action]
    Step 2: [Second action]
    Step 3: [Third action]
    ```
  </Card>

  <Card title="Think-Then-Answer" icon="brain">
    ```
    First, think through the problem.
    Then, provide your answer.
    ```
  </Card>

  <Card title="Explain-Your-Work" icon="chalkboard">
    ```
    Show your reasoning process.
    Explain each decision you make.
    ```
  </Card>

  <Card title="Self-Verification" icon="check-double">
    ```
    After solving, verify your answer.
    Check for common mistakes.
    ```
  </Card>
</CardGroup>

### Complex Problem Example

```
You are a financial advisor. A client asks:

"I have $10,000 to invest. Should I put it all in stocks or split 
between stocks and bonds?"

Approach this systematically:

1. Identify key factors to consider (risk tolerance, time horizon, goals)
2. Explain the pros and cons of each option
3. Ask clarifying questions if needed
4. Provide a reasoned recommendation
5. Explain the rationale behind your advice

Response:
```

This structure ensures the model considers multiple angles before recommending.

***

## Principle 3: Provide Reference Information

### The Hallucination Problem

LLMs can generate plausible-sounding but incorrect information. Providing context grounds responses in facts.

### Without Context vs. With Context

<Tabs>
  <Tab title="❌ Without Context">
    ```
    Who won the 2028 Olympics basketball gold medal?
    ```

    **Problem:** The model might:

    * Invent a plausible answer
    * Admit it doesn't know (better)
    * Confuse with past Olympics
  </Tab>

  <Tab title="✅ With Context (RAG Approach)">
    ```
    You are an expert at answering questions based on provided context.

    Context: 
    """
    The 2028 Summer Olympics will be held in Los Angeles. 
    Basketball competitions are scheduled for July 24 - August 9, 2028.
    As of now, the games have not yet occurred.
    """

    Question: Who won the 2028 Olympics basketball gold medal?

    Answer based only on the context provided. If the information 
    is not in the context, say so.
    ```

    **Expected Output:**

    ```
    Based on the provided context, the 2028 Olympics have not yet 
    occurred, so there is no winner yet. The games are scheduled 
    for July-August 2028 in Los Angeles.
    ```
  </Tab>
</Tabs>

### When to Provide Context

<Steps>
  <Step title="Factual Questions">
    Provide source documents, data, or verified information
  </Step>

  <Step title="Domain-Specific Tasks">
    Include relevant background, terminology, or constraints
  </Step>

  <Step title="Document Analysis">
    Supply the full document or relevant excerpts
  </Step>

  <Step title="Code Debugging">
    Include the actual code, error messages, and environment details
  </Step>
</Steps>

### Context Best Practices

<CardGroup cols={2}>
  <Card title="Be Relevant" icon="filter">
    Only include information pertinent to the task
  </Card>

  <Card title="Be Complete" icon="circle-check">
    Provide all necessary details to answer fully
  </Card>

  <Card title="Be Organized" icon="layer-group">
    Structure context logically (chronological, hierarchical)
  </Card>

  <Card title="Be Clear" icon="eye">
    Use delimiters to separate context from instructions
  </Card>
</CardGroup>

***

## Principle 4: Format Matters

### How Format Influences Interpretation

The way you structure your prompt significantly impacts how the model parses and responds to it.

### Format Comparison

<Tabs>
  <Tab title="Unstructured">
    ```
    Translate I have an orange to German
    ```

    **Issues:**

    * Ambiguous boundaries
    * Unclear what to translate
    * No format guidance
  </Tab>

  <Tab title="Structured with Delimiters">
    ```
    Translate the following text (delimited by triple quotes) to German.

    Text: """I have an orange."""

    Translation:
    ```

    **Benefits:**

    * Clear input boundaries
    * Explicit task
    * Output format indicated
  </Tab>

  <Tab title="Code-Style Format">
    ```
    [English] = [I have an apple.]
    [German] = [Ich habe einen Apfel.]
    [English] = [I have an orange.]
    [German] =
    ```

    **Benefits:**

    * Pattern-based
    * Implicit few-shot learning
    * Clear input-output mapping
  </Tab>
</Tabs>

### Effective Formatting Techniques

<AccordionGroup>
  <Accordion title="Use Delimiters" icon="quotes">
    **Common delimiters:**

    * Triple quotes: `"""`
    * Triple backticks: ` ``` `
    * XML tags: `<text>...</text>`
    * Brackets: `[...]`

    **Example:**

    ```
    Summarize the article below (delimited by ###).

    ###
    [Article content here]
    ###

    Summary:
    ```
  </Accordion>

  <Accordion title="Label Sections Clearly" icon="tags">
    ```
    Task: Translation
    Source Language: English
    Target Language: Spanish
    Style: Formal

    Input: "Hello, how are you?"
    Output:
    ```
  </Accordion>

  <Accordion title="Use Structured Lists" icon="list">
    ```
    Analyze the following code and provide:

    1. A brief description of what it does
    2. Any bugs or issues found
    3. Suggestions for improvement
    4. Refactored version

    Code:
    [code here]

    Analysis:
    ```
  </Accordion>

  <Accordion title="Specify Output Format" icon="file-code">
    ```
    Extract information and return as JSON with these fields:
    - name (string)
    - age (integer)
    - occupation (string)
    - skills (array of strings)

    Text: "John Smith, 35, is a software engineer skilled in 
    Python, JavaScript, and cloud architecture."

    JSON:
    ```
  </Accordion>
</AccordionGroup>

***

## Common Pitfalls to Avoid

<Warning>
  **Watch out for these mistakes:**

  1. **Assuming the LLM knows what you want**
     * ❌ "Fix this"
     * ✅ "Fix the syntax error on line 5 where the function is missing a closing parenthesis"

  2. **Providing contradictory instructions**
     * ❌ "Be brief but comprehensive"
     * ✅ "Provide a comprehensive overview in under 200 words"

  3. **Using ambiguous language**
     * ❌ "Make it better"
     * ✅ "Improve readability by adding comments and using descriptive variable names"

  4. **Neglecting output format**
     * ❌ "List the items"
     * ✅ "List the items as a numbered list with one item per line"

  5. **Information overload**
     * ❌ Dumping entire documents without focus
     * ✅ Providing relevant excerpts with clear context
</Warning>

***

## Putting It All Together

### The Complete Prompt Framework

Here's how to apply all four principles in a single prompt:

````
[PRINCIPLE 1: CLARITY & SPECIFICITY]
You are a technical writer creating API documentation.

[PRINCIPLE 2: REASONING GUIDANCE]
Follow this process:
1. Analyze the function signature and parameters
2. Identify the purpose and use cases
3. Note any edge cases or limitations
4. Structure the documentation clearly

[PRINCIPLE 3: CONTEXT]
Function to document:
```python
def calculate_discount(price: float, discount_percent: float, 
                       min_price: float = 0) -> float:
    """Apply discount with minimum price floor."""
    discounted = price * (1 - discount_percent / 100)
    return max(discounted, min_price)
````

\[PRINCIPLE 4: FORMAT]
Provide documentation in this format:

## Function Name

**Purpose:** \[Brief description]

**Parameters:**

* param1: \[type] - \[description]
* param2: \[type] - \[description]

**Returns:** \[type] - \[description]

**Example Usage:**

```python theme={null}
[code example]
```

**Notes:** \[Any important considerations]

Documentation:

```

---

## Practice Exercise: Apply All Principles

Transform this weak prompt using all four principles:

**Weak Prompt:**
```

Write about machine learning

```

**Your Task:**
Apply each principle to create a strong prompt. Consider:
- What specific aspect of ML?
- What reasoning process?
- What context is needed?
- What format works best?

<Accordion title="Sample Solution">
```

\[CLARITY & SPECIFICITY]
You are an educator creating an introductory lesson on machine learning
for high school students with no prior programming experience.

\[REASONING GUIDANCE]
Structure your explanation by:

1. Starting with a relatable real-world example
2. Explaining the core concept in simple terms
3. Describing how it differs from traditional programming
4. Providing a concrete application example

\[CONTEXT]
Focus on supervised learning, specifically classification tasks.
Avoid technical jargon. Use analogies to everyday experiences.

\[FORMAT]
Create a 400-word lesson with:

## Introduction

\[Hook with relatable example]

## What is Machine Learning?

\[Simple definition and explanation]

## How It Works

\[Basic process description]

## Real-World Example

\[Concrete application]

## Key Takeaway

\[Summary in one sentence]

Lesson:

```
</Accordion>

---

## Key Takeaways

<CardGroup cols={2}>
<Card title="Clarity Reduces Ambiguity" icon="bullseye">
  Specific instructions narrow the possibility space and improve consistency
</Card>

<Card title="Reasoning Activates Thinking" icon="brain">
  Explicit guidance leads to deeper analysis and better answers
</Card>

<Card title="Context Grounds Responses" icon="anchor">
  Reference information prevents hallucination and improves accuracy
</Card>

<Card title="Format Shapes Interpretation" icon="shapes">
  Structure and delimiters help models parse your intent correctly
</Card>
</CardGroup>

---

## The Prompting Checklist

Before submitting any prompt, verify:

<Steps>
<Step title="✓ Is my instruction clear and specific?">
  No ambiguity about what I want
</Step>
<Step title="✓ Have I provided necessary context?">
  All relevant background information included
</Step>
<Step title="✓ Does my format reduce ambiguity?">
  Clear structure with appropriate delimiters
</Step>
<Step title="✓ Would examples help clarify my intent?">
  Consider adding demonstrations if needed
</Step>
<Step title="✓ Have I specified output format/length/style?">
  Clear expectations for the response
</Step>
</Steps>

---

## Module 1 Complete!

Congratulations! You've completed the foundations of prompting. You now understand:

- ✅ What prompting is and why it matters
- ✅ How to structure effective prompts
- ✅ In-context learning techniques
- ✅ The four core principles of great prompts

<Card title="Continue to Module 1 Assessment" icon="clipboard-check" href="/module-1/assessment">
Test your knowledge and earn your Module 1 completion
</Card>
```
