← All booksBook XI

Structure & Data

Shape of inputs, outputs, artefacts.

9 patterns in this book. · Updated

↓ download as png

When to reach for each

01. Structured Output Constrain the model's output to conform to a JSON Schema (or similar typed shape). Best for: Downstream code consumes typed data and free-form text would break parsers. Tradeoff: Provider lock-in for the strictest modes. Watch for: Output is for human consumption only and structure adds no value.

02. DSPy Signatures Specify agent behaviour as declarative typed signatures and modules; compile prompts and few-shot examples automatically against a metric. Best for: Hand-crafted prompts are brittle and drift across model versions. Tradeoff: Compilation requires labelled or auto-evaluable data. Watch for: The pipeline is a single prompt and the DSPy machinery is overkill.

03. Business + LLM Microservice Split Split an LLM application into a CPU-bound business microservice (retrieval, prompt assembly, orchestration) and a GPU-bound LLM microservice (only model.generate behind REST), so each tier scales on its own hardware budget. Best for: LLM inference and business logic have diverging scaling profiles. Tradeoff: One extra network hop per LLM call — latency cost. Watch for: Very low traffic — one service is simpler and within budget.

04. FTI LLM Pipeline Split Decompose an LLM/RAG system into three independently-deployable pipelines — feature, training, inference — communicating only via a feature store and a model registry. Best for: Feature, training, and inference have materially different cadences and ownership. Tradeoff: Two integration surfaces to operate and version. Watch for: System is small enough that one repository and one deploy cycle is fine.

05. Schema Extensibility Build schemas that evolve without breaking old clients via reserved namespaces and extension blocks. Best for: Schemas are long-lived and will accumulate fields over time. Tradeoff: Extension proliferation is a real risk. Watch for: The schema is internal, short-lived, and a single client owns it.

All patterns in this book

Structured Output

×46

Constrain the model's output to conform to a JSON Schema (or similar typed shape).

DSPy Signatures

×2

Specify agent behaviour as declarative typed signatures and modules; compile prompts and few-shot examples automatically against a metric.

Business + LLM Microservice Split

×1

Split an LLM application into a CPU-bound business microservice (retrieval, prompt assembly, orchestration) and a GPU-bound LLM microservice (only model.generate behind REST), so each tier scales on…

FTI LLM Pipeline Split

×1

Decompose an LLM/RAG system into three independently-deployable pipelines — feature, training, inference — communicating only via a feature store and a model registry.

Schema Extensibility

×1

Build schemas that evolve without breaking old clients via reserved namespaces and extension blocks.

Code-Switching-Aware Agent

×1

Treat mixed-language input (e.g. Hinglish in Roman script) as the expected shape, and design tokenisation, language tagging, and tool routing to handle it natively without forcing the user to commit…

Polymorphic Record

Represent a family of related entities in a single core schema with type-specific extensions.

Prompt/Response Optimiser

At runtime, transform user inputs and model outputs into standardised, template-aligned prompts and responses against predefined constraints, so the agent and its downstream consumers see consistent…

LLM as Periphery

Invert the typical LLM-in-the-middle architecture: a deterministic state machine and event store form the core; the LLM is restricted to edge tasks — input interpretation and output synthesis only.