Add SetFit model
Browse files- .gitattributes +1 -0
- 1_Pooling/config.json +1 -1
- README.md +33 -118
- config.json +11 -14
- model_head.pkl +2 -2
- pytorch_model.bin +2 -2
- tokenizer_config.json +5 -3
- unigram.json +3 -0
.gitattributes
CHANGED
@@ -28,3 +28,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
28 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
29 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
30 |
model_head.pkl filter=lfs diff=lfs merge=lfs -text
|
|
|
|
28 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
29 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
30 |
model_head.pkl filter=lfs diff=lfs merge=lfs -text
|
31 |
+
unigram.json filter=lfs diff=lfs merge=lfs -text
|
1_Pooling/config.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"word_embedding_dimension":
|
3 |
"pooling_mode_cls_token": false,
|
4 |
"pooling_mode_mean_tokens": true,
|
5 |
"pooling_mode_max_tokens": false,
|
|
|
1 |
{
|
2 |
+
"word_embedding_dimension": 384,
|
3 |
"pooling_mode_cls_token": false,
|
4 |
"pooling_mode_mean_tokens": true,
|
5 |
"pooling_mode_max_tokens": false,
|
README.md
CHANGED
@@ -1,134 +1,49 @@
|
|
1 |
---
|
2 |
-
|
3 |
tags:
|
|
|
4 |
- sentence-transformers
|
5 |
-
-
|
6 |
-
|
7 |
-
- transformers
|
8 |
-
license: creativeml-openrail-m
|
9 |
-
language:
|
10 |
-
- multilingual
|
11 |
-
|
12 |
---
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.
|
17 |
-
|
18 |
-
<!--- Describe your model here -->
|
19 |
|
20 |
-
|
21 |
-
```
|
22 |
|
23 |
-
|
|
|
24 |
|
25 |
-
## Usage
|
26 |
|
27 |
-
|
28 |
|
|
|
|
|
29 |
```
|
30 |
-
pip install -U sentence-transformers
|
31 |
-
```
|
32 |
-
|
33 |
-
Then you can use the model like this:
|
34 |
-
|
35 |
-
```python
|
36 |
-
from sentence_transformers import SentenceTransformer
|
37 |
-
sentences = ["This is an example sentence", "Each sentence is converted"]
|
38 |
-
|
39 |
-
model = SentenceTransformer('{MODEL_NAME}')
|
40 |
-
embeddings = model.encode(sentences)
|
41 |
-
print(embeddings)
|
42 |
-
```
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
## Usage (HuggingFace Transformers)
|
47 |
-
Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.
|
48 |
|
49 |
```python
|
50 |
-
from
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
#
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
# Compute token embeddings
|
72 |
-
with torch.no_grad():
|
73 |
-
model_output = model(**encoded_input)
|
74 |
-
|
75 |
-
# Perform pooling. In this case, mean pooling.
|
76 |
-
sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
|
77 |
-
|
78 |
-
print("Sentence embeddings:")
|
79 |
-
print(sentence_embeddings)
|
80 |
-
```
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
## Evaluation Results
|
85 |
-
|
86 |
-
<!--- Describe how your model was evaluated -->
|
87 |
-
|
88 |
-
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})
|
89 |
-
|
90 |
-
|
91 |
-
## Training
|
92 |
-
The model was trained with the parameters:
|
93 |
-
|
94 |
-
**DataLoader**:
|
95 |
-
|
96 |
-
`torch.utils.data.dataloader.DataLoader` of length 120 with parameters:
|
97 |
-
```
|
98 |
-
{'batch_size': 8, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
|
99 |
-
```
|
100 |
-
|
101 |
-
**Loss**:
|
102 |
-
|
103 |
-
`sentence_transformers.losses.CosineSimilarityLoss.CosineSimilarityLoss`
|
104 |
-
|
105 |
-
Parameters of the fit()-Method:
|
106 |
-
```
|
107 |
-
{
|
108 |
-
"epochs": 1,
|
109 |
-
"evaluation_steps": 0,
|
110 |
-
"evaluator": "NoneType",
|
111 |
-
"max_grad_norm": 1,
|
112 |
-
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
|
113 |
-
"optimizer_params": {
|
114 |
-
"lr": 2e-05
|
115 |
-
},
|
116 |
-
"scheduler": "WarmupLinear",
|
117 |
-
"steps_per_epoch": 120,
|
118 |
-
"warmup_steps": 12,
|
119 |
-
"weight_decay": 0.01
|
120 |
}
|
121 |
```
|
122 |
-
|
123 |
-
|
124 |
-
## Full Model Architecture
|
125 |
-
```
|
126 |
-
SentenceTransformer(
|
127 |
-
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
|
128 |
-
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
|
129 |
-
)
|
130 |
-
```
|
131 |
-
|
132 |
-
## Citing & Authors
|
133 |
-
|
134 |
-
<!--- Describe where people can find more information -->
|
|
|
1 |
---
|
2 |
+
license: apache-2.0
|
3 |
tags:
|
4 |
+
- setfit
|
5 |
- sentence-transformers
|
6 |
+
- text-classification
|
7 |
+
pipeline_tag: text-classification
|
|
|
|
|
|
|
|
|
|
|
8 |
---
|
9 |
|
10 |
+
# uaritm/lik_neuro_202
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
This is a [SetFit model](https://github.com/huggingface/setfit) that can be used for text classification. The model has been trained using an efficient few-shot learning technique that involves:
|
|
|
13 |
|
14 |
+
1. Fine-tuning a [Sentence Transformer](https://www.sbert.net) with contrastive learning.
|
15 |
+
2. Training a classification head with features from the fine-tuned Sentence Transformer.
|
16 |
|
17 |
+
## Usage
|
18 |
|
19 |
+
To use this model for inference, first install the SetFit library:
|
20 |
|
21 |
+
```bash
|
22 |
+
python -m pip install setfit
|
23 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
You can then run inference as follows:
|
|
|
|
|
26 |
|
27 |
```python
|
28 |
+
from setfit import SetFitModel
|
29 |
+
|
30 |
+
# Download from Hub and run inference
|
31 |
+
model = SetFitModel.from_pretrained("uaritm/lik_neuro_202")
|
32 |
+
# Run inference
|
33 |
+
preds = model(["i loved the spiderman movie!", "pineapple on pizza is the worst 🤮"])
|
34 |
+
```
|
35 |
+
|
36 |
+
## BibTeX entry and citation info
|
37 |
+
|
38 |
+
```bibtex
|
39 |
+
@article{https://doi.org/10.48550/arxiv.2209.11055,
|
40 |
+
doi = {10.48550/ARXIV.2209.11055},
|
41 |
+
url = {https://arxiv.org/abs/2209.11055},
|
42 |
+
author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
|
43 |
+
keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
|
44 |
+
title = {Efficient Few-Shot Learning Without Prompts},
|
45 |
+
publisher = {arXiv},
|
46 |
+
year = {2022},
|
47 |
+
copyright = {Creative Commons Attribution 4.0 International}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
CHANGED
@@ -1,29 +1,26 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-
|
3 |
"architectures": [
|
4 |
-
"
|
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":
|
14 |
"initializer_range": 0.02,
|
15 |
-
"intermediate_size":
|
16 |
-
"layer_norm_eps": 1e-
|
17 |
-
"max_position_embeddings":
|
18 |
-
"model_type": "
|
19 |
"num_attention_heads": 12,
|
20 |
"num_hidden_layers": 12,
|
21 |
-
"
|
22 |
-
"pad_token_id": 1,
|
23 |
"position_embedding_type": "absolute",
|
24 |
"torch_dtype": "float32",
|
25 |
-
"transformers_version": "4.
|
26 |
-
"type_vocab_size":
|
27 |
"use_cache": true,
|
28 |
-
"vocab_size":
|
29 |
}
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-MiniLM-L12-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 |
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 1536,
|
14 |
+
"layer_norm_eps": 1e-12,
|
15 |
+
"max_position_embeddings": 512,
|
16 |
+
"model_type": "bert",
|
17 |
"num_attention_heads": 12,
|
18 |
"num_hidden_layers": 12,
|
19 |
+
"pad_token_id": 0,
|
|
|
20 |
"position_embedding_type": "absolute",
|
21 |
"torch_dtype": "float32",
|
22 |
+
"transformers_version": "4.28.1",
|
23 |
+
"type_vocab_size": 2,
|
24 |
"use_cache": true,
|
25 |
+
"vocab_size": 250037
|
26 |
}
|
model_head.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2421d6f1b30c4b99b640d2fe0f976e6b5059035cdc2b8418f0f1cb5023624db6
|
3 |
+
size 6111
|
pytorch_model.bin
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ecc8dd7cb33f8042fa9dcf85a440777281970ba51d6e054a1d144700352cf866
|
3 |
+
size 470686253
|
tokenizer_config.json
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
{
|
2 |
"bos_token": "<s>",
|
|
|
3 |
"cls_token": "<s>",
|
|
|
4 |
"eos_token": "</s>",
|
5 |
"mask_token": {
|
6 |
"__type": "AddedToken",
|
@@ -11,10 +13,10 @@
|
|
11 |
"single_word": false
|
12 |
},
|
13 |
"model_max_length": 512,
|
14 |
-
"name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_paraphrase-multilingual-mpnet-base-v2/",
|
15 |
"pad_token": "<pad>",
|
16 |
"sep_token": "</s>",
|
17 |
-
"
|
18 |
-
"
|
|
|
19 |
"unk_token": "<unk>"
|
20 |
}
|
|
|
1 |
{
|
2 |
"bos_token": "<s>",
|
3 |
+
"clean_up_tokenization_spaces": true,
|
4 |
"cls_token": "<s>",
|
5 |
+
"do_lower_case": true,
|
6 |
"eos_token": "</s>",
|
7 |
"mask_token": {
|
8 |
"__type": "AddedToken",
|
|
|
13 |
"single_word": false
|
14 |
},
|
15 |
"model_max_length": 512,
|
|
|
16 |
"pad_token": "<pad>",
|
17 |
"sep_token": "</s>",
|
18 |
+
"strip_accents": null,
|
19 |
+
"tokenize_chinese_chars": true,
|
20 |
+
"tokenizer_class": "BertTokenizer",
|
21 |
"unk_token": "<unk>"
|
22 |
}
|
unigram.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:71b44701d7efd054205115acfa6ef126c5d2f84bd3affe0c59e48163674d19a6
|
3 |
+
size 14763234
|