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@atomic-trust.com


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.1.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.1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: atomictrust_tpf-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 6de31b63f99a7f79cf28236c4dd03bf7dec823dc46df072daa34b234d5dbf2f0
MD5 f90c31693be0f75aacfac53cd4567e0b
BLAKE2b-256 c7aa95cd320013dd26d5ae6912090cd9eaa0b8a5bfff0e460634ff47021ffb9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for atomictrust_tpf-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 640abcfa961dbe2206b71a3b9f853c2f7a4ae64322db827c518f0e3b601d83e5
MD5 75a5b0b2c9234abbfabc72404f9f9428
BLAKE2b-256 50b761ddaa9bc9e5affd483bc5c9c5771a640120a102012462e1ff822d69fddc

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