classone 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. classone-0.2.0/PKG-INFO +288 -0
  2. classone-0.2.0/README.md +260 -0
  3. {classone-0.1.0 → classone-0.2.0}/pyproject.toml +9 -5
  4. {classone-0.1.0 → classone-0.2.0}/src/classone/__init__.py +50 -48
  5. classone-0.2.0/src/classone/adapter.py +14 -0
  6. {classone-0.1.0 → classone-0.2.0}/src/classone/modeling/loss.py +71 -14
  7. {classone-0.1.0 → classone-0.2.0}/src/classone/modeling/modeling_classone.py +562 -357
  8. {classone-0.1.0 → classone-0.2.0}/src/classone/schemas.py +155 -143
  9. {classone-0.1.0 → classone-0.2.0}/src/classone/sdk.py +347 -290
  10. {classone-0.1.0 → classone-0.2.0}/src/classone/server/app.py +45 -2
  11. {classone-0.1.0 → classone-0.2.0}/src/classone/tokenizer.py +283 -215
  12. {classone-0.1.0 → classone-0.2.0}/src/classone/train/trainer.py +452 -334
  13. classone-0.2.0/src/classone.egg-info/PKG-INFO +288 -0
  14. {classone-0.1.0 → classone-0.2.0}/src/classone.egg-info/SOURCES.txt +5 -0
  15. {classone-0.1.0 → classone-0.2.0}/src/classone.egg-info/requires.txt +4 -0
  16. classone-0.2.0/tests/test_benchmarks.py +160 -0
  17. classone-0.2.0/tests/test_gemma4_e4b_integration.py +129 -0
  18. {classone-0.1.0 → classone-0.2.0}/tests/test_loss.py +110 -69
  19. classone-0.2.0/tests/test_published.py +197 -0
  20. classone-0.2.0/tests/test_quantization.py +71 -0
  21. {classone-0.1.0 → classone-0.2.0}/tests/test_sdk.py +154 -114
  22. {classone-0.1.0 → classone-0.2.0}/tests/test_server.py +16 -0
  23. classone-0.1.0/PKG-INFO +0 -152
  24. classone-0.1.0/README.md +0 -127
  25. classone-0.1.0/src/classone.egg-info/PKG-INFO +0 -152
  26. {classone-0.1.0 → classone-0.2.0}/LICENSE +0 -0
  27. {classone-0.1.0 → classone-0.2.0}/setup.cfg +0 -0
  28. {classone-0.1.0 → classone-0.2.0}/src/classone/data/__init__.py +0 -0
  29. {classone-0.1.0 → classone-0.2.0}/src/classone/data/dataset.py +0 -0
  30. {classone-0.1.0 → classone-0.2.0}/src/classone/modeling/__init__.py +0 -0
  31. {classone-0.1.0 → classone-0.2.0}/src/classone/modeling/configuration_classone.py +0 -0
  32. {classone-0.1.0 → classone-0.2.0}/src/classone/server/__init__.py +0 -0
  33. {classone-0.1.0 → classone-0.2.0}/src/classone/train/__init__.py +0 -0
  34. {classone-0.1.0 → classone-0.2.0}/src/classone.egg-info/dependency_links.txt +0 -0
  35. {classone-0.1.0 → classone-0.2.0}/src/classone.egg-info/top_level.txt +0 -0
  36. {classone-0.1.0 → classone-0.2.0}/tests/test_dataset.py +0 -0
  37. {classone-0.1.0 → classone-0.2.0}/tests/test_gemma_integration.py +0 -0
  38. {classone-0.1.0 → classone-0.2.0}/tests/test_modeling.py +0 -0
  39. {classone-0.1.0 → classone-0.2.0}/tests/test_schemas.py +0 -0
  40. {classone-0.1.0 → classone-0.2.0}/tests/test_tokenizer.py +0 -0
  41. {classone-0.1.0 → classone-0.2.0}/tests/test_training.py +0 -0
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: classone
3
+ Version: 0.2.0
4
+ Summary: Open-source System 1 decision model architecture built on Gemma 4 and Qwen 3.5
5
+ Author: Thiago Gonzaga
6
+ Project-URL: Homepage, https://github.com/devops-thiago/class-one
7
+ Project-URL: Repository, https://github.com/devops-thiago/class-one
8
+ Project-URL: Issues, https://github.com/devops-thiago/class-one/issues
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: pydantic>=2.5.0
13
+ Requires-Dist: fastapi>=0.110.0
14
+ Requires-Dist: uvicorn>=0.28.0
15
+ Requires-Dist: torch>=2.2.0
16
+ Requires-Dist: transformers>=4.40.0
17
+ Requires-Dist: peft>=0.10.0
18
+ Requires-Dist: accelerate>=0.21.0
19
+ Requires-Dist: numpy>=1.26.0
20
+ Provides-Extra: quant
21
+ Requires-Dist: bitsandbytes>=0.43.0; extra == "quant"
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
24
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
25
+ Requires-Dist: httpx>=0.27.0; extra == "dev"
26
+ Requires-Dist: bitsandbytes>=0.43.0; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # ClassOne: System 1 Decision Model Architecture
30
+
31
+ [![CI](https://github.com/devops-thiago/class-one/actions/workflows/ci.yml/badge.svg)](https://github.com/devops-thiago/class-one/actions/workflows/ci.yml)
32
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
33
+ [![Hugging Face Models](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Models-yellow)](https://huggingface.co/devops-thiago)
34
+ [![Hugging Face Dataset](https://img.shields.io/badge/%F0%9F%A4%97%20Dataset-Curriculum%20(23.5k)-orange)](https://huggingface.co/datasets/devops-thiago/classone-system1-decision-curriculum)
35
+
36
+ **ClassOne** is an open-source **System 1 decision model architecture**. Rather than generating conversational prose token-by-token (System 2 mechanics), ClassOne performs rapid, deterministic, schema-constrained decision execution across classification, routing, verification, and scoring in a **single non-autoregressive forward pass**.
37
+
38
+ Inspired by Daniel Kahneman's cognitive framework in *Thinking, Fast and Slow* and strictly proper scoring rules (Brier, 1950; Gneiting & Raftery, 2007).
39
+
40
+ ---
41
+
42
+ ## Benchmark Highlights
43
+
44
+ ClassOne achieves state-of-the-art decision accuracy and probability calibration across the industry-standard **JevBench** (231 public tasks) and **RLCDAlignBench** (100 safety/alignment failure modes) benchmarks:
45
+
46
+ | Model Backbone | Effective Params | JevBench Easy (48) | JevBench Orig (72) | JevBench Hard (111) | JevBench Overall (231) | AlignBench SOTA (100) | p50 Latency (Edge GPU) |
47
+ | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
48
+ | **ClassOne Qwen 3.5 9B** | 9.0B | **100.0%** (0.000 ECE) | **97.2%** (0.032 ECE) | **60.4%** | **80.1% (185/231)** 🏆 | **60.1%** (0.594 AUROC) | 115.1 ms |
49
+ | **ClassOne Gemma 4 E4B** | 4.3B (Multimodal) | **100.0%** (0.006 ECE) | **90.3%** (0.097 ECE) | 46.9% | **70.1% (162/231)** | **63.3%** (0.604 AUROC) | 68.4 ms |
50
+ | **ClassOne Qwen 3.5 4B** | 4.0B | **100.0%** (0.000 ECE) | **95.8%** (0.046 ECE) | 40.5% | **70.1% (162/231)** | 55.3% (0.604 AUROC) | 61.1 ms |
51
+ | **ClassOne Gemma 4 E2B** | 2.0B | **100.0%** (0.006 ECE) | **90.3%** (0.097 ECE) | 46.9% | **70.1% (162/231)** | 56.2% (Record) | 44.8 ms |
52
+ | **ClassOne Qwen 3.5 2B** | 2.0B | **100.0%** (0.001 ECE) | **91.7%** (0.065 ECE) | 38.7% | **68.0% (157/231)** | 58.0% (0.568 AUROC) | **40.3 ms** |
53
+ | *TypeSafe Jev (Proprietary)* | Closed API | 97.9% | 88.9% | 40.5% | 67.5% (156/231) | — | ~850 ms (Network) |
54
+
55
+ ---
56
+
57
+ ## Key Architectural Innovations
58
+
59
+ 1. **Bilinear Interaction Scorer (`ChoiceHead`):**
60
+ Combines scaled dot-product attention with full non-linear bilinear matching:
61
+ $$\text{features} = [q;\, k;\, |q - k|;\, q \odot k], \quad \text{logits} = \frac{q \cdot k}{\sqrt{d}} + \text{MLP}(\text{features})$$
62
+ Enables deep interaction matching between prompt instructions and semantic candidate descriptions without sequence decode.
63
+ 2. **Question Preamble Conditioning:**
64
+ For documents $>600$ tokens, the prompt builder automatically injects `<|state_start|>\nTarget Objectives:\n...\n<|state_end|>` ahead of the state body, priming causal self-attention across all transformer layers to resolve hard multi-hop contract constraints.
65
+ 3. **2D / 4D Position-Invariant Attention Mask:**
66
+ Eliminates option-order recency bias by isolating candidate options during ingestion so choices attend only to the state and criteria without causally attending to earlier options.
67
+ 4. **Scale-Invariant Normalized Confidence:**
68
+ Computes calibrated confidence invariant to candidate set size:
69
+ $$\text{Confidence} = \frac{K \cdot P_{\max} - 1}{K - 1} \quad \text{for } K \text{ choices}$$
70
+ 5. **Precision Guard & Dynamic Quantization:**
71
+ Backbone weights support 4-bit NF4 and 8-bit dynamic quantization while decision heads remain strictly in **FP16 / FP32** to preserve calibrated probability margins.
72
+ 6. **Ultra-Low Latency CPU Containerization:**
73
+ Containerized execution on **2 vCPUs and 8GB RAM** achieves **2,097.15 tokens/sec** and **19.54 decisions/sec** at 754.6 ms median latency (0 GPUs, 0 GGUF).
74
+
75
+ ---
76
+
77
+ ## Training Methodology: RLCD (Reinforcement Learning for Calibrated Decisions)
78
+
79
+ ClassOne models are aligned using **Strictly Proper Scoring Rules** rather than open-ended conversational RLHF:
80
+
81
+ 1. **Multi-Objective RLCD Loss:**
82
+ $$\mathcal{L}_{\text{RLCD}} = \alpha \mathcal{L}_{\text{Focal}}(\gamma=2.0) + \beta \mathcal{L}_{\text{Brier}} + \lambda \mathcal{L}_{\text{Margin}}$$
83
+ - **Focal Log-Loss:** Down-weights easy examples and forces gradient updates to concentrate on hard decision boundaries.
84
+ - **Brier Score:** Penalizes probability deviation, mathematically guaranteeing that the model has zero incentive to hedge or hallucinate unwarranted overconfidence.
85
+ - **Contrastive Margin Penalty:** Directly penalizes decisions with sub-threshold logit separation between top-1 and distractor options.
86
+ 2. **Temperature Floor Clamping:**
87
+ Post-hoc temperature scaling prevents probability softening by enforcing empirical calibration floors:
88
+ $$T_{\text{noul}} \in [0.45, 0.60], \quad T_{\text{choice}} \in [0.45, 0.60], \quad T_{\text{score}} \in [0.55, 0.65]$$
89
+ 3. **Progressive Multi-Stage Curricula:**
90
+ Trained on a 23,500-sample human-curated curriculum spanning ContractNLI, CUAD, SciQ, Banking77, ToxicChat, XSTest, and Agentic boundary pairs.
91
+ 4. **Weight-Averaged Model Souping:**
92
+ Combines converged LoRA weights and decision heads across curriculum stages (`soup_heads_70.py`), yielding monotonic calibration and benchmark gains.
93
+
94
+ ---
95
+
96
+ ## Published Models on Hugging Face Hub
97
+
98
+ > [!TIP]
99
+ > Explore all published models and datasets in the official Hugging Face Collection:
100
+ > **[ClassOne System 1 Decision Models Collection](https://huggingface.co/collections/devops-thiago/classone-system-1-decision-models-6ac685b81e8bbfa51e646e21)**
101
+
102
+ | Repository ID | Base Model | Context | Formats |
103
+ | :--- | :--- | :--- | :--- |
104
+ | [`devops-thiago/classone-qwen3.5-9b`](https://huggingface.co/devops-thiago/classone-qwen3.5-9b) | Qwen/Qwen3.5-9B | 128k | BF16, 4-bit NF4, LoRA |
105
+ | [`devops-thiago/classone-gemma4-e4b`](https://huggingface.co/devops-thiago/classone-gemma4-e4b) | google/gemma-4-E4B-it | 128k | BF16, 4-bit NF4, LoRA |
106
+ | [`devops-thiago/classone-qwen3.5-4b`](https://huggingface.co/devops-thiago/classone-qwen3.5-4b) | Qwen/Qwen3.5-4B | 128k | BF16, 4-bit NF4, LoRA |
107
+ | [`devops-thiago/classone-gemma4-e2b`](https://huggingface.co/devops-thiago/classone-gemma4-e2b) | google/gemma-4-e2b-it | 128k | FP16, 8-bit, LoRA |
108
+ | [`devops-thiago/classone-qwen3.5-2b`](https://huggingface.co/devops-thiago/classone-qwen3.5-2b) | Qwen/Qwen3.5-2B | 128k | FP16, 8-bit, LoRA |
109
+
110
+ ---
111
+
112
+ ## Quickstart
113
+
114
+ ### 1. Installation
115
+
116
+ ```bash
117
+ git clone https://github.com/devops-thiago/class-one.git
118
+ cd class-one
119
+ python3 -m venv .venv
120
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
121
+ pip install -e ".[dev]"
122
+ ```
123
+
124
+ ### 2. Run Test Suite
125
+
126
+ ```bash
127
+ pytest tests/ -v
128
+ ```
129
+
130
+ ### 3. Start API Service
131
+
132
+ ```bash
133
+ uvicorn classone.server.app:app --host 0.0.0.0 --port 8000
134
+ ```
135
+
136
+ ### 4. Query via Python SDK
137
+
138
+ ```python
139
+ from classone import ClassOneClient, Choice, Noul, Score
140
+
141
+ with ClassOneClient(base_url="http://localhost:8000") as client:
142
+ response = client.decide(
143
+ state="Customer account was locked after three incorrect attempts within 15 minutes.",
144
+ questions={
145
+ "urgent": Noul(instructions="Is this an urgent security event?"),
146
+ "action": Choice(
147
+ instructions="Action required:",
148
+ criteria={
149
+ "unlock": "Send automated unlock verification link",
150
+ "escalate": "Escalate to SecOps fraud team",
151
+ },
152
+ ),
153
+ "severity": Score(instructions="Assess severity:", criteria=["low", "medium", "critical"]),
154
+ },
155
+ )
156
+
157
+ print("Urgent P(true):", response.nouls["urgent"].noul)
158
+ print("Action Choice:", response.choices["action"].choice)
159
+ print("Choice Margin:", response.choices["action"].margin)
160
+ print("Severity Score:", response.scores["severity"].score)
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Docker Deployment (2 vCPUs, 8GB RAM, Pure CPU)
166
+
167
+ Build and deploy the lean CPU container with zero GPU requirements:
168
+
169
+ ```bash
170
+ # 1. Build image (uses CPU-only PyTorch wheels)
171
+ docker build -t classone:cpu .
172
+
173
+ # 2. Run container constrained to 2 vCPUs and 8GB RAM
174
+ docker run -d --name classone-cpu \
175
+ --cpus=2 --memory=8g -p 8000:8000 \
176
+ -e CLASSONE_DEVICE=cpu \
177
+ -e CLASSONE_BASE_MODEL=/app/checkpoints/classone_cpu_q8.pt \
178
+ -v "$(pwd)/checkpoints:/app/checkpoints:ro" \
179
+ classone:cpu
180
+
181
+ # 3. Run parallel load benchmark (5 concurrent worker threads)
182
+ python scripts/benchmark_docker_cpu.py --url http://localhost:8000 --concurrency 5 --requests 50
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Evaluation & Benchmark Reproduction
188
+
189
+ ### 1. Official JevBench v1.6.1 Benchmark (4-Axis Harmonic Mean)
190
+
191
+ Evaluates chance-corrected Intelligence (equal type weighting across Choice, Noul, Score), multi-bin Expected Calibration Error, Speed (logarithmic latency scoring), and Cost (tariff per 1,000 decisions):
192
+
193
+ ```bash
194
+ # Evaluate Qwen 3.5 9B locally on GPU:
195
+ python scripts/eval_jevbench_v16.py --mode local
196
+
197
+ # Evaluate against live HTTP API endpoint:
198
+ python scripts/eval_jevbench_v16.py --mode api --endpoint http://127.0.0.1:8000/v1/decide
199
+ ```
200
+
201
+ **Official JevBench v1.6.1 Scorecard (ClassOne Qwen 3.5 9B):**
202
+
203
+ | Axis | Weight | Score (0–100) | Metric Details |
204
+ | :--- | :---: | :---: | :--- |
205
+ | **Composite Score** | **100%** | **73.48** 🏆 | Equal-weight 4-axis Harmonic Mean |
206
+ | **Capability Score** | — | **75.85** | Harmonic Mean of Intelligence & Calibration |
207
+ | **Axis 1: Intelligence** | 25% | **81.38** | Choice: 85.07 \| Noul: 84.07 \| Score: 75.00 |
208
+ | **Axis 2: Calibration** | 25% | **71.02** | ECE: 0.1549 \| Brier: 0.1596 |
209
+ | **Axis 3: Speed** | 25% | **89.01** | p50: 148.5 ms \| p95: 845.0 ms |
210
+ | **Axis 4: Cost** | 25% | **59.41** | $0.02253 per 1,000 decisions |
211
+
212
+ *Public Tiers: Easy 100.0% (48/48), Standard 97.2% (70/72), Hard 56.8% (63/111).*
213
+
214
+ ---
215
+
216
+ ### 2. Hugging Face Decision Index (`multimodalart/jev-decision-index`)
217
+
218
+ Evaluates decision quality across all 5 canonical capability domains and generates official submission manifests (`scores.json` and `index.json`):
219
+
220
+ ```bash
221
+ # Evaluate Qwen 3.5 9B locally on GPU:
222
+ python scripts/eval_decision_index.py --mode local
223
+
224
+ # Evaluate against live HTTP API endpoint:
225
+ python scripts/eval_decision_index.py --mode api --endpoint http://127.0.0.1:8000/v1/decide
226
+ ```
227
+
228
+ **Official Decision Index Results (ClassOne Qwen 3.5 9B):**
229
+
230
+ | Capability Domain | Official Weight | Domain Score | Raw Accuracy |
231
+ | :--- | :---: | :---: | :---: |
232
+ | **Knowledge & Verification** | 25.8% | **100.00** | 100.0% (10/10) |
233
+ | **Language & Policy Contracts** | 25.8% | **100.00** | 100.0% (10/10) |
234
+ | **Retrieval & Relevance Triage** | 20.0% | **100.00** | 100.0% (10/10) |
235
+ | **Tools & Execution Guardrails** | 18.3% | **100.00** | 100.0% (10/10) |
236
+ | **Rubric & Quality Scoring** | 10.1% | **100.00** | 100.0% (10/10) |
237
+ | **Overall Decision Index** | **100.0%** | **100.00** 🏆 | **Overall ECE: 0.0051** |
238
+
239
+ ---
240
+
241
+ ### 3. Additional Benchmark Suites
242
+
243
+ ```bash
244
+ # Evaluate RLCDAlignBench (100 alignment/safety failure modes):
245
+ python scripts/eval_rlcd_alignbench.py --model devops-thiago/classone-gemma4-e2b
246
+
247
+ # Verify all published Hugging Face models via SDK:
248
+ python scripts/test_all_hf_models_sdk.py
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Reference & Deep Dives
254
+
255
+ - **Architecture Specification:** [`ARCHITECTURE.md`](ARCHITECTURE.md)
256
+ - **Empirical Learnings & Plateau Analysis:** [`docs/empirical_learnings_and_plateau_analysis.md`](docs/empirical_learnings_and_plateau_analysis.md)
257
+ - **Docker CPU Benchmarks:** [`docs/docker_cpu_benchmarks.md`](docs/docker_cpu_benchmarks.md)
258
+ - **Hugging Face Collection:** [`devops-thiago/classone-system-1-decision-models`](https://huggingface.co/collections/devops-thiago/classone-system-1-decision-models-6ac685b81e8bbfa51e646e21)
259
+ - **Training Dataset Release:** [`devops-thiago/classone-system-one-curriculum`](https://huggingface.co/datasets/devops-thiago/classone-system-one-curriculum)
260
+
261
+ ---
262
+
263
+ ## Client SDKs & Package Distribution
264
+
265
+ ClassOne provides official client libraries across 6 languages with native HTTP transports, zero unnecessary dependencies, and type-safe probabilistic primitives (`Noul`, `Choice`, `Score`):
266
+
267
+ | Language | Package Registry | Installation / Dependency | Repository |
268
+ |---|---|---|---|
269
+ | **Python** | [PyPI (`classone`)](https://pypi.org/project/classone/) | `pip install classone` | Built-in (`src/classone/sdk`) |
270
+ | **Node.js / TS** | [npm (`@classone/sdk`)](https://www.npmjs.com/package/@classone/sdk) | `npm install @classone/sdk` | [`classone-sdks/nodejs`](https://github.com/devops-thiago/classone-sdks/tree/main/nodejs) |
271
+ | **Go** | [pkg.go.dev](https://pkg.go.dev/github.com/devops-thiago/classone-sdks/go) | `go get github.com/devops-thiago/classone-sdks/go@v0.1.1` | [`classone-sdks/go`](https://github.com/devops-thiago/classone-sdks/tree/main/go) |
272
+ | **Rust** | [crates.io (`classone`)](https://crates.io/crates/classone) | `cargo add classone` | [`classone-sdks/rust`](https://github.com/devops-thiago/classone-sdks/tree/main/rust) |
273
+ | **Java** | [Maven Central (`io.classone:classone-sdk`)](https://central.sonatype.com/artifact/io.classone/classone-sdk) | `implementation 'io.classone:classone-sdk:0.1.1'` | [`classone-sdks/java`](https://github.com/devops-thiago/classone-sdks/tree/main/java) |
274
+ | **Ruby** | [RubyGems (`classone`)](https://rubygems.org/gems/classone) | `gem install classone` | [`classone-sdks/ruby`](https://github.com/devops-thiago/classone-sdks/tree/main/ruby) |
275
+
276
+ To verify all SDKs against a running server:
277
+ ```bash
278
+ python scripts/test_all_sdks_live.py --url http://127.0.0.1:8000
279
+ python scripts/package_and_verify_all_sdks.py
280
+ ```
281
+
282
+ ---
283
+
284
+ ## License & Attribution
285
+
286
+ - Released under the [Apache 2.0 License](LICENSE).
287
+ - **Gemma** is a trademark of Google LLC and provided subject to the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).
288
+ - **Qwen** is developed by the Qwen Team at Alibaba Cloud and provided under the [Apache 2.0 License](https://github.com/QwenLM/Qwen2.5).
@@ -0,0 +1,260 @@
1
+ # ClassOne: System 1 Decision Model Architecture
2
+
3
+ [![CI](https://github.com/devops-thiago/class-one/actions/workflows/ci.yml/badge.svg)](https://github.com/devops-thiago/class-one/actions/workflows/ci.yml)
4
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
5
+ [![Hugging Face Models](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Models-yellow)](https://huggingface.co/devops-thiago)
6
+ [![Hugging Face Dataset](https://img.shields.io/badge/%F0%9F%A4%97%20Dataset-Curriculum%20(23.5k)-orange)](https://huggingface.co/datasets/devops-thiago/classone-system1-decision-curriculum)
7
+
8
+ **ClassOne** is an open-source **System 1 decision model architecture**. Rather than generating conversational prose token-by-token (System 2 mechanics), ClassOne performs rapid, deterministic, schema-constrained decision execution across classification, routing, verification, and scoring in a **single non-autoregressive forward pass**.
9
+
10
+ Inspired by Daniel Kahneman's cognitive framework in *Thinking, Fast and Slow* and strictly proper scoring rules (Brier, 1950; Gneiting & Raftery, 2007).
11
+
12
+ ---
13
+
14
+ ## Benchmark Highlights
15
+
16
+ ClassOne achieves state-of-the-art decision accuracy and probability calibration across the industry-standard **JevBench** (231 public tasks) and **RLCDAlignBench** (100 safety/alignment failure modes) benchmarks:
17
+
18
+ | Model Backbone | Effective Params | JevBench Easy (48) | JevBench Orig (72) | JevBench Hard (111) | JevBench Overall (231) | AlignBench SOTA (100) | p50 Latency (Edge GPU) |
19
+ | :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
20
+ | **ClassOne Qwen 3.5 9B** | 9.0B | **100.0%** (0.000 ECE) | **97.2%** (0.032 ECE) | **60.4%** | **80.1% (185/231)** 🏆 | **60.1%** (0.594 AUROC) | 115.1 ms |
21
+ | **ClassOne Gemma 4 E4B** | 4.3B (Multimodal) | **100.0%** (0.006 ECE) | **90.3%** (0.097 ECE) | 46.9% | **70.1% (162/231)** | **63.3%** (0.604 AUROC) | 68.4 ms |
22
+ | **ClassOne Qwen 3.5 4B** | 4.0B | **100.0%** (0.000 ECE) | **95.8%** (0.046 ECE) | 40.5% | **70.1% (162/231)** | 55.3% (0.604 AUROC) | 61.1 ms |
23
+ | **ClassOne Gemma 4 E2B** | 2.0B | **100.0%** (0.006 ECE) | **90.3%** (0.097 ECE) | 46.9% | **70.1% (162/231)** | 56.2% (Record) | 44.8 ms |
24
+ | **ClassOne Qwen 3.5 2B** | 2.0B | **100.0%** (0.001 ECE) | **91.7%** (0.065 ECE) | 38.7% | **68.0% (157/231)** | 58.0% (0.568 AUROC) | **40.3 ms** |
25
+ | *TypeSafe Jev (Proprietary)* | Closed API | 97.9% | 88.9% | 40.5% | 67.5% (156/231) | — | ~850 ms (Network) |
26
+
27
+ ---
28
+
29
+ ## Key Architectural Innovations
30
+
31
+ 1. **Bilinear Interaction Scorer (`ChoiceHead`):**
32
+ Combines scaled dot-product attention with full non-linear bilinear matching:
33
+ $$\text{features} = [q;\, k;\, |q - k|;\, q \odot k], \quad \text{logits} = \frac{q \cdot k}{\sqrt{d}} + \text{MLP}(\text{features})$$
34
+ Enables deep interaction matching between prompt instructions and semantic candidate descriptions without sequence decode.
35
+ 2. **Question Preamble Conditioning:**
36
+ For documents $>600$ tokens, the prompt builder automatically injects `<|state_start|>\nTarget Objectives:\n...\n<|state_end|>` ahead of the state body, priming causal self-attention across all transformer layers to resolve hard multi-hop contract constraints.
37
+ 3. **2D / 4D Position-Invariant Attention Mask:**
38
+ Eliminates option-order recency bias by isolating candidate options during ingestion so choices attend only to the state and criteria without causally attending to earlier options.
39
+ 4. **Scale-Invariant Normalized Confidence:**
40
+ Computes calibrated confidence invariant to candidate set size:
41
+ $$\text{Confidence} = \frac{K \cdot P_{\max} - 1}{K - 1} \quad \text{for } K \text{ choices}$$
42
+ 5. **Precision Guard & Dynamic Quantization:**
43
+ Backbone weights support 4-bit NF4 and 8-bit dynamic quantization while decision heads remain strictly in **FP16 / FP32** to preserve calibrated probability margins.
44
+ 6. **Ultra-Low Latency CPU Containerization:**
45
+ Containerized execution on **2 vCPUs and 8GB RAM** achieves **2,097.15 tokens/sec** and **19.54 decisions/sec** at 754.6 ms median latency (0 GPUs, 0 GGUF).
46
+
47
+ ---
48
+
49
+ ## Training Methodology: RLCD (Reinforcement Learning for Calibrated Decisions)
50
+
51
+ ClassOne models are aligned using **Strictly Proper Scoring Rules** rather than open-ended conversational RLHF:
52
+
53
+ 1. **Multi-Objective RLCD Loss:**
54
+ $$\mathcal{L}_{\text{RLCD}} = \alpha \mathcal{L}_{\text{Focal}}(\gamma=2.0) + \beta \mathcal{L}_{\text{Brier}} + \lambda \mathcal{L}_{\text{Margin}}$$
55
+ - **Focal Log-Loss:** Down-weights easy examples and forces gradient updates to concentrate on hard decision boundaries.
56
+ - **Brier Score:** Penalizes probability deviation, mathematically guaranteeing that the model has zero incentive to hedge or hallucinate unwarranted overconfidence.
57
+ - **Contrastive Margin Penalty:** Directly penalizes decisions with sub-threshold logit separation between top-1 and distractor options.
58
+ 2. **Temperature Floor Clamping:**
59
+ Post-hoc temperature scaling prevents probability softening by enforcing empirical calibration floors:
60
+ $$T_{\text{noul}} \in [0.45, 0.60], \quad T_{\text{choice}} \in [0.45, 0.60], \quad T_{\text{score}} \in [0.55, 0.65]$$
61
+ 3. **Progressive Multi-Stage Curricula:**
62
+ Trained on a 23,500-sample human-curated curriculum spanning ContractNLI, CUAD, SciQ, Banking77, ToxicChat, XSTest, and Agentic boundary pairs.
63
+ 4. **Weight-Averaged Model Souping:**
64
+ Combines converged LoRA weights and decision heads across curriculum stages (`soup_heads_70.py`), yielding monotonic calibration and benchmark gains.
65
+
66
+ ---
67
+
68
+ ## Published Models on Hugging Face Hub
69
+
70
+ > [!TIP]
71
+ > Explore all published models and datasets in the official Hugging Face Collection:
72
+ > **[ClassOne System 1 Decision Models Collection](https://huggingface.co/collections/devops-thiago/classone-system-1-decision-models-6ac685b81e8bbfa51e646e21)**
73
+
74
+ | Repository ID | Base Model | Context | Formats |
75
+ | :--- | :--- | :--- | :--- |
76
+ | [`devops-thiago/classone-qwen3.5-9b`](https://huggingface.co/devops-thiago/classone-qwen3.5-9b) | Qwen/Qwen3.5-9B | 128k | BF16, 4-bit NF4, LoRA |
77
+ | [`devops-thiago/classone-gemma4-e4b`](https://huggingface.co/devops-thiago/classone-gemma4-e4b) | google/gemma-4-E4B-it | 128k | BF16, 4-bit NF4, LoRA |
78
+ | [`devops-thiago/classone-qwen3.5-4b`](https://huggingface.co/devops-thiago/classone-qwen3.5-4b) | Qwen/Qwen3.5-4B | 128k | BF16, 4-bit NF4, LoRA |
79
+ | [`devops-thiago/classone-gemma4-e2b`](https://huggingface.co/devops-thiago/classone-gemma4-e2b) | google/gemma-4-e2b-it | 128k | FP16, 8-bit, LoRA |
80
+ | [`devops-thiago/classone-qwen3.5-2b`](https://huggingface.co/devops-thiago/classone-qwen3.5-2b) | Qwen/Qwen3.5-2B | 128k | FP16, 8-bit, LoRA |
81
+
82
+ ---
83
+
84
+ ## Quickstart
85
+
86
+ ### 1. Installation
87
+
88
+ ```bash
89
+ git clone https://github.com/devops-thiago/class-one.git
90
+ cd class-one
91
+ python3 -m venv .venv
92
+ source .venv/bin/activate # On Windows: .venv\Scripts\activate
93
+ pip install -e ".[dev]"
94
+ ```
95
+
96
+ ### 2. Run Test Suite
97
+
98
+ ```bash
99
+ pytest tests/ -v
100
+ ```
101
+
102
+ ### 3. Start API Service
103
+
104
+ ```bash
105
+ uvicorn classone.server.app:app --host 0.0.0.0 --port 8000
106
+ ```
107
+
108
+ ### 4. Query via Python SDK
109
+
110
+ ```python
111
+ from classone import ClassOneClient, Choice, Noul, Score
112
+
113
+ with ClassOneClient(base_url="http://localhost:8000") as client:
114
+ response = client.decide(
115
+ state="Customer account was locked after three incorrect attempts within 15 minutes.",
116
+ questions={
117
+ "urgent": Noul(instructions="Is this an urgent security event?"),
118
+ "action": Choice(
119
+ instructions="Action required:",
120
+ criteria={
121
+ "unlock": "Send automated unlock verification link",
122
+ "escalate": "Escalate to SecOps fraud team",
123
+ },
124
+ ),
125
+ "severity": Score(instructions="Assess severity:", criteria=["low", "medium", "critical"]),
126
+ },
127
+ )
128
+
129
+ print("Urgent P(true):", response.nouls["urgent"].noul)
130
+ print("Action Choice:", response.choices["action"].choice)
131
+ print("Choice Margin:", response.choices["action"].margin)
132
+ print("Severity Score:", response.scores["severity"].score)
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Docker Deployment (2 vCPUs, 8GB RAM, Pure CPU)
138
+
139
+ Build and deploy the lean CPU container with zero GPU requirements:
140
+
141
+ ```bash
142
+ # 1. Build image (uses CPU-only PyTorch wheels)
143
+ docker build -t classone:cpu .
144
+
145
+ # 2. Run container constrained to 2 vCPUs and 8GB RAM
146
+ docker run -d --name classone-cpu \
147
+ --cpus=2 --memory=8g -p 8000:8000 \
148
+ -e CLASSONE_DEVICE=cpu \
149
+ -e CLASSONE_BASE_MODEL=/app/checkpoints/classone_cpu_q8.pt \
150
+ -v "$(pwd)/checkpoints:/app/checkpoints:ro" \
151
+ classone:cpu
152
+
153
+ # 3. Run parallel load benchmark (5 concurrent worker threads)
154
+ python scripts/benchmark_docker_cpu.py --url http://localhost:8000 --concurrency 5 --requests 50
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Evaluation & Benchmark Reproduction
160
+
161
+ ### 1. Official JevBench v1.6.1 Benchmark (4-Axis Harmonic Mean)
162
+
163
+ Evaluates chance-corrected Intelligence (equal type weighting across Choice, Noul, Score), multi-bin Expected Calibration Error, Speed (logarithmic latency scoring), and Cost (tariff per 1,000 decisions):
164
+
165
+ ```bash
166
+ # Evaluate Qwen 3.5 9B locally on GPU:
167
+ python scripts/eval_jevbench_v16.py --mode local
168
+
169
+ # Evaluate against live HTTP API endpoint:
170
+ python scripts/eval_jevbench_v16.py --mode api --endpoint http://127.0.0.1:8000/v1/decide
171
+ ```
172
+
173
+ **Official JevBench v1.6.1 Scorecard (ClassOne Qwen 3.5 9B):**
174
+
175
+ | Axis | Weight | Score (0–100) | Metric Details |
176
+ | :--- | :---: | :---: | :--- |
177
+ | **Composite Score** | **100%** | **73.48** 🏆 | Equal-weight 4-axis Harmonic Mean |
178
+ | **Capability Score** | — | **75.85** | Harmonic Mean of Intelligence & Calibration |
179
+ | **Axis 1: Intelligence** | 25% | **81.38** | Choice: 85.07 \| Noul: 84.07 \| Score: 75.00 |
180
+ | **Axis 2: Calibration** | 25% | **71.02** | ECE: 0.1549 \| Brier: 0.1596 |
181
+ | **Axis 3: Speed** | 25% | **89.01** | p50: 148.5 ms \| p95: 845.0 ms |
182
+ | **Axis 4: Cost** | 25% | **59.41** | $0.02253 per 1,000 decisions |
183
+
184
+ *Public Tiers: Easy 100.0% (48/48), Standard 97.2% (70/72), Hard 56.8% (63/111).*
185
+
186
+ ---
187
+
188
+ ### 2. Hugging Face Decision Index (`multimodalart/jev-decision-index`)
189
+
190
+ Evaluates decision quality across all 5 canonical capability domains and generates official submission manifests (`scores.json` and `index.json`):
191
+
192
+ ```bash
193
+ # Evaluate Qwen 3.5 9B locally on GPU:
194
+ python scripts/eval_decision_index.py --mode local
195
+
196
+ # Evaluate against live HTTP API endpoint:
197
+ python scripts/eval_decision_index.py --mode api --endpoint http://127.0.0.1:8000/v1/decide
198
+ ```
199
+
200
+ **Official Decision Index Results (ClassOne Qwen 3.5 9B):**
201
+
202
+ | Capability Domain | Official Weight | Domain Score | Raw Accuracy |
203
+ | :--- | :---: | :---: | :---: |
204
+ | **Knowledge & Verification** | 25.8% | **100.00** | 100.0% (10/10) |
205
+ | **Language & Policy Contracts** | 25.8% | **100.00** | 100.0% (10/10) |
206
+ | **Retrieval & Relevance Triage** | 20.0% | **100.00** | 100.0% (10/10) |
207
+ | **Tools & Execution Guardrails** | 18.3% | **100.00** | 100.0% (10/10) |
208
+ | **Rubric & Quality Scoring** | 10.1% | **100.00** | 100.0% (10/10) |
209
+ | **Overall Decision Index** | **100.0%** | **100.00** 🏆 | **Overall ECE: 0.0051** |
210
+
211
+ ---
212
+
213
+ ### 3. Additional Benchmark Suites
214
+
215
+ ```bash
216
+ # Evaluate RLCDAlignBench (100 alignment/safety failure modes):
217
+ python scripts/eval_rlcd_alignbench.py --model devops-thiago/classone-gemma4-e2b
218
+
219
+ # Verify all published Hugging Face models via SDK:
220
+ python scripts/test_all_hf_models_sdk.py
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Reference & Deep Dives
226
+
227
+ - **Architecture Specification:** [`ARCHITECTURE.md`](ARCHITECTURE.md)
228
+ - **Empirical Learnings & Plateau Analysis:** [`docs/empirical_learnings_and_plateau_analysis.md`](docs/empirical_learnings_and_plateau_analysis.md)
229
+ - **Docker CPU Benchmarks:** [`docs/docker_cpu_benchmarks.md`](docs/docker_cpu_benchmarks.md)
230
+ - **Hugging Face Collection:** [`devops-thiago/classone-system-1-decision-models`](https://huggingface.co/collections/devops-thiago/classone-system-1-decision-models-6ac685b81e8bbfa51e646e21)
231
+ - **Training Dataset Release:** [`devops-thiago/classone-system-one-curriculum`](https://huggingface.co/datasets/devops-thiago/classone-system-one-curriculum)
232
+
233
+ ---
234
+
235
+ ## Client SDKs & Package Distribution
236
+
237
+ ClassOne provides official client libraries across 6 languages with native HTTP transports, zero unnecessary dependencies, and type-safe probabilistic primitives (`Noul`, `Choice`, `Score`):
238
+
239
+ | Language | Package Registry | Installation / Dependency | Repository |
240
+ |---|---|---|---|
241
+ | **Python** | [PyPI (`classone`)](https://pypi.org/project/classone/) | `pip install classone` | Built-in (`src/classone/sdk`) |
242
+ | **Node.js / TS** | [npm (`@classone/sdk`)](https://www.npmjs.com/package/@classone/sdk) | `npm install @classone/sdk` | [`classone-sdks/nodejs`](https://github.com/devops-thiago/classone-sdks/tree/main/nodejs) |
243
+ | **Go** | [pkg.go.dev](https://pkg.go.dev/github.com/devops-thiago/classone-sdks/go) | `go get github.com/devops-thiago/classone-sdks/go@v0.1.1` | [`classone-sdks/go`](https://github.com/devops-thiago/classone-sdks/tree/main/go) |
244
+ | **Rust** | [crates.io (`classone`)](https://crates.io/crates/classone) | `cargo add classone` | [`classone-sdks/rust`](https://github.com/devops-thiago/classone-sdks/tree/main/rust) |
245
+ | **Java** | [Maven Central (`io.classone:classone-sdk`)](https://central.sonatype.com/artifact/io.classone/classone-sdk) | `implementation 'io.classone:classone-sdk:0.1.1'` | [`classone-sdks/java`](https://github.com/devops-thiago/classone-sdks/tree/main/java) |
246
+ | **Ruby** | [RubyGems (`classone`)](https://rubygems.org/gems/classone) | `gem install classone` | [`classone-sdks/ruby`](https://github.com/devops-thiago/classone-sdks/tree/main/ruby) |
247
+
248
+ To verify all SDKs against a running server:
249
+ ```bash
250
+ python scripts/test_all_sdks_live.py --url http://127.0.0.1:8000
251
+ python scripts/package_and_verify_all_sdks.py
252
+ ```
253
+
254
+ ---
255
+
256
+ ## License & Attribution
257
+
258
+ - Released under the [Apache 2.0 License](LICENSE).
259
+ - **Gemma** is a trademark of Google LLC and provided subject to the [Gemma Terms of Use](https://ai.google.dev/gemma/terms).
260
+ - **Qwen** is developed by the Qwen Team at Alibaba Cloud and provided under the [Apache 2.0 License](https://github.com/QwenLM/Qwen2.5).
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "classone"
7
- version = "0.1.0"
8
- description = "Open-source System 1 decision model architecture built on Gemma 4 E2B"
7
+ version = "0.2.0"
8
+ description = "Open-source System 1 decision model architecture built on Gemma 4 and Qwen 3.5"
9
9
  readme = "README.md"
10
- authors = [{ name = "Thiago" }]
11
- requires-python = ">=3.10"
10
+ authors = [{ name = "Thiago Gonzaga" }]
11
+ requires-python = ">=3.11"
12
12
  dependencies = [
13
13
  "pydantic>=2.5.0",
14
14
  "fastapi>=0.110.0",
@@ -26,10 +26,14 @@ Repository = "https://github.com/devops-thiago/class-one"
26
26
  Issues = "https://github.com/devops-thiago/class-one/issues"
27
27
 
28
28
  [project.optional-dependencies]
29
+ quant = [
30
+ "bitsandbytes>=0.43.0",
31
+ ]
29
32
  dev = [
30
33
  "pytest>=8.0.0",
31
34
  "pytest-asyncio>=0.23.0",
32
35
  "httpx>=0.27.0",
36
+ "bitsandbytes>=0.43.0",
33
37
  ]
34
38
 
35
39
  [tool.setuptools.packages.find]
@@ -41,7 +45,7 @@ pythonpath = ["src"]
41
45
 
42
46
  [tool.ruff]
43
47
  line-length = 120
44
- target-version = "py310"
48
+ target-version = "py311"
45
49
 
46
50
  [tool.ruff.lint]
47
51
  select = ["E", "F", "I", "W", "UP"]