yasirdemircan commited on
Commit
8c6a8c4
·
verified ·
1 Parent(s): 1841f18

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
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,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: cross-encoder/ms-marco-MiniLM-L-6-v2
3
+ library_name: setfit
4
+ metrics:
5
+ - accuracy
6
+ pipeline_tag: text-classification
7
+ tags:
8
+ - setfit
9
+ - sentence-transformers
10
+ - text-classification
11
+ - generated_from_setfit_trainer
12
+ widget:
13
+ - text: The internal DRBG state value of the RNG is stored in NVRAM for persistent
14
+ use.
15
+ - text: X9.31 PRNG seed keys Triple-DES (112 bit) Generated by gathering entropy.
16
+ - text: A hardware noise source is used as a non-Approved RNG to generate seed material
17
+ (consisting of random sequences of ones and zeroes) for the FIPS-approved RNG.
18
+ - text: ANSI X9.31 RNG Seed Key 168-bit TDES keys/ 256-bit AES key Generated by the
19
+ TRNG.
20
+ - text: X9.31 PRNG seed keys Triple-DES (112 bit) Generated by gathering entropy RAM
21
+ only
22
+ inference: true
23
+ ---
24
+
25
+ # SetFit with cross-encoder/ms-marco-MiniLM-L-6-v2
26
+
27
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [cross-encoder/ms-marco-MiniLM-L-6-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-6-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.
28
+
29
+ The model has been trained using an efficient few-shot learning technique that involves:
30
+
31
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
32
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
33
+
34
+ ## Model Details
35
+
36
+ ### Model Description
37
+ - **Model Type:** SetFit
38
+ - **Sentence Transformer body:** [cross-encoder/ms-marco-MiniLM-L-6-v2](https://huggingface.co/cross-encoder/ms-marco-MiniLM-L-6-v2)
39
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
40
+ - **Maximum Sequence Length:** 512 tokens
41
+ - **Number of Classes:** 2 classes
42
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
43
+ <!-- - **Language:** Unknown -->
44
+ <!-- - **License:** Unknown -->
45
+
46
+ ### Model Sources
47
+
48
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
49
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
50
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
51
+
52
+ ### Model Labels
53
+ | Label | Examples |
54
+ |:---------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
55
+ | positive | <ul><li>'PRNG seed key Pre-loaded during the manufacturing process, compiled in the binary.'</li><li>'RNG Key ANSI X9.31 AES 128 bits Key used by the Approved RNG underlying encryption algorithm N/A In plaintext in tamper protected memory entered in factory.'</li><li>'The PRNG seed key is pre-loaded during manufacturing and compiled directly into the binary code.'</li></ul> |
56
+ | negative | <ul><li>'The seed key is used as an input to the X9.31 RNG, a deterministic random number generator, and is generally not stored long term.'</li><li>'module stores RNG and DRBG state values only in RAM.'</li><li>'128 bits Random Number Key Key value is used by the random number generator. RTC-RAM Zeroize CSPs service.'</li></ul> |
57
+
58
+ ## Uses
59
+
60
+ ### Direct Use for Inference
61
+
62
+ First install the SetFit library:
63
+
64
+ ```bash
65
+ pip install setfit
66
+ ```
67
+
68
+ Then you can load this model and run inference.
69
+
70
+ ```python
71
+ from setfit import SetFitModel
72
+
73
+ # Download from the 🤗 Hub
74
+ model = SetFitModel.from_pretrained("yasirdemircan/setfit_rng_v3")
75
+ # Run inference
76
+ preds = model("X9.31 PRNG seed keys Triple-DES (112 bit) Generated by gathering entropy.")
77
+ ```
78
+
79
+ <!--
80
+ ### Downstream Use
81
+
82
+ *List how someone could finetune this model on their own dataset.*
83
+ -->
84
+
85
+ <!--
86
+ ### Out-of-Scope Use
87
+
88
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
89
+ -->
90
+
91
+ <!--
92
+ ## Bias, Risks and Limitations
93
+
94
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
95
+ -->
96
+
97
+ <!--
98
+ ### Recommendations
99
+
100
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
101
+ -->
102
+
103
+ ## Training Details
104
+
105
+ ### Training Set Metrics
106
+ | Training set | Min | Median | Max |
107
+ |:-------------|:----|:-------|:----|
108
+ | Word count | 6 | 19.2 | 53 |
109
+
110
+ | Label | Training Sample Count |
111
+ |:---------|:----------------------|
112
+ | negative | 22 |
113
+ | positive | 23 |
114
+
115
+ ### Training Hyperparameters
116
+ - batch_size: (16, 16)
117
+ - num_epochs: (4, 4)
118
+ - max_steps: -1
119
+ - sampling_strategy: oversampling
120
+ - body_learning_rate: (2e-05, 1e-05)
121
+ - head_learning_rate: 0.01
122
+ - loss: CosineSimilarityLoss
123
+ - distance_metric: cosine_distance
124
+ - margin: 0.25
125
+ - end_to_end: False
126
+ - use_amp: False
127
+ - warmup_proportion: 0.1
128
+ - l2_weight: 0.01
129
+ - seed: 42
130
+ - eval_max_steps: -1
131
+ - load_best_model_at_end: True
132
+
133
+ ### Training Results
134
+ | Epoch | Step | Training Loss | Validation Loss |
135
+ |:------:|:----:|:-------------:|:---------------:|
136
+ | 0.0149 | 1 | 0.1738 | - |
137
+ | 0.7463 | 50 | 0.3142 | - |
138
+ | 1.0 | 67 | - | 0.3065 |
139
+ | 1.4925 | 100 | 0.045 | - |
140
+ | 2.0 | 134 | - | 0.2712 |
141
+ | 2.2388 | 150 | 0.0053 | - |
142
+ | 2.9851 | 200 | 0.0023 | - |
143
+ | 3.0 | 201 | - | 0.2794 |
144
+ | 3.7313 | 250 | 0.0018 | - |
145
+ | 4.0 | 268 | - | 0.2812 |
146
+
147
+ ### Framework Versions
148
+ - Python: 3.10.15
149
+ - SetFit: 1.2.0.dev0
150
+ - Sentence Transformers: 3.3.1
151
+ - Transformers: 4.45.2
152
+ - PyTorch: 2.5.1+cu124
153
+ - Datasets: 2.19.1
154
+ - Tokenizers: 0.20.1
155
+
156
+ ## Citation
157
+
158
+ ### BibTeX
159
+ ```bibtex
160
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
161
+ doi = {10.48550/ARXIV.2209.11055},
162
+ url = {https://arxiv.org/abs/2209.11055},
163
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
164
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
165
+ title = {Efficient Few-Shot Learning Without Prompts},
166
+ publisher = {arXiv},
167
+ year = {2022},
168
+ copyright = {Creative Commons Attribution 4.0 International}
169
+ }
170
+ ```
171
+
172
+ <!--
173
+ ## Glossary
174
+
175
+ *Clearly define terms in order to be accessible across audiences.*
176
+ -->
177
+
178
+ <!--
179
+ ## Model Card Authors
180
+
181
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
182
+ -->
183
+
184
+ <!--
185
+ ## Model Card Contact
186
+
187
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
188
+ -->
config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "cross-encoder/ms-marco-MiniLM-L-6-v2",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 384,
12
+ "id2label": {
13
+ "0": "LABEL_0"
14
+ },
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 1536,
17
+ "label2id": {
18
+ "LABEL_0": 0
19
+ },
20
+ "layer_norm_eps": 1e-12,
21
+ "max_position_embeddings": 512,
22
+ "model_type": "bert",
23
+ "num_attention_heads": 12,
24
+ "num_hidden_layers": 6,
25
+ "pad_token_id": 0,
26
+ "position_embedding_type": "absolute",
27
+ "sbert_ce_default_activation_function": "torch.nn.modules.linear.Identity",
28
+ "torch_dtype": "float32",
29
+ "transformers_version": "4.45.2",
30
+ "type_vocab_size": 2,
31
+ "use_cache": true,
32
+ "vocab_size": 30522
33
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.3.1",
4
+ "transformers": "4.45.2",
5
+ "pytorch": "2.5.1+cu124"
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:1029baca611f2a3e126c834a86c701b72b455e5f39d50add39f1079b55cf5c8e
3
+ size 90864192
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf08e868ca18751478ca82efbe18b004171f3fbbb844d906a0b32c27a97c63fc
3
+ size 3983
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,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
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