Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qsem-protocol

qsem-protocol is the executable protocol behind a master's thesis on whether the semantics of a prompt behaves non-classically. It does not assume the answer: it treats prompts as operators on a model's semantic state, measures their behaviour through three independent external instruments, and reports every outcome, including nulls. The object of study is the statistics of prompt semantics — non-commutativity, interference, contextuality, and CHSH-style correlations — compared against what a classical declarative baseline can reproduce. Nothing here is asserted to be quantum; the repository measures, and the claim discipline below fixes how far the measurements may be read.

This repository is Phase 5 (the pre-registered, executable protocol) of the thesis "The Quantum-Like Nature of Prompt Semantics — A Symptomatic Investigation into Semantic Equality and Operator Algebra across LLMs and VLMs" (S. Stronati, adv. F. Corradini, Università di Camerino). See Relation to the thesis.

Anti-circularity: the D1 ∧ D2 ∧ D3 rule

The method rests on one principle: the patient does not self-diagnose. No LLM may certify a semantic judgment about LLM output, so every verdict is produced by an external instrument that runs rather than opines. Three independent judges observe the same prompts from disjoint angles: D1 (M_det) — a logic engine (SWI-Prolog / a DMN engine) executes artifacts emitted from the prompts and reads off outcome distributions; D2 (M_robot) — a MuJoCo simulation turns prompt-derived plans into physical traces, pinned and seeded so that runs are bit-identical; D3 (M_out) — a frozen embedding encoder maps sampled outputs to an estimated density matrix whose geometry (Bures angle, von Neumann entropy) is measured. A claim is certified only by the conjunction D1 ∧ D2 ∧ D3; agreement of one instrument is never enough, and the battery maximum over the three judges is that conjunction.

Reproducibility

The campaign is pre-registered in three stages. PILOT runs a small sample to estimate variance, token cost, and split-half stability. FREEZE locks the experiment: make freeze writes FROZEN.md with the corpus hash, the per-metric thresholds (ε_M), the pinned model/encoder/simulator versions, and all seeds; after FREEZE the protocol is normative and any divergence is a logged protocol deviation, not a silent edit. CAMPAIGN executes the frozen plan end-to-end and emits figures plus the claim ledger. All runs enter the analysis — there is no post-hoc quality filtering, and a non-compiling artifact () is a legitimate outcome, never discarded.

Two CI gates are load-bearing and are built before anything else:

  • Anti-circularity gate (ci/anticirc_check.py) — fails the build if a battery.yaml manifest names an LLM endpoint as judge J (the judge allowlist is SWI-Prolog, a DMN engine, MuJoCo, and the local embedding pipeline), or if any module under metrics/, tests/, or report/ imports an LLM client (anthropic, openai, …). LLM calls are permitted only in pipelines/*/generate.py.
  • Determinism gate — three same-seed D2 runs must produce bit-identical traces (tests/t_determinism); any drift turns CI red. This is what makes the robot instrument a judge rather than another source of noise.

Repository layout

qsem-protocol/
├── CLAUDE.md              seed brief + normative build order for the building agent
├── docs/                  protocol (fase5, normative) + phases 1–4 + 03-STATO (memory)
├── ci/
│   └── anticirc_check.py  anti-circularity gate: no LLM judge, no LLM import in metrics/tests/report
├── battery/               measurement-context schema (battery.yaml) + validator
├── metrics/               pure distance/geometry functions, NO LLM; metric axioms unit-tested
│                          tv · l2_aligned · levenshtein (Yujian–Bo) · bures · entropy · cm
├── pipelines/
│   ├── det/               prompt → Prolog/DMN artifact → sandboxed run → outcome vector (D1)
│   ├── robot/             prompt → MuJoCo trace, CPU, pinned, fixed seed → bit-identical (D2)
│   └── out/               prompt → sampled outputs → frozen encoder → ρ̂ geometry (D3)
│                          (LLM calls live ONLY in each pipeline's generate.py)
├── calibration/           split-half auto-distance, quantiles, `make freeze` → FROZEN.md
├── tests/
│   ├── t1..t10/           one module per decision rule (protocol §6), uniform JSON output
│   └── t_determinism/     D2 bit-identity check
├── report/                `make campaign` → figures + the claim ledger (thesis appendix)
└── corpus/                C1..C10 YAML, per-item provenance, revised & frozen at FREEZE

The corpus is organised into ten measurement categories: C1 substantial paraphrases, C2 similar-but-different pairs, C3 section permutations, C4 interference triples, C5 three-polarizer triples, C6 E-CONG near-identical pairs, C7 articulation ladders, C8 schema-rigidity items, C9 semantic-Bell / CHSH items, and C10 register transforms.

Build order

The normative build order lives in CLAUDE.md §Build order and is summarised here for orientation: (1) the anti-circularity gate and the battery/ schema + validator; (2) metrics/ as pure functions with metric-axiom unit tests that fail the build on any violation; (3) pipelines/det/; (4) pipelines/robot/ with the determinism test; (5) pipelines/out/; (6) calibration/ and make freeze; (7) tests/t1..t10/, one module per decision rule; (8) report/ and make campaign. The two CI gates come first because everything downstream depends on them holding. The metric contracts and decision-rule refinements (T6 E-CONG extensional scope; T7 CHSH with CbD S − 2 > Δ0) are specified in CLAUDE.md and are normative against docs/fase5-protocollo.md.

Claim discipline

Findings are reported at three levels and never above the evidence. L1 — structural analogy between prompt semantics and operator algebra (the honest fallback). L2 — non-classical statistics relative to a declared classical baseline; this is what the protocol is built to support. L3 — the physical-identity reading (prompt semantics is quantum); this is an explicitly flagged research programme, not a result of this repository. The code produces L2 evidence. No string in this repository should claim the work proves, demonstrates, or shows that prompt semantics is quantum.

Done criterion

A third party, given this repository and the protocol document, can run the whole campaign end-to-end — PILOT, FREEZE, CAMPAIGN — without asking anything, and obtain the figures and the claim ledger reproducibly.

Status

Pre-PILOT. The protocol (docs/fase5-protocollo.md, v1.1) is normative; on any conflict between code and protocol, the protocol wins. Definitions, decisions, and verified anchors are recorded in docs/03-STATO.md.

Relation to the thesis

This repository is the executable Phase 5 of the thesis. Phases 1–4 (semantic equality, operator algebra, an information-geometric reading, and the bridges to quantum structure) are documented under docs/; Phase 5 operationalises their predictions as a pre-registered protocol so that the thesis's empirical claims are reproducible and externally judged. The repository is an experimental apparatus and its claim ledger is the thesis's experimental appendix — it is not a standalone assertion about the nature of language models.

License

Dual license, following research-repository convention. Source code is under the MIT License (see LICENSE). Corpus data (corpus/) and documentation (docs/, README.md, and the other prose files) are under Creative Commons Attribution 4.0 International (CC-BY-4.0)https://creativecommons.org/licenses/by/4.0/. Note to maintainers: confirm this dual-licensing arrangement with the Università di Camerino IP policy before publishing; do not treat the split as settled until that check is done.

How to cite

Citation metadata is in CITATION.cff (CFF 1.2.0). The DOI is left blank until one is minted — do not cite a fabricated identifier.

About

Executable, pre-registered protocol testing quantum-like (non-classical) structure in LLM/VLM prompt semantics via three external judges.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors