samratduttaofficial commited on
Commit
07f1ef2
·
0 Parent(s):

Initial commit

Browse files
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
NOTICE ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ WaterSheep
2
+ Copyright 2026 Samrat Dutta <samratduttaofficial@gmail.com>
3
+
4
+ The WaterSheep code and model weights are licensed under the Apache License,
5
+ Version 2.0 (see LICENSE).
6
+
7
+ -------------------------------------------------------------------------------
8
+ Base model
9
+ -------------------------------------------------------------------------------
10
+ The WaterSheep model is fine-tuned from ModernBERT-base by Answer.AI and
11
+ LightOn (https://huggingface.co/answerdotai/ModernBERT-base), licensed under
12
+ the Apache License, Version 2.0. The encoder weights were modified by
13
+ fine-tuning, and a decision head was added.
14
+
15
+ -------------------------------------------------------------------------------
16
+ Synthetic training data
17
+ -------------------------------------------------------------------------------
18
+ Synthetic training examples, label descriptions and soft labels were produced
19
+ with Qwen3.5-4B by the Qwen team, Alibaba Cloud
20
+ (https://huggingface.co/Qwen/Qwen3.5-4B), licensed under the Apache License,
21
+ Version 2.0.
22
+
23
+ -------------------------------------------------------------------------------
24
+ Public training data
25
+ -------------------------------------------------------------------------------
26
+ The model was also trained on the public datasets below. The datasets are not
27
+ included in this repository or in the model files; the code downloads them
28
+ from their sources. Each dataset remains under its own license, as stated by
29
+ its source, and the Apache License of this project does not replace it.
30
+
31
+ Hugging Face (https://huggingface.co/datasets/<name>)
32
+ allenai/ai2_arc CC BY-SA 4.0
33
+ allenai/openbookqa Apache 2.0
34
+ allenai/prosocial-dialog CC BY 4.0
35
+ allenai/quartz CC BY 4.0
36
+ allenai/reward-bench ODC-By 1.0
37
+ allenai/scitail Apache 2.0
38
+ allenai/winogrande CC BY
39
+ Anthropic/hh-rlhf MIT
40
+ aps/super_glue (COPA) BSD 2-Clause
41
+ aps/super_glue (WSC) CC BY 4.0
42
+ benayas/snips Apache 2.0
43
+ bitext/Bitext-customer-support-llm-chatbot-training-dataset CDLA-Sharing 1.0
44
+ cais/mmlu MIT
45
+ chengxuphd/liar2 Apache 2.0
46
+ clinc/clinc_oos CC BY 3.0
47
+ coastalcph/lex_glue CC BY 4.0
48
+ deepset/prompt-injections Apache 2.0
49
+ demelin/moral_stories MIT
50
+ Deysi/spam-detection-dataset Apache 2.0
51
+ fancyzhx/dbpedia_14 CC BY-SA 3.0
52
+ GBaker/MedQA-USMLE-4-options CC BY 4.0
53
+ gfissore/arxiv-abstracts-2021 CC0 1.0
54
+ glaiveai/glaive-function-calling-v2 Apache 2.0
55
+ gonglinyuan/CoSQA MIT
56
+ google-research-datasets/go_emotions Apache 2.0
57
+ google-research-datasets/paws Free for any purpose
58
+ google-research-datasets/poem_sentiment CC BY 4.0
59
+ google/boolq CC BY-SA 3.0
60
+ google/civil_comments CC0 1.0
61
+ gretelai/symptom_to_diagnosis Apache 2.0
62
+ hendrycks/ethics MIT
63
+ HuggingFaceH4/ultrafeedback_binarized MIT
64
+ Intel/orca_dpo_pairs Apache 2.0
65
+ jackhhao/jailbreak-classification Apache 2.0
66
+ jakartaresearch/semeval-absa CC BY 4.0
67
+ lmsys/mt_bench_human_judgments CC BY 4.0
68
+ marksverdhei/clickbait_title_classification MIT
69
+ mikex86/stackoverflow-posts CC BY-SA
70
+ mmathys/openai-moderation-api-evaluation MIT
71
+ mteb/amazon_counterfactual CC BY 4.0
72
+ mteb/banking77 MIT
73
+ mteb/toxic_conversations_50k CC BY 4.0
74
+ nvidia/Aegis-AI-Content-Safety-Dataset-2.0 CC BY 4.0
75
+ nvidia/HelpSteer CC BY 4.0
76
+ nvidia/HelpSteer2 CC BY 4.0
77
+ nyu-mll/glue (QNLI) CC BY-SA 4.0
78
+ nyu-mll/multi_nli OANC / CC BY-SA 3.0 / CC BY 3.0
79
+ openlifescienceai/medmcqa Apache 2.0
80
+ owaiskha9654/PubMed_MultiLabel_Text_Classification_Dataset_MeSH AFL 3.0
81
+ pminervini/HaluEval Apache 2.0
82
+ prometheus-eval/Feedback-Collection CC BY 4.0
83
+ prometheus-eval/Preference-Collection CC BY 4.0
84
+ qiaojin/PubMedQA MIT
85
+ rajpurkar/squad_v2 CC BY-SA 4.0
86
+ reshabhs/SPML_Chatbot_Prompt_Injection MIT
87
+ SetFit/amazon_massive_intent_en-US CC BY 4.0
88
+ SetFit/amazon_massive_scenario_en-US CC BY 4.0
89
+ SetFit/student-question-categories CC0 1.0
90
+ stanfordnlp/snli CC BY-SA 4.0
91
+ tals/vitaminc CC BY-SA 3.0
92
+ tasksource/bigbench Apache 2.0
93
+ tasksource/crowdflower (political media subsets) CC0 1.0
94
+ tasksource/esci Apache 2.0
95
+ tasksource/folio CC BY-SA 4.0
96
+ tau/commonsense_qa MIT
97
+ tdavidson/hate_speech_offensive MIT
98
+ thesofakillers/jigsaw-toxic-comment-classification-challenge CC BY-SA 3.0
99
+ TIGER-Lab/MMLU-Pro MIT
100
+ TimSchopf/medical_abstracts CC BY-SA 3.0
101
+ truthfulqa/truthful_qa Apache 2.0
102
+ ucirvine/sms_spam CC BY 4.0
103
+ zeroshot/twitter-financial-news-sentiment MIT
104
+ zeroshot/twitter-financial-news-topic MIT
105
+
106
+ Kaggle (https://www.kaggle.com/datasets/<name>)
107
+ andrewmvd/cyberbullying-classification CC BY 4.0
108
+ imoore/60k-stack-overflow-questions-with-quality-rate MIT / CC BY-SA
109
+ jp797498e/twitter-entity-sentiment-analysis CC0 1.0
110
+ nicapotato/womens-ecommerce-clothing-reviews CC0 1.0
111
+ rmisra/clothing-fit-dataset-for-size-recommendation CC BY 4.0
112
+ rounakbanik/the-movies-dataset CC0 1.0
113
+ saurabhshahane/ecommerce-text-classification CC BY 4.0
114
+ shivamb/real-or-fake-fake-jobposting-prediction CC0 1.0
115
+ snap/amazon-fine-food-reviews CC0 1.0
116
+ snehaanbhawal/resume-dataset CC0 1.0
117
+ subhajournal/phishingemails LGPL 3.0
118
+ tboyle10/medicaltranscriptions CC0 1.0
119
+
120
+ Other sources
121
+ NLU Evaluation Data (HWU64) CC BY 4.0
122
+ https://github.com/xliuhw/NLU-Evaluation-Data
123
+ UCI News Aggregator CC BY 4.0
124
+ https://archive.ics.uci.edu/dataset/359/news+aggregator
125
+ UCI YouTube Spam Collection CC BY 4.0
126
+ https://archive.ics.uci.edu/dataset/380/youtube+spam+collection
127
+
128
+ -------------------------------------------------------------------------------
129
+ Held-out data
130
+ -------------------------------------------------------------------------------
131
+ The pipeline also downloads these datasets but withholds them from training;
132
+ they are used only to test the model on data it has not seen.
133
+
134
+ allenai/qasc CC BY 4.0
135
+ https://huggingface.co/datasets/allenai/qasc
136
+ PromptCloudHQ/amazon-reviews-unlocked-mobile-phones CC0 1.0
137
+ https://www.kaggle.com/datasets/PromptCloudHQ/amazon-reviews-unlocked-mobile-phones
138
+ rmisra/news-category-dataset CC BY 4.0
139
+ https://www.kaggle.com/datasets/rmisra/news-category-dataset
140
+ rmisra/news-headlines-dataset-for-sarcasm-detection CC BY 4.0
141
+ https://www.kaggle.com/datasets/rmisra/news-headlines-dataset-for-sarcasm-detection
README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ library_name: transformers
6
+ pipeline_tag: zero-shot-classification
7
+ base_model: answerdotai/ModernBERT-base
8
+ tags:
9
+ - decision-model
10
+ - calibration
11
+ - multi-label
12
+ datasets:
13
+ - Anthropic/hh-rlhf
14
+ - Deysi/spam-detection-dataset
15
+ - GBaker/MedQA-USMLE-4-options
16
+ - HuggingFaceH4/ultrafeedback_binarized
17
+ - Intel/orca_dpo_pairs
18
+ - SetFit/amazon_massive_intent_en-US
19
+ - SetFit/amazon_massive_scenario_en-US
20
+ - SetFit/student-question-categories
21
+ - TIGER-Lab/MMLU-Pro
22
+ - TimSchopf/medical_abstracts
23
+ - allenai/ai2_arc
24
+ - allenai/openbookqa
25
+ - allenai/prosocial-dialog
26
+ - allenai/quartz
27
+ - allenai/reward-bench
28
+ - allenai/scitail
29
+ - allenai/winogrande
30
+ - aps/super_glue
31
+ - benayas/snips
32
+ - bitext/Bitext-customer-support-llm-chatbot-training-dataset
33
+ - cais/mmlu
34
+ - chengxuphd/liar2
35
+ - clinc/clinc_oos
36
+ - coastalcph/lex_glue
37
+ - deepset/prompt-injections
38
+ - demelin/moral_stories
39
+ - fancyzhx/dbpedia_14
40
+ - gfissore/arxiv-abstracts-2021
41
+ - glaiveai/glaive-function-calling-v2
42
+ - gonglinyuan/CoSQA
43
+ - google-research-datasets/go_emotions
44
+ - google-research-datasets/paws
45
+ - google-research-datasets/poem_sentiment
46
+ - google/boolq
47
+ - google/civil_comments
48
+ - gretelai/symptom_to_diagnosis
49
+ - hendrycks/ethics
50
+ - jackhhao/jailbreak-classification
51
+ - jakartaresearch/semeval-absa
52
+ - lmsys/mt_bench_human_judgments
53
+ - marksverdhei/clickbait_title_classification
54
+ - mikex86/stackoverflow-posts
55
+ - mmathys/openai-moderation-api-evaluation
56
+ - mteb/amazon_counterfactual
57
+ - mteb/banking77
58
+ - mteb/toxic_conversations_50k
59
+ - nvidia/Aegis-AI-Content-Safety-Dataset-2.0
60
+ - nvidia/HelpSteer
61
+ - nvidia/HelpSteer2
62
+ - nyu-mll/glue
63
+ - nyu-mll/multi_nli
64
+ - openlifescienceai/medmcqa
65
+ - owaiskha9654/PubMed_MultiLabel_Text_Classification_Dataset_MeSH
66
+ - pminervini/HaluEval
67
+ - prometheus-eval/Feedback-Collection
68
+ - prometheus-eval/Preference-Collection
69
+ - qiaojin/PubMedQA
70
+ - rajpurkar/squad_v2
71
+ - reshabhs/SPML_Chatbot_Prompt_Injection
72
+ - stanfordnlp/snli
73
+ - tals/vitaminc
74
+ - tasksource/bigbench
75
+ - tasksource/crowdflower
76
+ - tasksource/esci
77
+ - tasksource/folio
78
+ - tau/commonsense_qa
79
+ - tdavidson/hate_speech_offensive
80
+ - thesofakillers/jigsaw-toxic-comment-classification-challenge
81
+ - truthfulqa/truthful_qa
82
+ - ucirvine/sms_spam
83
+ - zeroshot/twitter-financial-news-sentiment
84
+ - zeroshot/twitter-financial-news-topic
85
+ ---
86
+
87
+ ![WaterSheep](https://samratduttaofficial.github.io/WaterSheep/banner.svg)
88
+
89
+ # ![](https://samratduttaofficial.github.io/WaterSheep/logo.svg) WaterSheep
90
+
91
+ [Website](https://samratduttaofficial.github.io/WaterSheep/) · [Demo](https://huggingface.co/spaces/samratduttaofficial/WaterSheep) · [Code](https://github.com/SamratDuttaOfficial/WaterSheep)
92
+
93
+ WaterSheep answers yes/no, single-choice, rating and multi-label questions about any text, with a
94
+ probability for every option. Version 0.1.0 (`watersheep-20260928-125452`).
95
+
96
+ ## Usage
97
+
98
+ ```bash
99
+ pip install transformers torch
100
+ ```
101
+
102
+ ```python
103
+ from transformers import pipeline
104
+
105
+ ws = pipeline(model="samratduttaofficial/WaterSheep", trust_remote_code=True)
106
+ ws("I was charged twice.", question="Which team should handle this?", options=["billing", "shipping", "support"])
107
+ ```
108
+
109
+ | Type | Options | Answer |
110
+ |---|---|---|
111
+ | `noul` | none (yes/no) | probability of yes |
112
+ | `choice` | any labels | the best option |
113
+ | `score` | a digit scale, e.g. `1` to `5` | the expected level |
114
+ | `multi` | any labels, with `type="multi"` | every option above the threshold |
115
+
116
+ Every answer includes a probability for each option.
117
+
118
+ ## Download
119
+
120
+ ```bash
121
+ hf download samratduttaofficial/WaterSheep --local-dir WaterSheep
122
+ ```
123
+
124
+ Or with Git (requires Git LFS):
125
+
126
+ ```bash
127
+ git clone https://huggingface.co/samratduttaofficial/WaterSheep
128
+ ```
129
+
130
+ Then load it from the folder, offline:
131
+
132
+ ```python
133
+ ws = pipeline(model="WaterSheep", trust_remote_code=True)
134
+ ```
135
+
136
+ ## API
137
+
138
+ Deploy it as an [Inference Endpoint](https://endpoints.huggingface.co), then:
139
+
140
+ ```bash
141
+ curl https://YOUR-ENDPOINT -H "Authorization: Bearer $HF_TOKEN" -H "Content-Type: application/json" -d '{"inputs": "I was charged twice.", "parameters": {"question": "Which team should handle this?", "options": ["billing", "shipping", "support"]}}'
142
+ ```
143
+
144
+ ## JavaScript
145
+
146
+ No install; runs in the browser:
147
+
148
+ ```html
149
+ <script type="module">
150
+ import { decide } from "https://samratduttaofficial.github.io/WaterSheep/watersheep.js";
151
+ console.log(await decide("I was charged twice.", "Which team should handle this?", ["billing", "shipping", "support"]));
152
+ </script>
153
+ ```
154
+
155
+ With a downloaded copy on your web server, call `load({ base: "WaterSheep/" })` first.
156
+
157
+ Other languages: run `onnx/model_quantized.onnx` with ONNX Runtime; `watersheep.js` shows the input format.
158
+
159
+ ## Evaluation
160
+
161
+ | Evaluation | Accuracy | ECE |
162
+ |---|---|---|
163
+ | In-distribution test split | 77.8% | 0.026 |
164
+ | Held-out datasets, not seen in training | 61.2% | 0.043 |
165
+
166
+ ECE is the expected calibration error (lower is better).
167
+
168
+ ### Benchmarks
169
+
170
+ | Benchmark | Suite | Questions | Accuracy | ECE | In training data |
171
+ |---|---|---|---|---|---|
172
+ | [goemotions](https://huggingface.co/datasets/google-research-datasets/go_emotions) | sentiment | 2000 | 22.4% | 0.023 | other split |
173
+ | [hatecheck](https://huggingface.co/datasets/Paul/hatecheck) | safety | 2000 | 75.1% | 0.139 | no |
174
+ | [legal_abercrombie](https://huggingface.co/datasets/nguha/legalbench) | legal | 95 | 21.1% | 0.316 | no |
175
+ | [legal_contract_nli_confidentiality_of_agreement](https://huggingface.co/datasets/nguha/legalbench) | legal | 82 | 69.5% | 0.177 | no |
176
+ | [legal_corporate_lobbying](https://huggingface.co/datasets/nguha/legalbench) | legal | 490 | 68.4% | 0.216 | no |
177
+ | [legal_cuad_audit_rights](https://huggingface.co/datasets/nguha/legalbench) | legal | 1216 | 86.3% | 0.041 | no |
178
+ | [legal_definition_classification](https://huggingface.co/datasets/nguha/legalbench) | legal | 1337 | 56.9% | 0.279 | no |
179
+ | [legal_function_of_decision_section](https://huggingface.co/datasets/nguha/legalbench) | legal | 367 | 24.3% | 0.245 | no |
180
+ | [legal_hearsay](https://huggingface.co/datasets/nguha/legalbench) | legal | 94 | 56.4% | 0.307 | no |
181
+ | [legal_overruling](https://huggingface.co/datasets/nguha/legalbench) | legal | 2000 | 62.5% | 0.151 | no |
182
+ | [legal_personal_jurisdiction](https://huggingface.co/datasets/nguha/legalbench) | legal | 50 | 50.0% | 0.160 | no |
183
+ | [legal_privacy_policy_qa](https://huggingface.co/datasets/nguha/legalbench) | legal | 2000 | 58.9% | 0.274 | no |
184
+ | [legal_proa](https://huggingface.co/datasets/nguha/legalbench) | legal | 95 | 51.6% | 0.379 | no |
185
+ | [legal_ucc_v_common_law](https://huggingface.co/datasets/nguha/legalbench) | legal | 94 | 62.8% | 0.171 | no |
186
+ | [prompt_injection](https://huggingface.co/datasets/deepset/prompt-injections) | safety | 116 | 91.4% | 0.079 | other split |
187
+ | [xstest](https://huggingface.co/datasets/Paul/XSTest) | safety | 450 | 73.6% | 0.140 | no |
188
+
189
+ ## Limitations
190
+
191
+ - English only.
192
+ - Long inputs are truncated.
193
+ - Rating-scale answers are less accurate than the other types.
194
+ - Probabilities are calibrated on data like the training data; validate them on your own.
195
+ - Not for high-stakes decisions (medical, legal, financial, hiring) on its own.
196
+
197
+ ## License
198
+
199
+ Apache 2.0 (`LICENSE`). Trained on openly licensed data; credits in `NOTICE`.
200
+
201
+ ## Citation
202
+
203
+ ```bibtex
204
+ @misc{watersheep,
205
+ author = {Samrat Dutta},
206
+ title = {WaterSheep: calibrated decisions for any text},
207
+ year = {2026},
208
+ url = {https://huggingface.co/samratduttaofficial/WaterSheep}
209
+ }
210
+ ```
config.json ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "WaterSheepModel"
4
+ ],
5
+ "model_type": "watersheep",
6
+ "auto_map": {
7
+ "AutoConfig": "modeling_watersheep.WaterSheepConfig",
8
+ "AutoModel": "modeling_watersheep.WaterSheepModel"
9
+ },
10
+ "custom_pipelines": {
11
+ "zero-shot-classification": {
12
+ "impl": "pipeline_watersheep.WaterSheepPipeline",
13
+ "pt": [
14
+ "AutoModel"
15
+ ]
16
+ }
17
+ },
18
+ "encoder_config": {
19
+ "architectures": [
20
+ "ModernBertForMaskedLM"
21
+ ],
22
+ "attention_bias": false,
23
+ "attention_dropout": 0.0,
24
+ "bos_token_id": 50281,
25
+ "classifier_activation": "gelu",
26
+ "classifier_bias": false,
27
+ "classifier_dropout": 0.0,
28
+ "classifier_pooling": "mean",
29
+ "cls_token_id": 50281,
30
+ "decoder_bias": true,
31
+ "deterministic_flash_attn": false,
32
+ "dtype": "float32",
33
+ "embedding_dropout": 0.0,
34
+ "eos_token_id": 50282,
35
+ "global_attn_every_n_layers": 3,
36
+ "gradient_checkpointing": false,
37
+ "hidden_activation": "gelu",
38
+ "hidden_size": 768,
39
+ "initializer_cutoff_factor": 2.0,
40
+ "initializer_range": 0.02,
41
+ "intermediate_size": 1152,
42
+ "layer_norm_eps": 1e-05,
43
+ "layer_types": [
44
+ "full_attention",
45
+ "sliding_attention",
46
+ "sliding_attention",
47
+ "full_attention",
48
+ "sliding_attention",
49
+ "sliding_attention",
50
+ "full_attention",
51
+ "sliding_attention",
52
+ "sliding_attention",
53
+ "full_attention",
54
+ "sliding_attention",
55
+ "sliding_attention",
56
+ "full_attention",
57
+ "sliding_attention",
58
+ "sliding_attention",
59
+ "full_attention",
60
+ "sliding_attention",
61
+ "sliding_attention",
62
+ "full_attention",
63
+ "sliding_attention",
64
+ "sliding_attention",
65
+ "full_attention"
66
+ ],
67
+ "local_attention": 128,
68
+ "max_position_embeddings": 8192,
69
+ "mlp_bias": false,
70
+ "mlp_dropout": 0.0,
71
+ "model_type": "modernbert",
72
+ "norm_bias": false,
73
+ "norm_eps": 1e-05,
74
+ "num_attention_heads": 12,
75
+ "num_hidden_layers": 22,
76
+ "pad_token_id": 50283,
77
+ "position_embedding_type": "absolute",
78
+ "rope_parameters": {
79
+ "full_attention": {
80
+ "rope_theta": 160000.0,
81
+ "rope_type": "default"
82
+ },
83
+ "sliding_attention": {
84
+ "rope_theta": 10000.0,
85
+ "rope_type": "default"
86
+ }
87
+ },
88
+ "sep_token_id": 50282,
89
+ "sparse_pred_ignore_index": -100,
90
+ "sparse_prediction": false,
91
+ "tie_word_embeddings": true,
92
+ "transformers_version": "5.16.1",
93
+ "vocab_size": 50368
94
+ },
95
+ "head_layers": 1,
96
+ "max_len": 512,
97
+ "max_question_tokens": 96,
98
+ "max_option_tokens": 32,
99
+ "max_options": 10,
100
+ "temperatures": {
101
+ "binary": 1.0594,
102
+ "choice": 1.0631,
103
+ "score": 1.0022,
104
+ "multi": 0.8276
105
+ },
106
+ "multi_threshold": 0.5,
107
+ "dtype": "float32",
108
+ "transformers_version": "5.16.1"
109
+ }
encoder/config.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ModernBertForMaskedLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 50281,
8
+ "classifier_activation": "gelu",
9
+ "classifier_bias": false,
10
+ "classifier_dropout": 0.0,
11
+ "classifier_pooling": "mean",
12
+ "cls_token_id": 50281,
13
+ "decoder_bias": true,
14
+ "deterministic_flash_attn": false,
15
+ "dtype": "float32",
16
+ "embedding_dropout": 0.0,
17
+ "eos_token_id": 50282,
18
+ "global_attn_every_n_layers": 3,
19
+ "gradient_checkpointing": false,
20
+ "hidden_activation": "gelu",
21
+ "hidden_size": 768,
22
+ "initializer_cutoff_factor": 2.0,
23
+ "initializer_range": 0.02,
24
+ "intermediate_size": 1152,
25
+ "layer_norm_eps": 1e-05,
26
+ "layer_types": [
27
+ "full_attention",
28
+ "sliding_attention",
29
+ "sliding_attention",
30
+ "full_attention",
31
+ "sliding_attention",
32
+ "sliding_attention",
33
+ "full_attention",
34
+ "sliding_attention",
35
+ "sliding_attention",
36
+ "full_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "full_attention",
40
+ "sliding_attention",
41
+ "sliding_attention",
42
+ "full_attention",
43
+ "sliding_attention",
44
+ "sliding_attention",
45
+ "full_attention",
46
+ "sliding_attention",
47
+ "sliding_attention",
48
+ "full_attention"
49
+ ],
50
+ "local_attention": 128,
51
+ "max_position_embeddings": 8192,
52
+ "mlp_bias": false,
53
+ "mlp_dropout": 0.0,
54
+ "model_type": "modernbert",
55
+ "norm_bias": false,
56
+ "norm_eps": 1e-05,
57
+ "num_attention_heads": 12,
58
+ "num_hidden_layers": 22,
59
+ "pad_token_id": 50283,
60
+ "position_embedding_type": "absolute",
61
+ "rope_parameters": {
62
+ "full_attention": {
63
+ "rope_theta": 160000.0,
64
+ "rope_type": "default"
65
+ },
66
+ "sliding_attention": {
67
+ "rope_theta": 10000.0,
68
+ "rope_type": "default"
69
+ }
70
+ },
71
+ "sep_token_id": 50282,
72
+ "sparse_pred_ignore_index": -100,
73
+ "sparse_prediction": false,
74
+ "tie_word_embeddings": true,
75
+ "transformers_version": "5.16.1",
76
+ "vocab_size": 50368
77
+ }
handler.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+
4
+ class EndpointHandler:
5
+ def __init__(self, path=""):
6
+ self.pipe = pipeline(model=path, trust_remote_code=True)
7
+
8
+ def __call__(self, data):
9
+ return self.pipe(data["inputs"], **(data.get("parameters") or {}))
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e55d28e1a26fada5ab701fce713ad56cc1d3d849df2d8be79c1a11a08da0981a
3
+ size 617352620
modeling_watersheep.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+
3
+ import torch
4
+ from torch import nn
5
+ from transformers import AutoConfig, AutoModel, PreTrainedConfig, PreTrainedModel
6
+ from transformers.utils import ModelOutput
7
+
8
+
9
+ class WaterSheepConfig(PreTrainedConfig):
10
+ model_type = "watersheep"
11
+
12
+ def __init__(self, encoder_config=None, head_layers=1, max_len=512, max_question_tokens=96,
13
+ max_option_tokens=32, max_options=10, temperatures=None, multi_threshold=0.5, **kwargs):
14
+ self.encoder_config = encoder_config or {}
15
+ self.head_layers = head_layers
16
+ self.max_len = max_len
17
+ self.max_question_tokens = max_question_tokens
18
+ self.max_option_tokens = max_option_tokens
19
+ self.max_options = max_options
20
+ self.temperatures = temperatures or {}
21
+ self.multi_threshold = multi_threshold
22
+ super().__init__(**kwargs)
23
+
24
+
25
+ @dataclass
26
+ class WaterSheepOutput(ModelOutput):
27
+ logits: torch.FloatTensor = None
28
+
29
+
30
+ class WaterSheepModel(PreTrainedModel):
31
+ config_class = WaterSheepConfig
32
+ base_model_prefix = "watersheep"
33
+
34
+ def __init__(self, config):
35
+ super().__init__(config)
36
+ enc = AutoConfig.for_model(**config.encoder_config)
37
+ if hasattr(enc, "reference_compile"):
38
+ enc.reference_compile = False
39
+ self.encoder = AutoModel.from_config(enc)
40
+ h = enc.hidden_size
41
+ self.proj = nn.Sequential(nn.Dropout(0.0), nn.Linear(h, h), nn.GELU(), nn.LayerNorm(h))
42
+ self.mix = None
43
+ if config.head_layers > 0:
44
+ layer = nn.TransformerEncoderLayer(h, nhead=max(1, h // 64), dim_feedforward=2 * h, dropout=0.0,
45
+ activation="gelu", batch_first=True, norm_first=True)
46
+ self.mix = nn.TransformerEncoder(layer, config.head_layers, enable_nested_tensor=False)
47
+ self.out = nn.Linear(h, 1)
48
+ self.post_init()
49
+
50
+ def forward(self, input_ids, attention_mask, option_positions, option_mask, **kwargs):
51
+ hs = self.encoder(input_ids=input_ids, attention_mask=attention_mask).last_hidden_state
52
+ idx = option_positions.clamp(min=0).unsqueeze(-1).expand(-1, -1, hs.size(-1))
53
+ x = self.proj(torch.gather(hs, 1, idx))
54
+ if self.mix is not None:
55
+ x = self.mix(x, src_key_padding_mask=~option_mask)
56
+ logits = self.out(x).squeeze(-1).float()
57
+ return WaterSheepOutput(logits=logits.masked_fill(~option_mask, -1e4))
onnx/model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:160ae91868f919ae0ddc6d1bd509b17d93194102aa33a466095469fbf04dc25b
3
+ size 158196995
pipeline_watersheep.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import torch
3
+ from transformers import AutoTokenizer, Pipeline
4
+
5
+ TYPES = {"noul": "binary", "binary": "binary", "yes/no": "binary", "boolean": "binary",
6
+ "choice": "choice", "score": "score", "multi": "multi", "multi_choice": "multi",
7
+ "multilabel": "multi", "multi-label": "multi"}
8
+ TAGS = {"binary": "[yes/no]", "choice": "[choose]", "score": "[rate]", "multi": "[select all]"}
9
+ DEFAULT_QUESTION = {"choice": "Which label fits the text?", "multi": "Which labels apply to the text?"}
10
+ YESNO = ["yes", "no"]
11
+
12
+
13
+ def _softmax(z, t):
14
+ z = np.asarray(z, np.float64) / max(1e-6, t)
15
+ e = np.exp(z - z.max())
16
+ return e / e.sum()
17
+
18
+
19
+ def _sigmoid(z, t):
20
+ z = np.clip(np.asarray(z, np.float64) / max(1e-6, t), -60, 60)
21
+ return 1.0 / (1.0 + np.exp(-z))
22
+
23
+
24
+ def _digits(opts):
25
+ return all(len(o) == 1 and o.isdigit() for o in opts)
26
+
27
+
28
+ def _infer_type(opts):
29
+ low = [o.strip().lower() for o in opts]
30
+ if low == YESNO:
31
+ return "binary"
32
+ if _digits(low):
33
+ v = [int(o) for o in low]
34
+ if v == list(range(v[0], v[0] + len(v))):
35
+ return "score"
36
+ return "choice"
37
+
38
+
39
+ class WaterSheepPipeline(Pipeline):
40
+ _load_tokenizer = False
41
+ _load_processor = False
42
+ _load_image_processor = False
43
+ _load_video_processor = False
44
+ _load_feature_extractor = False
45
+
46
+ def __init__(self, *args, **kwargs):
47
+ super().__init__(*args, **kwargs)
48
+ if self.tokenizer is None:
49
+ self.tokenizer = AutoTokenizer.from_pretrained(
50
+ self.model.name_or_path, subfolder="tokenizer",
51
+ revision=getattr(self.model.config, "_commit_hash", None))
52
+
53
+ def _sanitize_parameters(self, question=None, options=None, candidate_labels=None, type=None,
54
+ multi_label=None, threshold=None, hypothesis_template=None):
55
+ pre = {}
56
+ if question is not None:
57
+ pre["question"] = question
58
+ opts = options if options is not None else candidate_labels
59
+ if isinstance(opts, str):
60
+ opts = [o.strip() for o in opts.split(",") if o.strip()]
61
+ if opts is not None:
62
+ pre["options"] = list(opts)
63
+ if type is not None or multi_label:
64
+ pre["type"] = type or "multi"
65
+ return pre, {}, {} if threshold is None else {"threshold": threshold}
66
+
67
+ def preprocess(self, text, question=None, options=None, type=None):
68
+ opts = [str(o) for o in (options or YESNO)]
69
+ t = TYPES.get(str(type or "").lower()) or _infer_type(opts)
70
+ if t == "binary":
71
+ opts = list(YESNO)
72
+ question = question or DEFAULT_QUESTION.get(t)
73
+ if not question:
74
+ raise ValueError("a question is required")
75
+ return {"text": "" if text is None else str(text), "question": str(question), "type": t, "options": opts}
76
+
77
+ def _forward(self, x):
78
+ return {**x, "probs": self._probs(x["type"], x["text"], x["question"], x["options"])}
79
+
80
+ def postprocess(self, x, threshold=None):
81
+ t, opts, p = x["type"], x["options"], x["probs"]
82
+ res = {"type": t, "probs": {o: float(v) for o, v in zip(opts, p)}}
83
+ if t == "multi":
84
+ thr = self.model.config.multi_threshold if threshold is None else float(threshold)
85
+ res.update(answer=[o for o, v in zip(opts, p) if v >= thr],
86
+ confidence=float(np.mean([max(v, 1 - v) for v in p])))
87
+ else:
88
+ i = int(np.argmax(p))
89
+ res.update(answer=opts[i], index=i, confidence=float(p[i]))
90
+ if t == "binary":
91
+ res["p_yes"] = float(p[0])
92
+ elif t == "score":
93
+ res["expected"] = float(sum(k * v for k, v in enumerate(p))) + (int(opts[0]) if _digits(opts) else 0)
94
+ return res
95
+
96
+ def _logits(self, t, text, question, groups):
97
+ cfg, tok = self.model.config, self.tokenizer
98
+ cls = tok.cls_token_id if tok.cls_token_id is not None else tok.bos_token_id
99
+ sep = tok.sep_token_id if tok.sep_token_id is not None else tok.eos_token_id
100
+ mask, pad = tok.mask_token_id, tok.pad_token_id if tok.pad_token_id is not None else 0
101
+ enc = lambda xs: tok(xs, add_special_tokens=False)["input_ids"]
102
+ q = enc([TAGS[t] + " " + question])[0][:cfg.max_question_tokens]
103
+ s = enc([text])[0]
104
+ flat = enc([o for g in groups for o in g])
105
+ items, k = [], 0
106
+ for g in groups:
107
+ ids, pos = [cls] + q + [sep], []
108
+ for o in flat[k:k + len(g)]:
109
+ pos.append(len(ids))
110
+ ids += [mask] + o[:cfg.max_option_tokens]
111
+ k += len(g)
112
+ ids.append(sep)
113
+ room = cfg.max_len - len(ids) - 1
114
+ if room > 0 and s:
115
+ ids += s[:room]
116
+ ids.append(sep)
117
+ if len(ids) > cfg.max_len:
118
+ ids = ids[:cfg.max_len - 1] + [sep]
119
+ pos = [p for p in pos if p < cfg.max_len - 1]
120
+ items.append((ids, pos))
121
+ out, dev = [], self.device
122
+ bf16 = dev.type == "cuda" and torch.cuda.is_bf16_supported()
123
+ for i in range(0, len(items), 64):
124
+ part = items[i:i + 64]
125
+ n, m = max(len(a) for a, _ in part), max(len(p) for _, p in part)
126
+ x = torch.full((len(part), n), pad, dtype=torch.long)
127
+ am = torch.zeros((len(part), n), dtype=torch.long)
128
+ op = torch.zeros((len(part), m), dtype=torch.long)
129
+ om = torch.zeros((len(part), m), dtype=torch.bool)
130
+ for b, (ids, pos) in enumerate(part):
131
+ x[b, :len(ids)] = torch.tensor(ids)
132
+ am[b, :len(ids)] = 1
133
+ op[b, :len(pos)] = torch.tensor(pos)
134
+ om[b, :len(pos)] = True
135
+ with torch.autocast(dev.type, dtype=torch.bfloat16, enabled=bf16):
136
+ z = self.model(x.to(dev), am.to(dev), op.to(dev), om.to(dev)).logits.float().cpu().numpy()
137
+ for (ids, pos), g, zz in zip(part, groups[i:i + 64], z):
138
+ out.append(zz[:len(pos)] if len(pos) == len(g) else None)
139
+ return out
140
+
141
+ def _probs(self, t, text, question, opts, size=0):
142
+ cfg = self.model.config
143
+ temp = (cfg.temperatures or {}).get(t, 1.0)
144
+ n = len(opts)
145
+ size = min(size or max(2, min(10, int(cfg.max_options or 10))), n)
146
+ while True:
147
+ if n <= size:
148
+ (z,) = self._logits(t, text, question, [opts])
149
+ if z is not None:
150
+ return _sigmoid(z, temp) if t == "multi" else _softmax(z, temp)
151
+ else:
152
+ groups = [list(range(k, min(n, k + size))) for k in range(0, n, size)]
153
+ zs = self._logits(t, text, question, [[opts[i] for i in g] for g in groups])
154
+ if all(z is not None for z in zs):
155
+ break
156
+ if size <= 2:
157
+ raise ValueError("the options do not fit in the model's input - shorten them")
158
+ size = max(2, min(size - 1, 8) if size > 8 else size // 2)
159
+ if t == "multi":
160
+ p = np.zeros(n)
161
+ for g, z in zip(groups, zs):
162
+ p[g] = _sigmoid(z, temp)
163
+ return p
164
+ keep = max(1, size // len(groups))
165
+ local, finalists = {}, []
166
+ for g, z in zip(groups, zs):
167
+ pg = _softmax(z, temp)
168
+ local.update({i: pg[k] for k, i in enumerate(g)})
169
+ finalists += [g[k] for k in np.argsort(-pg)[:keep]]
170
+ pf = self._probs(t, text, question, [opts[i] for i in finalists], size)
171
+ p = np.zeros(n)
172
+ for g in groups:
173
+ top = max((i for i in g if i in finalists), key=lambda i: local[i])
174
+ scale = pf[finalists.index(top)] / max(1e-12, local[top])
175
+ for i in g:
176
+ p[i] = local[i] * scale
177
+ for k, i in enumerate(finalists):
178
+ p[i] = pf[k]
179
+ return p / p.sum()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ transformers>=5
tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": true,
4
+ "cls_token": "[CLS]",
5
+ "is_local": false,
6
+ "local_files_only": false,
7
+ "mask_token": "[MASK]",
8
+ "model_input_names": [
9
+ "input_ids",
10
+ "attention_mask"
11
+ ],
12
+ "model_max_length": 8192,
13
+ "pad_token": "[PAD]",
14
+ "sep_token": "[SEP]",
15
+ "tokenizer_class": "TokenizersBackend",
16
+ "unk_token": "[UNK]"
17
+ }
watersheep.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": 2,
3
+ "run_id": "run_20260928-070402",
4
+ "encoder": "answerdotai/ModernBERT-base",
5
+ "tokenizer": "hf",
6
+ "max_len": 512,
7
+ "max_question_tokens": 96,
8
+ "max_option_tokens": 32,
9
+ "max_options": 10,
10
+ "head_layers": 1,
11
+ "temperatures": {
12
+ "binary": 1.0594,
13
+ "choice": 1.0631,
14
+ "score": 1.0022,
15
+ "multi": 0.8276
16
+ },
17
+ "metrics": {
18
+ "test_calibrated": {
19
+ "acc": 0.7778176740474766,
20
+ "ece": 0.025550670609045353
21
+ },
22
+ "zeroshot_calibrated": {
23
+ "acc": 0.6121272507294855,
24
+ "ece": 0.04295260971909359
25
+ }
26
+ },
27
+ "multi_threshold": 0.5,
28
+ "created": "20260928-125453",
29
+ "name": "watersheep-20260928-125452"
30
+ }