Think Forward.

The Narrative Compiler Framework: Fixing LLM Hallucination & Tokenomics

580
Chapters: 5 7.6 min read

4: Chapter 4: Tokenomics & Failure 113

Token usage in direct generation scales with both input size and document count. When identical datasets are used repeatedly, the same information is reintroduced into prompts and reprocessed each time. This creates redundancy across runs. A staged pipeline changes this behavior by separating computation from generation. Feature computation runs once per dataset. The results are stored and reused. The generation step receives only derived values and semantic tags rather than raw input data. Let Tin represent the original input size and T'in the reduced representation produced after feature extraction. For n documents derived from the same dataset, direct generation cost scales with n⋅Tin. In the staged system, cost splits into a one-time computation cost plus n⋅Tin. As n increases, the amortized cost of preprocessing becomes negligible relative to repeated generation savings. This structure also changes verification cost. When outputs depend on raw inputs embedded inside prompts, validation requires rechecking both computation and interpretation. When outputs depend on precomputed features, verification reduces to checking alignment between text and deterministic values. This reduces the scope of manual review. A second effect concerns failure containment. In end-to-end generation, errors in reasoning, calculation, and phrasing occur in the same process, making attribution difficult. A staged pipeline isolates these responsibilities. Feature computation is deterministic and testable. Semantic classification is rule-based and auditable. Generation is constrained to express only pre-validated inputs. Validation operates as a final comparison layer between text and deterministic outputs. In practical terms, this structure prevents entire classes of errors that arise when models are allowed to both compute and express facts. Numerical inconsistencies, misapplied rules, and unsupported claims can be traced back to specific layers and eliminated without affecting unrelated parts of the system. The result is a system where cost and correctness are both controlled through separation of responsibilities rather than increased model complexity.

5: Chapter 5: Formalize & Systemize 110

A working implementation begins with a narrowly defined document type. The unit of construction is a skill, which combines input schema, feature computation, semantic rules, generation constraints, and validation logic into a single packaged pipeline. The input schema defines the structure of accepted data. Each field has a fixed type and meaning. Inputs outside this structure are rejected or normalized before processing. This step removes ambiguity at the entry point. The feature layer computes derived values from the input schema. These computations are deterministic and expressed in standard tooling such as SQL or Python. The outputs include numerical transformations, aggregations, and formatted representations. Once computed, these values are stored and reused across all downstream operations for the same input. The semantic layer maps computed features into categorical labels. These mappings are expressed as explicit rules that define thresholds and conditions. The rules function as a translation layer between raw computation and narrative intent. Changes in business definition are reflected by modifying rules rather than rewriting logic. The generation layer receives three inputs: original data, computed features, and semantic labels. It produces structured text under strict constraints. The model is restricted to expressing provided values. No additional facts are introduced. Output formats are predefined, often as structured JSON containing narrative sections. The validation layer compares generated text against deterministic outputs. It extracts numerical values, categorical claims, and references, then checks them against the feature and semantic layers. Any deviation indicates failure. Output is either accepted or routed for correction. A complete skill behaves like a compiled artifact. Input enters through a fixed interface. Output is produced in a predictable format. Internal logic remains inspectable and versioned. Once a single skill is stable, the same structure can be replicated across multiple document types. Financial reports, product summaries, operational dashboards, and compliance documents follow identical architectural patterns. Variation exists only in schema definitions, feature logic, and semantic rules. As the number of skills increases, duplication appears in semantic definitions. Terms such as “strong performance,” “declining trend,” or “high risk” recur across domains, often with subtle differences in meaning depending on context. A static rule system cannot represent these contextual variations efficiently. Each skill encodes its own version of definitions, which leads to inconsistency and maintenance overhead. A knowledge graph introduces a shared semantic layer. Concepts are represented as nodes, and relationships between them are explicitly defined. Each concept carries attributes such as context, domain, and threshold values. This allows meaning to vary based on surrounding conditions rather than fixed rule files embedded in individual skills. In this structure, a query retrieves the appropriate definition of a concept based on context parameters such as industry, market state, or organizational role. The semantic layer no longer evaluates rules directly. It resolves references into context-specific definitions drawn from the graph. Feature computation remains unchanged. Inputs are still transformed into deterministic values. The difference lies in how those values are interpreted. Instead of fixed thresholds embedded in code or configuration files, interpretation depends on graph queries that return context-aware mappings. This creates composability across systems. Multiple skills reference the same underlying semantic nodes. A change in definition propagates through the graph without modifying individual pipelines. Consistency emerges from shared structure rather than replicated configuration. The generation layer remains unchanged. It still receives features and resolved semantic labels. The difference lies upstream, where those labels are derived from a shared semantic space rather than isolated rule sets. Validation also extends naturally. Outputs can be traced not only to feature computations but also to the specific semantic definitions used during interpretation. This adds a second layer of provenance, linking each statement to both numerical derivation and contextual meaning. The system shifts from isolated pipelines to a connected network of shared meaning, where document generation becomes an application of structured knowledge rather than repeated local interpretation.