sciev 0.2.1__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.
- sciev-0.2.1/LICENSE +186 -0
- sciev-0.2.1/PKG-INFO +196 -0
- sciev-0.2.1/README.md +163 -0
- sciev-0.2.1/pyproject.toml +50 -0
- sciev-0.2.1/sciev/__init__.py +6 -0
- sciev-0.2.1/sciev/calibration.py +644 -0
- sciev-0.2.1/sciev/dapt.py +187 -0
- sciev-0.2.1/sciev/data.py +422 -0
- sciev-0.2.1/sciev/decisions.py +258 -0
- sciev-0.2.1/sciev/eval.py +816 -0
- sciev-0.2.1/sciev/inference.py +473 -0
- sciev-0.2.1/sciev/metrics.py +268 -0
- sciev-0.2.1/sciev/model.py +455 -0
- sciev-0.2.1/sciev/protocol.py +287 -0
- sciev-0.2.1/sciev/readout.py +139 -0
- sciev-0.2.1/sciev/serve.py +228 -0
- sciev-0.2.1/sciev/train.py +479 -0
- sciev-0.2.1/sciev.egg-info/PKG-INFO +196 -0
- sciev-0.2.1/sciev.egg-info/SOURCES.txt +32 -0
- sciev-0.2.1/sciev.egg-info/dependency_links.txt +1 -0
- sciev-0.2.1/sciev.egg-info/requires.txt +11 -0
- sciev-0.2.1/sciev.egg-info/top_level.txt +1 -0
- sciev-0.2.1/setup.cfg +4 -0
- sciev-0.2.1/tests/test_builders.py +609 -0
- sciev-0.2.1/tests/test_calibration_pipeline.py +531 -0
- sciev-0.2.1/tests/test_data_alignment.py +345 -0
- sciev-0.2.1/tests/test_decisions.py +180 -0
- sciev-0.2.1/tests/test_inference.py +654 -0
- sciev-0.2.1/tests/test_metrics_alignment.py +479 -0
- sciev-0.2.1/tests/test_paper_results.py +47 -0
- sciev-0.2.1/tests/test_protocol.py +470 -0
- sciev-0.2.1/tests/test_r2_alignment.py +153 -0
- sciev-0.2.1/tests/test_serve.py +325 -0
- sciev-0.2.1/tests/test_smoke.py +211 -0
sciev-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
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 patents and to the extent such
|
|
79
|
+
patentable contributions are licensed hereunder, provided that the
|
|
80
|
+
Work done by such Contributor is not otherwise restricted under the
|
|
81
|
+
License.
|
|
82
|
+
|
|
83
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
84
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
85
|
+
modifications, and in Source or Object form, provided that You
|
|
86
|
+
meet the following conditions:
|
|
87
|
+
|
|
88
|
+
(a) You must give any other recipients of the Work or
|
|
89
|
+
Derivative Works a copy of this License; and
|
|
90
|
+
|
|
91
|
+
(b) You must cause any modified files to carry prominent notices
|
|
92
|
+
stating that You changed the files; and
|
|
93
|
+
|
|
94
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
95
|
+
that You distribute, all copyright, patent, trademark, and
|
|
96
|
+
attribution notices from the Source form of the Work,
|
|
97
|
+
excluding those notices that do not pertain to any part of
|
|
98
|
+
the Derivative Works; and
|
|
99
|
+
|
|
100
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
101
|
+
distribution, then any Derivative Works that You distribute must
|
|
102
|
+
include a readable copy of the attribution notices contained
|
|
103
|
+
within such NOTICE file, excluding those notices that do not
|
|
104
|
+
pertain to any part of the Derivative Works, in at least one
|
|
105
|
+
of the following places: within a NOTICE text file distributed
|
|
106
|
+
as part of the Derivative Works; within the documentation for
|
|
107
|
+
the Derivative Works, if provided along with the Derivative Works;
|
|
108
|
+
or, within a display generated by the Derivative Works, if and
|
|
109
|
+
wherever such third-party notices normally appear. The contents
|
|
110
|
+
of the NOTICE file are for informational purposes only and
|
|
111
|
+
do not modify the License.
|
|
112
|
+
|
|
113
|
+
You may add Your own copyright statement to Your modifications and
|
|
114
|
+
may provide additional or different license terms and conditions
|
|
115
|
+
for Your modifications.
|
|
116
|
+
|
|
117
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
118
|
+
any Contribution intentionally submitted for inclusion in the Work by
|
|
119
|
+
You shall be subject to the same rights and obligations as the
|
|
120
|
+
copyright holder to the original owner of the Work, and any Contribution
|
|
121
|
+
submitted for inclusion in the Work by You shall be deemed to be free
|
|
122
|
+
of additional terms or conditions.
|
|
123
|
+
|
|
124
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
125
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
126
|
+
except as required for reasonable and customary use in describing the
|
|
127
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
128
|
+
|
|
129
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
130
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
131
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
132
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
133
|
+
implied, including, without limitation, any warranties or conditions
|
|
134
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
135
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
136
|
+
appropriateness of using or redistributing and you assume all risks
|
|
137
|
+
associated with use of Your Licensed Applications.
|
|
138
|
+
|
|
139
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
140
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
141
|
+
unless required by applicable law (such as deliberate and grossly
|
|
142
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
143
|
+
liable for any damages, including any direct, indirect, special,
|
|
144
|
+
incidental, or consequential damages of any character arising as a
|
|
145
|
+
result of this License or out of the use or inability to use the
|
|
146
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
147
|
+
work stoppage, computer failure or malfunction, or any and all other
|
|
148
|
+
commercial damages or losses), even if such Contributor has been
|
|
149
|
+
advised of the possibility of such damages.
|
|
150
|
+
|
|
151
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
152
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
153
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
154
|
+
or other liability obligations and/or other warranty rights.
|
|
155
|
+
However, in accepting such obligations, You may act only on Your
|
|
156
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
157
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
158
|
+
and hold each Contributor harmless for any liability or expenses
|
|
159
|
+
incurred by the use of Your rights under this License.
|
|
160
|
+
|
|
161
|
+
END OF TERMS AND CONDITIONS
|
|
162
|
+
|
|
163
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
164
|
+
|
|
165
|
+
To apply the Apache License to your work, attach the following
|
|
166
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
167
|
+
replaced with your own identifying information. (Don't include
|
|
168
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
169
|
+
comment syntax for the file format. We also recommend that a
|
|
170
|
+
file or class name and description of purpose be included on the
|
|
171
|
+
same "printed page" as the copyright notice for easier
|
|
172
|
+
identification within third-party archives.
|
|
173
|
+
|
|
174
|
+
Copyright 2026 alrobles
|
|
175
|
+
|
|
176
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
177
|
+
you may not use this file except in compliance with the License.
|
|
178
|
+
You may obtain a copy of the License at
|
|
179
|
+
|
|
180
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
181
|
+
|
|
182
|
+
Unless required by applicable law or agreed to in writing, software
|
|
183
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
184
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
185
|
+
See the License for the specific language governing permissions and
|
|
186
|
+
limitations under the License.
|
sciev-0.2.1/PKG-INFO
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sciev
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Typed decision heads on frozen masked-diffusion backbones with held-out calibration.
|
|
5
|
+
Author: Angel Robles
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/alrobles/sciev-devel
|
|
8
|
+
Project-URL: Repository, https://github.com/alrobles/sciev-devel
|
|
9
|
+
Project-URL: Issues, https://github.com/alrobles/sciev-devel/issues
|
|
10
|
+
Project-URL: Releases, https://github.com/alrobles/sciev-devel/releases
|
|
11
|
+
Keywords: scientific-computing,decision-models,masked-diffusion,calibration,classification
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: torch>=2.0.0
|
|
24
|
+
Requires-Dist: transformers>=4.45.0
|
|
25
|
+
Requires-Dist: numpy>=1.20.0
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Provides-Extra: serve
|
|
28
|
+
Requires-Dist: fastapi>=0.100; extra == "serve"
|
|
29
|
+
Requires-Dist: uvicorn>=0.23; extra == "serve"
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Sciev
|
|
35
|
+
|
|
36
|
+
**Sciev** (`sci`·ence + `ev`·aluation) — open **System-One-style
|
|
37
|
+
decision models** on a frozen masked-diffusion backbone. Typed
|
|
38
|
+
questions (`choice` / `noul` / `score`) over a `state`, answered with
|
|
39
|
+
probabilities in **one forward pass**, calibrated with held-out dev data —
|
|
40
|
+
no text generation or output parsing. Classification errors remain possible.
|
|
41
|
+
|
|
42
|
+
*(repo: `alrobles/sciev-devel`; `pip install sciev`)*
|
|
43
|
+
|
|
44
|
+
General-purpose by design, with a scientific specialty: the heads are
|
|
45
|
+
trained on passage-grounded scientific decisions and transfer zero-shot
|
|
46
|
+
to general classification.
|
|
47
|
+
|
|
48
|
+
Sciev uses a **masked-diffusion language model** (LLaDA-8B) and canonical
|
|
49
|
+
option sorting. Distinct option token sequences produce the same model
|
|
50
|
+
input under permutation; duplicate or truncated-to-identical options need
|
|
51
|
+
an explicit tie policy if their external identifiers must be distinguished.
|
|
52
|
+
|
|
53
|
+
## Results (v0.2, `systemone-v2` encoding, 3 seeds)
|
|
54
|
+
|
|
55
|
+
| eval | type | fr (release) mean ± sd | da (DAPT, experimental) |
|
|
56
|
+
|---|---|---:|---:|
|
|
57
|
+
| sci battery elite | choice | **0.970 ± 0.017** | 0.961 ± 0.011 |
|
|
58
|
+
| sci battery elite | noul | **0.925 ± 0.006** | 0.913 ± 0.007 |
|
|
59
|
+
| sci battery elite | score | **0.859 ± 0.075** | 0.779 ± 0.109 |
|
|
60
|
+
| GPQA main | choice | 0.295 ± 0.014 | 0.288 ± 0.018 |
|
|
61
|
+
| GPQA diamond | choice | 0.307 ± 0.012 | 0.297 ± 0.011 |
|
|
62
|
+
| SciFact dev | noul | 0.483 ± 0.023 | **0.709 ± 0.020** |
|
|
63
|
+
| SciFact dev | choice | 0.479 ± 0.018 | 0.444 ± 0.062 |
|
|
64
|
+
|
|
65
|
+
Under matched seeds, recipe and data, DAPT helps out-of-domain
|
|
66
|
+
verification (SciFact noul +22.6pt) but degrades in-domain ordinal
|
|
67
|
+
scoring — task-dependent, not uniform. Evidence controls (empty /
|
|
68
|
+
shuffled passages) show `choice` retains option-side leakage
|
|
69
|
+
(agreement-with-reference ~0.80 without evidence) while `score`
|
|
70
|
+
collapses toward chance; see the paper and `manifests/` in the release
|
|
71
|
+
assets. Earlier v0.1.1 zero-shot numbers (SST-2 0.93, AG News 0.85)
|
|
72
|
+
remain archived in the release JSONs.
|
|
73
|
+
|
|
74
|
+
| benchmark (archived v0.1.x, `c_*` heads) | type | n | acc | ECE | auto@5%err |
|
|
75
|
+
|---|---|---:|---:|---:|---:|
|
|
76
|
+
| sci battery (elite) | choice | 653 | **0.8698** | 0.0253 | **0.8070** |
|
|
77
|
+
| sci battery (elite) | noul | 1959 | 0.7825 | 0.0957 | 0.2777 |
|
|
78
|
+
| sci battery (elite) | score | 1959 | 0.6075 | 0.1221 | 0.4334 |
|
|
79
|
+
| SciFact dev | noul | 340 | **0.8500** | 0.0998 | 0.2706 |
|
|
80
|
+
| SciFact dev | score | 340 | 0.6294 | 0.0796 | 0.2559 |
|
|
81
|
+
| GPQA main | choice | 448 | 0.3125 | 0.3180 | 0.0112 |
|
|
82
|
+
| GPQA diamond | choice | 198 | 0.3182 | 0.3089 | 0.0152 |
|
|
83
|
+
| SST-2 (zero-shot) | choice | 872 | **0.9300** | 0.0682 | **0.9415** |
|
|
84
|
+
| AG News (zero-shot) | choice | 7600 | **0.8537** | 0.0556 | 0.3674 |
|
|
85
|
+
| Enron spam (zero-shot) | choice | 2000 | 0.7510 | 0.1046 | 0.0000 |
|
|
86
|
+
| Banking77 (K=77) | choice | 3080 | 0.2289 | 0.0809 | 0.0195 |
|
|
87
|
+
|
|
88
|
+
The archived v0.1.x table is kept for provenance; `paper/results.json`
|
|
89
|
+
records source hashes, metrics, and training settings. Third-party
|
|
90
|
+
scores with unverified protocol equivalence are not included as direct
|
|
91
|
+
comparisons.
|
|
92
|
+
|
|
93
|
+
`auto@5%err` is the largest confidence-ranked prefix with realized error
|
|
94
|
+
≤ 5% on labeled evaluation data, not a deployment error guarantee.
|
|
95
|
+
v0.2 fits temperatures on dev data only, and calibration artifacts are
|
|
96
|
+
bound to the checkpoint SHA-256.
|
|
97
|
+
|
|
98
|
+
Known limits: weak K>4 performance (Banking77, v0.1.x), low GPQA
|
|
99
|
+
accuracy, weaker elite score than choice, and the option-side leakage
|
|
100
|
+
quantified by the evidence controls.
|
|
101
|
+
|
|
102
|
+
## Architecture
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
ctx + question + options (canonically sorted by token-ids)
|
|
106
|
+
-> frozen LLaDA-8B (bidirectional masked-diffusion LM)
|
|
107
|
+
-> hidden states, layers {8,16,24,32}
|
|
108
|
+
-> specialist head per decision type
|
|
109
|
+
choice: AttnPoolHead — 67.2M parameters, four-layer span pooling
|
|
110
|
+
noul: MLP — 16.8M parameters, final-layer mean-pooled span
|
|
111
|
+
score: MLP — 16.8M parameters + ordinal auxiliary loss (P(y>=j))
|
|
112
|
+
-> per-option logits -> softmax (temperature fitted on dev)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Checkpoint sizes are 269.4 MB (choice) and 68.6 MB each (noul, score),
|
|
116
|
+
measured from the serialized heads. The backbone stays frozen and is
|
|
117
|
+
fetched separately from HF. No DAPT adapter is required for the release.
|
|
118
|
+
|
|
119
|
+
## Quickstart
|
|
120
|
+
|
|
121
|
+
Install the package, download the release heads, and evaluate a prepared
|
|
122
|
+
decision JSONL (the example assumes `my_decisions.jsonl` already exists):
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
pip install sciev
|
|
126
|
+
gh release download v0.2.1 --repo alrobles/sciev-devel \
|
|
127
|
+
--pattern 'fr_*.pt' --dir release
|
|
128
|
+
python -m sciev.eval \
|
|
129
|
+
--ckpt release/fr_choice.pt --decision-type choice \
|
|
130
|
+
--r2-mode spanpool --r2-layers=-1,-9,-17,-25 --canonical-order \
|
|
131
|
+
--r2-temp-fit-decisions my_decisions_dev.jsonl \
|
|
132
|
+
--decisions-eval my_decisions.jsonl \
|
|
133
|
+
--device cuda --out eval.json
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Temperatures are fitted on dev splits only (`--r2-temp-fit-decisions`);
|
|
137
|
+
the calibration artifact is bound to the checkpoint hash. Pass an
|
|
138
|
+
explicit `--r2-temp` to reuse a recorded value instead.
|
|
139
|
+
|
|
140
|
+
Decision records are `{ctx: [token-ids], opts: [[token-ids]...], gold}`
|
|
141
|
+
(`systemone-v2` also accepts text rows; see `sciev/decisions.py`).
|
|
142
|
+
Converters for GPQA / SciFact / SST-2 / AG News / Enron / Banking77 live
|
|
143
|
+
in `data/convert_benchmarks.py`; the scientific battery builder is
|
|
144
|
+
`data/build_sci_decisions.py`.
|
|
145
|
+
|
|
146
|
+
## Domain adaptation (DAPT)
|
|
147
|
+
|
|
148
|
+
`sciev/dapt.py` implements an experimental masked-token LoRA
|
|
149
|
+
adaptation loop for HF backbones (requires PEFT). Under the matched
|
|
150
|
+
comparison (same recipe, seeds and `systemone-v2` data), the adapted
|
|
151
|
+
backbone improves out-of-domain verification (SciFact noul +22.6pt) but
|
|
152
|
+
degrades in-domain ordinal scoring — the released heads therefore stay
|
|
153
|
+
frozen (`fr_*`), with `da_*` published as an experimental arm. See the
|
|
154
|
+
matched table and protocol caveats in the paper.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
python -m sciev.dapt \
|
|
158
|
+
--hf-backbone GSAI-ML/LLaDA-8B-Instruct \
|
|
159
|
+
--corpus papers.jsonl --field text \
|
|
160
|
+
--out runs/dapt --steps 6000 --bs 16 --seq-len 1024
|
|
161
|
+
# then retrain heads with --lora-adapter runs/dapt/lora-final
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
`--resume` loads adapter weights and `--start-step` skips batches and
|
|
165
|
+
advances the schedule; it does **not** restore optimizer or RNG state.
|
|
166
|
+
It is a warm start, not an exact training-state resume. The DAPT module
|
|
167
|
+
accepts `--hf-backbone`, not `--ckpt`; native MdLMMoE checkpoints can be
|
|
168
|
+
used separately with `sciev.train --ckpt`.
|
|
169
|
+
|
|
170
|
+
## Repo map
|
|
171
|
+
|
|
172
|
+
| path | qué |
|
|
173
|
+
|---|---|
|
|
174
|
+
| `sciev/model.py` | MdLMMoE + HFBackbone + heads + canonical layout |
|
|
175
|
+
| `sciev/train.py` | head training (CE, ordinal, RL-lite) |
|
|
176
|
+
| `sciev/eval.py` | acc/ECE/flip/auto@5%, temp-fit, remote API eval |
|
|
177
|
+
| `sciev/dapt.py` | domain-adaptive pretraining (LoRA) |
|
|
178
|
+
| `data/` | battery builders + benchmark converters |
|
|
179
|
+
| `scripts/*.slurm` | reproducible jobs (KU HPC) |
|
|
180
|
+
| `docs/PROJECT-STATUS.md` | roadmap, milestones, design decisions |
|
|
181
|
+
| `paper/main.tex` | arXiv draft |
|
|
182
|
+
|
|
183
|
+
## Verification
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
OMP_NUM_THREADS=2 MKL_NUM_THREADS=2 python -m pytest -q
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
The suite includes option-identity flip regressions and checks that paper
|
|
190
|
+
Tables 3 and 4 agree with `paper/results.json`. Compile the paper twice
|
|
191
|
+
with `pdflatex -interaction=nonstopmode -halt-on-error main.tex` from `paper/`.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
Apache-2.0 (code + heads). Backbones and datasets keep their own
|
|
196
|
+
licenses.
|
sciev-0.2.1/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Sciev
|
|
2
|
+
|
|
3
|
+
**Sciev** (`sci`·ence + `ev`·aluation) — open **System-One-style
|
|
4
|
+
decision models** on a frozen masked-diffusion backbone. Typed
|
|
5
|
+
questions (`choice` / `noul` / `score`) over a `state`, answered with
|
|
6
|
+
probabilities in **one forward pass**, calibrated with held-out dev data —
|
|
7
|
+
no text generation or output parsing. Classification errors remain possible.
|
|
8
|
+
|
|
9
|
+
*(repo: `alrobles/sciev-devel`; `pip install sciev`)*
|
|
10
|
+
|
|
11
|
+
General-purpose by design, with a scientific specialty: the heads are
|
|
12
|
+
trained on passage-grounded scientific decisions and transfer zero-shot
|
|
13
|
+
to general classification.
|
|
14
|
+
|
|
15
|
+
Sciev uses a **masked-diffusion language model** (LLaDA-8B) and canonical
|
|
16
|
+
option sorting. Distinct option token sequences produce the same model
|
|
17
|
+
input under permutation; duplicate or truncated-to-identical options need
|
|
18
|
+
an explicit tie policy if their external identifiers must be distinguished.
|
|
19
|
+
|
|
20
|
+
## Results (v0.2, `systemone-v2` encoding, 3 seeds)
|
|
21
|
+
|
|
22
|
+
| eval | type | fr (release) mean ± sd | da (DAPT, experimental) |
|
|
23
|
+
|---|---|---:|---:|
|
|
24
|
+
| sci battery elite | choice | **0.970 ± 0.017** | 0.961 ± 0.011 |
|
|
25
|
+
| sci battery elite | noul | **0.925 ± 0.006** | 0.913 ± 0.007 |
|
|
26
|
+
| sci battery elite | score | **0.859 ± 0.075** | 0.779 ± 0.109 |
|
|
27
|
+
| GPQA main | choice | 0.295 ± 0.014 | 0.288 ± 0.018 |
|
|
28
|
+
| GPQA diamond | choice | 0.307 ± 0.012 | 0.297 ± 0.011 |
|
|
29
|
+
| SciFact dev | noul | 0.483 ± 0.023 | **0.709 ± 0.020** |
|
|
30
|
+
| SciFact dev | choice | 0.479 ± 0.018 | 0.444 ± 0.062 |
|
|
31
|
+
|
|
32
|
+
Under matched seeds, recipe and data, DAPT helps out-of-domain
|
|
33
|
+
verification (SciFact noul +22.6pt) but degrades in-domain ordinal
|
|
34
|
+
scoring — task-dependent, not uniform. Evidence controls (empty /
|
|
35
|
+
shuffled passages) show `choice` retains option-side leakage
|
|
36
|
+
(agreement-with-reference ~0.80 without evidence) while `score`
|
|
37
|
+
collapses toward chance; see the paper and `manifests/` in the release
|
|
38
|
+
assets. Earlier v0.1.1 zero-shot numbers (SST-2 0.93, AG News 0.85)
|
|
39
|
+
remain archived in the release JSONs.
|
|
40
|
+
|
|
41
|
+
| benchmark (archived v0.1.x, `c_*` heads) | type | n | acc | ECE | auto@5%err |
|
|
42
|
+
|---|---|---:|---:|---:|---:|
|
|
43
|
+
| sci battery (elite) | choice | 653 | **0.8698** | 0.0253 | **0.8070** |
|
|
44
|
+
| sci battery (elite) | noul | 1959 | 0.7825 | 0.0957 | 0.2777 |
|
|
45
|
+
| sci battery (elite) | score | 1959 | 0.6075 | 0.1221 | 0.4334 |
|
|
46
|
+
| SciFact dev | noul | 340 | **0.8500** | 0.0998 | 0.2706 |
|
|
47
|
+
| SciFact dev | score | 340 | 0.6294 | 0.0796 | 0.2559 |
|
|
48
|
+
| GPQA main | choice | 448 | 0.3125 | 0.3180 | 0.0112 |
|
|
49
|
+
| GPQA diamond | choice | 198 | 0.3182 | 0.3089 | 0.0152 |
|
|
50
|
+
| SST-2 (zero-shot) | choice | 872 | **0.9300** | 0.0682 | **0.9415** |
|
|
51
|
+
| AG News (zero-shot) | choice | 7600 | **0.8537** | 0.0556 | 0.3674 |
|
|
52
|
+
| Enron spam (zero-shot) | choice | 2000 | 0.7510 | 0.1046 | 0.0000 |
|
|
53
|
+
| Banking77 (K=77) | choice | 3080 | 0.2289 | 0.0809 | 0.0195 |
|
|
54
|
+
|
|
55
|
+
The archived v0.1.x table is kept for provenance; `paper/results.json`
|
|
56
|
+
records source hashes, metrics, and training settings. Third-party
|
|
57
|
+
scores with unverified protocol equivalence are not included as direct
|
|
58
|
+
comparisons.
|
|
59
|
+
|
|
60
|
+
`auto@5%err` is the largest confidence-ranked prefix with realized error
|
|
61
|
+
≤ 5% on labeled evaluation data, not a deployment error guarantee.
|
|
62
|
+
v0.2 fits temperatures on dev data only, and calibration artifacts are
|
|
63
|
+
bound to the checkpoint SHA-256.
|
|
64
|
+
|
|
65
|
+
Known limits: weak K>4 performance (Banking77, v0.1.x), low GPQA
|
|
66
|
+
accuracy, weaker elite score than choice, and the option-side leakage
|
|
67
|
+
quantified by the evidence controls.
|
|
68
|
+
|
|
69
|
+
## Architecture
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
ctx + question + options (canonically sorted by token-ids)
|
|
73
|
+
-> frozen LLaDA-8B (bidirectional masked-diffusion LM)
|
|
74
|
+
-> hidden states, layers {8,16,24,32}
|
|
75
|
+
-> specialist head per decision type
|
|
76
|
+
choice: AttnPoolHead — 67.2M parameters, four-layer span pooling
|
|
77
|
+
noul: MLP — 16.8M parameters, final-layer mean-pooled span
|
|
78
|
+
score: MLP — 16.8M parameters + ordinal auxiliary loss (P(y>=j))
|
|
79
|
+
-> per-option logits -> softmax (temperature fitted on dev)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Checkpoint sizes are 269.4 MB (choice) and 68.6 MB each (noul, score),
|
|
83
|
+
measured from the serialized heads. The backbone stays frozen and is
|
|
84
|
+
fetched separately from HF. No DAPT adapter is required for the release.
|
|
85
|
+
|
|
86
|
+
## Quickstart
|
|
87
|
+
|
|
88
|
+
Install the package, download the release heads, and evaluate a prepared
|
|
89
|
+
decision JSONL (the example assumes `my_decisions.jsonl` already exists):
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pip install sciev
|
|
93
|
+
gh release download v0.2.1 --repo alrobles/sciev-devel \
|
|
94
|
+
--pattern 'fr_*.pt' --dir release
|
|
95
|
+
python -m sciev.eval \
|
|
96
|
+
--ckpt release/fr_choice.pt --decision-type choice \
|
|
97
|
+
--r2-mode spanpool --r2-layers=-1,-9,-17,-25 --canonical-order \
|
|
98
|
+
--r2-temp-fit-decisions my_decisions_dev.jsonl \
|
|
99
|
+
--decisions-eval my_decisions.jsonl \
|
|
100
|
+
--device cuda --out eval.json
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Temperatures are fitted on dev splits only (`--r2-temp-fit-decisions`);
|
|
104
|
+
the calibration artifact is bound to the checkpoint hash. Pass an
|
|
105
|
+
explicit `--r2-temp` to reuse a recorded value instead.
|
|
106
|
+
|
|
107
|
+
Decision records are `{ctx: [token-ids], opts: [[token-ids]...], gold}`
|
|
108
|
+
(`systemone-v2` also accepts text rows; see `sciev/decisions.py`).
|
|
109
|
+
Converters for GPQA / SciFact / SST-2 / AG News / Enron / Banking77 live
|
|
110
|
+
in `data/convert_benchmarks.py`; the scientific battery builder is
|
|
111
|
+
`data/build_sci_decisions.py`.
|
|
112
|
+
|
|
113
|
+
## Domain adaptation (DAPT)
|
|
114
|
+
|
|
115
|
+
`sciev/dapt.py` implements an experimental masked-token LoRA
|
|
116
|
+
adaptation loop for HF backbones (requires PEFT). Under the matched
|
|
117
|
+
comparison (same recipe, seeds and `systemone-v2` data), the adapted
|
|
118
|
+
backbone improves out-of-domain verification (SciFact noul +22.6pt) but
|
|
119
|
+
degrades in-domain ordinal scoring — the released heads therefore stay
|
|
120
|
+
frozen (`fr_*`), with `da_*` published as an experimental arm. See the
|
|
121
|
+
matched table and protocol caveats in the paper.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
python -m sciev.dapt \
|
|
125
|
+
--hf-backbone GSAI-ML/LLaDA-8B-Instruct \
|
|
126
|
+
--corpus papers.jsonl --field text \
|
|
127
|
+
--out runs/dapt --steps 6000 --bs 16 --seq-len 1024
|
|
128
|
+
# then retrain heads with --lora-adapter runs/dapt/lora-final
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`--resume` loads adapter weights and `--start-step` skips batches and
|
|
132
|
+
advances the schedule; it does **not** restore optimizer or RNG state.
|
|
133
|
+
It is a warm start, not an exact training-state resume. The DAPT module
|
|
134
|
+
accepts `--hf-backbone`, not `--ckpt`; native MdLMMoE checkpoints can be
|
|
135
|
+
used separately with `sciev.train --ckpt`.
|
|
136
|
+
|
|
137
|
+
## Repo map
|
|
138
|
+
|
|
139
|
+
| path | qué |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `sciev/model.py` | MdLMMoE + HFBackbone + heads + canonical layout |
|
|
142
|
+
| `sciev/train.py` | head training (CE, ordinal, RL-lite) |
|
|
143
|
+
| `sciev/eval.py` | acc/ECE/flip/auto@5%, temp-fit, remote API eval |
|
|
144
|
+
| `sciev/dapt.py` | domain-adaptive pretraining (LoRA) |
|
|
145
|
+
| `data/` | battery builders + benchmark converters |
|
|
146
|
+
| `scripts/*.slurm` | reproducible jobs (KU HPC) |
|
|
147
|
+
| `docs/PROJECT-STATUS.md` | roadmap, milestones, design decisions |
|
|
148
|
+
| `paper/main.tex` | arXiv draft |
|
|
149
|
+
|
|
150
|
+
## Verification
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
OMP_NUM_THREADS=2 MKL_NUM_THREADS=2 python -m pytest -q
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The suite includes option-identity flip regressions and checks that paper
|
|
157
|
+
Tables 3 and 4 agree with `paper/results.json`. Compile the paper twice
|
|
158
|
+
with `pdflatex -interaction=nonstopmode -halt-on-error main.tex` from `paper/`.
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
Apache-2.0 (code + heads). Backbones and datasets keep their own
|
|
163
|
+
licenses.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sciev"
|
|
3
|
+
version = "0.2.1"
|
|
4
|
+
description = "Typed decision heads on frozen masked-diffusion backbones with held-out calibration."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "Apache-2.0" }
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Angel Robles" },
|
|
10
|
+
]
|
|
11
|
+
keywords = [
|
|
12
|
+
"scientific-computing",
|
|
13
|
+
"decision-models",
|
|
14
|
+
"masked-diffusion",
|
|
15
|
+
"calibration",
|
|
16
|
+
"classification",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 4 - Beta",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"License :: OSI Approved :: Apache Software License",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"torch>=2.0.0",
|
|
30
|
+
"transformers>=4.45.0",
|
|
31
|
+
"numpy>=1.20.0",
|
|
32
|
+
"pyyaml>=6.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
serve = ["fastapi>=0.100", "uvicorn>=0.23"]
|
|
37
|
+
dev = ["pytest>=7.0"]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/alrobles/sciev-devel"
|
|
41
|
+
Repository = "https://github.com/alrobles/sciev-devel"
|
|
42
|
+
Issues = "https://github.com/alrobles/sciev-devel/issues"
|
|
43
|
+
Releases = "https://github.com/alrobles/sciev-devel/releases"
|
|
44
|
+
|
|
45
|
+
[build-system]
|
|
46
|
+
requires = ["setuptools>=68"]
|
|
47
|
+
build-backend = "setuptools.build_meta"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools]
|
|
50
|
+
packages = ["sciev"]
|