Learn Everything

Paths/AI Engineer/LLM Fundamentals / Sampling & Output Contracts

Practice Taskintermediateubuntu:24.04Ask AI

Define a Structured Output Schema

Free text has to be parsed. A JSON Schema makes the model answer with a shape your code can rely on - write one for a ticket classifier.

Validator

⏱ 0:00

IDLE — checks run live as you type commands; submit when done

01Requirements

live checks
  • File ~/llm-lab/schema.json exists○
  • The schema describes an object with properties○
  • The schema marks its fields as required○
  • The schema restricts the severity field to a fixed set of values○

02Walkthrough

1 of 3 revealed
  1. 01

    Write the schema

    type says the shape, properties names the fields, required lists the ones that must be there, and enum keeps a field inside a fixed set of values.

    echo '{"type": "object", "properties": {"severity": {"type": "string", "enum": ["P1", "P2", "P3"]}, "summary": {"type": "string"}}, "required": ["severity", "summary"]}' > ~/llm-lab/schema.json
  2. 2 locked · each failed submit reveals one

03Stuck?

0 of 3 revealed

Take a hint without losing the lab — each one points at the thing to look at, not at the answer.

04AI Tutor

guides, never solves

Tell me what you're stuck on — I'll nudge, not solve. Which requirement are you looking at?

04Notebook

saved locally in this browser

learner@lab — ubuntu:24.04

↑/↓ recalls commands · Ctrl+Enter submits · type help for the command list