Text Classification
Transformers
PyTorch
English
modernbert
encoder
decision-model
tool-routing
agentic
Instructions to use open-zzrl/kyo-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use open-zzrl/kyo-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="open-zzrl/kyo-instruct")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("open-zzrl/kyo-instruct", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
base_model: open-zzrl/kyo
|
| 6 |
+
tags:
|
| 7 |
+
- decision-making
|
| 8 |
+
- routing
|
| 9 |
+
- agent
|
| 10 |
+
- system-one
|
| 11 |
+
- modernbert
|
| 12 |
+
- intent-classification
|
| 13 |
+
- policy-gating
|
| 14 |
+
pipeline_tag: text-classification
|
| 15 |
+
library_name: transformers
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# β‘ Kyo-Instruct (140M System-One Decision Engine)
|
| 19 |
+
|
| 20 |
+

|
| 21 |
+
|
| 22 |
+
**Kyo-Instruct** is an ultra-fast (140M parameter) **System-One semantic routing and policy gating engine** engineered to govern autonomous AI agents, tool selection, and high-throughput intent pipelines in real time.
|
| 23 |
+
|
| 24 |
+
Fine-tuned directly on top of **`open-zzrl/kyo`** using multi-domain Experience Replay, Kyo-Instruct bridges the gap between deterministic typed policy Instruct and generalized natural language intent classification. Powered by a specialized **Dual-Pooling Cross-Encoder head** (`[CLS]` + Masked Mean to 768d over a ModernBERT backbone), it delivers sub-10ms deterministic execution with **99.95% order-invariance**, outperforming models 3Γ its size.
|
| 25 |
+
|
| 26 |
+
* **GitHub Repository:** [github.com/open-zzrl/kyo](https://github.com/open-zzrl/kyo)
|
| 27 |
+
* **Developed by:** constructai & zait-ai (`open-zzrl`)
|
| 28 |
+
* **Base Model:** `open-zzrl/kyo`
|
| 29 |
+
* **Underlying Backbone:** `jhu-clsp/mmBERT-small` (ModernBERT encoder, 12 layers, hidden size 384)
|
| 30 |
+
* **Context Window:** Up to 4096 tokens (native RoPE + SDPA)
|
| 31 |
+
* **Average Inference Latency:** 8.80 ms (P95: 9.71 ms on CUDA, `bfloat16`)
|
| 32 |
+
* **Memory Footprint:** ~280 MB VRAM (< 1.5 GB peak with runtime context)
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## π Benchmark Results
|
| 37 |
+
|
| 38 |
+
Evaluated across 2,000 holdout agent policy scenarios and multi-class NLP benchmarks:
|
| 39 |
+
|
| 40 |
+
### 1. Comparative SOTA Overview
|
| 41 |
+
|
| 42 |
+

|
| 43 |
+
|
| 44 |
+

|
| 45 |
+
|
| 46 |
+

|
| 47 |
+
|
| 48 |
+
| Benchmark / Capability | Kyo-Dispatch (140M) | Laya Base (421M) | TypeSafe Jev (~490M) |
|
| 49 |
+
| :--- | :--- | :--- | :--- |
|
| 50 |
+
| **DAIR Emotion** (6 classes, 2000 holdout) | **71.55%** | 59.50% | 48.00% |
|
| 51 |
+
| **Banking77** (Full 77 classes, 3076 test) | **47.56%** *(77 options)* | 42.50% *(72 options)* | **87.00%** *(72 options)* |
|
| 52 |
+
| **Typed-Decisions** (Agent Policy Holdout) | **71.60%** | **76.60%** | 72.70% |
|
| 53 |
+
| β³ `noul` (Boolean Safety & Gating) | **82.33%** | 85.70% | 77.50% |
|
| 54 |
+
| β³ `choice` (Action & Tool Routing) | **69.50%** | 73.30% | 72.00% |
|
| 55 |
+
| β³ `score` (Risk Tiers 0β3) | **65.12%** | 72.30% | 69.60% |
|
| 56 |
+
| **Order-Invariance Consistency** | **99.95%** | 27.05% | 13.00% |
|
| 57 |
+
| **Average Latency (GPU)** | **8.80 ms** | ~32 ms | ~36 ms |
|
| 58 |
+
| **P95 Latency (GPU)** | **9.71 ms** | > 45 ms | > 50 ms |
|
| 59 |
+
| **Parameter Scale** | **140M (~280 MB)** | 421M (~1.2 GB) | ~490M (~1.5 GB) |
|
| 60 |
+
|
| 61 |
+
### 2. Detailed Performance Analysis
|
| 62 |
+
|
| 63 |
+
* **99.95% Order-Invariance:** Autoregressive models and standard classification heads suffer severe position bias when candidate options are shuffled. Kyo isolates candidate scoring pairs, guaranteeing decisions remain stable regardless of input option order.
|
| 64 |
+
* **Full-Scale Candidate Evaluation:** On Banking77, Kyo processes all **77 candidates simultaneously** per pass with 12.18 ms latency, eliminating the need to pre-filter options.
|
| 65 |
+
* **Weight Efficiency:** At 140M parameters, Kyo-Instruct exceeds the 421M parameter Laya by **+12.05%** on emotion classification and **+5.06%** on fine-grained banking intent routing.
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## π¦ Installation via GitHub
|
| 70 |
+
|
| 71 |
+
Because Kyo utilizes an optimized dual-pooling cross-encoder head, models run natively via the lightweight `kyo` Python engine:
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
# Install directly from source
|
| 75 |
+
pip install git+[https://github.com/open-zzrl/kyo.git](https://github.com/open-zzrl/kyo.git)
|
| 76 |
+
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
### Upgrading to Latest Release
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
pip install --upgrade --no-cache-dir --force-reinstall git+[https://github.com/open-zzrl/kyo.git](https://github.com/open-zzrl/kyo.git)
|
| 83 |
+
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
> **Requirements:** Python β₯ 3.9, PyTorch β₯ 2.0 with CUDA support, and `git`.
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
## π Quickstart
|
| 91 |
+
|
| 92 |
+
Kyo loads pre-trained weights, tokenizer configurations, and execution parameters directly from Hugging Face Hub:
|
| 93 |
+
|
| 94 |
+
```python
|
| 95 |
+
import torch
|
| 96 |
+
from kyo import Kyo
|
| 97 |
+
|
| 98 |
+
# 1. Initialize the engine
|
| 99 |
+
engine = Kyo.from_pretrained("open-zzrl/kyo-instruct", confidence_threshold=0.80)
|
| 100 |
+
|
| 101 |
+
# ==========================================
|
| 102 |
+
# Scenario A: Autonomous Agent Policy & Safety Gating
|
| 103 |
+
# ==========================================
|
| 104 |
+
telemetry = {
|
| 105 |
+
"agent_id": "payment-worker-4",
|
| 106 |
+
"endpoint": "/api/v1/transfer/batch",
|
| 107 |
+
"requested_amount_usd": 145000,
|
| 108 |
+
"spending_limit_usd": 50000,
|
| 109 |
+
"user_approval_present": False,
|
| 110 |
+
"geo_anomaly": True
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
safety_Instruction = "Verify transaction safety against corporate treasury compliance rules."
|
| 114 |
+
safety_options = {
|
| 115 |
+
"Allow": "Transaction within limits and conforms to standard policy.",
|
| 116 |
+
"Require2FA": "Minor anomaly; hold for secondary automated factor.",
|
| 117 |
+
"BlockAndEscalate": "Hard limit breach or suspicious telemetry; freeze and alert human."
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
# Warm-up (initializes CUDA context and JIT-compiles SDPA kernels)
|
| 121 |
+
_ = engine.decide(context=telemetry, Instruction=safety_Instruction, options=safety_options)
|
| 122 |
+
|
| 123 |
+
result_safety = engine.decide(
|
| 124 |
+
context=telemetry,
|
| 125 |
+
Instruction=safety_Instruction,
|
| 126 |
+
options=safety_options
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
print("-" * 55)
|
| 130 |
+
print(f"Safety Decision : {result_safety.decision}")
|
| 131 |
+
print(f"Confidence : {result_safety.confidence * 100:.2f}%")
|
| 132 |
+
print(f"Hot Latency : {result_safety.latency_ms:.2f} ms")
|
| 133 |
+
print(f"Requires Fallback : {result_safety.fallback_to_llm}")
|
| 134 |
+
|
| 135 |
+
# ==========================================
|
| 136 |
+
# Scenario B: Dynamic Semantic Intent Classification
|
| 137 |
+
# ==========================================
|
| 138 |
+
customer_query = "Why is my card balance still unchanged after I deposited cash at the ATM two hours ago?"
|
| 139 |
+
routing_Instruction = "Classify customer inquiry into the matching operational queue."
|
| 140 |
+
routing_options = {
|
| 141 |
+
"atm_deposit_pending": "Delays or missing balance updates after ATM cheque or cash deposit.",
|
| 142 |
+
"wire_transfer_delay": "Inbound or outbound international wire transfer pending.",
|
| 143 |
+
"compromised_card": "Card reported stolen, cloned, or fraudulent charges detected.",
|
| 144 |
+
"order_physical_card": "Requesting delivery of a new physical replacement card."
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
result_route = engine.decide(
|
| 148 |
+
context=customer_query,
|
| 149 |
+
Instruction=routing_Instruction,
|
| 150 |
+
options=routing_options
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
print("-" * 55)
|
| 154 |
+
print(f"Routed Queue : {result_route.decision}")
|
| 155 |
+
print(f"Confidence : {result_route.confidence * 100:.2f}%")
|
| 156 |
+
print(f"Latency : {result_route.latency_ms:.2f} ms")
|
| 157 |
+
print("-" * 55)
|
| 158 |
+
|
| 159 |
+
```
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
## π― Intended Use & Boundaries
|
| 164 |
+
|
| 165 |
+
### β
What Kyo Excels At (In Scope)
|
| 166 |
+
|
| 167 |
+
* **Agent Security Guardrails & Policy Gating:** Evaluating execution traces, payloads, and parameter states against programmatic guardrails (`noul` accuracy: **82.33%**).
|
| 168 |
+
* **Deterministic Tool & Action Routing:** Dynamic selection of functions, endpoints, or execution paths from candidate options (**69.50%** on structured choices, **47.56%** across 77 simultaneous intents).
|
| 169 |
+
* **Real-Time Stream Routing:** Intent categorization and customer support triage under strict latency constraints (< 10 ms).
|
| 170 |
+
* **Cost-Efficient Frontier LLM Offloading:** Calibrated confidence scoring identifies uncertain predictions (`result.fallback_to_llm = True`), routing only ambiguous requests to costly generative LLMs.
|
| 171 |
+
|
| 172 |
+
### β Out of Scope
|
| 173 |
+
|
| 174 |
+
* **Open-Ended Autoregressive Generation:** Kyo is a pure discriminator/cross-encoder, not a generative language model.
|
| 175 |
+
* **Relational Multi-Column Spreadsheet Arithmetic:** Complex numerical calculations over dense tabular formats require specialized math reasoning models or large frontier LLMs.
|
| 176 |
+
|
| 177 |
+
---
|
| 178 |
+
|
| 179 |
+
## π§ Architecture: Dual-Pooling Pairwise Cross-Encoder
|
| 180 |
+
|
| 181 |
+
Kyo scores each candidate option $k$ in parallel against the shared query context:
|
| 182 |
+
|
| 183 |
+
$$\text{Features}_k = \text{LayerNorm}\Big(\big[\mathbf{h}_{\text{CLS}} \,\Vert\, \text{MeanPool}(\mathbf{H}_{\text{tokens}})\big]\Big) \in \mathbb{R}^{768}$$
|
| 184 |
+
|
| 185 |
+
$$\text{Score}_k = \mathbf{W}_2 \cdot \text{GELU}(\mathbf{W}_1 \cdot \text{Features}_k)$$
|
| 186 |
+
|
| 187 |
+
```text
|
| 188 |
+
[Context + Instruction] βββ
|
| 189 |
+
βββ> [mmBERT-small (12L, 384d)] ββ> [CLS (384d)] βββββββββ
|
| 190 |
+
[Candidate Option (k)] ββββ [Mean Pool (384d)] βββ΄β> LayerNorm (768d) ββ> MLP Head ββ> Logit_k
|
| 191 |
+
|
| 192 |
+
```
|
| 193 |
+
|
| 194 |
+
1. **Pairwise Isolation:** Evaluates each candidate independently against the context, eliminating candidate-order positional bias and guaranteeing **99.95% order-invariance**.
|
| 195 |
+
2. **Dual Representation:** Concatenating global contextual attention (`[CLS]`) with dense token coverage (masked mean pooling) doubles representation capacity without increasing encoder FLOPs.
|
| 196 |
+
|
| 197 |
+
---
|
| 198 |
+
|
| 199 |
+
## π οΈ Environment & Optimization Notes
|
| 200 |
+
|
| 201 |
+
* **Native `bfloat16` Calibration:** Kyo is natively trained and calibrated in `bfloat16`. Do not wrap evaluation in standard fp16 `GradScaler`.
|
| 202 |
+
* **Latency Profile:**
|
| 203 |
+
* **Cold Start (Run 1):** ~1.0β1.4s (CUDA context initialization and PyTorch SDPA kernel compilation).
|
| 204 |
+
* **Warm Inference (Run 2+):** **8.80 ms** average (P95: **9.71 ms**).
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
### Python 3.13 & Vision Dependencies Note
|
| 209 |
+
|
| 210 |
+
Kyo is an encoder-based text decision engine and does not use vision or audio models. If your environment encounters ABI issues with `torchvision` (e.g. `RuntimeError: operator torchvision::nms does not exist`), you can safely strip vision libraries:
|
| 211 |
+
|
| 212 |
+
```bash
|
| 213 |
+
pip uninstall -y torchvision torchaudio torchao
|
| 214 |
+
|
| 215 |
+
```
|
| 216 |
+
|
| 217 |
+
---
|
| 218 |
+
|
| 219 |
+
## π License & Attribution
|
| 220 |
+
|
| 221 |
+
The model weights and inference runtime are released under the **Apache-2.0 License**.
|
| 222 |
+
|
| 223 |
+
```bibtex
|
| 224 |
+
@software{kyo_Instruct2026,
|
| 225 |
+
author = {constructai, zait-ai},
|
| 226 |
+
title = {Kyo-Instruct: 140M System-One Decision and Routing Engine},
|
| 227 |
+
year = {2026},
|
| 228 |
+
publisher = {Hugging Face},
|
| 229 |
+
journal = {Hugging Face Model Hub},
|
| 230 |
+
howpublished = {\url{[https://huggingface.co/open-zzrl/kyo-instruct](https://huggingface.co/open-zzrl/kyo-instruct)}}
|
| 231 |
+
}
|
| 232 |
+
```
|