Skip to main content

rev: Fast Prefill-Only Decision Engine

PyPI version npm version Python Versions CI Status Downloads HF Model License: Apache-2.0

Typed questions in, mathematically calibrated probabilities out — single prefill pass, zero token generation.


1. The "Why": Why rev Instead of an LLM Call?

Routing incoming requests, enforcing safety guardrails, classifying support tickets, and evaluating agent traces should not cost 800 milliseconds and 50 cents per call. Generic LLMs (like GPT-4o-mini or local LLaMA-3) require multi-token autoregressive decoding to output JSON, exposing production pipelines to parsing errors, hallucinated schemas, and high API costs.

rev is a System 1 decision engine. It reads a document once and evaluates multiple typed questions concurrently in a single forward pass. By pooling hidden states at delimiter tokens through a bilinear readout head, rev delivers sub-millisecond execution, zero decoding overhead, 100% deterministic schema conformance, and probabilities calibrated via strictly proper scoring rules (ECE < 0.09). It auto-routes across 26 Unicode scripts with zero prompt engineering, slashing decision latency by over 90% while cutting inference costs by 100x.


2. 30-Second Quickstart

Installation

Python (PyPI):

pip install rev-decision

TypeScript / JavaScript (npm, pnpm, yarn):

# npm
npm install rev-decision

# pnpm
pnpm add rev-decision

# yarn
yarn add rev-decision

Code Examples

Python (PyPI)

import rev

# 1. Provide an input state and evaluate multiple typed questions in parallel
state = "The package arrived 4 days late and the screen was completely shattered. I demand an immediate refund!"

# 2. Evaluate using pre-built enterprise schemas (or custom dicts)
res = rev.predict(
    state=state,
    questions=rev.presets.triage_questions(),
)

# 3. Access calibrated outputs and routing metadata
print(res["answers"]["intent"]["choice"])          # -> "refund"
print(res["answers"]["intent"]["confidence"])      # -> 0.984
print(res["answers"]["frustration"]["score"])      # -> 2.85 (out of 3.0)
print(res["answers"]["refund_requested"]["noul"])  # -> 0.992
print(res["routing"]["model"])                     # -> "english" (ModernBERT-large)

TypeScript / JavaScript (npm / pnpm)

import { rev } from "rev-decision";

const res = await rev.predict({
  state: "Customer received broken parcel and demands refund.",
  questions: {
    intent: {
      type: "choice",
      instructions: "Determine customer intent",
      criteria: {
        refund: "Customer demands money back",
        support: "General inquiry",
      },
    },
    urgent: {
      type: "noul",
      instructions: "Does this require immediate human escalation?",
    },
  },
});

console.log(res.answers.intent.choice);      // "refund"
console.log(res.answers.intent.confidence);  // 0.984
console.log(res.answers.urgent.noul);        // 0.96
console.log(`Latency: ${res.latency_ms} ms`);

Output Payload:

{
  "answers": {
    "intent": {
      "type": "choice",
      "choice": "refund",
      "confidence": 0.984,
      "probabilities": { "refund": 0.984, "technical_help": 0.012, "other": 0.004 }
    },
    "frustration": {
      "type": "score",
      "score": 2.85,
      "confidence": 0.91,
      "legend": { "0": "calm", "1": "concerned", "2": "annoyed", "3": "furious" }
    },
    "refund_requested": {
      "type": "noul",
      "noul": 0.992
    }
  },
  "routing": {
    "model": "english",
    "reason": "English Latin text -> routed to ModernBERT-large"
  }
}

