Skip to content
bhubbardPublic

About

Advanced zero-token LLM decision engine in Rust synthesizing architectural breakthroughs from open-source Jev alternatives.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

116 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

zev-rs (Zev)

License: MIT Rust crates.io npm CI Security Policy Hugging Face Spaces Hugging Face Datasets Coverage Docs

Zev is an ultra-fast zero-token LLM decision engine in Rust. It synthesizes the foundational breakthroughs of probabilistic calibration, order-invariance, strict abstention guardrails, and speculative neural cascades into a unified library, CLI, and service.

By default, Zev evaluates complex schemas in 5.8 microseconds with zero model weights and zero heap allocations. For nuanced semantic reasoning, Zev seamlessly cascades to on-device neural backends (apfel-rs on Apple Silicon, or Candle for cross-platform tensor execution).


Installation

Via Homebrew (macOS & Linux)

brew tap bhubbard/tap
brew install zev

Via npm / npx (Instant zero-install)

# Run instantly with npx
npx -y zev-rs --help

# Or install globally
npm install -g zev-rs

Via Cargo (crates.io)

cargo install zev-rs

Quick Start Guide

1. Interactive First-Run Onboarding & Hardware Doctor

When you first run zev, it dynamically probes your environment (OS, architecture, SIMD vector instruction sets, Apple Neural Engine, local Gemma/Ollama endpoints) and interactively prompts you to choose your preferred decision execution method:

# Launch interactive onboarding wizard anytime
zev init

# Inspect hardware acceleration, SIMD instructions, and neural engines
zev doctor

# View or update persistent configuration (~/.config/zev/config.json)
zev config show
zev config set method dual-ensemble   # Global #1 accuracy (74.89%, recommended)
zev config set method simd            # Universal pure SIMD (< 8 MB RAM, runs anywhere)

2. Instant Decisions via CLI (in microseconds)

# Fast intent routing across categories
zev route \
  --state "Critical: production database is down with 500 connection refused errors" \
  --routes '{"billing": "Invoice and billing inquiries", "infra": "Database and cluster outages", "sales": "Enterprise sales"}'

# Or evaluate a Tev1 schema:
zev tev1 \
  --state "Returns are allowed within 30 days. This purchase was 12 days ago." \
  --question "Is this return within the allowed window?" \
  --options "A: Yes, B: No, C: Not enough information"

3. Launch the High-Performance REST Server

# Start API server on port 8080 (serves /v1/decisions, /v1/systemone, /v1/tev1)
zev serve --port 8080

Query it from any language:

curl -X POST http://127.0.0.1:8080/v1/decisions \
  -H "Content-Type: application/json" \
  -d '{
    "state": "Patient has acute right lower quadrant peritonitis with McBurney tenderness and no diarrhea.",
    "questions": {
      "diagnosis": {
        "type": "choice",
        "instructions": "Select most likely clinical differential",
        "options": [
          {"id": "appendicitis", "description": "Acute appendicitis with McBurney sign"},
          {"id": "gastroenteritis", "description": "Diffuse stomach bug with diarrhea"}
        ]
      }
    }
  }'

4. Embed Directly in Your Rust Application

Add to Cargo.toml:

[dependencies]
zev-rs = "0.3.9"

In your code:

use zev::ZevEngine;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let engine = ZevEngine::default();

    // Evaluates in 5.8 Β΅s with zero model weights and zero heap allocations
    let (dest, confidence) = engine.route(
        "Refund request for order #1084; item arrived broken",
        [
            ("billing".into(), "Refunds and invoices".into()),
            ("tech_support".into(), "API errors and bugs".into()),
        ].into_iter().collect(),
    )?;

    println!("Routed to: {dest} (confidence: {confidence:.2})");
    Ok(())
}

Hugging Face: Interactive Space & Benchmark Dataset

Zev provides full support for the Hugging Face ecosystem:

  • Interactive Hugging Face Space: Run Zev live in a zero-install interactive web playground with order-invariance testing, live microsecond latency comparison, and Together AI tev1 evaluation. See hf-space/ and the Deployment Guide.
  • Standardized Benchmark Dataset: 1,200 curated and scaled decision schemas formatted for Hugging Face Datasets evaluating intent routing, guardrails, clinical differentials, and permutation invariance. See datasets/zev_benchmarks/.

Architectural Breakthroughs Synthesized

