ashercn97 commited on
Commit
807f473
·
verified ·
1 Parent(s): 5a5ea14

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,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget:
8
+ - text: '- Barth BM, Shanmugavelandy SS, Tacelosky DM, Kester M, Morad SA, Cabot MC
9
+ (2013). "Gaucher''s disease and cancer: a sphingolipid perspective". Crit Rev
10
+ Oncog 18 (3): 221–34. doi:10.1615/critrevoncog.2013005814. PMC 3604879.'
11
+ - text: '"The intersection of attention-deficit/hyperactivity disorder and substance
12
+ abuse". Curr Opin Psychiatry. 24 (4): 280–285. doi:10.1097/YCO.0b013e328345c956.
13
+ PMC .'
14
+ - text: 'Parrilla-Rodriguez AM, Gorrin-Peralta JJ. La Lactancia Materna en Puerto
15
+ Rico: Patrones Tradicionales, Tendencias Nacionales y Estrategias para el Futuro.
16
+ P R Health Sci J 1999;18:223-228. (42.) Ni H, Simile C, Hardy AM.'
17
+ - text: 'For cases where there is an actual exposure to someone who is confirmed to
18
+ have COVID-19, report code Z20.828, Contact with and (suspected) exposure to other
19
+ viral communicable diseases. This code is not necessary if the exposed patient
20
+ is confirmed to have COVID-19. - Signs and symptoms: For patients presenting with
21
+ any signs/symptoms and where a definitive diagnosis has not been established,
22
+ assign the appropriate code(s) for each of the presenting signs and symptoms such
23
+ as: Cough (R05); Shortness of breath (R06.02) or Fever unspecified (R50.9). Do
24
+ not report “suspected” cases of COVID-19 with B97.29. In addition, diagnosis code
25
+ B34.2, Coronavirus infection, unspecified, typically is not appropriate.'
26
+ - text: '- HCPCS codes: what the provider used. - ICD-10-CM: why the provider ''did''
27
+ and ''used''. For example, if a urologist diagnoses a patient with bladder cancer
28
+ and performs a bladder instillation of 1 mg of Bacillus Calmette-Guerin (BCG)
29
+ to treat the tumor, the medical coder might assign:
30
+
31
+ - CPT® codes (did): 51720 (Bladder instillation of anticarcinogenic agent (including
32
+ retention time))
33
+
34
+ - HCPCS code (used): J9030 (BCG live intravesical instillation, 1mg)
35
+
36
+ - ICD-10 code (why): C67.9 (Malignant neoplasm of bladder, unspecified)
37
+
38
+ As mentioned above, though, there are some exceptions to these general code set
39
+ concepts. WHEN TO CHOOSE CPT® Vs HCPCS
40
+
41
+ First, not all payers accept HCPCS Level II codes. Initially intended for Medicare
42
+ claims, many private payers have since adopted the HCPCS Level II code set.'
43
+ metrics:
44
+ - accuracy
45
+ pipeline_tag: text-classification
46
+ library_name: setfit
47
+ inference: true
48
+ base_model: sentence-transformers/paraphrase-mpnet-base-v2
49
+ model-index:
50
+ - name: SetFit with sentence-transformers/paraphrase-mpnet-base-v2
51
+ results:
52
+ - task:
53
+ type: text-classification
54
+ name: Text Classification
55
+ dataset:
56
+ name: Unknown
57
+ type: unknown
58
+ split: test
59
+ metrics:
60
+ - type: accuracy
61
+ value: 0.8571428571428571
62
+ name: Accuracy
63
+ ---
64
+
65
+ # SetFit with sentence-transformers/paraphrase-mpnet-base-v2
66
+
67
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2) as the Sentence Transformer embedding model. A [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance is used for classification.
68
+
69
+ The model has been trained using an efficient few-shot learning technique that involves:
70
+
71
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
72
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
73
+
74
+ ## Model Details
75
+
76
+ ### Model Description
77
+ - **Model Type:** SetFit
78
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2)
79
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
80
+ - **Maximum Sequence Length:** 512 tokens
81
+ - **Number of Classes:** 2 classes
82
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
83
+ <!-- - **Language:** Unknown -->
84
+ <!-- - **License:** Unknown -->
85
+
86
+ ### Model Sources
87
+
88
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
89
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
90
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
91
+
92
+ ### Model Labels
93
+ | Label | Examples |
94
+ |:---------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
95
+ | negative | <ul><li>'Estimates of mortality attributable to TB\nVital registration systems were considered to be good in 81 countries with a total population of 2.7 billion (Table 4). Most of the population of the WHO European and South-East Asia Regions and the Region of the Americas was covered by good vital registration systems. However, this proportion was low (< 20%) in the African, Eastern Mediterranean and Western Pacific Regions (Table 4). Of the 22 countries with a high burden of TB, only three (India, Philippines and the Russian Federation) with a total population of 1.3 billion were considered to have good vital registration systems. Seventy-seven of the 81 countries with a good vital registration system reported data on mortality statistics using ICD-9 or ICD-10 to WHO.'</li><li>'2000. Aggressive behavior, increased accumbal dopamine, and decreased cortical serotonin in rats. Journal of Neuroscience, 20(24): 9320-9325. Van Gastel A, Schotte C, Maes M. 1997. The prediction of suicidal intent in depressed patients.'</li><li>'Conventional childhood and adult cardiovascular risk factors did not explain the association between place of birth and AF-related mortality. Lifecourse cardiovascular epidemiology has demonstrated that early life risk factors such as low birthweight and childhood socioeconomic adversity predict greater risk for angina and atherosclerosis as well as adult mortality from coronary heart disease and stroke. (Galobardes et al., 2006, Fabsitz and Feinleib, 1980, Batty et al., 2007, Glymour et al., 2007) Atrial fibrillation (AF) is the most common cardiac arrhythmia, (Benjamin et al., 2009, Magnani et al., 2011) and is responsible for significant morbidity from heart failure, dementia, and stroke, and increased mortality. Few articles have addressed whether early life conditions contribute to the development of AF. Preliminary evidence suggests that early life factors may influence AF, but via mechanisms distinct from those established for most other cardiovascular outcomes.'</li></ul> |
96
+ | positive | <ul><li>'As a result, these are not reimbursed at the usual rate, sometimes these are not paid at all. The provider has to have in-depth knowledge regarding the assignment of the correct primary and secondary diagnostic codes to ensure full reimbursement. • Reporting all professional services in all settings such as inpatient, outpatient, home and nursing facilities, correctly using the appropriate CPT five digit codes\n• Appropriate use of evaluation and management (E/M) codes or the five digit codes used to report non-procedural professional services. These codes should clearly highlight the complexity of the service provided. Tests such as gait and balance assessment, mini mental status exam, history, physical and family interview do not have their own CPT codes.'</li><li>'Possible locations of an aortic aneurysm are as follows:\n• Ascending (441.2); if ruptured, use 441.1;\n• Arch (441.2); if ruptured, use 441.1;\n• Descending, not otherwise specified (NOS) (441.9); if ruptured, use 441.5;\n• Thoracic descending (441.2); if ruptured, use 441.1;\n• Abdominal descending (441.4); if ruptured, use 441.3;\n• Thoracoabdominal (441.7); if ruptured, use 441.6;\n• Abdominal (441.4); if ruptured, use 441.3. An abdominal aortic aneurysm is the most common type. If an aortic aneurysm is documented but not specified as to site, assign code 441.9. A ruptured aortic aneurysm, NOS is classified to code 441.5. A pseudoaneurysm (false aneurysm) is an aneurysm that does not have some or all of the aortic wall layers.'</li><li>'International Classification of Diseases, Clinical Modification (ICD-9-CM) is an adaption created by the U.S. National Center for Health Statistics (NCHS) and used in assigning diagnostic and procedure codes associated with inpatient, outpatient, and physician office utilization in the United States. The ICD-9-CM is based on the ICD-9 but provides for additional morbidity detail. It is updated annually on October 1. It consists of two or three volumes:\n- Volumes 1 and 2 contain diagnosis codes. (Volume 1 is a tabular listing, and volume 2 is an index.)'</li></ul> |
97
+
98
+ ## Evaluation
99
+
100
+ ### Metrics
101
+ | Label | Accuracy |
102
+ |:--------|:---------|
103
+ | **all** | 0.8571 |
104
+
105
+ ## Uses
106
+
107
+ ### Direct Use for Inference
108
+
109
+ First install the SetFit library:
110
+
111
+ ```bash
112
+ pip install setfit
113
+ ```
114
+
115
+ Then you can load this model and run inference.
116
+
117
+ ```python
118
+ from setfit import SetFitModel
119
+
120
+ # Download from the 🤗 Hub
121
+ model = SetFitModel.from_pretrained("ashercn97/code-y-v3")
122
+ # Run inference
123
+ preds = model("\"The intersection of attention-deficit/hyperactivity disorder and substance abuse\". Curr Opin Psychiatry. 24 (4): 280–285. doi:10.1097/YCO.0b013e328345c956. PMC .")
124
+ ```
125
+
126
+ <!--
127
+ ### Downstream Use
128
+
129
+ *List how someone could finetune this model on their own dataset.*
130
+ -->
131
+
132
+ <!--
133
+ ### Out-of-Scope Use
134
+
135
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
136
+ -->
137
+
138
+ <!--
139
+ ## Bias, Risks and Limitations
140
+
141
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
142
+ -->
143
+
144
+ <!--
145
+ ### Recommendations
146
+
147
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
148
+ -->
149
+
150
+ ## Training Details
151
+
152
+ ### Training Set Metrics
153
+ | Training set | Min | Median | Max |
154
+ |:-------------|:----|:---------|:----|
155
+ | Word count | 21 | 101.3125 | 172 |
156
+
157
+ | Label | Training Sample Count |
158
+ |:---------|:----------------------|
159
+ | negative | 8 |
160
+ | positive | 8 |
161
+
162
+ ### Training Hyperparameters
163
+ - batch_size: (16, 16)
164
+ - num_epochs: (4, 4)
165
+ - max_steps: -1
166
+ - sampling_strategy: oversampling
167
+ - body_learning_rate: (2e-05, 1e-05)
168
+ - head_learning_rate: 0.01
169
+ - loss: CosineSimilarityLoss
170
+ - distance_metric: cosine_distance
171
+ - margin: 0.25
172
+ - end_to_end: False
173
+ - use_amp: False
174
+ - warmup_proportion: 0.1
175
+ - l2_weight: 0.01
176
+ - seed: 42
177
+ - eval_max_steps: -1
178
+ - load_best_model_at_end: True
179
+
180
+ ### Training Results
181
+ | Epoch | Step | Training Loss | Validation Loss |
182
+ |:------:|:----:|:-------------:|:---------------:|
183
+ | 0.1111 | 1 | 0.4011 | - |
184
+ | 1.0 | 9 | - | 0.1458 |
185
+ | 2.0 | 18 | - | 0.0775 |
186
+ | 3.0 | 27 | - | 0.0748 |
187
+ | 4.0 | 36 | - | 0.0664 |
188
+
189
+ ### Framework Versions
190
+ - Python: 3.10.12
191
+ - SetFit: 1.1.2
192
+ - Sentence Transformers: 4.0.2
193
+ - Transformers: 4.51.3
194
+ - PyTorch: 2.6.0
195
+ - Datasets: 3.5.0
196
+ - Tokenizers: 0.21.1
197
+
198
+ ## Citation
199
+
200
+ ### BibTeX
201
+ ```bibtex
202
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
203
+ doi = {10.48550/ARXIV.2209.11055},
204
+ url = {https://arxiv.org/abs/2209.11055},
205
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
206
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
207
+ title = {Efficient Few-Shot Learning Without Prompts},
208
+ publisher = {arXiv},
209
+ year = {2022},
210
+ copyright = {Creative Commons Attribution 4.0 International}
211
+ }
212
+ ```
213
+
214
+ <!--
215
+ ## Glossary
216
+
217
+ *Clearly define terms in order to be accessible across audiences.*
218
+ -->
219
+
220
+ <!--
221
+ ## Model Card Authors
222
+
223
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
224
+ -->
225
+
226
+ <!--
227
+ ## Model Card Contact
228
+
229
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
230
+ -->
config.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MPNetModel"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 768,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 3072,
13
+ "layer_norm_eps": 1e-05,
14
+ "max_position_embeddings": 514,
15
+ "model_type": "mpnet",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "pad_token_id": 1,
19
+ "relative_attention_num_buckets": 32,
20
+ "torch_dtype": "float32",
21
+ "transformers_version": "4.51.3",
22
+ "vocab_size": 30527
23
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "4.0.2",
4
+ "transformers": "4.51.3",
5
+ "pytorch": "2.6.0"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": [
4
+ "negative",
5
+ "positive"
6
+ ]
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06a2e908bdc7e7636b76bc2e7f543555655672f10a092caa16d0e75d860d5f89
3
+ size 437967672
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e8990e4411285ca4cc91ada89d9b6d945b31ddeb444d56417b7b66ca725cab48
3
+ size 7055
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,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": true,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "[UNK]",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "104": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "30526": {
36
+ "content": "<mask>",
37
+ "lstrip": true,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": false,
46
+ "cls_token": "<s>",
47
+ "do_basic_tokenize": true,
48
+ "do_lower_case": true,
49
+ "eos_token": "</s>",
50
+ "extra_special_tokens": {},
51
+ "mask_token": "<mask>",
52
+ "model_max_length": 512,
53
+ "never_split": null,
54
+ "pad_token": "<pad>",
55
+ "sep_token": "</s>",
56
+ "strip_accents": null,
57
+ "tokenize_chinese_chars": true,
58
+ "tokenizer_class": "MPNetTokenizer",
59
+ "unk_token": "[UNK]"
60
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff