classone 0.1.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.
- classone-0.1.0/LICENSE +189 -0
- classone-0.1.0/PKG-INFO +152 -0
- classone-0.1.0/README.md +127 -0
- classone-0.1.0/pyproject.toml +49 -0
- classone-0.1.0/setup.cfg +4 -0
- classone-0.1.0/src/classone/__init__.py +48 -0
- classone-0.1.0/src/classone/data/__init__.py +1 -0
- classone-0.1.0/src/classone/data/dataset.py +175 -0
- classone-0.1.0/src/classone/modeling/__init__.py +27 -0
- classone-0.1.0/src/classone/modeling/configuration_classone.py +29 -0
- classone-0.1.0/src/classone/modeling/loss.py +131 -0
- classone-0.1.0/src/classone/modeling/modeling_classone.py +357 -0
- classone-0.1.0/src/classone/schemas.py +143 -0
- classone-0.1.0/src/classone/sdk.py +290 -0
- classone-0.1.0/src/classone/server/__init__.py +1 -0
- classone-0.1.0/src/classone/server/app.py +131 -0
- classone-0.1.0/src/classone/tokenizer.py +215 -0
- classone-0.1.0/src/classone/train/__init__.py +1 -0
- classone-0.1.0/src/classone/train/trainer.py +334 -0
- classone-0.1.0/src/classone.egg-info/PKG-INFO +152 -0
- classone-0.1.0/src/classone.egg-info/SOURCES.txt +31 -0
- classone-0.1.0/src/classone.egg-info/dependency_links.txt +1 -0
- classone-0.1.0/src/classone.egg-info/requires.txt +13 -0
- classone-0.1.0/src/classone.egg-info/top_level.txt +1 -0
- classone-0.1.0/tests/test_dataset.py +141 -0
- classone-0.1.0/tests/test_gemma_integration.py +97 -0
- classone-0.1.0/tests/test_loss.py +69 -0
- classone-0.1.0/tests/test_modeling.py +141 -0
- classone-0.1.0/tests/test_schemas.py +82 -0
- classone-0.1.0/tests/test_sdk.py +114 -0
- classone-0.1.0/tests/test_server.py +107 -0
- classone-0.1.0/tests/test_tokenizer.py +80 -0
- classone-0.1.0/tests/test_training.py +173 -0
classone-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, You must include a readable copy of the
|
|
108
|
+
attribution notices contained within such NOTICE file,
|
|
109
|
+
excluding those notices that do not pertain to any part of
|
|
110
|
+
the Derivative Works, in at least one of the following places:
|
|
111
|
+
within a NOTICE text file distributed as part of the Derivative
|
|
112
|
+
Works; within the Source form or documentation, if provided
|
|
113
|
+
along with the Derivative Works; or, within a display generated
|
|
114
|
+
by the Derivative Works, if and wherever such third-party
|
|
115
|
+
notices normally appear. The contents of the NOTICE file are
|
|
116
|
+
for informational purposes only and do not modify the License.
|
|
117
|
+
You may add Your own attribution notices within Derivative
|
|
118
|
+
Works that You distribute, alongside or as an addendum to the
|
|
119
|
+
NOTICE text from the Work, provided that such additional
|
|
120
|
+
attribution notices cannot be construed as modifying the License.
|
|
121
|
+
|
|
122
|
+
You may add Your own copyright statement to Your modifications and
|
|
123
|
+
may provide additional or different license terms and conditions
|
|
124
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
125
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
126
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
127
|
+
the conditions stated in this License.
|
|
128
|
+
|
|
129
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
130
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
131
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
132
|
+
this License, without any additional terms or conditions.
|
|
133
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
134
|
+
the terms of any separate license agreement you may have executed
|
|
135
|
+
with Licensor regarding such Contributions.
|
|
136
|
+
|
|
137
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
138
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
139
|
+
except as required for reasonable and customary use in describing the
|
|
140
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
141
|
+
|
|
142
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
143
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
144
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
145
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
146
|
+
implied, including, without limitation, any warranties or conditions
|
|
147
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
148
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
149
|
+
appropriateness of using or redistributing the Work and assume any
|
|
150
|
+
risks associated with Your exercise of permissions under this License.
|
|
151
|
+
|
|
152
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
153
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
154
|
+
unless required by applicable law (such as deliberate and grossly
|
|
155
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
156
|
+
liable to You for damages, including any direct, indirect, special,
|
|
157
|
+
incidental, or consequential damages of any character arising as a
|
|
158
|
+
result of this License or out of the use or inability to use the
|
|
159
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
160
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
161
|
+
other commercial damages or losses), even if such Contributor
|
|
162
|
+
has been advised of the possibility of such damages.
|
|
163
|
+
|
|
164
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
165
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
166
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
167
|
+
or other liability obligations and/or rights consistent with this
|
|
168
|
+
License. However, in accepting such obligations, You may act only
|
|
169
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
170
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
171
|
+
defend, and hold each Contributor harmless for any liability
|
|
172
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
173
|
+
of your accepting any such warranty or additional liability.
|
|
174
|
+
|
|
175
|
+
END OF TERMS AND CONDITIONS
|
|
176
|
+
|
|
177
|
+
Copyright 2026 ClassOne Contributors
|
|
178
|
+
|
|
179
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
180
|
+
you may not use this file except in compliance with the License.
|
|
181
|
+
You may obtain a copy of the License at
|
|
182
|
+
|
|
183
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
184
|
+
|
|
185
|
+
Unless required by applicable law or agreed to in writing, software
|
|
186
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
187
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
188
|
+
See the License for the specific language governing permissions and
|
|
189
|
+
limitations under the License.
|
classone-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: classone
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Open-source System 1 decision model architecture built on Gemma 4 E2B
|
|
5
|
+
Author: Thiago
|
|
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.10
|
|
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: dev
|
|
21
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
23
|
+
Requires-Dist: httpx>=0.27.0; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# ClassOne: System 1 Decision Model Architecture
|
|
27
|
+
|
|
28
|
+
[](https://github.com/devops-thiago/class-one/actions/workflows/ci.yml)
|
|
29
|
+
[](LICENSE)
|
|
30
|
+
|
|
31
|
+
**ClassOne** is an open-source **System 1 decision model architecture** built on Google's **Gemma 4 E2B** (Effective 2B). It provides rapid, non-autoregressive, schema-constrained decision execution for classification, routing, verification, and scoring in a single forward pass.
|
|
32
|
+
|
|
33
|
+
Inspired by Daniel Kahneman's cognitive framework in *Thinking, Fast and Slow* and modern proper scoring rules (Brier, 1950; Gneiting & Raftery, 2007).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Key Features
|
|
38
|
+
|
|
39
|
+
- **System 1 Architecture:** Non-autoregressive decision model. Skips open-ended token generation entirely.
|
|
40
|
+
- **Single-Pass Parallel Evaluation:** Evaluates multiple typed questions (`Noul`, `Choice`, `Score`) simultaneously in a single forward pass over unstructured state (<10ms on MPS, <50ms on edge GPU).
|
|
41
|
+
- **Zero Structural Hallucinations:** Constrained by design to valid schema outputs.
|
|
42
|
+
- **Calibrated Probabilities (RLCD):** Trained and scored using Strictly Proper Scoring Rules (normalized Brier score + Negative Log-Likelihood) to penalize overconfidence.
|
|
43
|
+
- **Dual API Endpoints:** Exposes `POST /v1/decide` and `POST /v1/classone` for schema-out decision queries.
|
|
44
|
+
- **Python Client SDK:** Idiomatic synchronous and asynchronous client library (`from classone import ClassOneClient`).
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Quickstart
|
|
49
|
+
|
|
50
|
+
### 1. Installation
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/devops-thiago/class-one.git
|
|
54
|
+
cd class-one
|
|
55
|
+
python3 -m venv .venv
|
|
56
|
+
source .venv/bin/activate
|
|
57
|
+
pip install -e ".[dev]"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Run Test Suite
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pytest tests/
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Start the API Server
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uvicorn classone.server.app:app --host 0.0.0.0 --port 8000
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. Query via HTTP
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
curl -X POST http://localhost:8000/v1/classone \
|
|
76
|
+
-H "Content-Type: application/json" \
|
|
77
|
+
-d '{
|
|
78
|
+
"model": "class-one-gemma-4-e2b",
|
|
79
|
+
"state": {
|
|
80
|
+
"message": "I was double billed for my subscription."
|
|
81
|
+
},
|
|
82
|
+
"questions": {
|
|
83
|
+
"refund": {
|
|
84
|
+
"type": "noul",
|
|
85
|
+
"instructions": "Is customer asking for a refund?"
|
|
86
|
+
},
|
|
87
|
+
"routing": {
|
|
88
|
+
"type": "choice",
|
|
89
|
+
"instructions": "Which department?",
|
|
90
|
+
"criteria": {
|
|
91
|
+
"billing": "Charges and payouts",
|
|
92
|
+
"technical": "App bugs and crashes"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"urgency": {
|
|
96
|
+
"type": "score",
|
|
97
|
+
"instructions": "Ticket urgency",
|
|
98
|
+
"criteria": ["low", "normal", "critical"]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 5. Python SDK Usage
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from classone import ClassOneClient, Choice, Noul, Score
|
|
108
|
+
|
|
109
|
+
with ClassOneClient(base_url="http://localhost:8000") as client:
|
|
110
|
+
response = client.decide(
|
|
111
|
+
state="Customer account was locked after three incorrect attempts.",
|
|
112
|
+
questions={
|
|
113
|
+
"urgent": Noul(instructions="Is this an urgent security event?"),
|
|
114
|
+
"action": Choice(
|
|
115
|
+
instructions="Action required:",
|
|
116
|
+
criteria={"unlock": "Send unlock link", "escalate": "Escalate to SecOps"}
|
|
117
|
+
),
|
|
118
|
+
"severity": Score(
|
|
119
|
+
instructions="Assess severity:",
|
|
120
|
+
criteria=["low", "medium", "critical"]
|
|
121
|
+
),
|
|
122
|
+
}
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
print("Urgent P(true):", response.nouls["urgent"].noul)
|
|
126
|
+
print("Action Choice:", response.choices["action"].choice)
|
|
127
|
+
print("Severity Score:", response.scores["severity"].score)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## CLI Utilities
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Run single-pass decision inference on Gemma:
|
|
136
|
+
python scripts/run_classone.py --model google/gemma-2-2b-it --device auto
|
|
137
|
+
|
|
138
|
+
# Benchmark latency vs traditional autoregressive LLMs:
|
|
139
|
+
python scripts/benchmark_latency.py --iterations 30
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Reference
|
|
145
|
+
- **Architecture:** [`ARCHITECTURE.md`](ARCHITECTURE.md)
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Legal & Attribution Notices
|
|
150
|
+
|
|
151
|
+
- Gemma is a trademark of Google LLC.
|
|
152
|
+
- Gemma is provided under and subject to the Gemma Terms of Use found at [ai.google.dev/gemma/terms](https://ai.google.dev/gemma/terms).
|
classone-0.1.0/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# ClassOne: System 1 Decision Model Architecture
|
|
2
|
+
|
|
3
|
+
[](https://github.com/devops-thiago/class-one/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
**ClassOne** is an open-source **System 1 decision model architecture** built on Google's **Gemma 4 E2B** (Effective 2B). It provides rapid, non-autoregressive, schema-constrained decision execution for classification, routing, verification, and scoring in a single forward pass.
|
|
7
|
+
|
|
8
|
+
Inspired by Daniel Kahneman's cognitive framework in *Thinking, Fast and Slow* and modern proper scoring rules (Brier, 1950; Gneiting & Raftery, 2007).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Key Features
|
|
13
|
+
|
|
14
|
+
- **System 1 Architecture:** Non-autoregressive decision model. Skips open-ended token generation entirely.
|
|
15
|
+
- **Single-Pass Parallel Evaluation:** Evaluates multiple typed questions (`Noul`, `Choice`, `Score`) simultaneously in a single forward pass over unstructured state (<10ms on MPS, <50ms on edge GPU).
|
|
16
|
+
- **Zero Structural Hallucinations:** Constrained by design to valid schema outputs.
|
|
17
|
+
- **Calibrated Probabilities (RLCD):** Trained and scored using Strictly Proper Scoring Rules (normalized Brier score + Negative Log-Likelihood) to penalize overconfidence.
|
|
18
|
+
- **Dual API Endpoints:** Exposes `POST /v1/decide` and `POST /v1/classone` for schema-out decision queries.
|
|
19
|
+
- **Python Client SDK:** Idiomatic synchronous and asynchronous client library (`from classone import ClassOneClient`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
### 1. Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/devops-thiago/class-one.git
|
|
29
|
+
cd class-one
|
|
30
|
+
python3 -m venv .venv
|
|
31
|
+
source .venv/bin/activate
|
|
32
|
+
pip install -e ".[dev]"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Run Test Suite
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pytest tests/
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Start the API Server
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uvicorn classone.server.app:app --host 0.0.0.0 --port 8000
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 4. Query via HTTP
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
curl -X POST http://localhost:8000/v1/classone \
|
|
51
|
+
-H "Content-Type: application/json" \
|
|
52
|
+
-d '{
|
|
53
|
+
"model": "class-one-gemma-4-e2b",
|
|
54
|
+
"state": {
|
|
55
|
+
"message": "I was double billed for my subscription."
|
|
56
|
+
},
|
|
57
|
+
"questions": {
|
|
58
|
+
"refund": {
|
|
59
|
+
"type": "noul",
|
|
60
|
+
"instructions": "Is customer asking for a refund?"
|
|
61
|
+
},
|
|
62
|
+
"routing": {
|
|
63
|
+
"type": "choice",
|
|
64
|
+
"instructions": "Which department?",
|
|
65
|
+
"criteria": {
|
|
66
|
+
"billing": "Charges and payouts",
|
|
67
|
+
"technical": "App bugs and crashes"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"urgency": {
|
|
71
|
+
"type": "score",
|
|
72
|
+
"instructions": "Ticket urgency",
|
|
73
|
+
"criteria": ["low", "normal", "critical"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 5. Python SDK Usage
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from classone import ClassOneClient, Choice, Noul, Score
|
|
83
|
+
|
|
84
|
+
with ClassOneClient(base_url="http://localhost:8000") as client:
|
|
85
|
+
response = client.decide(
|
|
86
|
+
state="Customer account was locked after three incorrect attempts.",
|
|
87
|
+
questions={
|
|
88
|
+
"urgent": Noul(instructions="Is this an urgent security event?"),
|
|
89
|
+
"action": Choice(
|
|
90
|
+
instructions="Action required:",
|
|
91
|
+
criteria={"unlock": "Send unlock link", "escalate": "Escalate to SecOps"}
|
|
92
|
+
),
|
|
93
|
+
"severity": Score(
|
|
94
|
+
instructions="Assess severity:",
|
|
95
|
+
criteria=["low", "medium", "critical"]
|
|
96
|
+
),
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
print("Urgent P(true):", response.nouls["urgent"].noul)
|
|
101
|
+
print("Action Choice:", response.choices["action"].choice)
|
|
102
|
+
print("Severity Score:", response.scores["severity"].score)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## CLI Utilities
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Run single-pass decision inference on Gemma:
|
|
111
|
+
python scripts/run_classone.py --model google/gemma-2-2b-it --device auto
|
|
112
|
+
|
|
113
|
+
# Benchmark latency vs traditional autoregressive LLMs:
|
|
114
|
+
python scripts/benchmark_latency.py --iterations 30
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Reference
|
|
120
|
+
- **Architecture:** [`ARCHITECTURE.md`](ARCHITECTURE.md)
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Legal & Attribution Notices
|
|
125
|
+
|
|
126
|
+
- Gemma is a trademark of Google LLC.
|
|
127
|
+
- Gemma is provided under and subject to the Gemma Terms of Use found at [ai.google.dev/gemma/terms](https://ai.google.dev/gemma/terms).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=65.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "classone"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Open-source System 1 decision model architecture built on Gemma 4 E2B"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{ name = "Thiago" }]
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"pydantic>=2.5.0",
|
|
14
|
+
"fastapi>=0.110.0",
|
|
15
|
+
"uvicorn>=0.28.0",
|
|
16
|
+
"torch>=2.2.0",
|
|
17
|
+
"transformers>=4.40.0",
|
|
18
|
+
"peft>=0.10.0",
|
|
19
|
+
"accelerate>=0.21.0",
|
|
20
|
+
"numpy>=1.26.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/devops-thiago/class-one"
|
|
25
|
+
Repository = "https://github.com/devops-thiago/class-one"
|
|
26
|
+
Issues = "https://github.com/devops-thiago/class-one/issues"
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
dev = [
|
|
30
|
+
"pytest>=8.0.0",
|
|
31
|
+
"pytest-asyncio>=0.23.0",
|
|
32
|
+
"httpx>=0.27.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[tool.setuptools.packages.find]
|
|
36
|
+
where = ["src"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
testpaths = ["tests"]
|
|
40
|
+
pythonpath = ["src"]
|
|
41
|
+
|
|
42
|
+
[tool.ruff]
|
|
43
|
+
line-length = 120
|
|
44
|
+
target-version = "py310"
|
|
45
|
+
|
|
46
|
+
[tool.ruff.lint]
|
|
47
|
+
select = ["E", "F", "I", "W", "UP"]
|
|
48
|
+
ignore = ["UP007", "E501"]
|
|
49
|
+
|
classone-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""ClassOne: Open-source System 1 Decision Model Architecture built on Gemma 4 E2B."""
|
|
2
|
+
|
|
3
|
+
from classone.modeling import ClassOneConfig, ClassOneModel
|
|
4
|
+
from classone.schemas import (
|
|
5
|
+
ChoiceQuestion,
|
|
6
|
+
ChoiceResult,
|
|
7
|
+
DecisionRequest,
|
|
8
|
+
DecisionResponse,
|
|
9
|
+
DecisionUsage,
|
|
10
|
+
NoulQuestion,
|
|
11
|
+
NoulResult,
|
|
12
|
+
ScoreQuestion,
|
|
13
|
+
ScoreResult,
|
|
14
|
+
)
|
|
15
|
+
from classone.sdk import (
|
|
16
|
+
AsyncClassOneClient,
|
|
17
|
+
Choice,
|
|
18
|
+
ChoiceAnswer,
|
|
19
|
+
ClassOneClient,
|
|
20
|
+
ClassOneResponse,
|
|
21
|
+
Noul,
|
|
22
|
+
NoulAnswer,
|
|
23
|
+
Score,
|
|
24
|
+
ScoreAnswer,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"Choice",
|
|
29
|
+
"ChoiceAnswer",
|
|
30
|
+
"ChoiceQuestion",
|
|
31
|
+
"ChoiceResult",
|
|
32
|
+
"ClassOneClient",
|
|
33
|
+
"AsyncClassOneClient",
|
|
34
|
+
"ClassOneConfig",
|
|
35
|
+
"ClassOneModel",
|
|
36
|
+
"ClassOneResponse",
|
|
37
|
+
"DecisionRequest",
|
|
38
|
+
"DecisionResponse",
|
|
39
|
+
"DecisionUsage",
|
|
40
|
+
"Noul",
|
|
41
|
+
"NoulAnswer",
|
|
42
|
+
"NoulQuestion",
|
|
43
|
+
"NoulResult",
|
|
44
|
+
"Score",
|
|
45
|
+
"ScoreAnswer",
|
|
46
|
+
"ScoreQuestion",
|
|
47
|
+
"ScoreResult",
|
|
48
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Data handling and formatting pipelines for ClassOne."""
|