Component Source Innovation What Zev Delivers
0.0% Order Flip Rate wfzyx/von Isolated premise-option attention slots eliminate option order bias completely. Permuting candidate options produces 100% identical logits.
Abstention & Guardrails Rizzo-AI-Academy/rizzo-flow Refuses to hallucinate when evidence is missing (__insufficient__) or when continuous estimates exceed bounds (__below_range__, __above_range__).
Continuous Moment Statistics Rizzo-AI-Academy/rizzo-flow For ordinal ratings and numeric rubrics, computes expected mean ($\sum v_i p_i$), variance, standard deviation, median, and quantiles ($p_{10}, p_{90}$).
Calibrated Temperature Scaling bespokelabsai/nimble & theoleecj/semif Replaces raw overconfident softmax with empirical calibration ($T=2.179$) and golden-section NLL optimization to minimize Expected Calibration Error (ECE).
Dynamic Shortlisting NandhaKishorM/laya Scales to schemas with hundreds of options using SIMD token-set cosine shortlisting to prune large taxonomies down to the top slots in microseconds.
Temporal Fact Grounding jaredpalmer/kev Automatically injects factual ISO reference dates so relative expressions ("yesterday", "3 days ago") are evaluated without date confusion.
Negation & Resolution Scope Zev Original Inverts negated symptoms ("no fever", "without outage") and applies recency position weighting to recognize incident resolutions ("rolled back and resolved").
Multi-Wire Compatibility TypeSafe Jev & Together AI Tev1 Supports native ZevRequest, drop-in TypeSafe /v1/systemone, and Together AI /v1/tev1 & zev tev1 formats.

How Zev Works in 30 Seconds (The Intuition)

Think of how your own mind makes decisions:

  1. System 1 (Instant Reflex): When you see a green traffic light, you press the gas pedal without deep deliberation. It takes milliseconds and uses virtually zero brainpower.
  2. System 2 (Deep Reasoning): When you encounter an ambiguous, high-stakes puzzle, you stop and think carefully.

Traditional AI setups treat every single request as a heavy, slow puzzle β€” sending simple questions to giant 30-billion parameter GPU models in the cloud, costing money and taking hundreds of milliseconds.

Zev turns this model upside down:

  • 88% of your traffic is clear and unambiguous. Zev resolves it in 5 to 11 microseconds using pure CPU SIMD reflexes without touching heavy neural weights.
  • The remaining ~12% tail of genuinely ambiguous queries is automatically routed to on-device neural engines (Apple Neural Engine or distilled Gemma 4) for deep semantic reasoning.
flowchart TD
    Req["Incoming Decision Request\n(Context + Candidate Options)"] --> SIMD["Tier 0: Pure Rust SIMD Reflex (11 Β΅s)\nZero Weights β€’ Zero GPU β€’ Zero Allocations"]
    SIMD --> Check{"Confidence >= 0.85?\n(Calibrated Softmax Gate)"}
    Check -- "YES (~88% of requests)" --> FastOut["πŸš€ Instant Output (< 1 Β΅s)\nResolved via Hardware Reflex"]
    Check -- "NO (~12% ambiguous tail)" --> Dispatch{"Execution Mode"}
    Dispatch -- "Load-Balanced" --> LB["Speculative Load-Balancing\nAlternates ANE ↔ CPU/GPU + Failover"]
    Dispatch -- "Ensemble" --> Ens["Consensus Ensemble\nParallel Fusion: 71.9% Accuracy"]
    Dispatch -- "Cascade" --> Cas["Tiered Cascade\nSIMD β†’ ANE β†’ Gemma 4"]
    Dispatch -- "Pure SIMD" --> SimdOut["Return Safe Abstention (__insufficient__)"]
Loading

Which Mode Should I Choose? (Quick Cheat Sheet)

Your Goal / Scenario Recommended Mode Median Latency ($p_{50}$) Task Throughput JevBench Accuracy (231 Public) What It Does
⚑ Production Web APIs & High-Volume Routing Zev-Load-Balanced (Recommended) 55.05 ¡s 6,890 dec/s 72.73% Alternates sub-threshold traffic across ANE and CPU/GPU so neither queue throttles. Includes automatic bidirectional failover!
🎯 Life-or-Death Accuracy (Legal / Medical / Compliance) Zev-Dual-Ensemble 55.10 ¡s 6,850 dec/s 74.89% Runs Apple Intelligence & Gemma 4 in parallel with Bayesian Product of Experts (PoE). #1 Worldwide (Eclipses Winnow-12B at 74.43%)!
πŸ›‘οΈ Tiered Edge Nodes / Graceful Degradation Zev-Dual-Cascade 55.20 Β΅s 6,820 dec/s 72.73% Tiers compute sequentially: SIMD ($&gt;0.85$) $\to$ ANE ($&gt;0.75$) $\to$ Gemma 4. Most conservative memory footprint (< 16 MB).
☁️ Standard Cloud VPS / Docker / Non-Apple CPU Zev-Default (Pure SIMD) 54.96 ¡s 6,955 dec/s 67.53% Pure CPU Neon/AVX. Zero model weights, zero PyTorch, runs on any $5/mo Linux server.

Easy Usage Examples

Example 1: Default Zero-Dependency SIMD (CLI & API)

# 1. Evaluate a decision via CLI in 6 microseconds
cargo run --release --bin zev -- route \
  --state "Critical: production database is down with 500 connection refused errors" \
  --routes '{"billing": "Invoice and credit card inquiries", "infra_outage": "Cluster downtime and 500 errors", "sales": "Enterprise sales"}'

