JohanHeinsen commited on
Commit
fecace0
·
verified ·
1 Parent(s): 33b5e8c

Push model using huggingface_hub.

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,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - setfit
4
+ - sentence-transformers
5
+ - text-classification
6
+ - generated_from_setfit_trainer
7
+ widget:
8
+ - text: En Kokkepige søger Condition hos et Herskab eller honette Borgerfolk, enten
9
+ strax eller til St. Hansdag, anvises i Adelgaden No. 287, første Bagsal.
10
+ - text: En anstændig Pige ønsker Condition som Stue, Kokke= eller Ene=Pige. Hun forstaaer
11
+ Hvad hun paatage sig og recommenderes fra det Sted, hun nu tjener, paa Hjørnet
12
+ af Raadhuusstrædet og Brolæggerstrædet Nr. 46, anden Sal.
13
+ - text: Et anstændig Fruentimmer som i flere Aar har tient i store Landhuusholdninger,
14
+ ønsker sig en saadan Tieneste igien til 1ste November.
15
+ - text: En Pige søger Tieneste hos eenlige Folk, eller hvor der er et Par Børn at
16
+ passe, anvises i lille Færgestrædet Nr. 231.
17
+ - text: Formedelst Sygdom er en Tieneste ledig for en Pige som kan malke, men uden
18
+ godt Skudsmaal nytter det ikke at melde sig; Anviisningengives i Gothersgaden
19
+ 15.
20
+ metrics:
21
+ - accuracy
22
+ - f1
23
+ - precision
24
+ - recall
25
+ pipeline_tag: text-classification
26
+ library_name: setfit
27
+ inference: true
28
+ base_model: JohanHeinsen/Old_News_Segmentation_SBERT_V0.1
29
+ model-index:
30
+ - name: SetFit with JohanHeinsen/Old_News_Segmentation_SBERT_V0.1
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.9433962264150944
42
+ name: Accuracy
43
+ - type: f1
44
+ value: 0.9238578680203046
45
+ name: F1
46
+ - type: precision
47
+ value: 0.8921568627450981
48
+ name: Precision
49
+ - type: recall
50
+ value: 0.9578947368421052
51
+ name: Recall
52
+ ---
53
+
54
+ # SetFit with JohanHeinsen/Old_News_Segmentation_SBERT_V0.1
55
+
56
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [JohanHeinsen/Old_News_Segmentation_SBERT_V0.1](https://huggingface.co/JohanHeinsen/Old_News_Segmentation_SBERT_V0.1) 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.
57
+
58
+ The model has been trained using an efficient few-shot learning technique that involves:
59
+
60
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
61
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
62
+
63
+ ## Model Details
64
+
65
+ ### Model Description
66
+ - **Model Type:** SetFit
67
+ - **Sentence Transformer body:** [JohanHeinsen/Old_News_Segmentation_SBERT_V0.1](https://huggingface.co/JohanHeinsen/Old_News_Segmentation_SBERT_V0.1)
68
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
69
+ - **Maximum Sequence Length:** 512 tokens
70
+ - **Number of Classes:** 2 classes
71
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
72
+ <!-- - **Language:** Unknown -->
73
+ <!-- - **License:** Unknown -->
74
+
75
+ ### Model Sources
76
+
77
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
78
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
79
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
80
+
81
+ ### Model Labels
82
+ | Label | Examples |
83
+ |:------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
84
+ | 0 | <ul><li>'En skikkelig Karl fra Jylland søger Condition til St. Hansdag og er at finde paa Christianshavn paa Hiørnet af Dronningensgade og Torvegagen i Kielderen i Nr. 359.'</li><li>'En Amme søger Plads, eller i Mangel som Goldamme, er at finde i Nyehavn, anden Port fra Charlottenborg.'</li><li>'En skikkelig Pige, som kan forevise de bedste Skudsmaale, ønsker sig en Tieneste som Frøkenpige eller Stuepige til 1ste Novbr. enten paa en Herregaard eller hos en honet Familie i Kiøbstæden. Hun anvises fra Adressecomtoiret.'</li></ul> |
85
+ | 1 | <ul><li>'En skikkelig Jomfru, som forstaaer godt Madlavning, Vadsk, Reengjøren og deslige, kan faae Condition paa Vesterbro Nr. 63, men uden gode Recommendationer om Troskab og god Opførsel nytter det ikke at mælde sig.'</li><li>'En Pige, som kan paatage sig et Kjøkken, kan strax faae Condition, naar hun mælder sig i Toldbodgaden Nr. 44, i Stuen.'</li><li>'En Goldamme kan strax faae Condition i Kronprindsensgaden Nr. 39, 3die Sal.'</li></ul> |
86
+
87
+ ## Evaluation
88
+
89
+ ### Metrics
90
+ | Label | Accuracy | F1 | Precision | Recall |
91
+ |:--------|:---------|:-------|:----------|:-------|
92
+ | **all** | 0.9434 | 0.9239 | 0.8922 | 0.9579 |
93
+
94
+ ## Uses
95
+
96
+ ### Direct Use for Inference
97
+
98
+ First install the SetFit library:
99
+
100
+ ```bash
101
+ pip install setfit
102
+ ```
103
+
104
+ Then you can load this model and run inference.
105
+
106
+ ```python
107
+ from setfit import SetFitModel
108
+
109
+ # Download from the 🤗 Hub
110
+ model = SetFitModel.from_pretrained("setfit_model_id")
111
+ # Run inference
112
+ preds = model("En Pige søger Tieneste hos eenlige Folk, eller hvor der er et Par Børn at passe, anvises i lille Færgestrædet Nr. 231.")
113
+ ```
114
+
115
+ <!--
116
+ ### Downstream Use
117
+
118
+ *List how someone could finetune this model on their own dataset.*
119
+ -->
120
+
121
+ <!--
122
+ ### Out-of-Scope Use
123
+
124
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
125
+ -->
126
+
127
+ <!--
128
+ ## Bias, Risks and Limitations
129
+
130
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
131
+ -->
132
+
133
+ <!--
134
+ ### Recommendations
135
+
136
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
137
+ -->
138
+
139
+ ## Training Details
140
+
141
+ ### Training Set Metrics
142
+ | Training set | Min | Median | Max |
143
+ |:-------------|:----|:--------|:----|
144
+ | Word count | 8 | 32.1640 | 176 |
145
+
146
+ | Label | Training Sample Count |
147
+ |:------|:----------------------|
148
+ | 0 | 389 |
149
+ | 1 | 227 |
150
+
151
+ ### Training Hyperparameters
152
+ - batch_size: (16, 16)
153
+ - num_epochs: (2, 2)
154
+ - max_steps: -1
155
+ - sampling_strategy: oversampling
156
+ - num_iterations: 12
157
+ - body_learning_rate: (2e-05, 2e-05)
158
+ - head_learning_rate: 2e-05
159
+ - loss: CosineSimilarityLoss
160
+ - distance_metric: cosine_distance
161
+ - margin: 0.25
162
+ - end_to_end: False
163
+ - use_amp: False
164
+ - warmup_proportion: 0.1
165
+ - l2_weight: 0.01
166
+ - seed: 42
167
+ - eval_max_steps: -1
168
+ - load_best_model_at_end: False
169
+
170
+ ### Training Results
171
+ | Epoch | Step | Training Loss | Validation Loss |
172
+ |:------:|:----:|:-------------:|:---------------:|
173
+ | 0.0011 | 1 | 0.0621 | - |
174
+ | 0.0541 | 50 | 0.2937 | - |
175
+ | 0.1082 | 100 | 0.1367 | - |
176
+ | 0.1623 | 150 | 0.037 | - |
177
+ | 0.2165 | 200 | 0.0215 | - |
178
+ | 0.2706 | 250 | 0.0165 | - |
179
+ | 0.3247 | 300 | 0.0103 | - |
180
+ | 0.3788 | 350 | 0.0134 | - |
181
+ | 0.4329 | 400 | 0.0146 | - |
182
+ | 0.4870 | 450 | 0.003 | - |
183
+ | 0.5411 | 500 | 0.0028 | - |
184
+ | 0.5952 | 550 | 0.0027 | - |
185
+ | 0.6494 | 600 | 0.0039 | - |
186
+ | 0.7035 | 650 | 0.0003 | - |
187
+ | 0.7576 | 700 | 0.0001 | - |
188
+ | 0.8117 | 750 | 0.0001 | - |
189
+ | 0.8658 | 800 | 0.0001 | - |
190
+ | 0.9199 | 850 | 0.0001 | - |
191
+ | 0.9740 | 900 | 0.0 | - |
192
+ | 1.0281 | 950 | 0.0 | - |
193
+ | 1.0823 | 1000 | 0.0 | - |
194
+ | 1.1364 | 1050 | 0.0 | - |
195
+ | 1.1905 | 1100 | 0.0 | - |
196
+ | 1.2446 | 1150 | 0.0 | - |
197
+ | 1.2987 | 1200 | 0.0 | - |
198
+ | 1.3528 | 1250 | 0.0 | - |
199
+ | 1.4069 | 1300 | 0.0 | - |
200
+ | 1.4610 | 1350 | 0.0 | - |
201
+ | 1.5152 | 1400 | 0.0 | - |
202
+ | 1.5693 | 1450 | 0.0 | - |
203
+ | 1.6234 | 1500 | 0.0 | - |
204
+ | 1.6775 | 1550 | 0.0 | - |
205
+ | 1.7316 | 1600 | 0.0 | - |
206
+ | 1.7857 | 1650 | 0.0 | - |
207
+ | 1.8398 | 1700 | 0.0 | - |
208
+ | 1.8939 | 1750 | 0.0 | - |
209
+ | 1.9481 | 1800 | 0.0 | - |
210
+
211
+ ### Framework Versions
212
+ - Python: 3.11.12
213
+ - SetFit: 1.1.3
214
+ - Sentence Transformers: 4.1.0
215
+ - Transformers: 4.51.3
216
+ - PyTorch: 2.7.0
217
+ - Datasets: 2.19.2
218
+ - Tokenizers: 0.21.1
219
+
220
+ ## Citation
221
+
222
+ ### BibTeX
223
+ ```bibtex
224
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
225
+ doi = {10.48550/ARXIV.2209.11055},
226
+ url = {https://arxiv.org/abs/2209.11055},
227
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
228
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
229
+ title = {Efficient Few-Shot Learning Without Prompts},
230
+ publisher = {arXiv},
231
+ year = {2022},
232
+ copyright = {Creative Commons Attribution 4.0 International}
233
+ }
234
+ ```
235
+
236
+ <!--
237
+ ## Glossary
238
+
239
+ *Clearly define terms in order to be accessible across audiences.*
240
+ -->
241
+
242
+ <!--
243
+ ## Model Card Authors
244
+
245
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
246
+ -->
247
+
248
+ <!--
249
+ ## Model Card Contact
250
+
251
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
252
+ -->
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertModel"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 3072,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "bert",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 12,
17
+ "pad_token_id": 0,
18
+ "position_embedding_type": "absolute",
19
+ "torch_dtype": "float32",
20
+ "transformers_version": "4.51.3",
21
+ "type_vocab_size": 2,
22
+ "use_cache": true,
23
+ "vocab_size": 30522
24
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "4.1.0",
4
+ "transformers": "4.51.3",
5
+ "pytorch": "2.7.0"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "normalize_embeddings": false,
3
+ "labels": null
4
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bfe05b509f7127c81c880081fe5eda86eeb249573b67eba93246debed03de94
3
+ size 437951328
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d157cbd07acb9f8140f6adfeb7139b03d5c3e0197bd59eb3ebaa09134e6c7b5
3
+ size 7007
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,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "1": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
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
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "max_length": 512,
51
+ "model_max_length": 512,
52
+ "never_split": null,
53
+ "pad_to_multiple_of": null,
54
+ "pad_token": "[PAD]",
55
+ "pad_token_type_id": 0,
56
+ "padding_side": "right",
57
+ "sep_token": "[SEP]",
58
+ "stride": 0,
59
+ "strip_accents": null,
60
+ "tokenize_chinese_chars": true,
61
+ "tokenizer_class": "BertTokenizer",
62
+ "truncation_side": "right",
63
+ "truncation_strategy": "longest_first",
64
+ "unk_token": "[UNK]"
65
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff