Skip to main content

suave-torch

SUAVE — Sparse Uncertainty-Aware Vector Encoding

A novel LLM algorithm that solves hallucination at the architectural level.

The Problem

Every transformer-based LLM shares one fundamental flaw: the softmax attention function forces the model to always blend token representations — even when no relevant context exists. This is the mathematical root cause of hallucination. Additionally, LLMs internally generate uncertainty signals but these are silently discarded and never reach the output.

The SUAVE Solution

SUAVE combines two architectural innovations:

1. Sparse Selective Attention (replaces softmax) Uses entropy of the attention distribution to detect uncertainty. High entropy = uncertain = abstain signal raised. Low entropy = confident = normal attention proceeds.

2. Uncertainty Channel (new parallel pathway) A dedicated channel that carries uncertainty signals from the attention layer all the way through to the output logits. When internal uncertainty is high, output is automatically hedged.

Key Results

Metric Value
Separation Gap 0.7113
Confident sequence uncertainty 0.1281
Uncertain sequence uncertainty 0.8394
Uncertainty loss (epoch 1) 0.1864
Uncertainty loss (epoch 30) 0.0216

Installation

pip install suave-torch

Quick Start

from suave import SUAVEConfig, SUAVELanguageModel, SUAVETrainer
from suave.calibration import UncertaintyVisualizer

# Configure
config = SUAVEConfig(
    vocab_size=1000,
    embed_dim=128,
    num_heads=4,
    num_layers=3,
    ff_dim=256,
    max_seq_len=64
)

# Build
model = SUAVELanguageModel(config)
model.count_parameters()

# Train
trainer = SUAVETrainer(model, config)
history = trainer.fit(train_data, train_labels)

# Evaluate
results = trainer.evaluate(test_data, test_labels)

# Visualize
UncertaintyVisualizer.plot_distribution(
    confident_scores, uncertain_scores
)
UncertaintyVisualizer.plot_training_curves(history)

Architecture

Input Tokens ↓ Token + Position Embeddings ↓ ┌─── SUAVE Block × N ────────────────────┐ │ SparseSelectiveAttention │ │ (entropy-based uncertainty gating) │ │ ↓ ↓ │ │ Attention Uncertainty Signal │ │ Output ↓ │ │ ↓ UncertaintyChannel │ │ └──────────↓ │ │ Modulated Hidden States │ │ ↓ │ │ FeedForward + Residual │ └────────────────────────────────────────┘ ↓ LayerNorm ↓ Output Head (logits modulated by uncertainty) ↓ (logits, uncertainty_scores)

Author

Shabbir — Computer Engineering, Government Polytechnic Dahod, Gujarat Algorithm designed and proven: May 2026

License

MIT License

Metadata

Release files for suave-torch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for suave-torch 0.1.0
File Size Uploaded Provenance Actions
suave_torch-0.1.0.tar.gz 12.9 kB Without provenance Details for suave_torch-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for suave-torch 0.1.0
File Interpreter ABI Platform Actions
suave_torch-0.1.0-py3-none-any.whl Python 3 none any Details for suave_torch-0.1.0-py3-none-any.whl

Total release size: 28.7 kB

Release files / suave_torch-0.1.0.tar.gz

Download URL suave_torch-0.1.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e115ee6fcd19b7ed2af08ca22aba4867dc32d7dd2163c82724ba309fe484f8f8
BLAKE2b-256 checksum
How to use checksums
26d834630983456cb9f6c8e7611057d78c43fd5831dfc8673bfec6893075ddf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / suave_torch-0.1.0-py3-none-any.whl

Download URL suave_torch-0.1.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48665bcdb031a5e1d60c8674f7aae2c5f5ae77bcd13721571766fff25c10e39f
BLAKE2b-256 checksum
How to use checksums
d2d4e5780e84ee45437b507bf5c6b4540a0882a96c6b18615927e14804f317a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for suave-torch 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page