bew commited on
Commit
5679226
1 Parent(s): 27c692d

Push model using huggingface_hub.

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
3
+ "pooling_mode_cls_token": true,
4
+ "pooling_mode_mean_tokens": false,
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
+ }
README.md ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: Who was Cleopatra? She was a queen of ancient Egypt.
12
+ - text: Did you go anywhere interesting this weekend? Yes, I went to the zoo.
13
+ - text: Can robots think like humans? Not exactly, but AI can mimic some thinking
14
+ processes.
15
+ - text: Can you name an adjective? 'Quick' is an adjective because it describes.
16
+ - text: How does the water cycle work? Water evaporates, condenses into clouds, and
17
+ then precipitates back to the ground.
18
+ pipeline_tag: text-classification
19
+ inference: true
20
+ base_model: BAAI/bge-small-en-v1.5
21
+ ---
22
+
23
+ # SetFit with BAAI/bge-small-en-v1.5
24
+
25
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5) 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.
26
+
27
+ The model has been trained using an efficient few-shot learning technique that involves:
28
+
29
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
30
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
31
+
32
+ ## Model Details
33
+
34
+ ### Model Description
35
+ - **Model Type:** SetFit
36
+ - **Sentence Transformer body:** [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5)
37
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
38
+ - **Maximum Sequence Length:** 512 tokens
39
+ - **Number of Classes:** 7 classes
40
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
41
+ <!-- - **Language:** Unknown -->
42
+ <!-- - **License:** Unknown -->
43
+
44
+ ### Model Sources
45
+
46
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
47
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
48
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
49
+
50
+ ### Model Labels
51
+ | Label | Examples |
52
+ |:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
53
+ | English | <ul><li>"Can you tell me about your favorite book? I love 'Harry Potter' because it's full of magic and adventure."</li><li>'What did you learn about poems today? We learned about rhymes and how they create a rhythm in poems.'</li><li>"Can you make a sentence using the word 'enigmatic'? The old man's smile was enigmatic, making me wonder what secrets he hid."</li></ul> |
54
+ | Math | <ul><li>"What is 8 times 9? It's 72."</li><li>'How do you find the area of a rectangle? Multiply the length by the width.'</li><li>"What's the difference between a prime number and a composite number? A prime number has only two factors, 1 and itself, while a composite number has more than two factors."</li></ul> |
55
+ | Art | <ul><li>'What colors do you mix to make green? Yellow and blue make green.'</li><li>'Who painted the Mona Lisa? Leonardo da Vinci painted it.'</li><li>"What's the difference between sculpture and pottery? Sculpture is the art of making figures while pottery is specifically making vessels from clay."</li></ul> |
56
+ | Science | <ul><li>"What is photosynthesis? It's the process by which plants make their food using sunlight."</li><li>'Can you name the planets in our solar system? Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune.'</li><li>"What's the difference between a solid and a liquid? A solid has a fixed shape while a liquid takes the shape of its container."</li></ul> |
57
+ | History | <ul><li>'Who was the first president of the United States? George Washington was the first president.'</li><li>'Can you tell me about the Egyptian pyramids? They were massive tombs built for pharaohs, the biggest is the Pyramid of Giza.'</li><li>'What was the Renaissance? It was a period of great cultural and scientific advancement in Europe.'</li></ul> |
58
+ | Technology | <ul><li>"What is the Internet? It's a global network of computers that can share information."</li><li>'Can you name a famous computer scientist? Alan Turing is known as one of the fathers of computer science.'</li><li>"What does 'AI' stand for? It stands for Artificial Intelligence."</li></ul> |
59
+ | NONE | <ul><li>'What did you have for lunch today? I had a sandwich and some fruit.'</li><li>'Do you like playing outside? Yes, I love playing soccer with my friends.'</li><li>"What's your favorite TV show? I love watching 'SpongeBob SquarePants'."</li></ul> |
60
+
61
+ ## Uses
62
+
63
+ ### Direct Use for Inference
64
+
65
+ First install the SetFit library:
66
+
67
+ ```bash
68
+ pip install setfit
69
+ ```
70
+
71
+ Then you can load this model and run inference.
72
+
73
+ ```python
74
+ from setfit import SetFitModel
75
+
76
+ # Download from the 🤗 Hub
77
+ model = SetFitModel.from_pretrained("bew/setfit-subject-model-basic")
78
+ # Run inference
79
+ preds = model("Who was Cleopatra? She was a queen of ancient Egypt.")
80
+ ```
81
+
82
+ <!--
83
+ ### Downstream Use
84
+
85
+ *List how someone could finetune this model on their own dataset.*
86
+ -->
87
+
88
+ <!--
89
+ ### Out-of-Scope Use
90
+
91
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
92
+ -->
93
+
94
+ <!--
95
+ ## Bias, Risks and Limitations
96
+
97
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
98
+ -->
99
+
100
+ <!--
101
+ ### Recommendations
102
+
103
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
104
+ -->
105
+
106
+ ## Training Details
107
+
108
+ ### Training Set Metrics
109
+ | Training set | Min | Median | Max |
110
+ |:-------------|:----|:--------|:----|
111
+ | Word count | 6 | 14.1333 | 30 |
112
+
113
+ | Label | Training Sample Count |
114
+ |:-----------|:----------------------|
115
+ | Art | 10 |
116
+ | English | 10 |
117
+ | History | 10 |
118
+ | Math | 10 |
119
+ | NONE | 15 |
120
+ | Science | 10 |
121
+ | Technology | 10 |
122
+
123
+ ### Training Hyperparameters
124
+ - batch_size: (32, 32)
125
+ - num_epochs: (10, 10)
126
+ - max_steps: -1
127
+ - sampling_strategy: oversampling
128
+ - body_learning_rate: (2e-05, 1e-05)
129
+ - head_learning_rate: 0.01
130
+ - loss: CosineSimilarityLoss
131
+ - distance_metric: cosine_distance
132
+ - margin: 0.25
133
+ - end_to_end: False
134
+ - use_amp: False
135
+ - warmup_proportion: 0.1
136
+ - seed: 42
137
+ - eval_max_steps: -1
138
+ - load_best_model_at_end: False
139
+
140
+ ### Training Results
141
+ | Epoch | Step | Training Loss | Validation Loss |
142
+ |:------:|:----:|:-------------:|:---------------:|
143
+ | 0.0067 | 1 | 0.1987 | - |
144
+ | 0.3333 | 50 | 0.1814 | - |
145
+ | 0.6667 | 100 | 0.128 | - |
146
+ | 1.0 | 150 | 0.0146 | - |
147
+ | 1.3333 | 200 | 0.006 | - |
148
+ | 1.6667 | 250 | 0.0037 | - |
149
+ | 2.0 | 300 | 0.0031 | - |
150
+ | 2.3333 | 350 | 0.0027 | - |
151
+ | 2.6667 | 400 | 0.0024 | - |
152
+ | 3.0 | 450 | 0.0024 | - |
153
+ | 3.3333 | 500 | 0.002 | - |
154
+ | 3.6667 | 550 | 0.002 | - |
155
+ | 4.0 | 600 | 0.0017 | - |
156
+ | 4.3333 | 650 | 0.0019 | - |
157
+ | 4.6667 | 700 | 0.0018 | - |
158
+ | 5.0 | 750 | 0.0014 | - |
159
+ | 5.3333 | 800 | 0.0013 | - |
160
+ | 5.6667 | 850 | 0.0014 | - |
161
+ | 6.0 | 900 | 0.0014 | - |
162
+ | 6.3333 | 950 | 0.0014 | - |
163
+ | 6.6667 | 1000 | 0.0016 | - |
164
+ | 7.0 | 1050 | 0.0013 | - |
165
+ | 7.3333 | 1100 | 0.0013 | - |
166
+ | 7.6667 | 1150 | 0.0012 | - |
167
+ | 8.0 | 1200 | 0.0014 | - |
168
+ | 8.3333 | 1250 | 0.001 | - |
169
+ | 8.6667 | 1300 | 0.0012 | - |
170
+ | 9.0 | 1350 | 0.0014 | - |
171
+ | 9.3333 | 1400 | 0.0012 | - |
172
+ | 9.6667 | 1450 | 0.0012 | - |
173
+ | 10.0 | 1500 | 0.0011 | - |
174
+
175
+ ### Framework Versions
176
+ - Python: 3.10.12
177
+ - SetFit: 1.0.3
178
+ - Sentence Transformers: 2.3.1
179
+ - Transformers: 4.35.2
180
+ - PyTorch: 2.1.0+cu121
181
+ - Datasets: 2.17.0
182
+ - Tokenizers: 0.15.2
183
+
184
+ ## Citation
185
+
186
+ ### BibTeX
187
+ ```bibtex
188
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
189
+ doi = {10.48550/ARXIV.2209.11055},
190
+ url = {https://arxiv.org/abs/2209.11055},
191
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
192
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
193
+ title = {Efficient Few-Shot Learning Without Prompts},
194
+ publisher = {arXiv},
195
+ year = {2022},
196
+ copyright = {Creative Commons Attribution 4.0 International}
197
+ }
198
+ ```
199
+
200
+ <!--
201
+ ## Glossary
202
+
203
+ *Clearly define terms in order to be accessible across audiences.*
204
+ -->
205
+
206
+ <!--
207
+ ## Model Card Authors
208
+
209
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
210
+ -->
211
+
212
+ <!--
213
+ ## Model Card Contact
214
+
215
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
216
+ -->
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "BAAI/bge-small-en-v1.5",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 384,
11
+ "id2label": {
12
+ "0": "LABEL_0"
13
+ },
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 1536,
16
+ "label2id": {
17
+ "LABEL_0": 0
18
+ },
19
+ "layer_norm_eps": 1e-12,
20
+ "max_position_embeddings": 512,
21
+ "model_type": "bert",
22
+ "num_attention_heads": 12,
23
+ "num_hidden_layers": 12,
24
+ "pad_token_id": 0,
25
+ "position_embedding_type": "absolute",
26
+ "torch_dtype": "float32",
27
+ "transformers_version": "4.35.2",
28
+ "type_vocab_size": 2,
29
+ "use_cache": true,
30
+ "vocab_size": 30522
31
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.28.1",
5
+ "pytorch": "1.13.0+cu117"
6
+ }
7
+ }
config_setfit.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": [
4
+ "Art",
5
+ "English",
6
+ "History",
7
+ "Math",
8
+ "NONE",
9
+ "Science",
10
+ "Technology"
11
+ ]
12
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70e7ceb3c783d84186da0b847beb5192d78bc274b2ede2ef5ea62c4b661216ed
3
+ size 133462128
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ff9815077abf2ee920e760c8937213cd59a4da709101c382761c7a20edcd95f
3
+ size 22687
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.models.Normalize"
19
+ }
20
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": true
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