# Observers, LLM Alingment and Cartography

> Source: <https://github.com/robertdbak/multiview/>
> Published: 2026-11-29 11:52:53+00:00

**Key takeaway:** Cross-observer covariance can separate shared signal from observer-private noise in closed form without ground-truth labels or SGD, and the repo ships CPU (NumPy) and CUDA (PyTorch) packages plus Lean 4 proofs with 0 sorry.

This is a version that's trying to stay minimal in scope, while showcasing the use cases. The algebraic formulation is the one that seems the most straight-forward to understand and immiediately useful (as you can see from the example implementations), but the same generic idea seems to work all the way up to category theory (at least in practice, the solutions based on that work on real data). It's a one person project with heavy Google Gemini usage, any corrections, bug fixes, etc. are welcome.

This was used to extract the geometric shapes iniside LLMs, allowing for in-process better hallucination detection and aligment. It also work for analyzing open scientific data sets.

This repository contains the mathematical theory, Lean 4 formalisations, unified CPU/CUDA Python packages, interactive scientific workbenches, and official [OpenProblems.bio v2](https://openproblems.bio) method submissions for **Multi-Observer Algebra** (`multiobserver`).

Whenever an underlying state 

cross-observer covariance separates shared signal from observer-private noise **in closed form, without ground-truth labels or neural-network SGD**.

```
.
├── justfile                        # Root launcher for all UIs, servers, Marimo notebooks & tests
├── papers/                         # Core papers, companion papers, build scripts & Lean 4 proofs
│   ├── minimal_core_essay.{typ,pdf}# Accessible essay + self-contained ordered-field core
│   ├── minimal_core.{typ,pdf}      # Self-contained algebraic core & Four Hard Limits
│   ├── lean/                       # Zero-dependency Lean 4 Core proofs (0 sorry, 0 custom axioms)
│   └── extras/                     # Applied companion papers (usability & LLM alignment)
├── code/
│   ├── packages/                   # Unified uv Python workspace (core math, workbenches & LLM tools)
│   │   ├── multiobserver/          # Single-source CPU (NumPy) + GPU (PyTorch CUDA) math engine
│   │   ├── observer-lab/           # Scientific workbench CLI (`observer`) + Vue 3 / WASM Typst UI
│   │   ├── unbundle/               # Epistemic provenance store, gates & subspace-protected quantization
│   │   ├── statedrive/             # Cross-model state algebra, biorthogonal dials & voice enactment
│   │   ├── observer-llm/           # Multi-observer LLM onboarding, spherical steering & OpenAI /v1 server
│   │   └── llm-cartography/        # Category-blind all-layer LLM tomography & 7-tab WebGPU workbench
│   └── openproblems-submission/    # 6 Viash method components across 13 OpenProblems.bio v2 benchmarks
└── visualizations/                 # Standalone interactive 5-step geometric visual companion
```

Defines the exact algebraic laws and hard identifiability limits implemented across `code/`:

| File / Folder | What It Does | 
|---|---|
| [`papers/minimal_core_essay.pdf`](https://github.com/robertdbak/multiview/blob/main/papers/minimal_core_essay.pdf) | Plain-language introduction + complete ordered-field derivation of how three imperfect views calibrate each other without a gold standard. | 
| [`papers/minimal_core.pdf`](https://github.com/robertdbak/multiview/blob/main/papers/minimal_core.pdf) | Formal derivation of the Matrix Three-Cornered Hat, rational corrective glasses (zero square roots), precision fusion, **Regime vs. Conflict** OOD decomposition, solo deployment, and the**Four Hard Limits** (unanchored coordinates, the | 
| [`papers/lean/`](https://github.com/robertdbak/multiview/blob/main/papers/lean) | Zero-dependency Lean 4 Core proofs ( [`MinimalCore.lean`](https://github.com/robertdbak/multiview/blob/main/papers/lean/MinimalCore.lean) —`Init` only,`0 sorry` ,`0` custom axioms). | 
| [`papers/extras/`](https://github.com/robertdbak/multiview/blob/main/papers/extras) | Applied companions: [`usability_guide.pdf`](https://github.com/robertdbak/multiview/blob/main/papers/extras/usability_guide.pdf) (sensors & clinical monitors) and[`alignment_cartography.pdf`](https://github.com/robertdbak/multiview/blob/main/papers/extras/alignment_cartography.pdf) (LLM output-masking tomography). | 

Single-source library ([`code/packages/multiobserver/README.md`](https://github.com/robertdbak/multiview/blob/main/code/packages/multiobserver/README.md)) implementing every estimator against a unified `ArrayBackend` (`NumPyBackend` on CPU with **zero `scipy`/` sklearn`/` torch` imports**; `TorchBackend` inside `torch.inference_mode()` on CUDA GPUs, including matrix-free `cuSPARSE` CSR operators for `max_dim=None` full-transcriptome count matrices):

| Module / Class | What It Does | 
|---|---|
| `Observer` ,`Linear` ,`Log1p` ,`Periodic` (`RAD` ,`DEG` ,`TURN` ) | Explicit physical sensor wrappers ( `multiobserver.units` ). Transforms`Periodic` onto`Log1p` +`exposure` (`"none"` ,`"row_sum"` ,`"cp10k"` )**once on ingest** in | 
| `audit_observers` | Step-1 epistemic audit using the Wachter Jacobi-ensemble edge to verify | 
| `MinimalCoreAlgebra` | Exact closed-form Three-Cornered Hat separating common signal from **dense** private noise covariances | 
| `MultiObserverCalculus` | General EM / Two-Level Laird-Ware ( `groups=batch` ) multi-observer latent state & uncertainty estimator (`max_dim=None` matrix-free sparse/chunked ops,`.infer_aligned()` Fisher-metric + Product-of-Experts`Sigma_PoE` Bures-Wasserstein group covariance calibration, Student-$t_\nu$ glitch downweighting,`nan_policy="marginalize"` ). | 
| `SupervisedMultiObserver` &`ClassificationMultiObserver` | Closed-form Bayesian Errors-in-Variables (EIV) continuous and multi-class readouts that propagate posterior latent covariance | 
| `Harmonic*` (`HarmonicSupervisedMultiObserver` ,`HarmonicClassificationMultiObserver` ) | **Algebraic H4** : Li (1992) Stein canonical | 
| `MultiObserverStructure` &`MultiObserverDynamics` | Multi-environment EIV causal graph discovery + Pearl `do()` interventions (`structure` ), and Kalman/RTS smoothing + Weak-SINDy ODE discovery + RK4 rollouts (`dynamics` ). | 
| `ForwardRuntime` (`multiobserver.deploy` ) | Single-file ( `stdlib` +`numpy` only) standalone edge inference runtime loading`.save_npz()` archives across CPU/GPU boundaries. | 

CLI and web application ([`code/packages/observer-lab/README.md`](https://github.com/robertdbak/multiview/blob/main/code/packages/observer-lab/README.md)) wrapping `multiobserver` with automated diagnostics, declarative `.toml` configs, and an interactive browser UI:

- 
**`observer` CLI & 1-Line SDK (`observer_lab/cli.py`, `observer_lab/convenience.py`):** Commands` observer doctor` ,`observer presets` ,`observer inspect` ,`observer init` (MAR-grouped & count-aware`study.toml` scaffolding),`observer audit` ,`observer audit-preset` ,`observer explain` (native-unit channel attributions),`observer predict` ,`observer translate` ,`observer denoise` , and`observer ui --port 8770` , plus 1-line`ol.audit(...)` /`model.explain(...)` supporting in-memory DataFrames, live`AnnData` objects, zero-copy`.h5ad` CSR matrices, and automatic$M=1 \to M=3$ wide-matrix partitioning.
- 
**Declarative `study.toml` / `project.toml` (`StudyConfig` in `observer_lab/spec.py`):** Configures` mode` ,`enforce_raw_data` ,`allow_joint` ,`allow_harmonic` ,`target_unit` ,`target_exposure` , and per-observer`[observer_specs.<name>]` (`unit` ,`scale_policy` ,`exposure` ,`scrub_sink` ).
- 
**14 Deterministic Validity Checks (`V00`–` V13` in `observer_lab/checks/`):** Audits raw-data hygiene & synced clones (**V00** ,**V06** ), row alignment (**V01** ), entity/clock leakage (**V02** ), circular seams + partial-panel exposure / sparse channel-scale / raw-count sensor physics (**V03** ), foundation-model attention sinks (**V04** ), batch-target confounding + automatic PoE-Bures frame alignment on single-batch variance bursts (**V05** ,**V08** ), Corollary 2 over-identification (**V07** ), H4 / Student-$t$ gates (**V09** ,**V10** ), honest baselines (**V11** ), conformal 95% intervals + 2-axis Regime/Conflict OOD (**V12** ), and`.npz` runtime parity (**V13** ).
- 
**5-Workspace Vue 3 + ECharts + WebAssembly Typst UI (`observer_lab/ui/`):** Interactive data onboarding, validity scorecard, SNR/Solo-Glasses explorer, unseen holdout scorer, and browser WebAssembly Typst PDF preview (`just observer` ).

Self-contained, PR-ready Viash method components (`observer_algebra`, [` code/openproblems-submission/README.md`](https://github.com/robertdbak/multiview/blob/main/code/openproblems-submission/README.md)) evaluated across **6 official OpenProblems.bio v2 tasks (13 held-out benchmarks)**:

| Component / Script | What It Does | 
|---|---|
| [`prepare_local_submission.py`](https://github.com/robertdbak/multiview/blob/main/code/openproblems-submission/prepare_local_submission.py) | Verifies no vendored `multiobserver/` source exists in`task_*/src/methods/observer_algebra/` , validates`config.vsh.yaml` (Git pull of`multiobserver` ) +`project.toml` , and simulates isolated`viash test` against`.h5ad` slot contracts. | 
| [`run_official_benchmarks.py`](https://github.com/robertdbak/multiview/blob/main/code/openproblems-submission/run_official_benchmarks.py) | Executes all 6 Viash `script.py` components as isolated subprocesses across 13 official OpenProblems splits under both`--profile best` (`results/openproblems_official_results.json` ) and`--profile strict` (`results/openproblems_strict_zero_peeking_results.json` , universal zero-peeking & strictly inductive | 
| [`build_report.py`](https://github.com/robertdbak/multiview/blob/main/code/openproblems-submission/build_report.py) | Stdlib-only generator producing global, dual-profile & per-task SVG figures, README summaries, and [`report/openproblems_observer_report.pdf`](https://github.com/robertdbak/multiview/blob/main/code/openproblems-submission/report/openproblems_observer_report.pdf) . | 
| `task_predict_modality` | Cross-modality translation ( `GEX <-> ADT` ,`GEX <-> ATAC` ) on 100% unmodified raw`layers["counts"]` (`max_dim=None` ), persisted via`.save_npz()` before mapping predicted counts to OpenProblems' output evaluation slot (`clr` ,`log_cp10k` ,`atac_tfidf` ). | 
| `task_spatially_variable_genes` | Spatial characteristic-function H4 variance-fraction test across isotropic physical tissue coordinates `obsm["spatial"]` and raw spot counts (`layers["counts"]` ). | 
| `task_label_projection` | Donor-invariant Stein-H4 cell-type transfer across all 27k–30k raw genes ( `max_dim=None` , up to 330k cells and 17 organs). | 
| `task_batch_integration` | Strictly unsupervised Two-Level Laird-Ware + PoE-Bures `infer_aligned` integration across all 30,561 raw genes (`groups=batch` ), achieving`#5 / 20` (`0.5512` , beating`fastMNN` ,`ComBat` ,`scANVI` , and`scVI` ) without altering counts. | 
| `task_foundation_models` | Training-donor consensus across unreduced `Geneformer-V2` (768-D),`scGPT` (512-D),`ESM-2` (480-D), and all 30,561 raw count genes (`#1 / 9` overall,`0.7514` , zero`solution.h5ad` access). | 
| `task_perturbation_prediction` | Cross-cell-type compound (OP3 + SMILES) and CRISPRi ( `PIE_replogle_nadig` ) transcriptome response prediction with`audit_observers` layer pruning and optional transductive H4`id_map` refinement (`--disable_pseudolabel` toggle). | 

See [`code/packages/README.md`](https://github.com/robertdbak/multiview/blob/main/code/packages/README.md) for details on each companion package, and **[`code/packages/MULTI_LLM_GUIDE.md`](https://github.com/robertdbak/multiview/blob/main/code/packages/MULTI_LLM_GUIDE.md)** for a complete cookbook on calibrating and using multiple frozen LLMs together (`.npz` sidecar glasses, zero-label cross-model probe transfer, `StateBus` state translation & `1 Large + 2 Small` fleet calibration):

- **[`unbundle`](https://github.com/robertdbak/multiview/blob/main/code/packages/unbundle/README.md):** Separates LLM reasoning from static facts via intact-unit provenance indexing (`ProvenanceStore` ), hidden-state epistemic gates (`ThreeBandGate` ,`HorizonGate` ), and subspace-protected`INT2` /`INT3` /`INT4` weight surgery.
- **[`statedrive`](https://github.com/robertdbak/multiview/blob/main/code/packages/statedrive/README.md):** Common-mode-deconfounded stance banks (`StanceBank` ), biorthogonal control dials (`DialBank` ), cross-model`StateBus` transfer, and LLM-to-voice prosody enactment.
- **[`observer-llm`](https://github.com/robertdbak/multiview/blob/main/code/packages/observer-llm/README.md):** GPU-native multi-observer LLM onboarding, VJP-calibrated spherical steering (`SteerPlan` ), lossless suffix speculative decoding, and an OpenAI-compatible`/v1` server (`just observer-llm` ).
- **[`llm-cartography`](https://github.com/robertdbak/multiview/blob/main/code/packages/llm-cartography/README.md):** All-layer (`L0 .. L_max` ) category-blind LLM representation tomography, alignment/masking scanner, and 7-tab Vue 3 + WebGPU workbench (`just cartography` ).

Across `observer-lab` and `openproblems-submission`, callers **never** pre-normalize, HVG-filter, or PCA-truncate raw measurements (`layers["normalized"]` and `obsm["X_pca"]` are dropped on input; `Observer.data` is never mutated). Instead, sensor physics is declared explicitly on each `Observer` (or in `project.toml`):

| Setting | Options | Meaning | 
|---|---|---|
| **`unit`** | `"linear"` ,`"log1p"` ,`"deg"` ,`"rad"` ,`"periodic:<P>"` | Sensor chart: additive `Linear` , multiplicative count/absorbance`Log1p` (`(1)` of`minimal_core.pdf` ), or circular`Periodic` lifted onto | 
| **`scale_policy`** | `"per_channel"` ,`"isotropic"` ,`"poisson_shot"` | Internal channel standardization: per-channel variance ( `per_channel` ), uniform observer-wide scalar RMS (`isotropic` , avoiding rare-channel noise inflation when`max_dim=None` ), or Negative-Binomial shot scale (`poisson_shot` ). | 
| **`exposure`** | `"none"` ,`"row_sum"` ,`"cp10k"` | Row-wise total-exposure scaling applied once on ingest in `row_sum` normalizes to training mean depth;`cp10k` normalizes to`10,000` counts per row). | 

From the repository root:

```
# List all root tasks (workbenches, servers, Marimo notebooks, tests)
just

# Launch interactive workbenches
just observer                  # Observer Lab Scientific Workbench + WASM Typst Preview (:8770)
just cartography               # LLM Cartography 7-tab Workbench (:8787)
just observer-llm              # Multi-Observer LLM OpenAI /v1 Server + Chat UI
just marimo                    # Central Marimo hub with interactive notebooks (:2718)

# Run package test suites
just test-all
just test-marimo

# Build papers & verify Lean 4 proofs
cd papers && ./build.sh && lean lean/MinimalCore.lean

# Reproduce OpenProblems.bio contracts, 13 official benchmarks & PDF report
cd code/openproblems-submission
just prepare                   # Validate pull-based PR dirs & test all 6 Viash contracts offline
just benchmark                 # Run all 13 official OpenProblems benchmarks
just report                    # Regenerate all SVGs, Typst source & PDF report
just lint                      # Verify zero ruff lint warnings
```

- **Code, scripts & Lean 4 formalisations** (`code/**` ,`visualizations/**` ,`papers/lean/**` ,`papers/*.sh` ,`justfile` ):[Apache-2.0](https://github.com/robertdbak/multiview/blob/main/LICENSE) © 2026 Robert Bąk — see[NOTICE](https://github.com/robertdbak/multiview/blob/main/NOTICE) for attribution notices that must be preserved in redistributions.
- **Papers, essays, reports & figures** (`papers/**/*.typ` ,`papers/**/*.pdf` ,`papers/**/*.svg` , and generated benchmark reports/figures):[CC BY 4.0](https://github.com/robertdbak/multiview/blob/main/papers/LICENSE) © 2026 Robert Bąk.
- **Citation:** See[CITATION.cff](https://github.com/robertdbak/multiview/blob/main/CITATION.cff) (or GitHub's*"Cite this repository"* button).
- **Contact:** Robert Bąk —[robert_d_bak@pm.me](mailto:robert_d_bak@pm.me)

Pre-built front-end bundles checked into this repository embed third-party code
(Vue, naive-ui — MIT; ECharts, typst.ts and the Typst WASM compiler —
Apache-2.0). See [THIRD_PARTY_NOTICES.md](https://github.com/robertdbak/multiview/blob/main/THIRD_PARTY_NOTICES.md) for the
required attribution, and for the data-use terms of the public and
credentialed-access datasets used in the examples and benchmarks.