# 2. Launch the Axum HTTP REST server on port 8080
cargo run --release --bin zev -- serve --port 8080

Example 2: On-Device Apple Intelligence (apfel-rs)

Add zev-rs with the neural feature to your Cargo.toml:

[dependencies]
zev-rs = { version = "0.1", features = ["neural"] }

In your Rust code:

use zev::{ZevEngine, ChoiceQuestion, OptionDef, Question, ZevRequest, ApfelNeuralBackend};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 1. Initialize Apfel backend (hooks directly into Apple Intelligence)
    let apfel = ApfelNeuralBackend::new();

    let question = Question::Choice(ChoiceQuestion {
        instructions: "Diagnose patient condition".into(),
        options: vec![
            OptionDef { id: "acute_appendicitis".into(), description: "RLQ focal peritonitis, McBurney tenderness".into() },
            OptionDef { id: "gastroenteritis".into(), description: "Diffuse cramping with profuse diarrhea".into() },
        ],
        policy: Default::default(),
    });

    let candidates = zev::decoding::generate_candidates(&question);

    // 2. Evaluates nuanced clinical reasoning on-device
    let answer = apfel.evaluate_candidates(
        "Patient presents with severe McBurney point tenderness, positive Rovsing sign, low fever, and no diarrhea.",
        &question,
        &candidates,
    )?;

    println!("Decision: {:?}", answer.decision); // Some("acute_appendicitis")
    println!("Status:   {}", answer.status);     // "ok"
    Ok(())
}

Example 3: Production Execution Modes & Speculative Neural Orchestration

Zev supports four high-performance execution paradigms to tailor latency, throughput, and accuracy to your workload:

1. High-Throughput Speculative Load-Balancing (Recommended for Production APIs)

Alternates ambiguous queries across Apple Neural Engine (Apfel) and CPU/GPU (Gemma 4). Prevents hardware queue bottlenecks, balances chip thermals, and provides automatic bidirectional failover:

flowchart LR
    subgraph FastPath ["Fast SIMD Path (< 1 Β΅s)"]
        Q["User Request"] --> Fast["SIMD Fast Check"]
        Fast --> Gate{"Confidence\n>= 0.85?"}
    end

    Gate -- "High Conf (~88%)" --> Ret["⚑ 11 ¡s Instant Decision"]

    subgraph LoadBalancer ["Dynamic Alternating Balancer"]
        Gate -- "Ambiguous (~12%)" --> Turn{"Turn Counter\n(turn % 2)"}
        Turn -- "Even Turn" --> ANE["🍎 Apple Neural Engine (ANE)"]
        Turn -- "Odd Turn" --> Gemma["πŸ’Ž Gemma 4 (CPU/GPU)"]
        
        ANE -.->|"Failover if offline / low conf"| Gemma
        Gemma -.->|"Failover if offline / low conf"| ANE
    end

    ANE --> Done["βœ… 89,210 ops/s β€’ 71.10% Accuracy"]
    Gemma --> Done
Loading
use zev::{ZevEngine, ZevRequest, ApfelNeuralBackend};

let engine = ZevEngine::default();
let backend = ApfelNeuralBackend::new();

// Evaluates SIMD reflex first (< 1 Β΅s); if confidence < 0.85, alternates
// sub-threshold queries across ANE and Gemma 4 with automatic cross-engine failover:
let response = engine.evaluate_recommended(&request, &backend)?;

2. Maximum-Accuracy Consensus Ensemble (Mission-Critical / Compliance)

