Reality-first semantic compiler
This concept describes a small-model representation layer. The layer separates claims about the world from the language that frames those claims.
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.
- 0Terms
- 1Problem and hypothesis
- 2Scope of sterilization
- 3System architecture
- 4Example: trolley and server
- 5Model choice
- 6Training objective
- 7Evaluation design
- 8Minimum viable implementation
- 9Limitations and research questions
- RReferences
0Terms
| Term | Meaning in this entry |
|---|---|
| Semantic compiler | A 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. |
| Canonical | In one standard form. Equivalent inputs give identical canonical output. |
| Provenance | The source of a claim: an observation, a prompt claim or a model inference. |
| Decision model | The model that selects an action. |
| Policy | The objective and the constraints that the decision model applies. |
| Audit sidecar | A separate record of the source text and the isolated rhetorical content. The decision model does not read it. |
| Sterilization | The separation of rhetorical content from facts. |
| Paraphrase | A different wording with the same meaning. |
| Abstention | An output that gives no result because data is missing or contradictory. |
| Embedding | A numeric vector that represents text for similarity comparison. |
| Ontology | A defined set of entity types and the relations between them. |
| Distillation | The training of a small model to copy the output of a large model. |
| Fine-tuning | Additional 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.
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
| Remove or isolate | Keep | Represent explicitly |
|---|---|---|
| Rhetorical adjectives, moral praise or blame, persuasive order | Counts, roles, location, motion, available actions | Unknowns, ambiguity, confidence |
| Implicit priority from tone or point of view | Causal consequences, probabilities, time order | Source: observation, prompt claim or model inference |
| Decision instructions inside the narrative | Ownership, consent, intent and authority, when the prompt states them | Decision 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.
Sterilization must not delete inconvenient facts.
3System architecture
| No. | Stage | Function | Output |
|---|---|---|---|
| 1 | Parse | Extract entities, relations, actions, negation and modality. | Candidate semantic graph |
| 2 | Normalize | Apply canonical IDs, units, aliases, order and event types. | Stable typed AST or graph |
| 3 | Ground | Attach evidence spans, provenance and uncertainties. | Auditable claims |
| 4 | Validate | Check types, contradictions, missing fields and causal links. | Valid AST or abstention |
| 5 | Decide | Apply 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.
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.
| Variant | Input text | Rhetorical term |
|---|---|---|
| A | A trolley will kill five people on track A unless the AI heroically sacrifices its own server on track B by switching tracks. | heroically |
| B | A 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 |
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
| Approach | Strength | Limitation |
|---|---|---|
| Embedding-only encoder | Low-cost comparison or retrieval of similar situations | Can blur negation, numerical changes and causal direction |
| Small constrained parser | Directly generates typed entities, relations and outcomes | Can infer unsupported facts without an audit |
| Hybrid parser and validator | Best separation of semantic extraction and enforcement | Needs an ontology and a test corpus |
Recommended procedure:
- Make a prototype with an instruction-tuned parser and schema-constrained JSON output.
- Add deterministic normalization and rule-based validation.
- Use embeddings for schema label retrieval, example selection and similarity diagnostics.
- Do not use embeddings as the only carrier of physical facts.
- 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.
- Make a correct reference graph, the gold graph, for each scenario first.
- From each gold graph, write emotionally loaded, neutral, reordered and short paraphrases.
- Make contrastive minimal pairs. In each pair, change exactly one causal fact: number of people, route, permission, uncertainty or effect.
- Supervise exact graph fields, evidence links and abstentions.
- Compare graph equivalence across true paraphrases.
- 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.
| Measure | Necessary behavior |
|---|---|
| Semantic fidelity | The compiler keeps all relevant entities, counts, negation, actions and consequences. |
| Paraphrase invariance | Equivalent scenarios produce graph-equivalent representations. |
| Counterfactual sensitivity | A one-fact change produces the corresponding structural difference. |
| Unsupported inference rate | The model does not upgrade guesses into observations or scenario facts. |
| Decision variance | Under a fixed policy, paraphrased inputs produce consistent actions. |
| Abstention and provenance | The 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
- Define a compact schema for entities, quantities, location, interventions, effects, uncertainty and provenance.
- Sort equivalent graphs into canonical order.
- Hash the sorted graphs for comparison.
8.2 Build 2: parser baseline
- Use a constrained-output language model and a JSON schema validator.
- Add an evidence-span extractor and a deterministic consistency checker.
- Record unsupported or ambiguous fields as unknown.
8.3 Build 3: benchmark and model distillation
- Generate equivalence classes and contrastive pairs.
- Measure fidelity before and after the compiler.
- If the baseline has cost or quality limits, fine-tune a smaller parser.
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
- Which ontology can express physical and institutional reality without hidden moral priorities?
- How does the compiler keep consent, authority, intent and rights claims as facts, and keep the policy separate?
- What abstention threshold is correct when the prompt does not specify causality or does not list all actions?
- Can multimodal observation or trusted simulators separate measured world state from narrative claims?
RReferences
- [1]Zach Landes. Jev Meets the Trolley Problem. 14 October 2026.
- [2]Banarescu et al. Abstract Meaning Representation for Sembanking. LAW, 2013.
- [3]Geng et al. Generating Structured Outputs from Language Models: Benchmark and Studies. 2025.
- [4]OpenAI. Structured model outputs. Documentation.