Skip to content
Two abstract, 8-bit style icons represent data files: the first has three horizontal lines, indicating YAML format; the second shows curly brackets and an arrow, symbolizing a coding function. A minimalist gear stands for parsing or validation, and simple lines connect the files, function, and gear to suggest the process flow. The design uses five distinct corporate colors, stays flat, minimal, and abstract, and is set at a compact 128x128 size with no background.

YAML

YAML is a human-readable data serialization format that is commonly used for configuration files and data exchange.

In the context of LLM, YAML is friendlier to the tokenizer algorithm and is generally preferred over JSON to represent structured data.

The defData function renders an object to YAML in the prompt (and other formats if needed).

defData("DATA", data)

Similarly to the JSON class in JavaScript, the YAML class in LLM provides methods to parse and stringify YAML data.

const obj = YAML`value: ${x}`
const obj = YAML.parse(`...`)
const str = YAML.stringify(obj)

The parsers also provide a lenient parser for YAML. It returns undefined for invalid inputs.

const res = parsers.YAML("...")

JSON schemas defined with defSchema can also be used to validate YAML data.