thx01 1.0.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.
thx01-1.0.0/LICENSE ADDED
@@ -0,0 +1,176 @@
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, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
thx01-1.0.0/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ THX-01
2
+ Copyright 2026 HAL-X AI
3
+
4
+ This product includes the mmBERT encoder (jhu-clsp/mmBERT-base). Post-training data, post-trained weights, the batched
5
+ runtime, tournament decoding, the REST server, the Doom demo and all benchmarks are by HAL-X AI.
thx01-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,328 @@
1
+ Metadata-Version: 2.4
2
+ Name: thx01
3
+ Version: 1.0.0
4
+ Summary: THX-01: calibrated, non-autoregressive typed decisions in one forward pass (100+ languages, Azerbaijani-first)
5
+ Author: Elturan Ahmadbayli
6
+ Author-email: Farid Aghayev <farid.a@hal-x.ai>
7
+ License: Apache-2.0
8
+ Project-URL: Homepage, https://huggingface.co/doofz/THX-01
9
+ Project-URL: Documentation, https://huggingface.co/doofz/THX-01#quickstart
10
+ Project-URL: API docs, https://api.hal-x.ai/docs/thx-01/
11
+ Keywords: decision model,classification,routing,calibration,multilingual,azerbaijani,extraction,llm routing,typesafe
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Text Processing :: Linguistic
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ License-File: NOTICE
22
+ Requires-Dist: torch>=2.0.0
23
+ Requires-Dist: transformers>=4.48.0
24
+ Requires-Dist: safetensors>=0.4.0
25
+ Requires-Dist: huggingface_hub>=0.20.0
26
+ Requires-Dist: numpy>=1.20.0
27
+ Provides-Extra: server
28
+ Requires-Dist: fastapi>=0.110; extra == "server"
29
+ Requires-Dist: uvicorn>=0.29; extra == "server"
30
+ Provides-Extra: doom
31
+ Requires-Dist: vizdoom>=1.2; extra == "doom"
32
+ Requires-Dist: pillow; extra == "doom"
33
+ Requires-Dist: fastapi>=0.110; extra == "doom"
34
+ Requires-Dist: uvicorn>=0.29; extra == "doom"
35
+ Dynamic: license-file
36
+
37
+ # THX-01
38
+
39
+ THX-01 is a non-autoregressive, multilingual decision model developed by HAL-X AI. Given a state (a message, ticket, e-mail,
40
+ document, JSON record or agent trace) and one or more typed questions written in natural language, it returns a calibrated
41
+ answer to every question in a single forward pass of about 10 ms on one GPU.
42
+
43
+ THX-01 is trained with large-scale Reinforcement Learning for Calibrated Decisions (RLCD): the reward is a strictly proper
44
+ scoring rule, so reporting honest probabilities is the only way to maximise it. Beyond choosing among options, THX-01 can
45
+ return numbers stated in a document, verbatim excerpts and supporting citations, through the same interface.
46
+
47
+ | | |
48
+ |---|---|
49
+ | Parameters | 322M (307M encoder, 15M decision head) |
50
+ | Encoder | mmBERT-base, 22 layers, 256k vocabulary |
51
+ | Input | up to 1,024 tokens per question (question, options and state); longer states are truncated |
52
+ | Post-training | eight large-scale RLCD stages, about 2.1 million training decisions |
53
+ | Languages | post-trained in 18 languages with emphasis on Azerbaijani; 100+ supported |
54
+ | Latency | about 10 ms per request, about 1 ms per decision when batched |
55
+ | License | Apache 2.0 |
56
+
57
+ ## Contents
58
+
59
+ 1. [Question types](https://huggingface.co/doofz/THX-01#question-types)
60
+ 2. [Quickstart](https://huggingface.co/doofz/THX-01#quickstart)
61
+ 3. [Benchmarks](https://huggingface.co/doofz/THX-01#benchmarks)
62
+ 4. [Method](https://huggingface.co/doofz/THX-01#method)
63
+ 5. [Training](https://huggingface.co/doofz/THX-01#training)
64
+ 6. [Languages](https://huggingface.co/doofz/THX-01#languages)
65
+ 7. [REST API](https://huggingface.co/doofz/THX-01#rest-api)
66
+ 8. [Limitations](https://huggingface.co/doofz/THX-01#limitations)
67
+ 9. [Citation](https://huggingface.co/doofz/THX-01#citation)
68
+
69
+ ## Question types
70
+
71
+ | type | returns | criteria |
72
+ |---|---|---|
73
+ | `choice` | one of N options with a probability for each | `{"key": "description", ...}` or a list |
74
+ | `noul` | P(yes) | optional |
75
+ | `score` | an ordinal level and its distribution | ordered list of levels |
76
+ | `number` | a numeric value stated in the document, or `null` if it is not stated | optional `min`, `max`, `precision` |
77
+ | `excerpt` | a verbatim span of the document with its character offsets | none |
78
+ | `"cite": true` (any question) | the parts of the document that support the answer, with probabilities | none |
79
+
80
+ `number`, `excerpt` and citations are native THX-01 capabilities. They are not part of the TypeSafe question types
81
+ (`choice`, `noul`, `score`), where they have to be emulated in the service layer with repeated `choice` calls.
82
+ THX-01 also answers such emulation calls (value-range buckets and document chunks) through its native lookup, so existing
83
+ service layers work unchanged.
84
+
85
+ `number` returns values exactly as written in the document, normalised (`1,2 mln` becomes `1200000`). It performs no unit
86
+ or currency conversion: a question about kilometres when the document states miles, or about euros when it states US
87
+ dollars, is answered with `null`. `excerpt` cuts its answer out of the document, so it cannot contain invented text.
88
+
89
+ ## Quickstart
90
+
91
+ ```python
92
+ import thx01
93
+
94
+ agent = thx01.load("doofz/THX-01") # GPU if available
95
+
96
+ doc = ("Northwind Corp. reported Q3 2026 results. Revenue for the quarter was $48.3 million, up 14%. "
97
+ "Net income was $6.2 million, compared with $4.1 million a year ago. "
98
+ '"We will open two offices in Baku," said CEO Laura Chen.')
99
+
100
+ result = agent.decide(doc, {
101
+ "kind": {"type": "choice", "question": "What is this document?",
102
+ "criteria": {"earnings": "earnings report", "complaint": "customer complaint", "invoice": "invoice"}},
103
+ "revenue": {"type": "number", "question": "What was the revenue, in US dollars?", "cite": True},
104
+ "quote": {"type": "excerpt", "question": "What did the CEO say?"},
105
+ })
106
+ # kind -> earnings, revenue -> 48300000 (+ the supporting sentence),
107
+ # quote -> verbatim span starting "We will open two offices in Baku"
108
+ ```
109
+
110
+ Install from PyPI (the weights download from this repository on first use):
111
+
112
+ ```bash
113
+ pip install thx01 # library
114
+ pip install "thx01[server]" # plus the REST server
115
+ ```
116
+
117
+ ## Benchmarks
118
+
119
+ ### Support-ticket classification
120
+
121
+ Fifteen categories (billing, refund, login, technical bug, outage, delivery, order change, product question, account change,
122
+ security and fraud, data privacy, complaint, feature request, integration and API, contract and legal), four test sets with
123
+ 2,843 tickets in Azerbaijani, Russian, English and Turkish: Clean, Corrupted (transliteration, removed diacritics, typos,
124
+ noise), Messy (written messy on purpose) and Independent (written by GPT-6-Luna, never used for training).
125
+
126
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/thx01_ticket_bars.png" width="100%" />
127
+
128
+ | model | Clean | Corrupted | Messy | Independent | Avg | ECE | latency |
129
+ |---|---|---|---|---|---|---|---|
130
+ | **THX-01** | 99.2 | 97.7 | 98.8 | 97.9 | 98.4 | 0.003 | ~10 ms |
131
+ | Claude Sonnet 5.5 † | 98.5 | 98.0 | 98.5 | 99.0 | 98.5 | – | 1.5 s |
132
+ | Wahoo 1.5 | 99.8 | 96.3 | 98.0 | 97.2 | 97.8 | – | 145 ms |
133
+ | GPT-6-Luna | 98.6 | 97.4 | 96.7 | 98.2 | 97.7 | – | 1.9 s |
134
+ | TypeSafe Jev 1.13 | 99.2 | 95.0 | 96.2 | 99.0 | 97.4 | 0.007 | 331 ms |
135
+ | Kev-4B | 96.1 | 88.4 | 90.8 | 95.8 | 92.8 | 0.202 | 830 ms |
136
+
137
+ † Evaluated on a stratified subset of 200 tickets per set. ECE is measured on the Independent set; LLMs return no
138
+ probabilities. THX-01 latency on one GPU; other models through their APIs.
139
+
140
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/robustness.png" width="100%" />
141
+
142
+ ### Extraction and citation
143
+
144
+ Held-out multilingual documents (earnings reports, invoices, customs declarations, contracts, news, e-mails): 1,824 number
145
+ questions and 1,357 excerpt questions. Number tasks report exact-value accuracy, excerpt tasks token F1, citation the
146
+ accuracy of the top supporting part.
147
+
148
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/thx01_extraction.png" width="100%" />
149
+
150
+ | task | previous checkpoint | THX-01 |
151
+ |---|---|---|
152
+ | Number lookup | 69.6 | **93.4** |
153
+ | Number via range buckets (service-layer emulation) | 0.0 | **95.1** |
154
+ | Excerpt extraction (F1) | 20.1 | **84.1** |
155
+ | Excerpt via document chunks (F1) | 8.9 | **83.8** |
156
+ | Reference citation | 12.7 | **94.0** |
157
+
158
+ On number lookup over the same documents, TypeSafe Jev 1.13 reaches 96.6%.
159
+
160
+ ### Calibration and selective automation
161
+
162
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/reliability.png" width="100%" />
163
+
164
+ Because confidence is calibrated, a threshold turns it into an operating policy: THX-01 handles about three quarters of all
165
+ tickets automatically without a single error on any of the four sets, and 90% of tickets at an accuracy of at least 99.5%.
166
+
167
+ <p float="left">
168
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/coverage.png" width="49%" />
169
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/latency.png" width="49%" />
170
+ </p>
171
+
172
+ ### Multilingual decision suite
173
+
174
+ Thirty-nine held-out tasks: LLM routing, held-out synthetic schemas in 16 languages, MASSIVE scenarios and intents,
175
+ SIB-200 topic classification in ten languages, AG News, Banking77, SMS spam, DAIR Emotion and Azerbaijani app reviews.
176
+ Mean accuracy rises from 58.3% at initialisation to **84.2%**, and mean ECE falls from
177
+ 0.204 to **0.066**. Hand-written LLM routing reaches 100%.
178
+
179
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/suite.png" width="100%" />
180
+
181
+ <details>
182
+ <summary>All 39 tasks</summary>
183
+
184
+ | task | initialisation | THX-01 | ECE |
185
+ |---|---|---|---|
186
+ | LLM routing (hand-written) | 30.9 | 100.0 | 0.060 |
187
+ | Synthetic routing (held-out schemas) | 33.2 | 95.6 | 0.020 |
188
+ | Synthetic decisions (held-out schemas) | 53.4 | 87.8 | 0.025 |
189
+ | Synthetic guard (held-out schemas) | 66.9 | 96.8 | 0.024 |
190
+ | Synthetic taxonomy (held-out schemas) | 36.0 | 90.6 | 0.035 |
191
+ | Synthetic emotion (held-out schemas) | 58.6 | 96.4 | 0.051 |
192
+ | AG News (4) | 94.1 | 92.3 | 0.018 |
193
+ | DAIR Emotion (6) | 43.4 | 44.6 | 0.284 |
194
+ | Banking77 (77) | 51.7 | 65.9 | 0.087 |
195
+ | SMS spam (yes/no) | 73.5 | 87.3 | 0.048 |
196
+ | AZ app-review sentiment | 73.5 | 87.0 | 0.072 |
197
+ | MASSIVE-intent@20 (az) | 36.3 | 89.7 | 0.038 |
198
+ | Intent yes/no (az) | 65.2 | 95.2 | 0.017 |
199
+ | MASSIVE-intent@20 (en) | 61.9 | 93.5 | 0.041 |
200
+ | Intent yes/no (en) | 66.7 | 95.3 | 0.017 |
201
+ | MASSIVE-scenario (en) | 69.4 | 90.8 | 0.049 |
202
+ | MASSIVE-scenario (az) | 41.6 | 88.8 | 0.052 |
203
+ | MASSIVE-scenario (ru) | 57.6 | 89.8 | 0.039 |
204
+ | MASSIVE-scenario (tr) | 50.2 | 87.4 | 0.055 |
205
+ | MASSIVE-scenario (de) | 56.4 | 88.2 | 0.050 |
206
+ | MASSIVE-scenario (fr) | 59.8 | 90.4 | 0.044 |
207
+ | MASSIVE-scenario (es) | 55.0 | 87.8 | 0.040 |
208
+ | MASSIVE-scenario (ar) | 43.8 | 82.2 | 0.050 |
209
+ | MASSIVE-scenario (hi) | 46.2 | 85.4 | 0.037 |
210
+ | MASSIVE-scenario (zh-CN) | 61.0 | 87.2 | 0.060 |
211
+ | MASSIVE-scenario (fa) | 46.6 | 89.0 | 0.052 |
212
+ | MASSIVE-scenario (ka) | 16.8 | 78.0 | 0.060 |
213
+ | MASSIVE-scenario (ja) | 59.2 | 91.8 | 0.043 |
214
+ | MASSIVE-scenario (ko) | 48.8 | 86.4 | 0.039 |
215
+ | SIB-200 (az) | 67.2 | 73.5 | 0.111 |
216
+ | SIB-200 (en) | 78.4 | 78.4 | 0.068 |
217
+ | SIB-200 (ru) | 75.5 | 76.0 | 0.082 |
218
+ | SIB-200 (tr) | 74.0 | 73.5 | 0.126 |
219
+ | SIB-200 (de) | 75.5 | 79.9 | 0.080 |
220
+ | SIB-200 (ar) | 73.0 | 76.5 | 0.076 |
221
+ | SIB-200 (hi) | 67.2 | 69.6 | 0.132 |
222
+ | SIB-200 (zh) | 77.9 | 77.9 | 0.082 |
223
+ | SIB-200 (kk) | 68.6 | 68.1 | 0.158 |
224
+ | SIB-200 (uz) | 58.3 | 70.1 | 0.145 |
225
+
226
+ </details>
227
+
228
+ ### Speed
229
+
230
+ | workload | time on one GPU |
231
+ |---|---|
232
+ | one question | about 9 ms |
233
+ | three questions about the same state | about 10 ms |
234
+ | 150 requests batched | about 156 ms |
235
+ | peak throughput | about 3,000 decisions per second |
236
+
237
+ ## Method
238
+
239
+ Every question is serialised as `[CLS] question [MASK] option 1 [MASK] option 2 ... [SEP] state`. The encoder reads the
240
+ whole sequence at once; a two-layer decision head scores each option at its own `[MASK]` position, and a softmax with a
241
+ temperature fitted per question type and option count gives calibrated probabilities. All questions of a request are
242
+ scored in one batched pass. Questions with more than 24 options are decided by a two-round tournament.
243
+
244
+ ### Reinforcement Learning for Calibrated Decisions
245
+
246
+ Each question is a one-step game: the policy reports a distribution q over the options, the outcome y is revealed, and the
247
+ reward is
248
+
249
+ R(q, t) = sum_k t_k log q_k + 0.5 * (sum_k t_k q_k) / ||q||_2 - 1[ordinal] * RPS(q, t)
250
+
251
+ a combination of the logarithmic, spherical and ranked-probability scores. Because the reward is strictly proper, its
252
+ expectation is maximised only when the reported distribution equals the true one. THX-01 optimises the expected reward with
253
+ an exact, zero-variance gradient. Soft targets teach two further behaviours: a uniform target when no option applies (so
254
+ the model reports uncertainty instead of a confident wrong answer) and near-miss credit on ordinal scales.
255
+
256
+ ## Training
257
+
258
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/training.png" width="100%" />
259
+
260
+ | stage | focus | decisions per epoch |
261
+ |---|---|---|
262
+ | S1 | broad multilingual RLCD: synthetic decisions in 16 languages, MASSIVE in 14 languages, Azerbaijani sentiment | 157,912 (x2) |
263
+ | S2 | spatial and control decisions | 53,040 |
264
+ | S3 | LLM and agent routing | 48,000 |
265
+ | S4 | generic skills: bare-key options, identifier lookup, no-good-option honesty | 77,000 |
266
+ | S5 | robustness and domain: 600 new business taxonomies, confusable pairs, transliteration and noise, support tickets | 213,961 (x2) |
267
+ | S6 | boundary cases between confusable categories, three teacher models | 284,207 |
268
+ | S7 | weight interpolation and temperature refit | – |
269
+ | S8 | extraction and citation: numbers, excerpts, supporting parts, currency equivalence, new hard decisions, full replay | 493,442 |
270
+
271
+ Training data combines curated data from the HAL-X data team, public benchmarks' training splits and verified synthetic
272
+ data. Synthetic items are generated label-first by teacher models (Wahoo 1.5, GPT-6-Luna, Claude Sonnet 5.5) and kept only
273
+ when a blind second pass agrees; test items and their near-duplicates are excluded from training. Optimisation uses 8-bit
274
+ AdamW, bf16, length-bucketed batches, random option order and option subsets, and a frozen token-embedding matrix that
275
+ preserves the encoder's coverage of more than 1,800 pretraining languages.
276
+
277
+ <img src="https://huggingface.co/doofz/THX-01/resolve/main/assets/progression.png" width="60%" />
278
+
279
+ ## Languages
280
+
281
+ Post-training covers Azerbaijani, English, Russian, Turkish, German, French, Spanish, Arabic, Hindi, Chinese, Persian,
282
+ Georgian, Japanese, Korean, Ukrainian, Kazakh, Uzbek and Italian, with Azerbaijani the largest language in every synthetic
283
+ component. A dedicated curriculum covers the way text is actually typed in the region: Azerbaijani without its letters
284
+ (e for the schwa, s for s-cedilla, c for c-cedilla), Russian in Latin transliteration, and code-mixing of Azerbaijani,
285
+ Russian and English. Through its encoder THX-01 supports more than 100 languages.
286
+
287
+ | model | Independent az | ru | en | Corrupted az | ru | en |
288
+ |---|---|---|---|---|---|---|
289
+ | **THX-01** | 97.1 | 98.3 | 98.3 | 97.9 | 96.6 | 97.9 |
290
+ | Claude Sonnet 5.5 † | 98.5 | 100.0 | 98.5 | 97.6 | 100.0 | 97.5 |
291
+ | Wahoo 1.5 | 96.2 | 95.8 | 99.6 | 94.5 | 95.0 | 98.9 |
292
+ | GPT-6-Luna | 97.9 | 97.5 | 99.2 | 97.2 | 95.0 | 98.6 |
293
+ | TypeSafe Jev 1.13 | 98.8 | 98.3 | 100.0 | 92.9 | 93.3 | 98.2 |
294
+ | Kev-4B | 94.2 | 95.4 | 97.9 | 83.1 | 89.1 | 94.3 |
295
+
296
+ ## REST API
297
+
298
+ ```bash
299
+ pip install "thx01[server]"
300
+ THX01_MODEL=doofz/THX-01 THX01_API_KEY=your-key python -m thx01.server --port 8095
301
+ ```
302
+
303
+ `POST /v1/decide` (alias `POST /v1/systemone`, TypeSafe-compatible) takes `{"state": ..., "questions": {...}}` and returns
304
+ `{"answers": {...}, "latency_ms": ...}`; `POST /v1/decide/batch` (alias `/v1/systemone/batch`) takes `{"items": [...]}`.
305
+ The state may be a string or an object with a `document` field; the question text may be given as `instructions` or
306
+ `question`. Requests are micro-batched on the GPU.
307
+
308
+ ## Limitations
309
+
310
+ - Fine-grained intent sets with many near-synonymous labels remain hard: Banking77 (77 intents) reaches 65.9%.
311
+ - Emotion with six overlapping classes (DAIR Emotion) reaches 44.6%; the model reports correspondingly low confidence.
312
+ - `number` and `excerpt` locate text that is present in the document; they do not perform arithmetic, unit conversion or
313
+ paraphrase.
314
+
315
+ ## Citation
316
+
317
+ ```bibtex
318
+ @techreport{thx01_2026,
319
+ title = {THX-01: Large-Scale Reinforcement Learning for Calibrated Decisions in 100+ Languages},
320
+ author = {Aghayev, Farid and Ahmadbayli, Elturan},
321
+ institution = {HAL-X AI},
322
+ year = {2026}
323
+ }
324
+ ```
325
+
326
+ ## License
327
+
328
+ Apache License 2.0. See [LICENSE](https://huggingface.co/doofz/THX-01/blob/main/LICENSE) and [NOTICE](https://huggingface.co/doofz/THX-01/blob/main/NOTICE).