gmenchetti commited on
Commit
536e7bd
1 Parent(s): f2266c7

Add SetFit model

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 1024,
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,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ pipeline_tag: text-classification
12
+ inference: true
13
+ base_model: facebook/bart-large-mnli
14
+ ---
15
+
16
+ # SetFit with facebook/bart-large-mnli
17
+
18
+ This is a [SetFit](https://github.com/huggingface/setfit) model that can be used for Text Classification. This SetFit model uses [facebook/bart-large-mnli](https://huggingface.co/facebook/bart-large-mnli) 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.
19
+
20
+ The model has been trained using an efficient few-shot learning technique that involves:
21
+
22
+ 1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
23
+ 2. Training a classification head with features from the fine-tuned Sentence Transformer.
24
+
25
+ ## Model Details
26
+
27
+ ### Model Description
28
+ - **Model Type:** SetFit
29
+ - **Sentence Transformer body:** [facebook/bart-large-mnli](https://huggingface.co/facebook/bart-large-mnli)
30
+ - **Classification head:** a [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) instance
31
+ - **Maximum Sequence Length:** 1024 tokens
32
+ <!-- - **Number of Classes:** Unknown -->
33
+ <!-- - **Training Dataset:** [Unknown](https://huggingface.co/datasets/unknown) -->
34
+ <!-- - **Language:** Unknown -->
35
+ <!-- - **License:** Unknown -->
36
+
37
+ ### Model Sources
38
+
39
+ - **Repository:** [SetFit on GitHub](https://github.com/huggingface/setfit)
40
+ - **Paper:** [Efficient Few-Shot Learning Without Prompts](https://arxiv.org/abs/2209.11055)
41
+ - **Blogpost:** [SetFit: Efficient Few-Shot Learning Without Prompts](https://huggingface.co/blog/setfit)
42
+
43
+ ## Uses
44
+
45
+ ### Direct Use for Inference
46
+
47
+ First install the SetFit library:
48
+
49
+ ```bash
50
+ pip install setfit
51
+ ```
52
+
53
+ Then you can load this model and run inference.
54
+
55
+ ```python
56
+ from setfit import SetFitModel
57
+
58
+ # Download from the 🤗 Hub
59
+ model = SetFitModel.from_pretrained("gmenchetti/bart-large-mnli-empathy-tuned")
60
+ # Run inference
61
+ preds = model("I loved the spiderman movie!")
62
+ ```
63
+
64
+ <!--
65
+ ### Downstream Use
66
+
67
+ *List how someone could finetune this model on their own dataset.*
68
+ -->
69
+
70
+ <!--
71
+ ### Out-of-Scope Use
72
+
73
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
74
+ -->
75
+
76
+ <!--
77
+ ## Bias, Risks and Limitations
78
+
79
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
80
+ -->
81
+
82
+ <!--
83
+ ### Recommendations
84
+
85
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
86
+ -->
87
+
88
+ ## Training Details
89
+
90
+ ### Framework Versions
91
+ - Python: 3.10.13
92
+ - SetFit: 1.0.3
93
+ - Sentence Transformers: 2.6.1
94
+ - Transformers: 4.39.3
95
+ - PyTorch: 2.0.0.post200
96
+ - Datasets: 2.16.1
97
+ - Tokenizers: 0.15.2
98
+
99
+ ## Citation
100
+
101
+ ### BibTeX
102
+ ```bibtex
103
+ @article{https://doi.org/10.48550/arxiv.2209.11055,
104
+ doi = {10.48550/ARXIV.2209.11055},
105
+ url = {https://arxiv.org/abs/2209.11055},
106
+ author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
107
+ keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
108
+ title = {Efficient Few-Shot Learning Without Prompts},
109
+ publisher = {arXiv},
110
+ year = {2022},
111
+ copyright = {Creative Commons Attribution 4.0 International}
112
+ }
113
+ ```
114
+
115
+ <!--
116
+ ## Glossary
117
+
118
+ *Clearly define terms in order to be accessible across audiences.*
119
+ -->
120
+
121
+ <!--
122
+ ## Model Card Authors
123
+
124
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
125
+ -->
126
+
127
+ <!--
128
+ ## Model Card Contact
129
+
130
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
131
+ -->
config.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "facebook/bart-large-mnli",
3
+ "_num_labels": 3,
4
+ "activation_dropout": 0.0,
5
+ "activation_function": "gelu",
6
+ "add_final_layer_norm": false,
7
+ "architectures": [
8
+ "BartModel"
9
+ ],
10
+ "attention_dropout": 0.0,
11
+ "bos_token_id": 0,
12
+ "classif_dropout": 0.0,
13
+ "classifier_dropout": 0.0,
14
+ "d_model": 1024,
15
+ "decoder_attention_heads": 16,
16
+ "decoder_ffn_dim": 4096,
17
+ "decoder_layerdrop": 0.0,
18
+ "decoder_layers": 12,
19
+ "decoder_start_token_id": 2,
20
+ "dropout": 0.1,
21
+ "encoder_attention_heads": 16,
22
+ "encoder_ffn_dim": 4096,
23
+ "encoder_layerdrop": 0.0,
24
+ "encoder_layers": 12,
25
+ "eos_token_id": 2,
26
+ "forced_eos_token_id": 2,
27
+ "gradient_checkpointing": false,
28
+ "id2label": {
29
+ "0": "contradiction",
30
+ "1": "neutral",
31
+ "2": "entailment"
32
+ },
33
+ "init_std": 0.02,
34
+ "is_encoder_decoder": true,
35
+ "label2id": {
36
+ "contradiction": 0,
37
+ "entailment": 2,
38
+ "neutral": 1
39
+ },
40
+ "max_position_embeddings": 1024,
41
+ "model_type": "bart",
42
+ "normalize_before": false,
43
+ "num_hidden_layers": 12,
44
+ "output_past": false,
45
+ "pad_token_id": 1,
46
+ "scale_embedding": false,
47
+ "torch_dtype": "float32",
48
+ "transformers_version": "4.39.3",
49
+ "use_cache": true,
50
+ "vocab_size": 50265
51
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.6.1",
4
+ "transformers": "4.39.3",
5
+ "pytorch": "2.0.0.post200"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null
9
+ }
config_setfit.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "labels": null,
3
+ "normalize_embeddings": false
4
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7beb9d8d9086590f8b114f59244166879517b24caf4028f0b7a5e8c822d04e4
3
+ size 1625222792
model_head.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eeb64fd4391137a31b5f11d0bf5a3dd044f2b3b0468c6a2610cbb1133f15bb4f
3
+ size 9055
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": 1024,
3
+ "do_lower_case": false
4
+ }
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": true,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
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
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": true,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": true,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 1024,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "tokenizer_class": "BartTokenizer",
55
+ "trim_offsets": true,
56
+ "unk_token": "<unk>"
57
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff