poma-bio 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. poma_bio-1.0.0/CITATION.cff +10 -0
  2. poma_bio-1.0.0/LICENSE +21 -0
  3. poma_bio-1.0.0/MANIFEST.in +10 -0
  4. poma_bio-1.0.0/PKG-INFO +233 -0
  5. poma_bio-1.0.0/README.md +173 -0
  6. poma_bio-1.0.0/configs/poma_benchmark.yaml +274 -0
  7. poma_bio-1.0.0/pyproject.toml +96 -0
  8. poma_bio-1.0.0/setup.cfg +4 -0
  9. poma_bio-1.0.0/src/poma/__init__.py +69 -0
  10. poma_bio-1.0.0/src/poma/backbones.py +284 -0
  11. poma_bio-1.0.0/src/poma/bayesian.py +123 -0
  12. poma_bio-1.0.0/src/poma/config.py +101 -0
  13. poma_bio-1.0.0/src/poma/data/__init__.py +1 -0
  14. poma_bio-1.0.0/src/poma/data/admet.py +265 -0
  15. poma_bio-1.0.0/src/poma/data/aintibody_abrank.py +312 -0
  16. poma_bio-1.0.0/src/poma/data/antibodies.py +437 -0
  17. poma_bio-1.0.0/src/poma/data/download.py +707 -0
  18. poma_bio-1.0.0/src/poma/data/pmo_oracles.py +376 -0
  19. poma_bio-1.0.0/src/poma/data/transforms.py +271 -0
  20. poma_bio-1.0.0/src/poma/dependency.py +125 -0
  21. poma_bio-1.0.0/src/poma/generation.py +139 -0
  22. poma_bio-1.0.0/src/poma/logica_bridge.py +174 -0
  23. poma_bio-1.0.0/src/poma/metrics/__init__.py +1 -0
  24. poma_bio-1.0.0/src/poma/metrics/evaluation.py +262 -0
  25. poma_bio-1.0.0/src/poma/model.py +409 -0
  26. poma_bio-1.0.0/src/poma/models/__init__.py +1 -0
  27. poma_bio-1.0.0/src/poma/models/architecture.py +849 -0
  28. poma_bio-1.0.0/src/poma/models/biofm_alignment.py +258 -0
  29. poma_bio-1.0.0/src/poma/models/encoders.py +212 -0
  30. poma_bio-1.0.0/src/poma/models/gpu_extensions.py +592 -0
  31. poma_bio-1.0.0/src/poma/models/heads.py +2874 -0
  32. poma_bio-1.0.0/src/poma/models/logica_poma.py +1302 -0
  33. poma_bio-1.0.0/src/poma/models/losses.py +169 -0
  34. poma_bio-1.0.0/src/poma/models/spectral_heads.py +778 -0
  35. poma_bio-1.0.0/src/poma_bio.egg-info/PKG-INFO +233 -0
  36. poma_bio-1.0.0/src/poma_bio.egg-info/SOURCES.txt +37 -0
  37. poma_bio-1.0.0/src/poma_bio.egg-info/dependency_links.txt +1 -0
  38. poma_bio-1.0.0/src/poma_bio.egg-info/requires.txt +42 -0
  39. poma_bio-1.0.0/src/poma_bio.egg-info/top_level.txt +1 -0