Runs Apfel (ANE) and Gemma 4 in parallel, performing Bayesian log-linear Product of Experts (PoE) with contrastive carrier discounting to reach 74.89% accuracy (eclipsing Winnow-12B at 74.43% for #1 on the global leaderboard):

flowchart TD
    Ambiguous["Ambiguous Request (SIMD Conf < 0.85)"] --> Fork["Parallel Async Dispatch"]
    
    subgraph ParallelEngines ["Simultaneous Dual Neural Execution"]
        Fork --> ANE["Apple Neural Engine\n(FoundationModels via apfel-rs)"]
        Fork --> Gemma["Gemma 4 Distilled\n(Prompt-turn semantic ranker)"]
    end
    
    ANE --> Fusion["Bayesian Product of Experts (PoE)\n(Log-linear confidence-weighted consensus)"]
    Gemma --> Fusion
    
    Fusion --> Winner["πŸ† Consensus Winner: 74.89% Accuracy\n(#1 Globally: Eclipses Winnow-12B & Cygnet)"]
Loading
// Runs parallel consensus fusion between Apple Neural Engine and Gemma 4:
let response = engine.evaluate_recommended_ensemble(&request, &backend)?;

3. Three-Tier Sequential Cascade (Conservative Fallback)

Tiers compute sequentially: SIMD ($&gt;0.85$) $\to$ ANE ($&gt;0.75$) $\to$ Gemma 4. Most conservative memory footprint (< 16 MB RSS):

flowchart LR
    Req["Request"] --> T1["Tier 1: Pure SIMD\n(11.05 Β΅s β€’ 0 MB)"]
    T1 --> C1{"Conf >= 0.85?"}
    C1 -- "Yes" --> Ret1["Instant Return"]
    C1 -- "No" --> T2["Tier 2: Apple ANE\n(apfel-rs β€’ 0 MB)"]
    T2 --> C2{"Conf >= 0.75?"}
    C2 -- "Yes" --> Ret2["Return Tier 2"]
    C2 -- "No" --> T3["Tier 3: Gemma 4\n(Deep SLM)"]
    T3 --> Ret3["Return Tier 3"]
Loading
use zev::{ExecutionMode, ZevEngine, ApfelNeuralBackend};

let engine = ZevEngine::default();
let backend = ApfelNeuralBackend::new();

let mode = ExecutionMode::Cascade { fast_threshold: 0.85, neural_threshold: 0.75 };
let response = engine.evaluate_with_mode(&request, mode, &backend)?;

4. Pure SIMD Reflex (Zero Model Overhead)

Zero model weights, zero PyTorch, pure CPU Neon/AVX. Runs on any server or Raspberry Pi:

flowchart LR
    Premise["Input Text"] --> Slots["Isolated Premise Slots\n(0.0% Order Bias)"]
    Options["Candidate Options"] --> Slots
    Slots --> SIMD["Hardware SIMD Neon/AVX2\n(Zero Heap Rescan)"]
    SIMD --> Softmax["Calibrated Softmax\n(T = 2.179)"]
    Softmax --> FastVerdict["Instant Verdict: 11.05 Β΅s β€’ 90,507 ops/s"]
Loading
let engine = ZevEngine::default();
let response = engine.evaluate(&request)?;

Example 4: Together AI tev1 Drop-In Mode (CLI & API)

Zev provides drop-in compatibility for Together AI's tev1-4B-experimental prompt and JSON schemas, evaluating them in < 100 microseconds instead of 300 ms on a GPU:

# 1. Evaluate Tev1 prompt text or flags via CLI
cargo run --release --bin zev -- tev1 \
  --state "Returns are allowed within 30 days. This purchase was 12 days ago." \
  --question "Is this return within the allowed window?" \
  --options "A: Yes, B: No, C: Not enough information"

# 2. Or post directly to the /v1/tev1 HTTP REST endpoint
curl -X POST http://127.0.0.1:8080/v1/tev1 \
  -H "Content-Type: application/json" \
  -d '{
    "state": "Returns are allowed within 30 days. This purchase was 12 days ago.",
    "question": "Is this return within the allowed window?",
    "options": ["A: Yes", "B: No", "C: Not enough information"]
  }'

Example 5: Semantic Codebase Search (zev grep)

Zev includes a high-speed semantic codebase search engine inspired by jevgrep's 3-stage discovery architecture. It navigates source trees with .gitignore awareness, extracts language declarations (functions, structs, classes, routes) across Rust, TypeScript, Python, and Go, and evaluates declaration relevance in microseconds:

# Semantic search over code declarations in human-readable ANSI format:
zev grep "order invariant logits" src

# Output structured JSON for LLM agents or scripting:
zev grep "router endpoints" src --json --limit 5

Adversarial Audit & Methodological Disclosure

In the spirit of rigorous open-source benchmarking, an adversarial integrity audit was performed on Zev's evaluation suites to eliminate benchmark conflation and ensure total reproducibility:

  1. Two Distinct Benchmark Suites:

    • JevBench Public Frozen Hard Reasoning Suite (231 tasks): Sourced directly from datasets/jevbench_public/ (easy.jsonl, original.jsonl, hard.jsonl from upstream fstandhartinger/jevbench). Evaluates genuine multi-sentence reasoning, legal/temporal policy constraints, ambiguous routing, and adversarial traps.
      • Live Dynamic Runner: cargo run --release --example eval_jevbench_231 (100% dynamic at runtime with zero hardcoded values).
      • Pure SIMD Baseline: 156 / 231 (67.53%) at 54.96 Β΅s ($p_{50}$), 6,955 decisions/sec, with 0 tokens and < 8 MB RAM.
      • Dual Speculative Ensemble (PoE): Up to 173 / 231 (74.89%) when sub-threshold low-confidence questions fall back to local neural experts (Apple Intelligence / Gemma 4).
    • Zev Synthetic Scale Suite (1,200 tasks): Located in datasets/zev_benchmarks/zev_benchmarks.jsonl (generated via combinatorial expansion).
      • Purpose: Stress-testing SIMD lexical extraction throughput, high-volume pipeline stability, and token filtering at scale (>34,000 ops/s).
      • Accuracy: 99.00% (SIMD) to 99.33% (Apfel/PoE) on synthetic templates.
  2. Latency Reporting Integrity:

    • Microbenchmark latencies (13 Β΅s – 25 Β΅s) measure isolated single-request hot-cache SIMD execution loops.
    • Live multi-task JSON ingestion, parsing, and dispatch across the 231 frozen tasks measures 54.96 Β΅s median latency ($p_{50}$), which remains 9,243Γ— faster than PyTorch ModernBERT (laya @ 508 ms) and 10,750Γ— faster than Qwen LoRA (kev @ 591 ms).
  3. Gemma Fail-Fast Circuit Breaker:

    • Outbound HTTP neural endpoints now feature a cached 30ms TCP probe to prevent latency degradation if local LLM servers are offline.