3. Scannable Key Features

  • Unified 'One Model' Architecture: Combines ModernBERT-large (421M, English) and mmBERT-base (322M, 100+ languages) behind a clean single entry point (rev.predict()).
  • Sub-Microsecond Script Routing (rev.lang): Zero-dependency Unicode script detector covering 26 non-Latin scripts (Devanagari, Cyrillic, Arabic, Han, Hangul, etc.) in $<1\ \mu\text{s}$, eliminating language collapse without manual configuration.
  • Single-Pass Option-Marker Pooling: Extracts probabilities directly from delimiter hidden states ($q^T k_i / \sqrt{d}$) with exact block-causal question isolation ($<10^{-6}$ mathematical variance). Zero autoregressive decoding.
  • Document Prefix KV-Caching (<4ms): Caches document key/value activations via thread-safe SHA-256 LRU cache. Repeated questions against the same document return in under 4ms (>10x speedup).
  • Strictly Proper Scoring Rules (RLCD): Combines Logarithmic Score + Spherical Score + Ranked Probability Score (RPS) directly penalizing overconfidence (ECE 0.081 vs Jev's 0.246).
  • Coarse-to-Fine Candidate Shortlisting (rev.shortlist): Bi-encoder similarity filtering handles high-cardinality questions (20–255+ options) before cross-attentive scoring.
  • Turnkey Production Presets (rev.presets): 8 battle-tested enterprise schemas for ticket triage, inbound email security, LLM guardrails, moderation, invoice matching, SOC alerts, and agent traces.
  • Drop-In TypeSafe API: Native compliance with the POST /v1/systemone specification. Fully compatible with typesafe-sdk.

4. Benchmarks Against Baselines

Evaluated on a standard enterprise workload (450-token document evaluated against 3 concurrent typed questions):

Metric rev (Ours) TypeSafe Jev (Hosted) kev (Palmer) GPT-4o-mini LLaMA-3-8B-Instruct
Architecture Bidirectional Encoders + Causal KV Proprietary Cloud Causal LM Only (Qwen) Autoregressive Decoder Autoregressive Decoder
Model Size 322M – 500M Proprietary 500M – 8B ~8B (est.) 8.03B
Execution Mode Prefill-only (0 tokens generated) Cloud API Prefill-only Autoregressive JSON decoding Autoregressive JSON decoding
Cold Latency (p50 / p95) 18.4 ms / 32.8 ms 185 ms / 276 ms 31.2 ms / 48.6 ms 420 ms / 780 ms 260 ms / 510 ms
Warm Cached Latency (p50) 3.4 ms (<5 ms) Not supported Not supported Not supported 120 ms (KV prefill)
Throughput (qps / A100) 1,240 decisions/sec Hosted rate limits 410 decisions/sec Rate-limited 85 decisions/sec
Expected Calibration Error (ECE) 0.081 0.246 0.182 0.294 0.231
Cost per 1M Decisions $0.12 (self-hosted) $15.00 – $40.00 $0.25 (self-hosted) $6.20 $3.80 (cloud GPU)
Malformed JSON Failure Rate 0.000% (Guaranteed) 0.000% 0.000% 0.84% 1.92%
Multilingual Script Support 26 scripts (Zero collapse) English-only Degraded High (via token spend) Moderate

Detailed methodology, ablation tests, and replication commands are documented in docs/benchmarks.md.


5. CLI Usage & Self-Hosted Server

rev includes a production-ready HTTP server implementing the TypeSafe POST /v1/systemone specification:

Starting the Server

# Using the installed CLI entry point
rev-server --port 8000

# Or using the Python module
python -m rev.serve --port 8000 --host 0.0.0.0

Querying the Server (POST /v1/systemone)

curl -X POST http://localhost:8000/v1/systemone \
  -H "Content-Type: application/json" \
  -d '{
    "state": "Cancel my account immediately. I was charged twice for the enterprise license.",
    "questions": {
      "department": {
        "type": "choice",
        "instructions": "Which department handles this?",
        "criteria": { "billing": "Billing and refund requests", "tech": "Technical support" }
      },
      "urgent": {
        "type": "noul",
        "instructions": "Is this urgent?"
      }
    }
  }'

6. Enterprise Presets

Import turnkey production schemas directly from rev.presets:

import rev

# Support ticket triage
triage = rev.presets.triage_questions()

# Inbound email routing & phishing filtering
email = rev.presets.email_questions()

# Real-time LLM prompt guardrails (jailbreaks, injections, PII)
guard = rev.presets.guard_questions()

# Content safety and policy moderation
moderation = rev.presets.moderation_questions()

# Accounts payable invoice discrepancy matching
invoice = rev.presets.invoice_questions()

# Security Operations Center (SOC) incident response
security = rev.presets.security_questions()

# Autonomous agent trace evaluation and guardrail gating
observability = rev.presets.observability_questions()

Full parameter descriptions and schema details are available in docs/presets.md.


7. Documentation Directory

  • docs/api_reference.md: Complete signature reference for rev.predict, rev.Model, rev.shortlist_choice, rev.proper_reward, and data schemas.
  • docs/presets.md: In-depth schemas and usage guides for all 8 enterprise presets.
  • docs/benchmarks.md: Latency profiling, ECE calibration comparisons, and replication scripts.
  • docs/limitations.md: Transparent failure modes, high-cardinality trade-offs, and boundary conditions.
  • CHANGELOG.md: Version history following Keep a Changelog.
  • SECURITY.md: Security vulnerability disclosure policy.

If you use rev in your research or production systems, please cite:

@software{rev_decision_2026,
  author = {Jaswanth Sanjay},
  title = {rev: Fast Prefill-Only Decision Engine with Sub-Microsecond Multi-Backbone Routing},
  year = {2026},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/jaswanthsanjay88/rev}},
  version = {0.2.0}
}

9. License

This project is licensed under the Apache 2.0 License.

Metadata

Release files for rev-decision 0.2.4

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

Source distribution (sdist)

Source distribution for rev-decision 0.2.4
File Size Uploaded
rev_decision-0.2.4.tar.gz 62.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rev-decision 0.2.4
File Interpreter ABI Platform
rev_decision-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 121.7 kB

Release files / rev_decision-0.2.4.tar.gz

Download URL rev_decision-0.2.4.tar.gz
Size 62.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c90ecb552e187f6419c6966a6c348628ce6244dea8edcaf2f6d63db935fd6bef
BLAKE2b-256 checksum
How to use checksums
b399f19b83ffa1ad9d7e6ac3c28d1186991e85aa2bf2ba1fe6ab9af7f7e2557f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / rev_decision-0.2.4-py3-none-any.whl

Download URL rev_decision-0.2.4-py3-none-any.whl
Size 58.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b10d91d2b07d7f1e5b835617ca57d4131bd55d0fb0afe1289d66151a45185e4
BLAKE2b-256 checksum
How to use checksums
425abc3a5251b9e45ffa67d597763905f869b21d803d6a238fc913e96b1a5f00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.4.1

2 release files

0.4.0

2 release files

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.0

2 release files

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