Skip to main content

Free uncertainty quantification for diffusion language models

Project description

Atomic Trust™ TPF

Free uncertainty quantification for diffusion language models.

License Patent Paper


The Discovery

TPF (Tokens-Per-Forward) reveals generation confidence in diffusion LLMs at zero cost.

Query TPF Interpretation
7 × 8 = ? 13.58 High confidence (pattern retrieval)
23 × 17 = ? 2.68 Low confidence (active computation)

Your model is telling you when it's uncertain. Listen.

Correlation: r = -0.88 (p < 0.001) between TPF and output entropy across 28 benchmarks.


Inverse Signal: Hallucination Detection

Low TPF on uncertain query  → Expected (honest uncertainty)
High TPF on uncertain query → Potential fabrication (flag for review)

This bidirectional signal is structurally unavailable in autoregressive models.


FlashAPCE: Attention Verification

FlashAPCE enables attention verification inside FlashAttention's tiled computation without materializing the O(n²) attention matrix.

Verification signals extracted in-kernel:

  • Conservation deviation
  • Entropy fingerprint
  • Attention distribution metrics

Performance: Sub-1% overhead on 7B+ parameter models.

Velado's Contradiction Theorem: D(ε) × I(ε) ≥ κ

Attacks cannot simultaneously achieve high impact AND low detectability. This is a mathematical bound, not a heuristic.


Installation

pip install atomictrust-tpf

Optional GPU dependencies:

pip install atomictrust-tpf[gpu]   # torch + triton
pip install atomictrust-tpf[full]  # + vllm, transformers

Quick Start

from atomictrust_tpf import TPFRLMHybrid

router = TPFRLMHybrid()
result = router.generate("What is 23 × 17?")

print(f"Answer: {result.text}")
print(f"TPF: {result.tpf_metrics.tpf:.2f}")
print(f"Route: {result.route.name}")

Architecture

┌─────────────────────────────────────────────────────────┐
│                 Atomic Trust™ TPF Router                │
├─────────────────────────────────────────────────────────┤
│  1. Semantic Pre-Filter                                 │
│     └── Catches temporal/ambiguous queries              │
├─────────────────────────────────────────────────────────┤
│  2. Diffusion Generation                                │
│     └── Extracts TPF + Entropy (zero-cost signals)      │
├─────────────────────────────────────────────────────────┤
│  3. Confidence-Based Routing                            │
│     ├── High TPF → Direct response                      │
│     ├── Low TPF  → Escalate for verification            │
│     └── Anomalous TPF → Flag for review                 │
├─────────────────────────────────────────────────────────┤
│  4. FlashAPCE Verification                              │
│     └── Velado's Theorem guarantee                      │
└─────────────────────────────────────────────────────────┘

Validation

# Run test suite
pytest tests/ -v

# Quick validation
python -c "from atomictrust_tpf import TPFRLMHybrid; print('OK')"

Citation

If you use this work, please cite:

@article{velado2025tpf,
    title   = {Parallel Decoding as Intrinsic Uncertainty:
               Tokens-Per-Forward Reveals Generation Confidence
               in Diffusion Language Models},
    author  = {Velado, Rafael},
    year    = {2025},
    doi     = {10.5281/zenodo.18111467}
}

@article{velado2025contradiction,
    title   = {Velado's Contradiction Theorem: Mathematical
               Guarantees for Attention Verification},
    author  = {Velado, Rafael},
    year    = {2025},
    doi     = {10.5281/zenodo.18079657}
}

Patents

This work is protected under US Provisional Patent Applications:

  • US 63/951,960 — TPF-Based Confidence Routing (filed Dec 31, 2025)
  • US 63/948,782 — FlashAPCE Attention Verification (filed Dec 26, 2025)

Open source under Apache 2.0 for research and evaluation. Commercial licensing: licensing@atomictrust.io


Author

Rafael Velado LinkedIn · Atomic Trust™


License

Apache 2.0 with patent grant. See LICENSE.


Atomic Trust™ is a trademark of Rafael Velado.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atomictrust_tpf-1.0.0.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

atomictrust_tpf-1.0.0-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file atomictrust_tpf-1.0.0.tar.gz.

File metadata

  • Download URL: atomictrust_tpf-1.0.0.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for atomictrust_tpf-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5ad73758d17c8f4ecab01ebb89ae8aac62feb9f85d62a1124beb5fb606c39ec2
MD5 d3214fa98bca7934f3e1c4ebfb0a2c4b
BLAKE2b-256 2d0d569774818919e5d174141427b217e35f14dfc5e43dc3389bf0907dde998e

See more details on using hashes here.

File details

Details for the file atomictrust_tpf-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for atomictrust_tpf-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cb5212db54bf9af6d5157be8dd9b658b648691f699f1456393d316acbf10f69
MD5 0aa8f95641b78a20e8ed04b5199b07e3
BLAKE2b-256 7870634d3f50f927706d1cc06d6b0e1cee118e4d89270eadd1c23e0e05f8f851

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page