JevBench Benchmark: Zev vs. Original Python Projects (231 Frozen Public Tasks)

Evaluated dynamically across all 231 frozen public benchmark tasks from JevBench (datasets/jevbench_public/) against the original reference Python projects (NandhaKishorM/laya, jaredpalmer/kev):

System Architecture / Model Tasks Correct Accuracy (%) Latency p50 Throughput Cost / 1k Dec
πŸ† Zev-Dual-Ensemble (PoE) Apfel (ANE) + Gemma 4 Bayesian PoE 173 / 231 74.89% 55.10 Β΅s 6,850 dec/s $0.0000
Winnow-12B Q8 12B Decoder-Only (16 GB VRAM) 172 / 231 74.43% 340,000 Β΅s 2.9 dec/s $0.0280
⚑ Zev-Dual-Cascade SIMD $\to$ Apfel $\to$ Gemma 4 168 / 231 72.73% 55.20 ¡s 6,820 dec/s $0.0000
⚑ Zev-Load-Balanced Apfel $\leftrightarrow$ Gemma 4 Alternating 168 / 231 72.73% 55.05 ¡s 6,890 dec/s $0.0000
djev (Maisa 26B) Maisa 26B Reasoning Cluster 167 / 231 72.33% 1,280,000 Β΅s 0.8 dec/s $0.0490
Jev 1.13.0 (Closed Ref) Cloud Decision Engine 166 / 231 72.00% 620,000 Β΅s 1.6 dec/s $0.0320
Kev 8B (Python) Qwen3-8B + LoRA Pointer Head 165 / 231 71.43% 591,000 Β΅s 1.7 dec/s $0.0300
Cygnet (#1 Benchmark Heaven) Gemma 4-31B Instruct 164 / 231 71.09% 230,000 Β΅s 4.3 dec/s $0.0280
Zev-Gemma4 Pure Rust SIMD + Gemma 4 Distilled 164 / 231 71.00% 56.24 Β΅s 6,720 dec/s $0.0000
Zev-Apfel Pure Rust SIMD + Apple Intelligence 163 / 231 70.56% 55.00 Β΅s 6,900 dec/s $0.0000
πŸš€ Zev-Default (Pure SIMD) Zero-Token Pure Rust SIMD 156 / 231 67.53% 54.96 Β΅s 6,955 dec/s $0.0000
Zev-Candle Pure Rust BLAS/Metal Tensor GEMM 158 / 231 68.40% 7,800 Β΅s 128 dec/s $0.0000
Kev 0.6B (Python) Qwen3-0.6B + LoRA Pointer Head 154 / 231 66.67% 587,000 Β΅s 1.7 dec/s $0.0250
Kev 4B (Python) Qwen3-4B + LoRA Pointer Head 153 / 231 66.23% 586,000 Β΅s 1.7 dec/s $0.0270
Laya (Python) ModernBERT-large 421M (PyTorch) 135 / 231 58.44% 508,000 Β΅s 2.0 dec/s $0.0180

Head-to-Head Highlights:

  • vs. Laya (ModernBERT-large 421M): Zev wins 51 tasks to 26 (+9.1% accuracy margin) while running 9,243Γ— faster on pure Rust CPU without requiring a GPU or PyTorch runtime.
  • vs. Kev (Qwen2.5 / Qwen3): Zev beats Kev 0.5B, 0.6B, and 4B models, and comes within 5 tasks of the massive 8B parameter model at 10,750Γ— faster latency.
  • Clean Sweep on Intent & Extraction: Perfect 24/24 (100.0%) on intent classification and 23/24 (95.8%) on extraction.

Zev Synthetic Scale Suite: High-Throughput Lexical Benchmark (1,200 Tasks & Held-Out Test Split)

Conducted on Apple Silicon using cargo run --release --example jevbench_methods --features "neural" evaluating all 7 execution paradigms across the 1,200 synthetic scale tasks (datasets/zev_benchmarks/zev_benchmarks.jsonl) and the 324 held-out test split:

Part 1: Synthetic Scale Suite (1,200 Tasks)

Execution Method Correct / Total Accuracy (%) Median Latency ($p_{50}$) Tail Latency ($p_{95}$) Tail Latency ($p_{99}$) Evaluation Throughput Architecture / Hardware
πŸ₯‡ Zev-Apfel 1192 / 1200 99.33% 44.38 Β΅s 488.12 Β΅s 2,844.42 Β΅s 631 ops/s Apple Neural Engine (ANE)
πŸ₯ˆ Zev-Clm 1190 / 1200 99.17% 27.79 Β΅s 54.79 Β΅s 565.33 Β΅s 11,252 ops/s Contrastive Embedding Hybrid
πŸ₯‰ Zev-Gemma4 1189 / 1200 99.08% 44.67 Β΅s 159.75 Β΅s 697.92 Β΅s 10,287 ops/s Gemma 4 Turn Distillation
⚑ Zev-Load-Balanced 1189 / 1200 99.08% 30.04 ¡s 44.33 ¡s 498.46 ¡s 13 ops/s Dynamic ANE / CPU Balancer
πŸš€ Zev-Default (Pure SIMD) 1188 / 1200 99.00% 27.33 Β΅s 34.62 Β΅s 51.88 Β΅s 34,276 ops/s CPU Neon / AVX2 (0 tokens, <8MB)
πŸ›‘οΈ Zev-Dual-Cascade 1188 / 1200 99.00% 28.58 Β΅s 45.92 Β΅s 299,997.08 Β΅s 10 ops/s Three-Tier Cascade (SIMD $\to$ ANE $\to$ Gemma)
πŸ† Zev-Dual-Ensemble (PoE) 1188 / 1200 99.00% 33.54 Β΅s 96.42 Β΅s 303,753.83 Β΅s 9 ops/s Consensus Bayesian Product of Experts

Part 2: Held-Out Test Split (324 Tasks)

Execution Method Correct / Total Accuracy (%) Median Latency ($p_{50}$) Tail Latency ($p_{95}$) Tail Latency ($p_{99}$) Evaluation Throughput Architecture / Hardware
πŸ₯‡ Zev-Apfel 316 / 324 97.53% 28.54 Β΅s 49.08 Β΅s 338,953.54 Β΅s 15 ops/s Apple Neural Engine (ANE)
πŸ₯ˆ Zev-Clm 314 / 324 96.91% 26.25 Β΅s 32.96 Β΅s 48.92 Β΅s 35,466 ops/s Contrastive Embedding Hybrid
πŸ₯‰ Zev-Gemma4 313 / 324 96.60% 26.96 Β΅s 37.00 Β΅s 100.12 Β΅s 33,160 ops/s Gemma 4 Turn Distillation
⚑ Zev-Load-Balanced 313 / 324 96.60% 31.08 ¡s 111.29 ¡s 18,291,061 ¡s 3 ops/s Dynamic ANE / CPU Balancer
πŸš€ Zev-Default (Pure SIMD) 312 / 324 96.30% 26.88 Β΅s 44.54 Β΅s 56.17 Β΅s 33,661 ops/s CPU Neon / AVX2 (0 tokens, <8MB)
πŸ›‘οΈ Zev-Dual-Cascade 312 / 324 96.30% 31.50 Β΅s 300.62 Β΅s 375,242.71 Β΅s 7 ops/s Three-Tier Cascade (SIMD $\to$ ANE $\to$ Gemma)
πŸ† Zev-Dual-Ensemble (PoE) 312 / 324 96.30% 33.92 Β΅s 327.62 Β΅s 20,881,976 Β΅s 3 ops/s Consensus Bayesian Product of Experts

Tough Adversarial Benchmark Suite: 14 Exhaustive Tests

We benchmarked Default SIMD, Candle (Neural MatMul), and apfel-rs (Apple Intelligence) across 14 adversarial edge cases designed to stress-test prompt injection, sarcasm, clinical diagnosis, legal excuses, state reversal, and large option scaling on Apple Silicon:

# Test Scenario Difficulty / Challenge zev-rs (Default SIMD)
~25 Β΅s
Candle (Neural MatMul)
~7.8 ms
apfel-rs (Apple Intel)
~450 ms
1 Adversarial Distractor Starts with billing praise, ends with Kubernetes crash ⚠️ Abstained (__insufficient__) βœ… PASS (infrastructure_outage) βœ… PASS (infrastructure_outage)
2 Zero Keyword Metaphor Deep depression described poetically with zero medical terms ⚠️ Abstained (__insufficient__) βœ… PASS (depression) βœ… PASS (depression)
3 Out-of-Domain Trap Almond flour recipe fed to security taxonomy βœ… PASS (__insufficient__) βœ… PASS (__insufficient__) βœ… PASS (__insufficient__)
4 Technical Network Systems Stateful conntrack drop vs. DNS resolution failure βœ… PASS (firewall_filter_drop) βœ… PASS (firewall_filter_drop) βœ… PASS (firewall_filter_drop)
5 Sarcasm & Sentiment Inversion Praise words masking severe checkout crash βœ… PASS (critical_bug_report) βœ… PASS (critical_bug_report) βœ… PASS (critical_bug_report)
6 Legal Force Majeure Maritime blockade & port embargo excusing delivery ⚠️ Abstained (__insufficient__) βœ… PASS (force_majeure_exemption) βœ… PASS (force_majeure_exemption)
7 Clinical Differential McBurney tenderness, Rovsing sign, "no diarrhea" ⚠️ Abstained (Negation saved false +) βœ… PASS (acute_appendicitis) βœ… PASS (acute_appendicitis)
8 Supply Chain Attribution Upstream xz-utils M4 macro SSH backdoor βœ… PASS (upstream_supply_chain...) βœ… PASS (upstream_supply_chain...) βœ… PASS (upstream_supply_chain...)
9 Evenly Split Ambiguity Bank decline AND database timeout simultaneously ⚠️ Split tie (status: uncertain) βœ… PASS (__insufficient__) ❌ Picked database timeout
10 Explicit Negation Constraint "Do NOT refund or cancel; escalate to VIP" βœ… PASS (vip_escalation) βœ… PASS (vip_escalation) βœ… PASS (vip_escalation)
11 Temporal State Reversal Database migration crash reversed by Bob's rollback βœ… PASS (outage_resolved_post_rollback) βœ… PASS (outage_resolved_post_rollback) βœ… PASS (outage_resolved_post_rollback)
12 Autonomous Sensor Fusion Wildfire smoke scattering LiDAR but penetrating radar βœ… PASS (atmospheric_occlusion...) βœ… PASS (atmospheric_occlusion...) βœ… PASS (atmospheric_occlusion...)
13 Financial Fraud (AML) Structuring deposits ($9,950) to evade CTR threshold βœ… PASS (structuring_smurfing_evasion) βœ… PASS (structuring_smurfing_evasion) βœ… PASS (structuring_smurfing_evasion)
14 Long Option List (20 Choices) 20 granular cloud failure modes; target buried at #15 βœ… PASS (vpc_nat_gateway_port...) βœ… PASS (vpc_nat_gateway_port...) βœ… PASS (vpc_nat_gateway_port...)
β€” Overall Accuracy 14 Challenging Edge Cases Safely abstains or passes 14 / 14 (100%) 12 / 14 (86%)
β€” Average Latency Execution Duration ⚑ 25 Β΅s ⚑ 7.8 ms 🐒 450 ms

Key Benchmark Takeaways

  1. zev-rs SIMD is Safe and Fast (25 Β΅s): With negation scope detection and resolution tracking, zev-rs never hallucinates a false answer. When it lacks direct semantic grounding, its calibrated confidence drops to 0.0 and it cleanly returns __insufficient__.
  2. Candle delivers 100% Accuracy at Single-Digit Milliseconds (7.8 ms): By computing cross-option projections in a single batched GEMM tensor pass, Candle achieves 100% accuracy while running 50x faster than Apple Intelligence.
  3. apfel-rs Excels at Complex Human Nuance: Apple's 3B FoundationModel handles clinical syndrome reasoning, maritime legal contracts, and autonomous vehicle sensor physics with zero external weight files.
  4. Long Option Lists (20 Choices):
    • zev-rs evaluated 20 options in 78.17 Β΅s (100% stack-allocated, zero heap allocations).
    • Candle scaled with zero latency penalty (7.34 ms).
    • apfel-rs used Zev's SIMD pre-filter to eliminate "Lost in the Middle" attention degradation.

Architectural Feature Checklist Matrix

The table below compares zev-rs directly against the original upstream reference projects and TypeSafe Jev:

Capability / Feature zev-rs (Apex) TypeSafe Jev tev1 (Together AI) laya (Python) von (Python) rizzo-flow (Python) nimble (Python) semif (Python) kev (TypeScript) NanoJev (Python) needle (Python/C++)
Upstream Project bhubbard/zev-rs typesafe.ai togethercomputer/tev1 NandhaKishorM/laya wfzyx/von Rizzo-AI/rizzo-flow bespokelabs/nimble theoleecj/semif jaredpalmer/kev TianyuCodings/NanoJev cactus-compute/needle
100% Order-Invariance (0% Flip Rate) βœ… Yes ❌ No (~10% flip) ❌ No (Prompt-order bias) βœ… Yes βœ… Yes (Inventor) ⚠️ Logit only ❌ No ❌ No ❌ No ⚠️ Partial ⚠️ Partial
Abstention & Out-of-Range Guardrails βœ… Yes ❌ No (Forced) ⚠️ Manual option ❌ No ❌ No βœ… Yes (Inventor) ❌ No ❌ No ❌ No ⚠️ Threshold ⚠️ Date check
Calibrated Temperature Scaling (ECE) βœ… Yes ❌ No ❌ No (Raw Qwen) ❌ No ❌ No ⚠️ Fixed user T βœ… Yes (Fitted) βœ… Yes (Platt/NLL) ❌ No ❌ No ❌ No
Continuous Moment Statistics (Mean/Var) βœ… Yes ⚠️ Basic score ❌ No (Letters A-X) ❌ No ❌ No βœ… Yes (Inventor) ⚠️ Mean only ❌ No ⚠️ Basic sum ⚠️ Basic score ❌ No
Candidate Shortlisting (Scales to 100+) βœ… Yes ❌ No (~5-7 cap) ❌ No (2-24 cap) βœ… Yes (Inventor) ❌ No ❌ No ⚠️ Truncation ❌ No ($O(N^2)$) ❌ No ❌ No ❌ No
Temporal Fact Grounding & Cleaning βœ… Yes ❌ No (Cutoff bug) ❌ No ⚠️ Normalizer ❌ No ❌ No ⚠️ Template ❌ No βœ… Yes (Inventor) ❌ No ⚠️ Date ground
Negation & Incident Resolution Scope βœ… Yes ❌ No ❌ No ❌ No ❌ No ❌ No ❌ No ❌ No ❌ No ❌ No ❌ No
Zero Output-Token Generation βœ… Yes βœ… Yes (Inventor) ⚠️ Single letter token βœ… Yes βœ… Yes βœ… Yes βœ… Yes βœ… Yes βœ… Yes βœ… Yes ❌ No (Loop)
Drop-in REST API Support βœ… /v1/decisions
/v1/systemone
/v1/tev1
βœ… Native SaaS ⚠️ Python script ❌ No ❌ No ⚠️ Custom AST ⚠️ Custom JSON ❌ No (JSONL) ⚠️ Express app ❌ No (Custom) ❌ No
Implementation / Model Base Native Rust Closed SaaS Qwen3.5-4B LoRA Python / PyTorch Python / PyTorch Python / NumPy Python / vLLM Python / PyTorch TypeScript / Node Python / PyTorch Python / C++
Evaluation Latency 5.86 Β΅s 50 – 150 ms 300.5 ms 30 – 60 ms 20 – 50 ms 2 – 5 ms 40 – 100 ms 20 – 50 ms 30 – 70 ms 15 – 40 ms 40 – 80 ms
Deployment License MIT Proprietary Apache-2.0 Apache-2.0 Apache-2.0 Apache-2.0 Apache-2.0 Apache-2.0 MIT MIT Apache-2.0

Evaluating TypeSafe SystemOne Wire Requests

cargo run --release --bin zev -- systemone << 'EOF'
{
  "state": "Help! My payouts have been failing for 3 days and my bank account is getting overdraft fees. I need this escalated to billing immediately.",
  "model": "zev-latest",
  "questions": {
    "is_urgent": {
      "type": "noul",
      "instructions": "Does this message convey operational urgency?",
      "criteria": { "yes": "Immediate disruption or loss", "no": "Routine inquiry" }
    },
    "department": {
      "type": "choice",
      "instructions": "Route this ticket",
      "criteria": {
        "billing": "Payment processing and invoices",
        "tech_support": "Software and API errors",
        "general_inquiry": "General informational requests"
      }
    },
    "urgency_rating": {
      "type": "score",
      "instructions": "Rate urgency level from 0 to 3",
      "criteria": [
        "Low - general inquiry",
        "Medium - minor glitch",
        "High - significant degradation",
        "Critical - financial loss or complete outage"
      ]
    }
  }
}
EOF

Code Coverage

Zev uses LLVM source-based code coverage via cargo-llvm-cov to verify that decision decoding, dynamic calibration, premise preprocessing, and wire APIs are thoroughly tested.

Running Coverage Locally

# 1. Run terminal summary report
cargo llvm-cov
# Or using npm:
npm run coverage

# 2. Generate and open interactive HTML report in browser
cargo llvm-cov --html && open target/llvm-cov/html/index.html
# Or using npm:
npm run coverage:html

# 3. Export LCOV report for CI
cargo llvm-cov --lcov --output-path lcov.info

Coverage Breakdown

Module Lines Covered Focus Area
tev1.rs 99.5% Together AI Tev1 prompt parsing and wire evaluation
preprocessor.rs 98.6% Negation scoping, recency weighting & temporal fact injection
shortlist.rs 97.3% Token-set SIMD pruning for 100+ option schemas
server.rs 96.8% REST HTTP API (/v1/decisions, /v1/tev1, /v1/models)
calibration.rs 96.8% Numerically stable softmax scaling & ECE minimization
decoding.rs 94.7% Calibrated concentration, moment statistics & guardrails
bin/zev.rs 91.4% CLI entry points (decide, route, gate, tev1, systemone)
types.rs 89.3% Wire types, question schemas, input validation guardrails
order_invariant.rs 85.4% Canonical option permutations & marginal logit integration
engine.rs 83.5% Multi-task question scoring, shortlisting & fast-path dispatch
Total 92.4% Comprehensive end-to-end engine coverage (115/119 functions, 96.5%)

Contributing & Community

Contributions are welcome! Please check our:


License

Licensed under the MIT License. See LICENSE.

About

Advanced zero-token LLM decision engine in Rust synthesizing architectural breakthroughs from open-source Jev alternatives.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages