Principle:666ghj BettaFish IR Validation
| Knowledge Sources | |
|---|---|
| Domains | Report_Generation, Data_Validation, Software_Architecture |
| Last Updated | 2026-10-08 00:00 GMT |
Overview
Technique that validates LLM-generated content against a structured Intermediate Representation (IR) schema, ensuring the output can be reliably consumed by rendering engines, with automated repair for common LLM output defects.
Description
IR Validation addresses the reliability problem of LLM-generated structured content: LLMs frequently produce malformed JSON, use inconsistent field names, omit required fields, or generate blocks with invalid structure. By defining a formal IR schema (a JSON specification of all valid block types, inline marks, and metadata), the system can: 1. Validate each chapter against the schema 2. Attempt automated repair for common defects (alias normalization, structure fixing) 3. Fall back to alternative generation strategies if repair fails
This ensures that the rendering engine receives well-formed input, preventing runtime errors and visual defects in the final report.
Usage
Use this principle when generating structured content (reports, documents, UI components) with LLMs where the output must be programmatically consumed by downstream systems.
Theoretical Basis
The validation-repair pipeline:
Where:
- = raw LLM JSON output (potentially malformed)
- = repaired JSON (brackets balanced, aliases normalized)
- = the Intermediate Representation schema
- = ensures all required fields exist with defaults
Pseudo-code Logic:
# Abstract pattern (NOT real implementation)
raw_json = llm.generate(prompt)
repaired = json_repair(raw_json) # Fix syntax errors
normalized = normalize_aliases(repaired) # "strong" -> "bold", etc.
if not validate(normalized, ir_schema):
normalized = repair_blocks(normalized)
return normalized
Related Pages
Implemented By
- Implementation:666ghj_BettaFish_ChapterGenerationNode_run
- Implementation:666ghj_BettaFish_DocumentComposer_build_document
- Implementation:666ghj_BettaFish_HTMLRenderer_render