Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"slidev.include": [
"**/slides.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/04_Memory.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/08_Text_Search.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/07_Process_Framework.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/06_SK_Agent_Framework.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/05_Middleware.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/03_Tools_and_Function_Invocation.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/02_Evaluations_and_Tests.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/01_Prompts_and_Prompt_Execution.md",
"dotnet/Workshops/IntroToSK/02_AI_Frameworks/00_Introduction_to_AI_Development.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/03_Anatomy_of_an_Effective_Prompt.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/02_Types_of_Prompts.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/04.2_Prompt_Engineering_Techniques.Reasoning_Techniques.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/04.1_Prompt_Engineering_Techniques.Basic_Techniques.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/01_Introduction_to_Prompt_Engineering.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/04.5_Prompt_Engineering_Techniques.Constrained_Decoding.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/04.4_Prompt_Engineering_Techniques.Parameter_Tuning.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/04.3_Prompt_Engineering_Techniques.RAG.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/09_Resources_for_Further_Learning.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/08_Safety_Ethics_and_Fallback_Responses.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/07_Testing_and_Evaluation_Strategies.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/06_Best_Practices_for_Effective_Prompts.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/05_Practical_Use_Cases_and_Examples.md",
"dotnet/Workshops/IntroToSK/01_Prompt_Engineering/04_Prompt_Engineering_Techniques.md"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: "Introduction to Prompt Engineering"
doc-type: intro
module: "01 - Prompt Engineering"
order: 1
tags:
- prompts
- sdk

marp: true
theme: gaia
size: 16:9
paginate: true

header: Introduction to Prompt Engineering
footer: "© Microsoft Corporation. All rights reserved."
style: |
@import '../styles/msft.css';

---

<!-- _class: 'title-slide' -->
<!-- _paginate: skip -->

# 1. Introduction to Prompt Engineering

- **Definition**: Crafting effective prompts to guide AI models toward optimal outputs.
- **Importance**:
- Enhances AI performance through clear instructions and context.
- Ensures accurate, relevant, and safe AI interactions.
- Improves control and predictability of AI responses.

---

## Prerequisites
- Access to an AI language model supported by Azure Inference Services, OpenAI, or OLLAMA.
- Visual Studio Code or Codespaces.
- AI Toolkit VS Code Extension ([ms-windows-ai-studio.windows-ai-studio](vscode:extension/ms-windows-ai-studio.windows-ai-studio)).

---

**Learning Objectives**
- Define prompt engineering and explain its significance in enterprise AI scenarios.
- Identify the key components and types of prompts.
- Structure prompts for clarity, safety, and effectiveness.
- Optimize prompts using measurable rubrics and evaluation metrics.

---

## Summary

This module on prompt engineering is designed for developers working in enterprise environments who want to master prompt engineering for AI systems. By the end of this section, you will be able to:
- Define prompt engineering and explain its significance in enterprise AI applications.
- Identify the key components and types of prompts.
- Learn how to structure prompts for clarity, safety, and effectiveness.
- Optimize prompts using measurable rubrics - whilst explaining your approach.
- Understand how to leverage tools like Semantic Kernel, Microsoft.Extensions.AI, and Prompty for prompt development and evaluation.

Throughout the workshop, you will use Semantic Kernel and Prompty to design, test, and optimize prompts against measurable rubrics.

---

## Table of Contents

| # | Module | Time | Summary |
|---|--------|------|---------|
| 1 | [Introduction to Prompt Engineering](./01_Introduction_to_Prompt_Engineering.md) | 15min | Core concepts, importance, and objectives. |
| 2 | [Types of Prompts](./02_Types_of_Prompts.md) | 15min | Overview of prompt types. |
| 3 | [Anatomy of an Effective Prompt](./03_Anatomy_of_an_Effective_Prompt.md) | 15min | Required and optional prompt components. |
| 4 | [Prompt Engineering Techniques](./04_Prompt_Engineering_Techniques.md) | 30min | Basic and advanced techniques, parameter tuning. |
| 5 | [Practical Use Cases and Examples](./05_Practical_Use_Cases_and_Examples.md) | 20min | Real-world applications across scenarios. |
| 6 | [Best Practices for Effective Prompts](./06_Best_Practices_for_Effective_Prompts.md) | 15min | Guidelines for clarity, context, and iteration. |
| 7 | [Testing and Evaluation Strategies](./07_Testing_and_Evaluation_Strategies.md) | 15min | Methods for evaluating prompt quality. |
| 8 | [Safety, Ethics, and Fallback Responses](./08_Safety_Ethics_and_Fallback_Responses.md) | 20min | Handling sensitive content and fallback. |
| 9 | [Resources for Further Learning](./09_Resources_for_Further_Learning.md) | 10min | Documentation and training resources. |

---

### Install the AI Toolkit VS Code Extension

To install the "[ms-windows-ai-studio.windows-ai-studio](vscode:extension/ms-windows-ai-studio.windows-ai-studio)" extension in VSCode using the CLI, follow these steps:

1. Open a terminal and run the following command to install the extension:

```bash
code --install-extension ms-windows-ai-studio.windows-ai-studio
```

2. Ensure that the extension is successfully installed by running:

```bash
code --list-extensions | grep ms-windows-ai-studio.windows-ai-studio
```

Alternatively, you can open this repository in a dev container and install the extension using the same command inside the container's terminal.
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
title: "Types of Prompts"
doc-type: content
module: "01 - Prompt Engineering"
order: 2
tags:
- prompts

marp: true
theme: gaia
size: 16:9
paginate: true

header: Introduction to Prompt Engineering
footer: "© Microsoft Corporation. All rights reserved."
style: |
@import '../styles/msft.css';

---

<!-- _class: 'title-slide' -->
<!-- _paginate: skip -->

# Types of Prompts

## Prerequisites
- Understand core principles from the Introduction to Prompt Engineering module.

## Learning Objectives
- Describe different prompt types and their use cases.

---

## Key Concepts
- Zero-shot prompts
- Few-shot and multi-shot prompts
- Chain of Thought prompts
- Zero-shot Chain of Thought prompts

Prompts influence how an AI, like ChatGPT, understands and responds to your request. Mastering prompt types will help you achieve more accurate and useful results.

---

### Zero-shot (Direct)

**Definition:** Provide the AI with a direct instruction—no examples are given.
**Purpose:** Test the AI’s general capability to follow instructions.
**Example:**
> Translate the following sentence to French: "Where is the library?"

**Use when:** You want a quick, straightforward answer or to test the model’s basic abilities.

---

### Few-shot and Multi-shot
**Definition:** Add one (few-shot) or several (multi-shot) examples in your prompt to guide the AI’s response.
**Purpose:** Demonstrate the desired format, style, or logic with concrete examples.

**Few-shot Example:**
```
Q: What is the capital of France?
A: Paris
Q: What is the capital of Italy?
A: Rome
Q: What is the capital of Germany?
A:
```

**Multi-shot Example:** (More than two examples)
```
Translate the following:
English: Hello | French: Bonjour
English: Good morning | French: Bonjour
English: Good night | French:
```

**Use when:** The task requires specific output style or handling uncommon instructions.

---

### Chain of Thought (CoT)

**Definition:** Ask the model to display its reasoning step-by-step.
**Purpose:** Promote transparency and accuracy in complex or multi-step problems.

**Example:**
```
Q: If there are 3 red balls and 2 blue balls in a box, and you take out one ball at random, what is the probability it is red? Explain your reasoning.
A: There are 3 red balls and 2 blue balls, so a total of 5 balls. The probability of drawing a red ball is 3 out of 5, or 3/5.
```

**Use when:** The task involves logical or mathematical reasoning that benefits from breaking down into steps.

---

### Zero-shot Chain of Thought (Zero-shot CoT)

**Definition:** Directly ask the model to reason step-by-step without providing examples.
**Purpose:** Encourages explicit reasoning without prior samples.

**Example:**
> What is 27 times 16? Please think step by step.

(AI might respond with intermediate calculation steps.)

**Use when:** You want the model to engage in reasoning but haven’t supplied examples.

---

### Tree of Thought

**Definition:** A prompt structure that encourages the model to explore multiple reasoning paths or solutions in a branching, tree-like manner. Each branch represents a different line of reasoning or possible answer, allowing the model to backtrack and compare alternatives.

**Purpose:** Useful for complex problem-solving where evaluating multiple options or strategies is beneficial.

**Example:**
> You are solving a puzzle. At each step, list all possible moves and their consequences. Then, choose the most promising path and continue. If you reach a dead end, backtrack and try another branch.

(AI might respond by outlining several possible moves at each step, evaluating them, and selecting the best one.)

**Use when:** The task involves decision-making, planning, or problems with multiple possible solutions that benefit from exploring alternatives.

---

### Graph of Thought

**Definition:** A prompt structure that allows the model to reason using a network or graph, where ideas, facts, or reasoning steps are represented as nodes connected by relationships (edges). This enables the model to consider dependencies and interactions between different concepts.

**Purpose:** Useful for tasks that require mapping relationships, integrating information from multiple sources, or handling non-linear reasoning.

**Example:**
> Map out the relationships between climate change, renewable energy, and economic growth. Show how each concept influences the others, and identify feedback loops.

(AI might respond with a diagram or description of nodes and connections, explaining how each factor affects the others.)

**Use when:** The task involves complex interdependencies, systems thinking, or integrating information from various domains.

---

### Sketch of Thought

**Definition:** A prompt style that encourages the model to quickly outline or sketch key ideas, steps, or components before elaborating in detail. This can take the form of bullet points, diagrams, or high-level summaries.

**Purpose:** Helps organize thinking, clarify structure, and ensure all important aspects are considered before deep reasoning.

**Example:**
> Before writing a detailed essay on the impact of AI in healthcare, list the main points and arguments you plan to cover as a quick outline.

(AI might respond with a bulleted list of key arguments or a rough structure for the essay.)

**Use when:** You want to brainstorm, plan, or structure a response before generating detailed content.
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
title: "Anatomy of an Effective Prompt"
doc-type: content
module: "01 - Prompt Engineering"
order: 3
tags:
- prompts
- sdk

marp: true
theme: gaia
size: 16:9

header: Introduction to Prompt Engineering
footer: "© Microsoft Corporation. All rights reserved."
style: |
@import '../styles/msft.css';

---

<!-- _class: 'title-slide' -->
<!-- _paginate: skip -->

# Anatomy of an Effective Prompt

## Prerequisites
- Complete the Types of Prompts module.

## Learning Objectives
- Describe required and optional components of an effective prompt.

---

## Key Concepts
- Core Task
- System Instructions
- Examples
- Contextual Information

Effective prompts are structured with deliberate components that enhance clarity, ensure context, and guide the language model toward the desired response. Below is a breakdown of the key elements:

---

### Core Task (Required)
The core task is the critical anchor of any prompt and must be both clear and specific. This involves:

- Clearly defined instructions or questions
- Eliminating ambiguity by stating exactly what needs to be accomplished
- Using direct language to focus the model’s attention

**Example:**

> Summarize the main points from the following article.

---

### System Instructions
Use this section to:

- Define the style, tone, or persona (e.g., "Respond as a technical expert")
- Impose constraints (e.g., "Limit your answer to three sentences" or "Avoid jargon")
- Clarify the expected format of output

**Example:**

> You are a friendly customer support agent. Answer in a helpful and concise manner.

---

### Examples
Demonstrate desired input-output relationships with examples to:

- Set expectations for style, structure, or reasoning
- Clarify edge cases or ambiguous requests

**Format:**

```
Input: [Sample input]
Output: [Expected output]
```

**Example:**

```
Input: What is the capital of France?
Output: Paris
```

---

### Contextual Information
Provide relevant background or reference data, such as:

- Definitions, reference documents, or data tables
- Context that grounds the response or clarifies assumptions

**Example:**

> Based on the attached project brief document, summarize the deliverables.

---

## Roles in Prompting
Understand the distinct responsibilities in prompt-driven workflows:

- **User:** Initiates the request, specifying tasks and providing necessary background or constraints.
- **Tool:** (If present) Applies prioritized instructions, policies, or constraints, often before passing to the assistant.
- **Assistant:** Generates the response, following the instructions, adapting to examples provided, and respecting any constraints.

---

## Tips

- Be explicit with required tasks.
- Layer optional components for increased accuracy.
- Use examples to reduce ambiguity.
- Specify roles and expectations as needed.
Loading