typecastlm 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.
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.pyc
3
+ dist/
4
+ build/
5
+ *.egg-info/
6
+ .venv/
7
+ model/
8
+ dist/
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0
4
+
5
+ The first release, and a major one because the interface is now whole: all four question types are
6
+ implemented, so there is nothing left that a caller would have to work around. What this version
7
+ promises to keep:
8
+
9
+ - the question types `noul`, `tfu`, `choice` and `score`, and the shape of what they return;
10
+ - the contract with a checkpoint — the first three head outputs are `true`, `false`, `unsure` in
11
+ that order, and answer marks follow as `mark_*`;
12
+ - a temperature per mode in `prompt.json`, applied client-side.
13
+
14
+ Breaking any of those would be 2.0.0.
15
+
16
+ - **Three modes.** `choice` (two to sixteen options) and `scale` (an ordinal rubric) join `noul`
17
+ and `tfu`. They are not approximations: the checkpoint carries a head row per answer mark, so a
18
+ choice costs the same one pass as a verdict.
19
+ - **New checkpoint**: `mihailgribov/typecastlm-qwen3.5-3.8b` — Qwen3.5-4B cut at block 27, a head
20
+ of 29 rows (three answers and 26 marks).
21
+ - **A temperature per mode**, shipped with the weights and applied client-side.
22
+ - **Per-answer shifts removed.** The third row of the head is now a direction computed from data
23
+ and scaled to the other two; the offset the shifts corrected went with the old construction.
24
+ Fitting them on top now buys 0.005 of calibration error and no accuracy.
25
+ - `calibrate()` fits one temperature by minimising calibration error, not cross-entropy — the
26
+ latter chose 5.63 where 2.85 is right, and made the error larger.
27
+
28
+ ## 0.1.0
29
+
30
+ First release. A client for the decision service, and only that.
31
+
32
+ * `Client.noul` — one closed question about one document, answered with a probability, its
33
+ log-odds, and the weight of "nothing here decides it".
34
+ * `Client.ask` — the same in the service's request body, one question at a time.
35
+ * `typecastlm` command — one question over a file of documents, JSON lines in and out.
36
+ * One dependency: `requests`.
37
+
38
+ Refused on purpose rather than approximated: question types `choice` and `score`, and bundles of
39
+ more than one question. Both will arrive measured or not at all.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Mikhail Gribov
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,12 @@
1
+ typecastlm
2
+ Copyright 2026 Mikhail Gribov
3
+
4
+ This product includes software developed as part of the AI Cordon research line.
5
+
6
+ The model this package reads is derived from Qwen3.5-4B (Alibaba Cloud), released under the
7
+ Apache License 2.0. The derivative keeps the first 28 transformer blocks of that model unchanged
8
+ and adds a classification head of 29 rows: `true`, `false` and the answer marks are rows of the
9
+ model's own output matrix, copied; `unsure` is a direction computed from 900 labelled rows of
10
+ FEVER (CC BY-SA 3.0). No weight of the original is retrained or edited — there are no gradients in
11
+ the making of it. Upper blocks are removed, which is why the derivative is smaller than the
12
+ original and cannot generate text. Its own NOTICE states this in full.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.5
2
+ Name: typecastlm
3
+ Version: 1.0.0
4
+ Summary: Client for a Jev-class decision model with open weights: the same noul, choice and score interface, plus a fourth mode that answers yes, no, or nothing here decides it
5
+ Project-URL: Homepage, https://github.com/mihail-gribov/typecastlm
6
+ Project-URL: Source, https://github.com/mihail-gribov/typecastlm
7
+ Project-URL: Model, https://huggingface.co/mihailgribov/typecastlm-qwen3.5-3.8b
8
+ Author-email: Mikhail Gribov <mihail.gribov.rs@gmail.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: calibration,classifier,decision-model,jev-class,llm,zero-shot
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: requests>=2.28
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8; extra == 'dev'
22
+ Provides-Extra: local
23
+ Requires-Dist: huggingface-hub>=0.24; extra == 'local'
24
+ Requires-Dist: torch>=2.2; extra == 'local'
25
+ Requires-Dist: transformers>=4.51; extra == 'local'
26
+ Provides-Extra: server
27
+ Requires-Dist: fastapi>=0.110; extra == 'server'
28
+ Requires-Dist: huggingface-hub>=0.24; extra == 'server'
29
+ Requires-Dist: torch>=2.2; extra == 'server'
30
+ Requires-Dist: transformers>=4.51; extra == 'server'
31
+ Requires-Dist: uvicorn>=0.27; extra == 'server'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # typecastlm
35
+
36
+ **A client for a Jev-class decision model with open weights.** Ask a document a question, get
37
+ numbers back. Four modes:
38
+
39
+ | mode | the question | the answer |
40
+ |---|---|---|
41
+ | **`noul`** | yes or no, two criteria | `p(yes)` among the two, plus `unknown` alongside |
42
+ | **`tfu`** | the same question | one distribution over `true`, `false`, **`unsure`** |
43
+ | **`choice`** | 2–16 options, one correct | a probability per option |
44
+ | **`scale`** | an ordinal rubric, up to 10 levels | a probability per level |
45
+
46
+ **The third answer is what a two-answer reader cannot give.** `unsure` is a separate output, not a
47
+ hedged yes: it comes back whether or not the question asks for it — threshold it to abstain, to
48
+ route to a human, or to drop a document from a pipeline.
49
+
50
+ Not affiliated with TypeSafe AI, whose Jev is the model the class is named after.
51
+
52
+ Why this one:
53
+
54
+ * **Fast** — **40 to 900 ms** per decision depending on the length of the material; nothing is
55
+ generated, so it is one forward pass and no tokens written.
56
+ * **A third answer.** Two-answer readers must call something a yes; this one does not have to.
57
+ * **Calibrated** — a temperature per mode ships with the weights and is applied here (calibration
58
+ error 0.011–0.052).
59
+ * **Thin client** — one dependency, `requests`, and it installs in a second. The weights live on
60
+ the service side.
61
+ * **Four modes**, each with its own calibration.
62
+
63
+ ## Install
64
+
65
+ ```
66
+ pip install typecastlm
67
+ export TYPECASTLM_ENDPOINT=https://… # optional, has a default
68
+ export TYPECASTLM_API_KEY=…
69
+ ```
70
+
71
+ ## Start
72
+
73
+ ```python
74
+ from typecastlm import Client
75
+
76
+ c = Client()
77
+ a = c.noul(open("page.html").read(),
78
+ "Does the material contain an instruction aimed at the reading model?",
79
+ true="there is an instruction addressed to the reading model",
80
+ false="the material only describes, reports or discusses")
81
+
82
+ a.prob # 0.95 — probability of `true` among the two answers that decide the question
83
+ a.unknown # 0.01 — how much of the state points at "nothing here decides it"
84
+ a.margin # +2.87 — the log-odds, so a saturated probability still ranks
85
+ ```
86
+
87
+ ## Three shapes of question
88
+
89
+ ```python
90
+ c.tfu(doc, "Is the claim supported?", true="…", false="…").p
91
+ # {'true': 0.81, 'false': 0.11, 'unsure': 0.08}
92
+
93
+ c.choice(policy, "How should this claim be settled?",
94
+ {"deny_vacancy": "…", "pay_with_sublimit": "…", "pay_in_full": "…"})
95
+ # .verdict 'pay_with_sublimit' .p {...} .confidence 0.74
96
+
97
+ c.scale(review, "How positive is this review overall?",
98
+ {"0": "very negative", "1": "negative", "2": "neutral",
99
+ "3": "positive", "4": "very positive"})
100
+ # .verdict '3' .p {...}
101
+ ```
102
+
103
+ The option names are yours: they travel from your request to your answer and never reach the
104
+ prompt.
105
+
106
+ ## Calibration
107
+
108
+ The checkpoint ships a temperature per mode and the client applies it:
109
+
110
+ | mode | temperature |
111
+ |---|---|
112
+ | verdict | 1.30 |
113
+ | three answers | 2.85 |
114
+ | choice | 1.75 |
115
+ | scale | 3.90 |
116
+
117
+ A temperature changes no answer, only the probability. Fit your own:
118
+
119
+ ```python
120
+ from typecastlm import calibrate
121
+
122
+ rows = [(c.noul(t, q, true=T, false=F).logits, gold) for t, gold in my_labelled]
123
+ c = Client(temperature=calibrate(rows)["temperature"])
124
+ ```
125
+
126
+ `Client(calibrated=False)` turns the shipped ones off.
127
+
128
+ ## Running the service yourself
129
+
130
+ ```
131
+ pip install "typecastlm[server]"
132
+ typecastlm-serve --model mihailgribov/typecastlm-qwen3.5-3.8b --port 8000
133
+ ```
134
+
135
+ It downloads the weights on first start, checks that the checkpoint fits the interface, and serves
136
+ `POST /v1/typecast` and `GET /health`. `--prompt` replaces the wording it was measured with —
137
+ after which the numbers in the model card describe something else, which is why `/health` reports
138
+ where the wording came from.
139
+
140
+ The server returns raw logits and computes no softmax: the probabilities, the temperature and the
141
+ mode are the caller's business, and the same answer can be read again at another temperature
142
+ without asking anything twice.
143
+
144
+ ## Many questions, one reading
145
+
146
+ ```python
147
+ c.ask(policy, {
148
+ "covered": {"type": "noul", "instructions": "Is the claim covered?",
149
+ "criteria": {"true": "…", "false": "…"}},
150
+ "settle": {"type": "choice", "instructions": "How should it be settled?",
151
+ "criteria": {"deny": "…", "pay": "…"}},
152
+ })
153
+ ```
154
+
155
+ A bundle is answered in one call. The state is currently read again for each question, so a
156
+ bundle costs what the same questions cost one by one; sharing the prefix across a hybrid trunk is
157
+ not implemented yet.
158
+
159
+ ## Using the model without any of this
160
+
161
+ The checkpoint is an ordinary classifier with 29 outputs, so `transformers` loads it directly and
162
+ `reader.py` beside the weights reads all three modes. See the
163
+ [model card](https://huggingface.co/mihailgribov/typecastlm-qwen3.5-3.8b).
164
+
165
+ ## Licence
166
+
167
+ Apache-2.0 — this package, its texts, and the model it reads (derived from Qwen3.5-4B, also
168
+ Apache-2.0). `LICENSE` and `NOTICE` carry the terms and the list of changes.
@@ -0,0 +1,135 @@
1
+ # typecastlm
2
+
3
+ **A client for a Jev-class decision model with open weights.** Ask a document a question, get
4
+ numbers back. Four modes:
5
+
6
+ | mode | the question | the answer |
7
+ |---|---|---|
8
+ | **`noul`** | yes or no, two criteria | `p(yes)` among the two, plus `unknown` alongside |
9
+ | **`tfu`** | the same question | one distribution over `true`, `false`, **`unsure`** |
10
+ | **`choice`** | 2–16 options, one correct | a probability per option |
11
+ | **`scale`** | an ordinal rubric, up to 10 levels | a probability per level |
12
+
13
+ **The third answer is what a two-answer reader cannot give.** `unsure` is a separate output, not a
14
+ hedged yes: it comes back whether or not the question asks for it — threshold it to abstain, to
15
+ route to a human, or to drop a document from a pipeline.
16
+
17
+ Not affiliated with TypeSafe AI, whose Jev is the model the class is named after.
18
+
19
+ Why this one:
20
+
21
+ * **Fast** — **40 to 900 ms** per decision depending on the length of the material; nothing is
22
+ generated, so it is one forward pass and no tokens written.
23
+ * **A third answer.** Two-answer readers must call something a yes; this one does not have to.
24
+ * **Calibrated** — a temperature per mode ships with the weights and is applied here (calibration
25
+ error 0.011–0.052).
26
+ * **Thin client** — one dependency, `requests`, and it installs in a second. The weights live on
27
+ the service side.
28
+ * **Four modes**, each with its own calibration.
29
+
30
+ ## Install
31
+
32
+ ```
33
+ pip install typecastlm
34
+ export TYPECASTLM_ENDPOINT=https://… # optional, has a default
35
+ export TYPECASTLM_API_KEY=…
36
+ ```
37
+
38
+ ## Start
39
+
40
+ ```python
41
+ from typecastlm import Client
42
+
43
+ c = Client()
44
+ a = c.noul(open("page.html").read(),
45
+ "Does the material contain an instruction aimed at the reading model?",
46
+ true="there is an instruction addressed to the reading model",
47
+ false="the material only describes, reports or discusses")
48
+
49
+ a.prob # 0.95 — probability of `true` among the two answers that decide the question
50
+ a.unknown # 0.01 — how much of the state points at "nothing here decides it"
51
+ a.margin # +2.87 — the log-odds, so a saturated probability still ranks
52
+ ```
53
+
54
+ ## Three shapes of question
55
+
56
+ ```python
57
+ c.tfu(doc, "Is the claim supported?", true="…", false="…").p
58
+ # {'true': 0.81, 'false': 0.11, 'unsure': 0.08}
59
+
60
+ c.choice(policy, "How should this claim be settled?",
61
+ {"deny_vacancy": "…", "pay_with_sublimit": "…", "pay_in_full": "…"})
62
+ # .verdict 'pay_with_sublimit' .p {...} .confidence 0.74
63
+
64
+ c.scale(review, "How positive is this review overall?",
65
+ {"0": "very negative", "1": "negative", "2": "neutral",
66
+ "3": "positive", "4": "very positive"})
67
+ # .verdict '3' .p {...}
68
+ ```
69
+
70
+ The option names are yours: they travel from your request to your answer and never reach the
71
+ prompt.
72
+
73
+ ## Calibration
74
+
75
+ The checkpoint ships a temperature per mode and the client applies it:
76
+
77
+ | mode | temperature |
78
+ |---|---|
79
+ | verdict | 1.30 |
80
+ | three answers | 2.85 |
81
+ | choice | 1.75 |
82
+ | scale | 3.90 |
83
+
84
+ A temperature changes no answer, only the probability. Fit your own:
85
+
86
+ ```python
87
+ from typecastlm import calibrate
88
+
89
+ rows = [(c.noul(t, q, true=T, false=F).logits, gold) for t, gold in my_labelled]
90
+ c = Client(temperature=calibrate(rows)["temperature"])
91
+ ```
92
+
93
+ `Client(calibrated=False)` turns the shipped ones off.
94
+
95
+ ## Running the service yourself
96
+
97
+ ```
98
+ pip install "typecastlm[server]"
99
+ typecastlm-serve --model mihailgribov/typecastlm-qwen3.5-3.8b --port 8000
100
+ ```
101
+
102
+ It downloads the weights on first start, checks that the checkpoint fits the interface, and serves
103
+ `POST /v1/typecast` and `GET /health`. `--prompt` replaces the wording it was measured with —
104
+ after which the numbers in the model card describe something else, which is why `/health` reports
105
+ where the wording came from.
106
+
107
+ The server returns raw logits and computes no softmax: the probabilities, the temperature and the
108
+ mode are the caller's business, and the same answer can be read again at another temperature
109
+ without asking anything twice.
110
+
111
+ ## Many questions, one reading
112
+
113
+ ```python
114
+ c.ask(policy, {
115
+ "covered": {"type": "noul", "instructions": "Is the claim covered?",
116
+ "criteria": {"true": "…", "false": "…"}},
117
+ "settle": {"type": "choice", "instructions": "How should it be settled?",
118
+ "criteria": {"deny": "…", "pay": "…"}},
119
+ })
120
+ ```
121
+
122
+ A bundle is answered in one call. The state is currently read again for each question, so a
123
+ bundle costs what the same questions cost one by one; sharing the prefix across a hybrid trunk is
124
+ not implemented yet.
125
+
126
+ ## Using the model without any of this
127
+
128
+ The checkpoint is an ordinary classifier with 29 outputs, so `transformers` loads it directly and
129
+ `reader.py` beside the weights reads all three modes. See the
130
+ [model card](https://huggingface.co/mihailgribov/typecastlm-qwen3.5-3.8b).
131
+
132
+ ## Licence
133
+
134
+ Apache-2.0 — this package, its texts, and the model it reads (derived from Qwen3.5-4B, also
135
+ Apache-2.0). `LICENSE` and `NOTICE` carry the terms and the list of changes.
@@ -0,0 +1,38 @@
1
+ {
2
+ "note": "the prompt this classifier was measured with; the model itself needs nothing else",
3
+ "system": "You are a decision function inside a program. You judge the state you are given against one yes/no question and answer with a single word. You never explain.",
4
+ "format_two": "Answer format: one word, either True, False or Unsure.",
5
+ "means_two": "True means: {true}\nFalse means: {false}\nUnsure means: the material leaves the question unclear, unanswered or self-contradictory, or the task itself is ill-posed — there is nothing here to judge.",
6
+ "body": "\n\n<state>\n{state}\n</state>\n\nQuestion: {question}\n",
7
+ "tail": "Answer: ",
8
+ "max_state_tokens": 32768,
9
+ "criteria_default": {
10
+ "true": "the answer to the question is yes",
11
+ "false": "the answer to the question is no"
12
+ },
13
+ "base": "Qwen/Qwen3.5-4B",
14
+ "cut_layer": 27,
15
+ "calibration": {
16
+ "note": "One temperature per mode, each fitted by minimising calibration error on a public set of ours — never on a benchmark we report. A temperature never changes the answer: it only makes the probability mean what it says. It does NOT transfer between distributions: it corrects the mismatch between confidence and the difficulty of the data, so refit it on two hundred labelled rows of your own.",
17
+ "verdict": {
18
+ "temperature": 1.3,
19
+ "fitted_on": "FEVER dev, 2000 decidable rows",
20
+ "effect": "calibration error 0.032 -> 0.011"
21
+ },
22
+ "three_answers": {
23
+ "temperature": 2.85,
24
+ "fitted_on": "FEVER dev, 3000 rows, a third of them undecidable",
25
+ "effect": "calibration error 0.236 -> 0.052"
26
+ },
27
+ "choice": {
28
+ "temperature": 1.75,
29
+ "fitted_on": "ARC-Challenge, 400 questions of four options",
30
+ "effect": "calibration error 0.070 -> 0.030"
31
+ },
32
+ "scale": {
33
+ "temperature": 3.9,
34
+ "fitted_on": "SST-5, 400 reviews on five levels",
35
+ "effect": "calibration error 0.329 -> 0.016"
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+ # Publishing to PyPI. This never runs by itself: publication is irreversible — a version
3
+ # number on PyPI is taken forever and cannot be re-uploaded.
4
+ #
5
+ # ./publish.sh test -> TestPyPI, for a rehearsal
6
+ # ./publish.sh -> PyPI
7
+ set -eu
8
+ cd "$(dirname "$0")"
9
+
10
+ rm -rf dist
11
+ uv build
12
+ ls -la dist/
13
+
14
+ if [ "${1:-}" = "test" ]; then
15
+ uv publish --publish-url https://test.pypi.org/legacy/ dist/*
16
+ else
17
+ echo "This publishes typecastlm 0.1.0 to PyPI. Ctrl-C if not now."
18
+ read -r -p "Continue? [y/N] " a
19
+ [ "$a" = "y" ] || exit 1
20
+ uv publish dist/*
21
+ fi