Corran commited on
Commit
c5c4986
1 Parent(s): caceec8

Add SetFit model

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
 
 
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
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
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
+ }
README.md ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: setfit
3
+ tags:
4
+ - setfit
5
+ - sentence-transformers
6
+ - text-classification
7
+ - generated_from_setfit_trainer
8
+ metrics:
9
+ - accuracy
10
+ widget:
11
+ - text: considering the use of so-called “fractional citations” in which one divides
12
+ the number of citations associated with a given paper by the number of authors
13
+ on that paper [33–38];
14
+ - text: Indeed, this is only one of a number of such practical inconsistencies inherent
15
+ in the traditional h-index; other similar inconsistencies are discussed in Refs.
16
+ [3, 4].
17
+ - text: One of the referees recommends mentioning Quesada (2008) as another characterization
18
+ of the Hirsch index relying as well on monotonicity.
19
+ - text: considering the use of so-called “fractional citations” in which one divides
20
+ the number of citations associated with a given paper by the number of authors
21
+ on that paper [33–38];
22
+ - text: increasing the weighting of very highly-cited papers, either through the introduction
23
+ of intrinsic weighting factors or the development of entirely new indices which
24
+ mix the h-index with other more traditional indices (such as total citation count)
25
+ [3, 4, 7, 8, 26–32];
26
+ pipeline_tag: text-classification
27
+ inference: true
28
+ base_model: sentence-transformers/paraphrase-multilingual-mpnet-base-v2
29
+ model-index:
30
+ - name: SetFit with sentence-transformers/paraphrase-multilingual-mpnet-base-v2
31
+ results:
32
+ - task:
33
+ type: text-classification
34
+ name: Text Classification
35
+ dataset:
36
+ name: Unknown
37
+ type: unknown
38
+ split: test
39
+ metrics:
40
+ - type: accuracy
41
+ value: 0.6111111111111112
42
+ name: Accuracy
43
+ ---
44
+
45
+ # SetFit with sentence-transformers/paraphrase-multilingual-mpnet-base-v2
46
+
47
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [sentence-transformers/paraphrase-multilingual-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-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.
48
+
49
+ The model has been trained using an efficient few-shot learning technique that involves:
50
+
51
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
52
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
53
+
54
+ ## Model Details
55
+
56
+ ### Model Description
57
+ - **Model Type:** SetFit
58
+ - **Sentence Transformer body:** [sentence-transformers/paraphrase-multilingual-mpnet-base-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2)
59
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
60
+ - **Maximum Sequence Length:** 128 tokens
61
+ - **Number of Classes:** 9 classes
62
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
63
+ <!-- - **Language:** Unknown -->
64
+ <!-- - **License:** Unknown -->
65
+
66
+ ### Model Sources
67
+
68
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
69
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
70
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
71
+
72
+ ### Model Labels
73
+ | Label | Examples |
74
+ |:-----------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75
+ | ccro:BasedOn | <ul><li>'The axiomatizations presented in Quesada (2010, 2011) also dispense with strong monotonicity.'</li></ul> |
76
+ | ccro:Basedon | <ul><li>'A formal mathematical description of the h-index introduced by Hirsch (2005)'</li><li>'Woeginger (2008a, b) and Quesada (2009, 2010) have already suggested characterizations of the Hirsch index'</li><li>'Woeginger (2008a, b) and Quesada (2009, 2010) have already suggested characterizations of the Hirsch index'</li></ul> |
77
+ | ccro:Compare | <ul><li>'Instead, a variety of studies [8, 9] have shown that the h index by and large agrees with other objective and subjective measures of scientific quality in a variety of different disciplines (10–15),'</li><li>'Instead, a variety of studies [8, 9] have shown that the h index by and large agrees with other objective and subjective measures of scientific quality in a variety of different disciplines (10–15),'</li><li>'Instead, a variety of studies [8, 9] have shown that the h index by and large agrees with other objective and subjective measures of scientific quality in a variety of different disciplines (10–15),'</li></ul> |
78
+ | ccro:Contrast | <ul><li>'Hirsch (2005) argues that two individuals with similar Hirsch-index are comparable in terms of their overall scientific impact, even if their total number of papers or their total number of citations is very different.'</li><li>'The three differ from Woeginger’s (2008a) characterization in requiring fewer axioms (three instead of five)'</li><li>'Marchant (2009), instead of characterizing the index itself, characterizes the ranking that the Hirsch index induces on outputs.'</li></ul> |
79
+ | ccro:Criticize | <ul><li>'The h-index does not take into account that some papers may have extraordinarily many citations, and the g-index tries to compensate for this; see also Egghe (2006b) and Tol (2008).'</li><li>'The h-index does not take into account that some papers may have extraordinarily many citations, and the g-index tries to compensate for this; see also Egghe (2006b) and Tol (2008).'</li><li>'Woeginger (2008a, p. 227) stresses that his axioms should be interpreted within the context of MON.'</li></ul> |
80
+ | ccro:Discuss | <ul><li>'The relation between N and h will depend on the detailed form of the particular distribution (HI0501-01)'</li><li>'As discussed by Redner (HI0501-03), most papers earn their citations over a limited period of popularity and then they are no longer cited.'</li><li>'It is also possible that papers "drop out" and then later come back into the h count, as would occur for the kind of papers termed "sleeping beauties" (HI0501-04).'</li></ul> |
81
+ | ccro:Extend | <ul><li>'In [3] the analogous formula for the g-index has been proved'</li></ul> |
82
+ | ccro:Incorporate | <ul><li>'In this paper, we provide an axiomatic characterization of the Hirsch-index, in very much the same spirit as Arrow (1950, 1951), May (1952), and Moulin (1988) did for numerous other problems in mathematical decision making.'</li><li>'In this paper, we provide an axiomatic characterization of the Hirsch-index, in very much the same spirit as Arrow (1950, 1951), May (1952), and Moulin (1988) did for numerous other problems in mathematical decision making.'</li><li>'In this paper, we provide an axiomatic characterization of the Hirsch-index, in very much the same spirit as Arrow (1950, 1951), May (1952), and Moulin (1988) did for numerous other problems in mathematical decision making.'</li></ul> |
83
+ | ccro:Negate | <ul><li>'Recently, Lehmann et al. (2, 3) have argued that the mean number of citations per paper (nc = Nc/Np) is a superior indicator.'</li><li>'If one chose instead to use as indicator of scientific achievement the mean number of citations per paper [following Lehmann et al. (2, 3)], our results suggest that (as in the stock market) ‘‘past performance is not predictive of future performance.’’'</li><li>'It has been argued in the literature that one drawback of the h index is that it does not give enough ‘‘credit’’ to very highly cited papers, and various modifications have been proposed to correct this, in particular, Egghe’s g index (4), Jin et al.’s AR index (5), and Komulski’s H(2) index (6).'</li></ul> |
84
+
85
+ ## Evaluation
86
+
87
+ ### Metrics
88
+ | Label | Accuracy |
89
+ |:--------|:---------|
90
+ | **all** | 0.6111 |
91
+
92
+ ## Uses
93
+
94
+ ### Direct Use for Inference
95
+
96
+ First install the SetFit library:
97
+
98
+ ```bash
99
+ pip install setfit
100
+ ```
101
+
102
+ Then you can load this model and run inference.
103
+
104
+ ```python
105
+ from setfit import SetFitModel
106
+
107
+ # Download from the 🤗 Hub
108
+ model = SetFitModel.from_pretrained("Corran/CCRO2")
109
+ # Run inference
110
+ preds = model("One of the referees recommends mentioning Quesada (2008) as another characterization of the Hirsch index relying as well on monotonicity.")
111
+ ```
112
+
113
+ <!--
114
+ ### Downstream Use
115
+
116
+ *List how someone could finetune this model on their own dataset.*
117
+ -->
118
+
119
+ <!--
120
+ ### Out-of-Scope Use
121
+
122
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
123
+ -->
124
+
125
+ <!--
126
+ ## Bias, Risks and Limitations
127
+
128
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
129
+ -->
130
+
131
+ <!--
132
+ ### Recommendations
133
+
134
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
135
+ -->
136
+
137
+ ## Training Details
138
+
139
+ ### Training Set Metrics
140
+ | Training set | Min | Median | Max |
141
+ |:-------------|:----|:--------|:----|
142
+ | Word count | 6 | 25.7812 | 53 |
143
+
144
+ | Label | Training Sample Count |
145
+ |:-----------------|:----------------------|
146
+ | ccro:BasedOn | 1 |
147
+ | ccro:Basedon | 11 |
148
+ | ccro:Compare | 21 |
149
+ | ccro:Contrast | 3 |
150
+ | ccro:Criticize | 4 |
151
+ | ccro:Discuss | 37 |
152
+ | ccro:Extend | 1 |
153
+ | ccro:Incorporate | 14 |
154
+ | ccro:Negate | 4 |
155
+
156
+ ### Training Hyperparameters
157
+ - batch_size: (60, 60)
158
+ - num_epochs: (1, 1)
159
+ - max_steps: -1
160
+ - sampling_strategy: oversampling
161
+ - num_iterations: 100
162
+ - body_learning_rate: (2e-05, 1e-05)
163
+ - head_learning_rate: 0.01
164
+ - loss: CosineSimilarityLoss
165
+ - distance_metric: cosine_distance
166
+ - margin: 0.25
167
+ - end_to_end: False
168
+ - use_amp: False
169
+ - warmup_proportion: 0.1
170
+ - seed: 42
171
+ - eval_max_steps: -1
172
+ - load_best_model_at_end: False
173
+
174
+ ### Training Results
175
+ | Epoch | Step | Training Loss | Validation Loss |
176
+ |:------:|:----:|:-------------:|:---------------:|
177
+ | 0.0042 | 1 | 0.2507 | - |
178
+ | 0.2083 | 50 | 0.0639 | - |
179
+ | 0.4167 | 100 | 0.0017 | - |
180
+ | 0.625 | 150 | 0.0016 | - |
181
+ | 0.8333 | 200 | 0.0059 | - |
182
+ | 0.0031 | 1 | 0.0051 | - |
183
+ | 0.1562 | 50 | 0.0005 | - |
184
+ | 0.3125 | 100 | 0.001 | - |
185
+ | 0.4688 | 150 | 0.0001 | - |
186
+ | 0.625 | 200 | 0.0 | - |
187
+ | 0.7812 | 250 | 0.0 | - |
188
+ | 0.9375 | 300 | 0.0001 | - |
189
+
190
+ ### Framework Versions
191
+ - Python: 3.10.12
192
+ - SetFit: 1.0.3
193
+ - Sentence Transformers: 2.2.2
194
+ - Transformers: 4.35.2
195
+ - PyTorch: 2.1.0+cu121
196
+ - Datasets: 2.16.1
197
+ - Tokenizers: 0.15.0
198
+
199
+ ## Citation
200
+
201
+ ### BibTeX
202
+ ```bibtex
203
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
204
+ doi = {10.48550/ARXIV.2209.11055},
205
+ url = {https://arxiv.org/abs/2209.11055},
206
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
207
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
208
+ title = {Efficient Few-Shot Learning Without Prompts},
209
+ publisher = {arXiv},
210
+ year = {2022},
211
+ copyright = {Creative Commons Attribution 4.0 International}
212
+ }
213
+ ```
214
+
215
+ <!--
216
+ ## Glossary
217
+
218
+ *Clearly define terms in order to be accessible across audiences.*
219
+ -->
220
+
221
+ <!--
222
+ ## Model Card Authors
223
+
224
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
225
+ -->
226
+
227
+ <!--
228
+ ## Model Card Contact
229
+
230
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
231
+ -->
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-mpnet-base-v2/",
3
+ "architectures": [
4
+ "XLMRobertaModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "bos_token_id": 0,
8
+ "classifier_dropout": null,
9
+ "eos_token_id": 2,
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 768,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 3072,
16
+ "layer_norm_eps": 1e-05,
17
+ "max_position_embeddings": 514,
18
+ "model_type": "xlm-roberta",
19
+ "num_attention_heads": 12,
20
+ "num_hidden_layers": 12,
21
+ "output_past": true,
22
+ "pad_token_id": 1,
23
+ "position_embedding_type": "absolute",
24
+ "torch_dtype": "float32",
25
+ "transformers_version": "4.35.2",
26
+ "type_vocab_size": 1,
27
+ "use_cache": true,
28
+ "vocab_size": 250002
29
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.7.0",
5
+ "pytorch": "1.9.0+cu102"
6
+ }
7
+ }
config_setfit.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": [
4
+ "ccro:BasedOn",
5
+ "ccro:Basedon",
6
+ "ccro:Compare",
7
+ "ccro:Contrast",
8
+ "ccro:Criticize",
9
+ "ccro:Discuss",
10
+ "ccro:Extend",
11
+ "ccro:Incorporate",
12
+ "ccro:Negate"
13
+ ]
14
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bfd86da657464c270f76271dc20d7f6d86870d667b769a703ef66e094d02b27d
3
+ size 1112197096
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24dc8f4a7425b0125546aa47df2164901e4df9b5eefcf19217364265cb8472d1
3
+ size 56767
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": 128,
3
+ "do_lower_case": false
4
+ }
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa685fc160bbdbab64058d4fc91b60e62d207e8dc60b9af5c002c5ab946ded00
3
+ size 17083009
tokenizer_config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
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": true,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "max_length": 128,
50
+ "model_max_length": 512,
51
+ "pad_to_multiple_of": null,
52
+ "pad_token": "<pad>",
53
+ "pad_token_type_id": 0,
54
+ "padding_side": "right",
55
+ "sep_token": "</s>",
56
+ "stride": 0,
57
+ "tokenizer_class": "XLMRobertaTokenizer",
58
+ "truncation_side": "right",
59
+ "truncation_strategy": "longest_first",
60
+ "unk_token": "<unk>"
61
+ }