@@ -0,0 +1,10 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use POMA or LogiCA-POMA in your research, please cite this work."
3
+ title: "Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models"
4
+ type: software
5
+ authors:
6
+ - family-names: "Pelissier"
7
+ given-names: "Aurelien"
8
+ repository-code: "https://github.com/AI-SysBio/POMA"
9
+ license: MIT
10
+ year: 2026
poma_bio-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aurelien Pelissier
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ include LICENSE README.md pyproject.toml CITATION.cff
2
+ recursive-include src/poma *.py
3
+ recursive-include configs *.yaml *.yml
4
+ prune manuscript
5
+ prune figures
6
+ prune lean
7
+ prune results
8
+ prune example
9
+ prune tests
10
+ global-exclude __pycache__ *.py[cod]
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: poma-bio
3
+ Version: 1.0.0
4
+ Summary: POMA: Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models
5
+ Author-email: Aurelien Pelissier <aurelien.pelissier.38@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/AI-SysBio/POMA
8
+ Project-URL: Repository, https://github.com/AI-SysBio/POMA
9
+ Project-URL: Issues, https://github.com/AI-SysBio/POMA/issues
10
+ Project-URL: LogiCA, https://github.com/AI-SysBio/LogiCA
11
+ Keywords: biological-foundation-models,multimodal-alignment,probabilistic-modeling,uncertainty-quantification,bayesian-experimental-design,spectroscopy,protein-engineering,single-cell,antibody-design
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.24
24
+ Requires-Dist: scipy>=1.10
25
+ Requires-Dist: pandas>=2.0
26
+ Requires-Dist: scikit-learn>=1.3
27
+ Requires-Dist: torch>=2.1
28
+ Requires-Dist: transformers>=4.40
29
+ Requires-Dist: huggingface-hub>=0.20
30
+ Requires-Dist: pyyaml>=6.0
31
+ Requires-Dist: matplotlib>=3.7
32
+ Provides-Extra: chem
33
+ Requires-Dist: rdkit>=2023.9; extra == "chem"
34
+ Requires-Dist: selfies>=2.1; extra == "chem"
35
+ Requires-Dist: pyarrow>=14.0; extra == "chem"
36
+ Requires-Dist: openpyxl>=3.1; extra == "chem"
37
+ Provides-Extra: singlecell
38
+ Requires-Dist: anndata>=0.10; extra == "singlecell"
39
+ Provides-Extra: antibody
40
+ Requires-Dist: ablang2>=0.1.2; extra == "antibody"
41
+ Requires-Dist: kagglehub>=0.3.0; extra == "antibody"
42
+ Provides-Extra: logica
43
+ Requires-Dist: logica-bio>=0.1.0; extra == "logica"
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest>=7.4; extra == "dev"
46
+ Requires-Dist: seaborn>=0.12; extra == "dev"
47
+ Requires-Dist: build>=1.0; extra == "dev"
48
+ Requires-Dist: twine>=5.0; extra == "dev"
49
+ Provides-Extra: all
50
+ Requires-Dist: rdkit>=2023.9; extra == "all"
51
+ Requires-Dist: selfies>=2.1; extra == "all"
52
+ Requires-Dist: pyarrow>=14.0; extra == "all"
53
+ Requires-Dist: openpyxl>=3.1; extra == "all"
54
+ Requires-Dist: anndata>=0.10; extra == "all"
55
+ Requires-Dist: ablang2>=0.1.2; extra == "all"
56
+ Requires-Dist: kagglehub>=0.3.0; extra == "all"
57
+ Requires-Dist: pytest>=7.4; extra == "all"
58
+ Requires-Dist: seaborn>=0.12; extra == "all"
59
+ Dynamic: license-file
60
+
61
+ # POMA: Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models
62
+
63
+ [![PyPI](https://img.shields.io/pypi/v/poma-bio.svg)](https://pypi.org/project/poma-bio/)
64
+ [![Manuscript](https://img.shields.io/badge/Manuscript-PDF-red.svg)](https://github.com/AI-SysBio/POMA/blob/main/manuscript/POMA_manuscript.pdf)
65
+ [![Lean 4](https://img.shields.io/badge/Lean%204-130%2F130%20theorems%20%C2%B7%200%20sorries-blueviolet.svg)](https://github.com/AI-SysBio/POMA/blob/main/lean/README.md)
66
+ [![Companion: LogiCA](https://img.shields.io/badge/LogiCA-AI--SysBio%2FLogiCA-purple.svg)](https://github.com/AI-SysBio/LogiCA)
67
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://github.com/AI-SysBio/POMA/blob/main/pyproject.toml)
68
+ [![PyTorch 2.1+](https://img.shields.io/badge/PyTorch-2.1%2B-ee4c2c.svg)](https://pytorch.org/)
69
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/AI-SysBio/POMA/blob/main/LICENSE)
70
+
71
+ <p align="center">
72
+ <img src="https://raw.githubusercontent.com/AI-SysBio/POMA/main/figures/POMA_Figure1.png" width="96%" alt="POMA: Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models"/>
73
+ </p>
74
+
75
+ **POMA** (*Probabilistic Output-Space Multimodal Alignment*) generalizes the conditional likelihood objective underlying masked language modeling (MLM) to native continuous biological measurements. Rather than replacing calibrated sequence likelihoods with pointwise MSE regression, numerical tokenization, or representation-only latent projections, POMA equips pretrained discrete and continuous biological foundation models with **structured predictive densities in their native output spaces**, connected through **unit-invariant, context-matched likelihood-ratio alignment**.
76
+
77
+ Because one learned statistical object preserves calibrated densities directly over native observables, **a single trained POMA checkpoint** exposes six unified capabilities without task-specific retraining:
78
+ - **Probabilistic Adaptation & Uncertainty Quantification** across nine structured output families (`LowRankMVN`, heavy-tailed `LowRankMVT`, multimodal `CoupledGMM`, zero-inflated `HurdleContinuous`, `CoupledTobit`, `BandedLowRank`, `Gaussian`, `Kumaraswamy`, `ZINB`);
79
+ - **Zero-Retraining Analytical Conditional Inference** via exact Woodbury/Schur conditioning (`76×–752×` per-update speedup on frozen `scGPT`, `>2,800×` vs. `117M DreaMS` re-encoding, `6.4×10⁻⁶` sequential-vs-joint Bayesian coherence);
80
+ - **Shortcut-Resistant Cross-Modal Alignment** via context-matched mixture-reference likelihood ratios and adaptive bidirectional weighting;
81
+ - **Continuous & Cross-Modal Dependency Maps** extracting exact Woodbury precision / partial-correlation matrices and cross-modal KL perturbation maps;
82
+ - **Bayesian Epistemic Closure & Experimental Design** (`POMA-Laplace`, Rao-Blackwellized joint feasibility, and cost-budgeted `EVSI/cost` acquisition);
83
+ - **Exact-Target Property-Conditioned Generation** (`Exact Local MH`, `Factor-Augmented MH`, and `Coordinate Gibbs`) preserving $\pi_\beta(x) \propto p_0(x)\exp(\beta U(x))$.
84
+
85
+ ---
86
+
87
+ ## Repository Structure
88
+
89
+ ```text
90
+ POMA/
91
+ ├── src/poma/ # Modular Python library (`pip install -e .`)
92
+ │ ├── backbones.py # Universal wrappers for discrete (HF MLM) & continuous (DreaMS, scGPT, custom) BioFMs
93
+ │ ├── model.py # Unified `POMA` (9 density families + Schur conditioning) & `CrossModalPOMA`
94
+ │ ├── bayesian.py # `BayesianPOMA` (last-layer Laplace, uncertainty decomposition, joint feasibility, EVSI/cost)
95
+ │ ├── dependency.py # `DependencyMapper` (Woodbury precision/partial-corr & cross-modal KL maps)
96
+ │ ├── generation.py # `POMAGenerator` (Exact Local MH & Coordinate Gibbs sequence design)
97
+ │ ├── logica_bridge.py # Drop-in `LogiCAPOMABridge` for AI-SysBio/LogiCA backbones
98
+ │ └── models/ # Core density heads, spectral heads, bioFM alignment blocks & losses
99
+ ├── example/ # Quickstart + all manuscript reproduction scripts (Main & Supp. E1–E15)
100
+ │ ├── quickstart.py # End-to-end runnable showcase of all 6 POMA capabilities
101
+ │ ├── README.md # Complete mapping from manuscript tables/experiments to scripts
102
+ │ └── 01_download_datasets.py .. 53_run_e15_unified_checkpoint.py
103
+ ├── manuscript/ # Latest manuscript PDF, LaTeX source & publication figures
104
+ │ ├── POMA_manuscript.pdf # Full compiled manuscript + supplementary
105
+ │ ├── main.tex # Standalone LaTeX source
106
+ │ └── figures/ # POMA_Figure1.pdf, POMA_Figure2.pdf, POMA_FigureS1.pdf
107
+ ├── lean/ # Complete Lean 4 formalization (130/130 theorems, 0 sorries)
108
+ │ ├── Poma.lean # Root Lean 4 library entry point
109
+ │ ├── AxiomCheck.lean # Machine-checked axiom audit
110
+ │ └── Poma/ # Formal proofs of invariance, Schur coherence, Laplace, EVSI & MH theorems
111
+ ├── figures/ # Top-level rendered figures (POMA_Figure1.png, POMA_Figure2.png)
112
+ ├── results/ # Aggregated benchmark tables & audit summaries
113
+ └── tests/ # Unit test suite covering the library API, heads, Bayes & samplers
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Installation
119
+
120
+ Python 3.10 or later is recommended. Install directly from PyPI:
121
+
122
+ ```bash
123
+ # Core library (`import poma`)
124
+ pip install poma-bio
125
+
126
+ # With chemistry (RDKit + SELFIES), single-cell (anndata), antibody (AbLang2), or all extras
127
+ pip install "poma-bio[chem]"
128
+ pip install "poma-bio[all]"
129
+ ```
130
+
131
+ Or install from source in editable mode:
132
+
133
+ ```bash
134
+ git clone https://github.com/AI-SysBio/POMA.git
135
+ cd POMA
136
+ pip install -e ".[all]"
137
+
138
+ # Run the unit test suite & end-to-end quickstart
139
+ pytest tests/ -v
140
+ python example/quickstart.py
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Quickstart: Using the Modular `poma` Library
146
+
147
+ ### 1. Plug in Any Pretrained Discrete or Continuous Foundation Model
148
+
149
+ ```python
150
+ import torch
151
+ from poma import ContinuousBackbone, CrossModalPOMA, DiscreteBackbone, POMA
152
+
153
+ # Discrete BioFM (any Hugging Face Masked LM: ChemBERTa, ESM-2, SELFormer, Nucleotide Transformer)
154
+ mol_fm = DiscreteBackbone.from_pretrained("DeepChem/ChemBERTa-77M-MLM", freeze=True)
155
+
156
+ # Continuous BioFM (official 117M DreaMS, frozen scGPT, or any custom PyTorch encoder)
157
+ spec_fm = ContinuousBackbone.from_dreams(num_tokens=8, freeze=True)
158
+ # scgpt_fm, gene_vocab = ContinuousBackbone.from_scgpt(freeze=True)
159
+
160
+ # Cross-modal output-space alignment with shortcut-resistant context-matched PMI (E12)
161
+ aligner = CrossModalPOMA(
162
+ primary_dim=mol_fm.hidden_dim,
163
+ partner_dim=spec_fm.hidden_dim,
164
+ adapter_dim=128,
165
+ num_heads=4,
166
+ )
167
+ # Contrastive loss using context-matched mixture reference log(q(x|y) / E_{y'}[q(x|y')])
168
+ loss = aligner.alignment_loss(ll_x_given_y, ll_y_given_x, temperature=0.15, context_matched=True)
169
+ ```
170
+
171
+ ### 2. Probabilistic Prediction & Zero-Retraining Analytical Conditioning
172
+
173
+ ```python
174
+ from poma import POMA
175
+
176
+ # Choose from: "mvn", "mvt", "gmm", "hurdle", "tobit", "banded_lowrank", "gaussian", "kumaraswamy", "zinb"
177
+ model = POMA(hidden_dim=64, distribution="mvn", rank=3)
178
+
179
+ h = torch.randn(16, 6, 64) # (batch, K coordinates/assays, hidden_dim)
180
+ y = torch.randn(16, 6) # continuous measurements
181
+ obs_mask = torch.rand(16, 6) > 0.25 # arbitrary missingness pattern
182
+ obs_mask[:, 0] = True
183
+
184
+ # Exact O(|S| r^2 + r^3) Woodbury masked negative log-likelihood
185
+ loss = model.nll(h, y, obs_mask=obs_mask)
186
+ pred = model.predict(h[:4]) # pred.mean, pred.variance, pred.lower95, pred.upper95
187
+
188
+ # Exact analytical Schur conditioning given newly observed coordinates (zero retraining!)
189
+ triage_mask = torch.tensor([[False, False, True, True, True, True]] * 4)
190
+ cond = model.condition(h[:4], y[:4], triage_mask)
191
+ ```
192
+
193
+ ### 3. Bayesian Epistemic Uncertainty, Dependency Maps & Exact-Target Generation
194
+
195
+ ```python
196
+ from poma import BayesianPOMA, DependencyMapper, POMAGenerator
197
+
198
+ # Closed-form last-layer Laplace epistemic uncertainty, joint feasibility & EVSI/cost
199
+ bayes = BayesianPOMA(model, prior_precision=3.0).fit(h, y, obs_mask=obs_mask)
200
+ unc = bayes.decompose_uncertainty(h[:4]) # aleatoric_var, epistemic_var, total_var
201
+ feas = bayes.joint_feasibility(h[:4], lower=torch.full((6,), -1.0), upper=torch.full((6,), 1.0))
202
+ evsi = bayes.evsi_per_cost(h[:4], lower=torch.full((6,), -1.0), upper=torch.full((6,), 1.0),
203
+ assay_costs=torch.tensor([10., 8., 1., 1., 2., 2.]))
204
+
205
+ # Continuous covariance, correlation, exact Woodbury precision & partial-correlation dependency maps
206
+ dep = DependencyMapper.continuous_dependency_map(model, h[:2])
207
+ # dep.covariance, dep.correlation, dep.precision, dep.partial_correlation
208
+
209
+ # Property-conditioned discrete sequence generation preserving pi_beta(x) propto p_0(x) exp(beta U(x))
210
+ generator = POMAGenerator(log_prior_fn=prior_fn, log_utility_fn=utility_fn, beta=1.0)
211
+ gen_out = generator.sample_exact_local_mh(init_seq="ACDEFGH", editable_positions=[1, 2, 3, 4], n_steps=100)
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Manuscript Reproduction (`example/`) & Lean 4 Formalization (`lean/`)
217
+
218
+ - **Reproducing Manuscript Results:** See [`example/README.md`](example/README.md) for the complete index of all 63 scripts reproducing every main-text benchmark and supplementary validation experiment (**E1–E15**), including large-scale `ChemBERTa-77M` $\leftrightarrow$ `117M DreaMS` alignment, 500-unique-molecule retrieval, shortcut-resistant context-matched alignment, representation leakage audits, mask-matched neural vs. analytical Schur conditioning, and unified single-checkpoint evaluation.
219
+ - **Machine-Checked Formalization (`lean/`):** All mathematical statements in the manuscript—likelihood-ratio unit invariance, Woodbury/Schur sequential-vs-joint coherence, Laplace epistemic closure, decision-aware acquisition bounds, and exact MH stationary invariance—are formally verified in Lean 4 (**130/130 theorems, zero `sorry`s**; see [`lean/README.md`](lean/README.md)).
220
+
221
+ ---
222
+
223
+ ## Citation
224
+
225
+ ```bibtex
226
+ @article{pelissier2026poma,
227
+ title = {Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models},
228
+ author = {Pelissier, Aurelien},
229
+ journal = {Preprint},
230
+ year = {2026},
231
+ url = {https://github.com/AI-SysBio/POMA}
232
+ }
233
+ ```
@@ -0,0 +1,173 @@
1
+ # POMA: Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/poma-bio.svg)](https://pypi.org/project/poma-bio/)
4
+ [![Manuscript](https://img.shields.io/badge/Manuscript-PDF-red.svg)](https://github.com/AI-SysBio/POMA/blob/main/manuscript/POMA_manuscript.pdf)
5
+ [![Lean 4](https://img.shields.io/badge/Lean%204-130%2F130%20theorems%20%C2%B7%200%20sorries-blueviolet.svg)](https://github.com/AI-SysBio/POMA/blob/main/lean/README.md)
6
+ [![Companion: LogiCA](https://img.shields.io/badge/LogiCA-AI--SysBio%2FLogiCA-purple.svg)](https://github.com/AI-SysBio/LogiCA)
7
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://github.com/AI-SysBio/POMA/blob/main/pyproject.toml)
8
+ [![PyTorch 2.1+](https://img.shields.io/badge/PyTorch-2.1%2B-ee4c2c.svg)](https://pytorch.org/)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/AI-SysBio/POMA/blob/main/LICENSE)
10
+
11
+ <p align="center">
12
+ <img src="https://raw.githubusercontent.com/AI-SysBio/POMA/main/figures/POMA_Figure1.png" width="96%" alt="POMA: Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models"/>
13
+ </p>
14
+
15
+ **POMA** (*Probabilistic Output-Space Multimodal Alignment*) generalizes the conditional likelihood objective underlying masked language modeling (MLM) to native continuous biological measurements. Rather than replacing calibrated sequence likelihoods with pointwise MSE regression, numerical tokenization, or representation-only latent projections, POMA equips pretrained discrete and continuous biological foundation models with **structured predictive densities in their native output spaces**, connected through **unit-invariant, context-matched likelihood-ratio alignment**.
16
+
17
+ Because one learned statistical object preserves calibrated densities directly over native observables, **a single trained POMA checkpoint** exposes six unified capabilities without task-specific retraining:
18
+ - **Probabilistic Adaptation & Uncertainty Quantification** across nine structured output families (`LowRankMVN`, heavy-tailed `LowRankMVT`, multimodal `CoupledGMM`, zero-inflated `HurdleContinuous`, `CoupledTobit`, `BandedLowRank`, `Gaussian`, `Kumaraswamy`, `ZINB`);
19
+ - **Zero-Retraining Analytical Conditional Inference** via exact Woodbury/Schur conditioning (`76×–752×` per-update speedup on frozen `scGPT`, `>2,800×` vs. `117M DreaMS` re-encoding, `6.4×10⁻⁶` sequential-vs-joint Bayesian coherence);
20
+ - **Shortcut-Resistant Cross-Modal Alignment** via context-matched mixture-reference likelihood ratios and adaptive bidirectional weighting;
21
+ - **Continuous & Cross-Modal Dependency Maps** extracting exact Woodbury precision / partial-correlation matrices and cross-modal KL perturbation maps;
22
+ - **Bayesian Epistemic Closure & Experimental Design** (`POMA-Laplace`, Rao-Blackwellized joint feasibility, and cost-budgeted `EVSI/cost` acquisition);
23
+ - **Exact-Target Property-Conditioned Generation** (`Exact Local MH`, `Factor-Augmented MH`, and `Coordinate Gibbs`) preserving $\pi_\beta(x) \propto p_0(x)\exp(\beta U(x))$.
24
+
25
+ ---
26
+
27
+ ## Repository Structure
28
+
29
+ ```text
30
+ POMA/
31
+ ├── src/poma/ # Modular Python library (`pip install -e .`)
32
+ │ ├── backbones.py # Universal wrappers for discrete (HF MLM) & continuous (DreaMS, scGPT, custom) BioFMs
33
+ │ ├── model.py # Unified `POMA` (9 density families + Schur conditioning) & `CrossModalPOMA`
34
+ │ ├── bayesian.py # `BayesianPOMA` (last-layer Laplace, uncertainty decomposition, joint feasibility, EVSI/cost)
35
+ │ ├── dependency.py # `DependencyMapper` (Woodbury precision/partial-corr & cross-modal KL maps)
36
+ │ ├── generation.py # `POMAGenerator` (Exact Local MH & Coordinate Gibbs sequence design)
37
+ │ ├── logica_bridge.py # Drop-in `LogiCAPOMABridge` for AI-SysBio/LogiCA backbones
38
+ │ └── models/ # Core density heads, spectral heads, bioFM alignment blocks & losses
39
+ ├── example/ # Quickstart + all manuscript reproduction scripts (Main & Supp. E1–E15)
40
+ │ ├── quickstart.py # End-to-end runnable showcase of all 6 POMA capabilities
41
+ │ ├── README.md # Complete mapping from manuscript tables/experiments to scripts
42
+ │ └── 01_download_datasets.py .. 53_run_e15_unified_checkpoint.py
43
+ ├── manuscript/ # Latest manuscript PDF, LaTeX source & publication figures
44
+ │ ├── POMA_manuscript.pdf # Full compiled manuscript + supplementary
45
+ │ ├── main.tex # Standalone LaTeX source
46
+ │ └── figures/ # POMA_Figure1.pdf, POMA_Figure2.pdf, POMA_FigureS1.pdf
47
+ ├── lean/ # Complete Lean 4 formalization (130/130 theorems, 0 sorries)
48
+ │ ├── Poma.lean # Root Lean 4 library entry point
49
+ │ ├── AxiomCheck.lean # Machine-checked axiom audit
50
+ │ └── Poma/ # Formal proofs of invariance, Schur coherence, Laplace, EVSI & MH theorems
51
+ ├── figures/ # Top-level rendered figures (POMA_Figure1.png, POMA_Figure2.png)
52
+ ├── results/ # Aggregated benchmark tables & audit summaries
53
+ └── tests/ # Unit test suite covering the library API, heads, Bayes & samplers
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Installation
59
+
60
+ Python 3.10 or later is recommended. Install directly from PyPI:
61
+
62
+ ```bash
63
+ # Core library (`import poma`)
64
+ pip install poma-bio
65
+
66
+ # With chemistry (RDKit + SELFIES), single-cell (anndata), antibody (AbLang2), or all extras
67
+ pip install "poma-bio[chem]"
68
+ pip install "poma-bio[all]"
69
+ ```
70
+
71
+ Or install from source in editable mode:
72
+
73
+ ```bash
74
+ git clone https://github.com/AI-SysBio/POMA.git
75
+ cd POMA
76
+ pip install -e ".[all]"
77
+
78
+ # Run the unit test suite & end-to-end quickstart
79
+ pytest tests/ -v
80
+ python example/quickstart.py
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Quickstart: Using the Modular `poma` Library
86
+
87
+ ### 1. Plug in Any Pretrained Discrete or Continuous Foundation Model
88
+
89
+ ```python
90
+ import torch
91
+ from poma import ContinuousBackbone, CrossModalPOMA, DiscreteBackbone, POMA
92
+
93
+ # Discrete BioFM (any Hugging Face Masked LM: ChemBERTa, ESM-2, SELFormer, Nucleotide Transformer)
94
+ mol_fm = DiscreteBackbone.from_pretrained("DeepChem/ChemBERTa-77M-MLM", freeze=True)
95
+
96
+ # Continuous BioFM (official 117M DreaMS, frozen scGPT, or any custom PyTorch encoder)
97
+ spec_fm = ContinuousBackbone.from_dreams(num_tokens=8, freeze=True)
98
+ # scgpt_fm, gene_vocab = ContinuousBackbone.from_scgpt(freeze=True)
99
+
100
+ # Cross-modal output-space alignment with shortcut-resistant context-matched PMI (E12)
101
+ aligner = CrossModalPOMA(
102
+ primary_dim=mol_fm.hidden_dim,
103
+ partner_dim=spec_fm.hidden_dim,
104
+ adapter_dim=128,
105
+ num_heads=4,
106
+ )
107
+ # Contrastive loss using context-matched mixture reference log(q(x|y) / E_{y'}[q(x|y')])
108
+ loss = aligner.alignment_loss(ll_x_given_y, ll_y_given_x, temperature=0.15, context_matched=True)
109
+ ```
110
+
111
+ ### 2. Probabilistic Prediction & Zero-Retraining Analytical Conditioning
112
+
113
+ ```python
114
+ from poma import POMA
115
+
116
+ # Choose from: "mvn", "mvt", "gmm", "hurdle", "tobit", "banded_lowrank", "gaussian", "kumaraswamy", "zinb"
117
+ model = POMA(hidden_dim=64, distribution="mvn", rank=3)
118
+
119
+ h = torch.randn(16, 6, 64) # (batch, K coordinates/assays, hidden_dim)
120
+ y = torch.randn(16, 6) # continuous measurements
121
+ obs_mask = torch.rand(16, 6) > 0.25 # arbitrary missingness pattern
122
+ obs_mask[:, 0] = True
123
+
124
+ # Exact O(|S| r^2 + r^3) Woodbury masked negative log-likelihood
125
+ loss = model.nll(h, y, obs_mask=obs_mask)
126
+ pred = model.predict(h[:4]) # pred.mean, pred.variance, pred.lower95, pred.upper95
127
+
128
+ # Exact analytical Schur conditioning given newly observed coordinates (zero retraining!)
129
+ triage_mask = torch.tensor([[False, False, True, True, True, True]] * 4)
130
+ cond = model.condition(h[:4], y[:4], triage_mask)
131
+ ```
132
+
133
+ ### 3. Bayesian Epistemic Uncertainty, Dependency Maps & Exact-Target Generation
134
+
135
+ ```python
136
+ from poma import BayesianPOMA, DependencyMapper, POMAGenerator
137
+
138
+ # Closed-form last-layer Laplace epistemic uncertainty, joint feasibility & EVSI/cost
139
+ bayes = BayesianPOMA(model, prior_precision=3.0).fit(h, y, obs_mask=obs_mask)
140
+ unc = bayes.decompose_uncertainty(h[:4]) # aleatoric_var, epistemic_var, total_var
141
+ feas = bayes.joint_feasibility(h[:4], lower=torch.full((6,), -1.0), upper=torch.full((6,), 1.0))
142
+ evsi = bayes.evsi_per_cost(h[:4], lower=torch.full((6,), -1.0), upper=torch.full((6,), 1.0),
143
+ assay_costs=torch.tensor([10., 8., 1., 1., 2., 2.]))
144
+
145
+ # Continuous covariance, correlation, exact Woodbury precision & partial-correlation dependency maps
146
+ dep = DependencyMapper.continuous_dependency_map(model, h[:2])
147
+ # dep.covariance, dep.correlation, dep.precision, dep.partial_correlation
148
+
149
+ # Property-conditioned discrete sequence generation preserving pi_beta(x) propto p_0(x) exp(beta U(x))
150
+ generator = POMAGenerator(log_prior_fn=prior_fn, log_utility_fn=utility_fn, beta=1.0)
151
+ gen_out = generator.sample_exact_local_mh(init_seq="ACDEFGH", editable_positions=[1, 2, 3, 4], n_steps=100)
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Manuscript Reproduction (`example/`) & Lean 4 Formalization (`lean/`)
157
+
158
+ - **Reproducing Manuscript Results:** See [`example/README.md`](example/README.md) for the complete index of all 63 scripts reproducing every main-text benchmark and supplementary validation experiment (**E1–E15**), including large-scale `ChemBERTa-77M` $\leftrightarrow$ `117M DreaMS` alignment, 500-unique-molecule retrieval, shortcut-resistant context-matched alignment, representation leakage audits, mask-matched neural vs. analytical Schur conditioning, and unified single-checkpoint evaluation.
159
+ - **Machine-Checked Formalization (`lean/`):** All mathematical statements in the manuscript—likelihood-ratio unit invariance, Woodbury/Schur sequential-vs-joint coherence, Laplace epistemic closure, decision-aware acquisition bounds, and exact MH stationary invariance—are formally verified in Lean 4 (**130/130 theorems, zero `sorry`s**; see [`lean/README.md`](lean/README.md)).
160
+
161
+ ---
162
+
163
+ ## Citation
164
+
165
+ ```bibtex
166
+ @article{pelissier2026poma,
167
+ title = {Probabilistic Output-Space Multimodal Alignment for Biological Foundation Models},
168
+ author = {Pelissier, Aurelien},
169
+ journal = {Preprint},
170
+ year = {2026},
171
+ url = {https://github.com/AI-SysBio/POMA}
172
+ }
173
+ ```