SUAVE: Sparse Uncertainty-Aware Vector Encoding — A novel LLM algorithm that solves hallucination at the architectural level
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file suave_torch-0.1.0.tar.gz.
File metadata
- Download URL: suave_torch-0.1.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e115ee6fcd19b7ed2af08ca22aba4867dc32d7dd2163c82724ba309fe484f8f8
|
|
| MD5 |
09be1c427360ab4fa4a625810798e386
|
|
| BLAKE2b-256 |
26d834630983456cb9f6c8e7611057d78c43fd5831dfc8673bfec6893075ddf9
|
File details
Details for the file suave_torch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: suave_torch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48665bcdb031a5e1d60c8674f7aae2c5f5ae77bcd13721571766fff25c10e39f
|
|
| MD5 |
e5cece696985533e0143ff40df946d34
|
|
| BLAKE2b-256 |
d2d4e5780e84ee45437b507bf5c6b4540a0882a96c6b18615927e14804f317a5
|