Skip to content
Roadmap0/111
not startedstudy day 4 of 6 · covers original days 4 & 5

LLM Internals & Token Budgets

Pydantic Structured Outputs

P1 AssistantS1S7M1
not started0/5 blocks
0/5
Jump & context

Week 1: Application Foundations, Model Trust, Tools & Authorization Boundaries

The five hours

  1. 01

    Concepts & system design

    60 min

    R04 — OWASP LLM Top 10: prompt & token risks

    R11 — Hugging Face model cards & tokenizer configs

    R07 — JSON Schema constraints

    R01 — Pydantic validation

    Read the assigned sections; map the mechanism, threat model and trade-offs.

  2. 02

    Project implementation

    120 min

    Study messages, roles (system/user/assistant/tool), context windows, tokenization, sampling, temperature/top-p, and output limits. Implement message history and token counting. *Lab:* Prove that role labels and system prompts do not enforce permissions.

    Implement validated request/response schemas and an invoice/receipt parser using Pydantic. *Lab:* Test malformed types, oversized strings, unexpected fields, and enum violations—verify the API fails closed.

    Build, integrate, debug and improve the increment in the active project.

  3. 03

    Security lab

    60 min

    No separate task text for this block on day 4 — the sourced work sits in the block above. Keep the time box.

    Test the abuse case, failure path, authorization bypass or resource limit.

  4. 04

    Verification & evidence

    30 min

    Token-budget test, temperature/top-p comparison note, trust-boundary note, and Pydantic negative schema test suite.

    Add or run regression tests; record the 9-point evidence record.

  5. 05

    Deliberate practice & Socratic review

    30 min

    Answer the 8 Socratic questions without notes: What? Why? How? What if? Why not? How can I prove it? Where can it break? What have I learned?

    Re-explain the hardest concept aloud, inspect one edge case, update the gap log.

  6. total5 h

Read today · inside the concepts block

R01 R04 R07 R11

Read only the named sections needed for today's task. Reading sits inside the 60-minute concepts block; it is not extra time.

Free resources for this day

5 curated
  • docsOWASP Gen AI Security Project
    LLM10:2025 Unbounded Consumption

    Names the consumption mechanisms you are budgeting against (context growth, output length, repeated calls) and the mitigations, so token accounting is tied to a threat rather than a cost guess.

    R04M5unchecked 2026-11-11
  • videoAndrej Karpathy · 2:13:35
    Let's build the GPT Tokenizer

    Implements byte-level BPE from scratch, which explains why the same string costs different token counts per model and why count-by-characters is wrong.

    R11checked 2026-11-11
  • videoMatt Pocock · 10:58
    Most devs don't understand how LLM tokens work

    Shows token counts, context limits, and cost behaviour against a real API in a few minutes, giving the practical intuition for max_tokens and history budgeting.

    R04checked 2026-11-11
  • articleJay Alammar
    The Illustrated Transformer

    Explains attention over a fixed input sequence and why the context window is a hard boundary, which is the structural reason history must be truncated rather than appended forever.

    S1checked 2026-11-11
  • repoGitHub
    openai/tiktoken

    The tokenizer library itself, with encode/decode you can wrap to count a message array before sending it, including per-message overhead.

    R04R11checked 2026-11-11

Evidence record · 9-point standard

0/9

A lab is complete only when it produces evidence. Installing PyRIT, Garak, Presidio or TransformerLens is not completion. Saved on this device only.

Day notes

empty

The two source formulations

verbatim · nothing summarised

Project & Stage Target

P1 | S1, S7, M1

Focus 1 (LLM Internals & Token Budgets — Orig. Day 4)

Study messages, roles (system/user/assistant/tool), context windows, tokenization, sampling, temperature/top-p, and output limits. Implement message history and token counting. *Lab:* Prove that role labels and system prompts do not enforce permissions.

Focus 2 (Pydantic Structured Outputs — Orig. Day 5)

Implement validated request/response schemas and an invoice/receipt parser using Pydantic. *Lab:* Test malformed types, oversized strings, unexpected fields, and enum violations—verify the API fails closed.

Verification & Evidence

Token-budget test, temperature/top-p comparison note, trust-boundary note, and Pydantic negative schema test suite.

Read Today (60m Concepts Block)

R04 (OWASP LLM Top 10: prompt & token risks), R11 (Hugging Face model cards & tokenizer configs), R07 (JSON Schema constraints), R01 (Pydantic validation).

---