Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:666ghj BettaFish IR Validation

From Leeroopedia
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:

J=LLM(prompt);J′=Repair(J) Valid=SchemaCheck(J′,IR);Chapter=Normalize(J′)

Where:

  • J = raw LLM JSON output (potentially malformed)
  • J′ = repaired JSON (brackets balanced, aliases normalized)
  • IR = the Intermediate Representation schema
  • Normalize = 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

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment