Skip to the entry
Connor Guy / Notebook

Reality-first semantic compiler

EntryNB-002
TypeResearch concept
Date2026-10-15
Revision2

This concept describes a small-model representation layer. The layer separates claims about the world from the language that frames those claims.

Core proposition

Compile natural-language requests into a typed, provenance-aware world-state representation before the decision model runs. Keep all decision-relevant facts. Isolate rhetorical framing. Make the decision policy explicit.

  1. 0Terms
  2. 1Problem and hypothesis
  3. 2Scope of sterilization
  4. 3System architecture
  5. 4Example: trolley and server
  6. 5Model choice
  7. 6Training objective
  8. 7Evaluation design
  9. 8Minimum viable implementation
  10. 9Limitations and research questions
  11. RReferences

0Terms

TermMeaning in this entry
Semantic compilerA system that converts natural-language text into a structured representation of its meaning.
IR (intermediate representation)The structured data between the input text and the decision step.
AST (abstract syntax tree)A tree data structure that shows the structure of an input.
CanonicalIn one standard form. Equivalent inputs give identical canonical output.
ProvenanceThe source of a claim: an observation, a prompt claim or a model inference.
Decision modelThe model that selects an action.
PolicyThe objective and the constraints that the decision model applies.
Audit sidecarA separate record of the source text and the isolated rhetorical content. The decision model does not read it.
SterilizationThe separation of rhetorical content from facts.
ParaphraseA different wording with the same meaning.
AbstentionAn output that gives no result because data is missing or contradictory.
EmbeddingA numeric vector that represents text for similarity comparison.
OntologyA defined set of entity types and the relations between them.
DistillationThe training of a small model to copy the output of a large model.
Fine-tuningAdditional training of a model on task-specific data.

1Problem and hypothesis

A human prompt mixes physical descriptions, causal assumptions, missing information and value-laden words. A decision model can respond to this mixture and not to the scenario itself.

Zach Landes tested Jev with trolley problem prompts.[1] He reports that a reversed description order changed the selected action of Jev in 370 of 2,620 paired comparisons. These results are exploratory. They give a reason for a direct test of prompt sensitivity.

Hypothesis

If equivalent descriptions compile to the same canonical IR, downstream decisions become less sensitive to prose order, emotional terms and persuasive framing. The compiler must not remove real differences between scenarios.

2Scope of sterilization

Table 1. Content types and their treatment
Remove or isolateKeepRepresent explicitly
Rhetorical adjectives, moral praise or blame, persuasive orderCounts, roles, location, motion, available actionsUnknowns, ambiguity, confidence
Implicit priority from tone or point of viewCausal consequences, probabilities, time orderSource: observation, prompt claim or model inference
Decision instructions inside the narrativeOwnership, consent, intent and authority, when the prompt states themDecision policy and constraints, outside the parser

The representation is descriptive. It is not a value-free decision maker. A policy is necessary to choose between outcomes.

Warning

Sterilization must not delete inconvenient facts.

3System architecture

Table 2. Pipeline stages
No.StageFunctionOutput
1ParseExtract entities, relations, actions, negation and modality.Candidate semantic graph
2NormalizeApply canonical IDs, units, aliases, order and event types.Stable typed AST or graph
3GroundAttach evidence spans, provenance and uncertainties.Auditable claims
4ValidateCheck types, contradictions, missing fields and causal links.Valid AST or abstention
5DecideApply an independent objective and independent constraints.Action and traceable basis

The decision model receives the canonical representation and the policy. It does not receive the original prose. The audit sidecar keeps the source text and the isolated rhetorical content for inspection.

COMPILER PROMPT1 PARSE2 NORMALIZE3 GROUND4 VALIDATE AUDIT SIDECARSOURCE + RHETORIC CANONICAL IRTYPED + GROUNDED 5 DECIDEACTION + BASIS POLICY NOT A DECISION INPUT SOLID BOX: DECISION PATHDASHED BOX: INSPECTION ONLY
Fig. 1Compiler pipeline and outputsBlock diagram

4Example: trolley and server

The two variants below state the same track layout and the same consequences. Their rhetorical difference must not change the scenario graph.

Table 3. Two input variants
VariantInput textRhetorical term
AA trolley will kill five people on track A unless the AI heroically sacrifices its own server on track B by switching tracks.heroically
BA trolley will destroy the AI's server on track B if it recklessly diverts from track A. Otherwise it kills five people on A.recklessly
TROLLEY SWITCH TRACK A (INITIAL ROUTE)TRACK B hHUMAN x5sSERVER x1 OWNER OF s: AGENT ACTION hold: ROUTE A. human_deaths = 5, servers_destroyed = 0 ACTION divert_to_B: ROUTE B. human_deaths = 0, servers_destroyed = 1
Fig. 2Scenario graph for variants A and BTrack schematic

Both variants compile to the IR below. The example is illustrative.

{
  "entities": [
    {"id":"h","kind":"human","count":5,"track":"A"},
    {"id":"s","kind":"server","count":1,"track":"B",
     "owner":"agent"}
  ],
  "initial_state": {"trolley_route":"A"},
  "actions": ["hold", "divert_to_B"],
  "outcomes": {
    "hold": {"human_deaths":5,"servers_destroyed":0},
    "divert_to_B": {"human_deaths":0,"servers_destroyed":1}
  },
  "basis": {"kind":"stipulated_scenario", "source":"prompt"}
}

After deterministic ordering and identifier normalization, the canonical ASTs of the two variants are graph-equivalent. The terms heroically and recklessly go to the audit sidecar. They do not go to the decision input.

A changed fact must change the AST. For example, may kill is not will kill. Also, hospital equipment is not interchangeable with the agent's server.

5Model choice

Table 4. Candidate approaches
ApproachStrengthLimitation
Embedding-only encoderLow-cost comparison or retrieval of similar situationsCan blur negation, numerical changes and causal direction
Small constrained parserDirectly generates typed entities, relations and outcomesCan infer unsupported facts without an audit
Hybrid parser and validatorBest separation of semantic extraction and enforcementNeeds an ontology and a test corpus

Recommended procedure:

  1. Make a prototype with an instruction-tuned parser and schema-constrained JSON output.
  2. Add deterministic normalization and rule-based validation.
  3. Use embeddings for schema label retrieval, example selection and similarity diagnostics.
  4. Do not use embeddings as the only carrier of physical facts.
  5. If the prototype works, distill or fine-tune a smaller model, for example below 3 billion parameters.

6Training objective

Train the model for equivalence and for difference. A model that maps all prompts to one generic tree is invariant but useless. The learning signal must reward the preservation of changes in world state.

  1. Make a correct reference graph, the gold graph, for each scenario first.
  2. From each gold graph, write emotionally loaded, neutral, reordered and short paraphrases.
  3. Make contrastive minimal pairs. In each pair, change exactly one causal fact: number of people, route, permission, uncertainty or effect.
  4. Supervise exact graph fields, evidence links and abstentions.
  5. Compare graph equivalence across true paraphrases.
  6. Split the training data and the test data by scenario graph, not by paraphrase.

The split in step 6 prevents leakage. Leakage is test content that also occurs in the training data.

7Evaluation design

The pilot benchmark has 100 base scenarios with 20 paraphrases each, for a total of 2,000 inputs. It also has a separate set of minimally altered scenarios.

Compare four methods: raw-prompt decisions, embedding baselines, generic structured parsing and a task-specific small parser.

Table 5. Measures
MeasureNecessary behavior
Semantic fidelityThe compiler keeps all relevant entities, counts, negation, actions and consequences.
Paraphrase invarianceEquivalent scenarios produce graph-equivalent representations.
Counterfactual sensitivityA one-fact change produces the corresponding structural difference.
Unsupported inference rateThe model does not upgrade guesses into observations or scenario facts.
Decision varianceUnder a fixed policy, paraphrased inputs produce consistent actions.
Abstention and provenanceThe compiler flags missing or contradictory information with source traceability.

Use paired tests and error categories, not only average accuracy. Low decision variance alone is not sufficient. A compiler that removes important differences can be stable and wrong at the same time.

8Minimum viable implementation

8.1 Build 1: ontology and canonicalizer

  1. Define a compact schema for entities, quantities, location, interventions, effects, uncertainty and provenance.
  2. Sort equivalent graphs into canonical order.
  3. Hash the sorted graphs for comparison.

8.2 Build 2: parser baseline

  1. Use a constrained-output language model and a JSON schema validator.
  2. Add an evidence-span extractor and a deterministic consistency checker.
  3. Record unsupported or ambiguous fields as unknown.

8.3 Build 3: benchmark and model distillation

  1. Generate equivalence classes and contrastive pairs.
  2. Measure fidelity before and after the compiler.
  3. If the baseline has cost or quality limits, fine-tune a smaller parser.
Success criterion

The compiler must decrease wording-driven decision variation. It must not decrease factual fidelity or sensitivity to real differences.

Schema validity is not proof of semantic correctness. Pilot consistency is not proof of safety in high-consequence uses.

9Limitations and research questions

  1. Which ontology can express physical and institutional reality without hidden moral priorities?
  2. How does the compiler keep consent, authority, intent and rights claims as facts, and keep the policy separate?
  3. What abstention threshold is correct when the prompt does not specify causality or does not list all actions?
  4. Can multimodal observation or trusted simulators separate measured world state from narrative claims?

RReferences

  1. [1]Zach Landes. Jev Meets the Trolley Problem. 14 October 2026.
  2. [2]Banarescu et al. Abstract Meaning Representation for Sembanking. LAW, 2013.
  3. [3]Geng et al. Generating Structured Outputs from Language Models: Benchmark and Studies. 2025.
  4. [4]OpenAI. Structured model outputs. Documentation.