Mathematical and adversarial verification library for calculating drift/hallucination scores between outputs
Project description
CMVK - Cross-Model Verification Kernel
Mathematical drift detection between outputsโpure functions, zero dependencies on agent logic. Part of the Agent OS ecosystem.
๐ง Why CMVK?
Agent systems fail when they cannot measure semantic drift. LLMs hallucinate, models diverge, and outputs degrade without quantifiable verification. The naive approach couples verification logic directly into agent control loops, creating brittle, untestable architectures.
CMVK exists because verification is a primitive, not a feature. We subtract LLM calls, agent orchestration, and correction loops from the verification layer. What remains is a pure mathematical kernel: verify(a, b) -> score. This separation enables compositionโverification becomes a reusable building block across the Agent OS stack.
Scale by Subtraction: Remove dependencies on external services. CMVK uses only numpy (and optionally scipy). No API keys. No network calls. No side effects. Just deterministic drift calculation.
๐ฆ Installation
pip install cmvk
For enhanced statistical functions:
pip install cmvk[scipy]
โก Quick Start
from cmvk import verify
score = verify("def add(a, b): return a + b", "def add(x, y): return x + y")
print(f"Drift: {score.drift_score:.3f}") # 0.0 = identical
That's it. Five lines, zero configuration. verify() returns a VerificationScore with drift magnitude (0.0-1.0), confidence, and classification (semantic, structural, numerical, or lexical).
๐๏ธ Architecture
CMVK sits at Layer 1 (Primitives) of the Agent OS. It provides low-level mathematical operations that higher layers depend on:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 3: Framework (agent-control-plane)โ
โ โโ Self-Correction Loop (scak) โ
โ โโ Orchestration Logic โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โ uses verification scores
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 2: Infrastructure โ
โ โโ iatp: Trust Protocol โ
โ โโ amb: Message Bus โ
โ โโ atr: Tool Registry โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
โ composes primitives
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 1: Primitives (THIS LAYER) โ
โ โโ cmvk: Verification (THIS PROJECT) * โ
โ โโ caas: Context-as-a-Service โ
โ โโ emk: Episodic Memory Kernel โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Design Principle: CMVK never calls external services. Higher layers (like scak) orchestrate correction loops using CMVK's verification scores. This inverted dependency enables testing, composability, and deterministic behavior.
API Surface:
verify(a, b)โ High-level text comparisonverify_embeddings(emb_a, emb_b)โ Vector comparison (cosine, euclidean)verify_distributions(dist_a, dist_b)โ Distribution comparison (KL divergence, JS divergence)verify_sequences(seq_a, seq_b)โ Sequence comparison (edit distance, LCS)verify_batch(...)โ Batch operations with aggregation
All functions return immutable VerificationScore objects:
@dataclass(frozen=True)
class VerificationScore:
drift_score: float # 0.0 (identical) to 1.0 (completely different)
confidence: float # 0.0 to 1.0
drift_type: DriftType # SEMANTIC | STRUCTURAL | NUMERICAL | LEXICAL
details: dict # Component scores and metadata
๐บ๏ธ Agent OS Ecosystem
CMVK is one component of a modular Agent Operating System. Each project solves a single problem without assuming the existence of others.
Layer 1: Primitives
- caas โ Context-as-a-Service: Efficient context window management
- cmvk (this project) โ Verification: Drift detection between outputs
- emk โ Episodic Memory Kernel: Long-term memory for agents
Layer 2: Infrastructure
- iatp โ Inter-Agent Trust Protocol: Cryptographic verification of agent messages
- amb โ Agent Message Bus: Decoupled communication between agents
- atr โ Agent Tool Registry: Dynamic tool discovery and invocation
Layer 3: Framework
- agent-control-plane โ The Core: Orchestrates primitives and infrastructure
- scak โ Self-Correction Agent Kernel: Verification-driven correction loops
Philosophy: Each layer subtracts complexity from the layer above. Primitives have zero cross-dependencies. Infrastructure composes primitives. Framework orchestrates infrastructure.
๐ Citation
If you use CMVK in research or production systems, please cite:
@software{cmvk2024,
author = {Siddique, Imran},
title = {CMVK: Cross-Model Verification Kernel},
year = {2024},
publisher = {GitHub},
url = {https://github.com/imran-siddique/cross-model-verification-kernel},
note = {Part of the Agent OS ecosystem}
}
๐ License
MIT License - see LICENSE for details.
๐ Links
- Repository: github.com/imran-siddique/cross-model-verification-kernel
- PyPI: cmvk
- Issues: GitHub Issues
- Changelog: CHANGELOG.md
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 cmvk-0.3.0.tar.gz.
File metadata
- Download URL: cmvk-0.3.0.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bc4f9e1ccb78929a3c0200ed67f146debbfc77ff0091e2e0bd34acfaa80c865
|
|
| MD5 |
1242565f286f4469e5bdcd402364c533
|
|
| BLAKE2b-256 |
070b6612528129ecbadb060e3a46a611ae4fca384d3bdf29822bf561ecb06c34
|
File details
Details for the file cmvk-0.3.0-py3-none-any.whl.
File metadata
- Download URL: cmvk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a52303f302174a9d017aa652feca897a07014b010e54ffeae1c80641715a269b
|
|
| MD5 |
0425ff2992226825387a844575649bc3
|
|
| BLAKE2b-256 |
bc6625c25bb18bea666e9215db9e8af1862b89f7b6c993c3fa3c1c8c6f60d1f1
|