LLM104 · Prompt Design and Structured Outputs for Developers
About Course
Design prompts as engineered components: clear instructions, examples and context, plus JSON outputs that your code can validate and trust.
Who it is for
Developers building LLM features that must return consistent, machine-readable results.
Prerequisites
LLM103 or experience sending requests to an LLM API from Python.
What you will be able to do
- Write system prompts that separate role, rules, context and output format
- Use few-shot examples and delimiters to improve consistency on extraction and classification tasks
- Define a JSON Schema or Pydantic model and obtain validated structured output from an LLM
- Build a prompt test set and compare prompt versions using measured accuracy
Lessons
- Lesson 1 · Prompts as engineered components
- Lesson 2 · Examples, reasoning and consistency
- Lesson 3 · Structured outputs and prompt testing
- Lesson 4 · Lab and assignment
Lab: An invoice and order extractor with validated JSON
You will design a prompt that extracts structured data from messy order emails and supplier invoices, enforce the output with a schema, and measure how many fields are extracted correctly across a labeled test set. You will compare at least two prompt versions using the numbers, not impressions.
Free tools: Google Colab or VS Code, Pydantic, and the Gemini API free tier or a local model through Ollama
Assessed assignment
Build a production-ready extraction function for a small wholesale distributor that turns incoming purchase-order emails into validated JSON ready for its order system. Your prompt must handle missing fields, multiple items, informal dates such as "next Friday" (resolved against a supplied current date) and emails that are not orders at all. Provide a test set of at least 15 examples, report field-level accuracy, and document your prompt versions and what each change did.
| Criterion | Weight | What excellent work looks like |
|---|---|---|
| Schema and validation | 25% | A precise schema with types, nullable fields and enums; every output is validated and failures are handled. |
| Prompt design | 25% | Instructions are structured, unambiguous and cover edge cases such as non-order emails and missing data. |
| Measured evaluation | 30% | A labeled test set of 15 or more cases, field-level accuracy and a comparison of at least two prompt versions. |
| Documentation | 20% | A clear changelog of prompt versions with the reasoning behind each change and remaining known weaknesses. |
Portfolio piece
A tested extraction function with its schema, versioned prompts and an accuracy report on a labeled test set.
Next step
Continue with LLM105 · Retrieval-Augmented Generation (RAG) · 8 hours · $56.00
Course Content
LLM104 · Prompt Design and Structured Outputs for Developers (6 h)
-
Lesson 1 · Prompts as engineered components
-
Lesson 2 · Examples, reasoning and consistency
-
Lesson 3 · Structured outputs and prompt testing
-
Lesson 4 · Lab and assignment
-
LLM104 Assessment · Prompt Design and Structured Outputs for Developers
