rkoh commited on
Commit
27b1dfd
·
verified ·
1 Parent(s): 2b370ab

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ metrics:
4
+ - accuracy
5
+ pipeline_tag: text-classification
6
+ tags:
7
+ - setfit
8
+ - sentence-transformers
9
+ - text-classification
10
+ - generated_from_setfit_trainer
11
+ widget:
12
+ - text: (1) The purpose of these rules is to provide administrative procedures for
13
+ fetal, infant, and maternal death reviews, and maternal and family interviews,
14
+ or both. (2) The program brings together key members of the community to review
15
+ cases of fetal, infant, and maternal deaths in order to identify the factors associated
16
+ with those deaths, to determine if those deaths represent system issues that require
17
+ change, to develop recommendations for change, and to assist in the implementation
18
+ of change. (3) The program's goal is to enhance the health and well-being of women,
19
+ infants, and families by improving the community resources and service delivery
20
+ systems available to them. The programs are operated under the auspices of the
21
+ Alabama Department of Public Health (ADPH), Bureau of Family Health Services,
22
+ State Perinatal Program.
23
+ - text: '(a) The enterprise fund may be used to cover closure costs only for major
24
+ waste tire facilities operated by government agencies. (b) The enterprise fund
25
+ shall dedicate its revenue exclusively or with exclusive first priority to financing
26
+ closure activities. (c) The enterprise fund shall be established and the documents
27
+ shall be worded as specified by using form CalRecycle 144 "Enterprise Fund for
28
+ Financial Assurances" (03/17), which is incorporated herein by reference. (See
29
+ Appendix A.) The wording, however, may be modified to accommodate special circumstances
30
+ on a case-by-case basis, as approved by the Board or its designee. (d) Revenue
31
+ generated by an enterprise fund shall be deposited into a financial assurance
32
+ mechanism which: (1) Provides equivalent protection to a trust fund as described
33
+ in section 18474 of this Article; (2) Shall be funded within five years as described
34
+ in Section 18474 of this Article; (3) Is used exclusively to finance closure activities
35
+ and shall remain inviolate against all other claims, including any claims by the
36
+ operator, the operator''s governing body, and the creditors of the operator and
37
+ its governing body; (4) Authorizes the Board or its designee to direct the provider
38
+ of financial assurance to pay closure costs if the Board or its designee determines
39
+ that the operator has failed to perform closure activities covered by the mechanism;
40
+ (5) Is maintained by a provider whose financial operations are regulated by a
41
+ federal or state agency, or the provider is otherwise certain to maintain and
42
+ disburse the assured funds properly; (6) Is maintained by a provider who has authority
43
+ to invest revenue deposited into the mechanism. (7) Meets other requirements that
44
+ the Board determines are necessary to ensure that the assured amount of funds
45
+ shall be available for closure activities in a timely manner.'
46
+ - text: (a) Various laws provide for the issuance of certifications by the state board
47
+ or regional boards. These regulations specify how the state board and the regional
48
+ boards implement various certification programs and how the state board acts on
49
+ petitions for reconsideration of certification actions or failures to act by the
50
+ executive director, regional boards, and executive officers. (b) Within five years
51
+ from the effective date of these regulations, the state board, in consultation
52
+ with the Secretary for Environmental Protection, shall review the provisions of
53
+ this Chapter to determine whether they should be retained, revised, or repealed.
54
+ - text: The Tax Reform Act of 1986, as amended, (the "act") establishes a Federal
55
+ tax credit ("low- income housing credit," "LIHTC" or "credit") administered by
56
+ state housing agencies for owners of housing for persons of low-income. The act
57
+ authorizes the governor of each state to allocate the low-income housing credit
58
+ ceiling among governmental units and other issuing authorities in the state. The
59
+ act requires that the allocation of credit to owners of low-income housing be
60
+ coordinated by a single state housing credit agency. The act further requires
61
+ each agency allocating credits to adopt a qualified allocation plan (the "plan"
62
+ or the "QAP") which sets forth the criteria and preferences by which credit will
63
+ be allocated to projects. By Executive Order, the New York State Division of Housing
64
+ and Community Renewal has been designated as the State Housing Credit Agency to
65
+ allocate the credit in a manner which maximizes the public benefit by addressing
66
+ the State's need for low-income housing and community revitalization incentives.
67
+ In order to provide for the effective coordination of the State's low-income housing
68
+ credit program with section 42 of the United States Internal Revenue Code (the
69
+ "code"), this plan shall be construed and administered in a manner consistent
70
+ with the code and regulations promulgated thereunder.
71
+ - text: It is the purpose and intent of the stream quality objectives specified in
72
+ the comprehensive plan to apply to artificial (man-made, as opposed to natural)
73
+ causes of pollution.
74
+ inference: true
75
+ ---
76
+
77
+ # SetFit
78
+
79
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
80
+
81
+ The model has been trained using an efficient few-shot learning technique that involves:
82
+
83
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
84
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
85
+
86
+ ## Model Details
87
+
88
+ ### Model Description
89
+ - **Model Type:** SetFit
90
+ <!-- - **Sentence Transformer:** [Unknown](https://huggingface.co/unknown) -->
91
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
92
+ - **Maximum Sequence Length:** 512 tokens
93
+ - **Number of Classes:** 32 classes
94
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
95
+ <!-- - **Language:** Unknown -->
96
+ <!-- - **License:** Unknown -->
97
+
98
+ ### Model Sources
99
+
100
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
101
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
102
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
103
+
104
+ ## Uses
105
+
106
+ ### Direct Use for Inference
107
+
108
+ First install the SetFit library:
109
+
110
+ ```bash
111
+ pip install setfit
112
+ ```
113
+
114
+ Then you can load this model and run inference.
115
+
116
+ ```python
117
+ from setfit import SetFitModel
118
+
119
+ # Download from the 🤗 Hub
120
+ model = SetFitModel.from_pretrained("rkoh/setfit-bert-a6-8per")
121
+ # Run inference
122
+ preds = model("It is the purpose and intent of the stream quality objectives specified in the comprehensive plan to apply to artificial (man-made, as opposed to natural) causes of pollution.")
123
+ ```
124
+
125
+ <!--
126
+ ### Downstream Use
127
+
128
+ *List how someone could finetune this model on their own dataset.*
129
+ -->
130
+
131
+ <!--
132
+ ### Out-of-Scope Use
133
+
134
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
135
+ -->
136
+
137
+ <!--
138
+ ## Bias, Risks and Limitations
139
+
140
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
141
+ -->
142
+
143
+ <!--
144
+ ### Recommendations
145
+
146
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
147
+ -->
148
+
149
+ ## Training Details
150
+
151
+ ### Training Set Metrics
152
+ | Training set | Min | Median | Max |
153
+ |:-------------|:-----------|:-----------------|:-------------|
154
+ | Word count | tensor(31) | tensor(329.9688) | tensor(4265) |
155
+
156
+ | Label | Training Sample Count |
157
+ |:-----------------------|:----------------------|
158
+ | non-purpose | 0 |
159
+ | purpose-administrative | 0 |
160
+ | purpose-regulatory | 0 |
161
+ | purpose-with-authority | 0 |
162
+ | purpose-with-scope | 0 |
163
+
164
+ ### Training Hyperparameters
165
+ - batch_size: (32, 32)
166
+ - num_epochs: (1, 1)
167
+ - max_steps: -1
168
+ - sampling_strategy: oversampling
169
+ - num_iterations: 20
170
+ - body_learning_rate: (2e-05, 1e-05)
171
+ - head_learning_rate: 0.01
172
+ - loss: CosineSimilarityLoss
173
+ - distance_metric: cosine_distance
174
+ - margin: 0.25
175
+ - end_to_end: False
176
+ - use_amp: False
177
+ - warmup_proportion: 0.1
178
+ - l2_weight: 0.01
179
+ - seed: 42
180
+ - eval_max_steps: -1
181
+ - load_best_model_at_end: True
182
+
183
+ ### Training Results
184
+ | Epoch | Step | Training Loss | Validation Loss |
185
+ |:-----:|:----:|:-------------:|:---------------:|
186
+ | 0.025 | 1 | 0.478 | - |
187
+ | 0.25 | 10 | 0.3818 | - |
188
+ | 0.5 | 20 | 0.3011 | - |
189
+ | 0.75 | 30 | 0.2555 | - |
190
+ | 1.0 | 40 | 0.1938 | 0.2208 |
191
+
192
+ ### Framework Versions
193
+ - Python: 3.10.12
194
+ - SetFit: 1.1.0
195
+ - Sentence Transformers: 3.2.1
196
+ - Transformers: 4.44.2
197
+ - PyTorch: 2.4.1+cu121
198
+ - Datasets: 3.0.2
199
+ - Tokenizers: 0.19.1
200
+
201
+ ## Citation
202
+
203
+ ### BibTeX
204
+ ```bibtex
205
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
206
+ doi = {10.48550/ARXIV.2209.11055},
207
+ url = {https://arxiv.org/abs/2209.11055},
208
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
209
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
210
+ title = {Efficient Few-Shot Learning Without Prompts},
211
+ publisher = {arXiv},
212
+ year = {2022},
213
+ copyright = {Creative Commons Attribution 4.0 International}
214
+ }
215
+ ```
216
+
217
+ <!--
218
+ ## Glossary
219
+
220
+ *Clearly define terms in order to be accessible across audiences.*
221
+ -->
222
+
223
+ <!--
224
+ ## Model Card Authors
225
+
226
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
227
+ -->
228
+
229
+ <!--
230
+ ## Model Card Contact
231
+
232
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
233
+ -->
config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/content/drive/My Drive/Fall-2024/models/legal-bert",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_ids": 0,
10
+ "hidden_act": "gelu",
11
+ "hidden_dropout_prob": 0.1,
12
+ "hidden_size": 768,
13
+ "id2label": {
14
+ "0": "LABEL_0",
15
+ "1": "LABEL_1",
16
+ "2": "LABEL_2",
17
+ "3": "LABEL_3",
18
+ "4": "LABEL_4"
19
+ },
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 3072,
22
+ "label2id": {
23
+ "LABEL_0": 0,
24
+ "LABEL_1": 1,
25
+ "LABEL_2": 2,
26
+ "LABEL_3": 3,
27
+ "LABEL_4": 4
28
+ },
29
+ "layer_norm_eps": 1e-12,
30
+ "max_position_embeddings": 512,
31
+ "model_type": "bert",
32
+ "num_attention_heads": 12,
33
+ "num_hidden_layers": 12,
34
+ "output_past": true,
35
+ "pad_token_id": 0,
36
+ "position_embedding_type": "absolute",
37
+ "problem_type": "single_label_classification",
38
+ "torch_dtype": "float32",
39
+ "transformers_version": "4.44.2",
40
+ "type_vocab_size": 2,
41
+ "use_cache": true,
42
+ "vocab_size": 30522
43
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.2.1",
4
+ "transformers": "4.44.2",
5
+ "pytorch": "2.4.1+cu121"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "labels": [
3
+ "non-purpose",
4
+ "purpose-administrative",
5
+ "purpose-regulatory",
6
+ "purpose-with-authority",
7
+ "purpose-with-scope"
8
+ ],
9
+ "normalize_embeddings": false
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5ee76df3676687c9122b7f166b4aee383591e6064f2fa7112dbfa691b93cf29
3
+ size 437951328
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:88f91083fb9a00a715839bd573ca356b3804948275ba10ddc2102890d1cc96c2
3
+ size 31647
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ }
14
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "never_split": null,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "BertTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff