Add model
Browse files- README.md +7 -43
- config.json +5 -10
- model_head.pkl +1 -1
- pytorch_model.bin +2 -2
- sentence_bert_config.json +1 -1
- special_tokens_map.json +1 -1
- tokenizer.json +2 -2
- tokenizer_config.json +54 -7
README.md
CHANGED
@@ -1,31 +1,18 @@
|
|
1 |
---
|
|
|
2 |
tags:
|
3 |
- setfit
|
4 |
- sentence-transformers
|
5 |
- text-classification
|
6 |
pipeline_tag: text-classification
|
7 |
-
datasets:
|
8 |
-
- mserras/alpaca-es-hackaton
|
9 |
-
- somosnlp/somos-clean-alpaca-es
|
10 |
-
language:
|
11 |
-
- es
|
12 |
---
|
13 |
|
14 |
# mserras/setfit-alpaca-es-unprocessable-sample-detection
|
15 |
|
16 |
-
This is a [SetFit model](https://github.com/huggingface/setfit) that can be used for
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
This model has been developed during the 2023 Hackaton organized by [SomosNLP](https://somosnlp.org/)/[HF Card](https://huggingface.co/somosnlp) and with the GPUs provided by [Q Blocks](https://www.qblocks.cloud)
|
21 |
-
|
22 |
-
This model has been trained over "unprocessable" samples of the translated [Clean Alpaca Es](https://huggingface.co/datasets/somosnlp/somos-clean-alpaca-es) dataset from
|
23 |
-
the HF [Argilla](https://argilla.io) space https://huggingface.co/spaces/mserras/somos-alpaca-es.
|
24 |
-
|
25 |
-
To this end, a custom tag is proposed: "unprocessable" which corresponds to instruction/input/output triplets that require processing image, fetching information from the
|
26 |
-
open web and similar tasks where the LLM has no capability action, thus, ending in hallucinations or strange outcomes.
|
27 |
-
|
28 |
-
As this model was trained over samples of Alpaca, which were generated using ChatGPT3.5 this model **cannot be used for commercial purposes or to compete against OpenAI**
|
29 |
|
30 |
## Usage
|
31 |
|
@@ -39,36 +26,13 @@ You can then run inference as follows:
|
|
39 |
|
40 |
```python
|
41 |
from setfit import SetFitModel
|
42 |
-
import argilla as rg
|
43 |
-
|
44 |
|
45 |
# Download from Hub and run inference
|
46 |
model = SetFitModel.from_pretrained("mserras/setfit-alpaca-es-unprocessable-sample-detection")
|
47 |
-
|
48 |
-
|
49 |
-
"""Given the instruction, input and output fields, return a text to be used by setfit"""
|
50 |
-
return f"INSTRUCTION:\n{field_instruction}\nINPUT:\n{field_input}\nOUTPUT:\n{field_output}\n"
|
51 |
-
|
52 |
-
def sample_to_text(sample: rg.TextClassificationRecord) -> str:
|
53 |
-
"""Converts and Argilla TextClassificationRecord to a text to be used by setfit"""
|
54 |
-
return instruct_fields_to_text(sample.inputs["1-instruction"], sample.inputs["2-input"], sample.inputs["3-output"])
|
55 |
-
|
56 |
-
# For a given Argilla record:
|
57 |
-
|
58 |
-
unprocessable_score = model.predict_proba([sample_to_text(argilla_record)])[0].tolist()[1]
|
59 |
-
|
60 |
```
|
61 |
|
62 |
-
## Evaluation
|
63 |
-
|
64 |
-
*Disclaimer*: There was no formal evaluation done, just a bunch of guys looking at the data & the outcomes.
|
65 |
-
|
66 |
-
## Changelog
|
67 |
-
|
68 |
-
- [09/04/2023] SQL code generation, date conversion, percentual discounts and renewable energies no longer detected as unprocessable.
|
69 |
-
- [06/04/2023] It no longer detects password generation as unprocessable.
|
70 |
-
|
71 |
-
|
72 |
## BibTeX entry and citation info
|
73 |
|
74 |
```bibtex
|
@@ -82,4 +46,4 @@ publisher = {arXiv},
|
|
82 |
year = {2022},
|
83 |
copyright = {Creative Commons Attribution 4.0 International}
|
84 |
}
|
85 |
-
```
|
|
|
1 |
---
|
2 |
+
license: apache-2.0
|
3 |
tags:
|
4 |
- setfit
|
5 |
- sentence-transformers
|
6 |
- text-classification
|
7 |
pipeline_tag: text-classification
|
|
|
|
|
|
|
|
|
|
|
8 |
---
|
9 |
|
10 |
# mserras/setfit-alpaca-es-unprocessable-sample-detection
|
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 |
|
|
|
26 |
|
27 |
```python
|
28 |
from setfit import SetFitModel
|
|
|
|
|
29 |
|
30 |
# Download from Hub and run inference
|
31 |
model = SetFitModel.from_pretrained("mserras/setfit-alpaca-es-unprocessable-sample-detection")
|
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
|
|
|
46 |
year = {2022},
|
47 |
copyright = {Creative Commons Attribution 4.0 International}
|
48 |
}
|
49 |
+
```
|
config.json
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "/home/mserras/Downloads/setfit-model/backup-model-setfit-unprocessable/",
|
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": 768,
|
@@ -15,15 +13,12 @@
|
|
15 |
"intermediate_size": 3072,
|
16 |
"layer_norm_eps": 1e-05,
|
17 |
"max_position_embeddings": 514,
|
18 |
-
"model_type": "
|
19 |
"num_attention_heads": 12,
|
20 |
"num_hidden_layers": 12,
|
21 |
-
"output_past": true,
|
22 |
"pad_token_id": 1,
|
23 |
-
"
|
24 |
"torch_dtype": "float32",
|
25 |
"transformers_version": "4.27.4",
|
26 |
-
"
|
27 |
-
"use_cache": true,
|
28 |
-
"vocab_size": 250002
|
29 |
}
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "/home/mserras/Downloads/setfit-model-nomulti/backup-model-setfit-unprocessable/",
|
3 |
"architectures": [
|
4 |
+
"MPNetModel"
|
5 |
],
|
6 |
"attention_probs_dropout_prob": 0.1,
|
7 |
"bos_token_id": 0,
|
|
|
8 |
"eos_token_id": 2,
|
|
|
9 |
"hidden_act": "gelu",
|
10 |
"hidden_dropout_prob": 0.1,
|
11 |
"hidden_size": 768,
|
|
|
13 |
"intermediate_size": 3072,
|
14 |
"layer_norm_eps": 1e-05,
|
15 |
"max_position_embeddings": 514,
|
16 |
+
"model_type": "mpnet",
|
17 |
"num_attention_heads": 12,
|
18 |
"num_hidden_layers": 12,
|
|
|
19 |
"pad_token_id": 1,
|
20 |
+
"relative_attention_num_buckets": 32,
|
21 |
"torch_dtype": "float32",
|
22 |
"transformers_version": "4.27.4",
|
23 |
+
"vocab_size": 30527
|
|
|
|
|
24 |
}
|
model_head.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 6991
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a895306e4dfca3415d2d3c6700eab5bd0eded8b713bb6bb2b27a53600dcc95ff
|
3 |
size 6991
|
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:a7e35ed7e8ee9d2a85b66741c57f9858eb69a6c15eb1eea1b5015161b6096589
|
3 |
+
size 438013677
|
sentence_bert_config.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
{
|
2 |
-
"max_seq_length":
|
3 |
"do_lower_case": false
|
4 |
}
|
|
|
1 |
{
|
2 |
+
"max_seq_length": 512,
|
3 |
"do_lower_case": false
|
4 |
}
|
special_tokens_map.json
CHANGED
@@ -11,5 +11,5 @@
|
|
11 |
},
|
12 |
"pad_token": "<pad>",
|
13 |
"sep_token": "</s>",
|
14 |
-
"unk_token": "
|
15 |
}
|
|
|
11 |
},
|
12 |
"pad_token": "<pad>",
|
13 |
"sep_token": "</s>",
|
14 |
+
"unk_token": "[UNK]"
|
15 |
}
|
tokenizer.json
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:5858fbf3342d891d40efa32ba2478c09c895e7eb3d94cdb721651126f0ba58f9
|
3 |
+
size 711831
|
tokenizer_config.json
CHANGED
@@ -1,7 +1,30 @@
|
|
1 |
{
|
2 |
-
"bos_token":
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
"mask_token": {
|
6 |
"__type": "AddedToken",
|
7 |
"content": "<mask>",
|
@@ -11,9 +34,33 @@
|
|
11 |
"single_word": false
|
12 |
},
|
13 |
"model_max_length": 512,
|
14 |
-
"
|
15 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
"special_tokens_map_file": null,
|
17 |
-
"
|
18 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
|
|
1 |
{
|
2 |
+
"bos_token": {
|
3 |
+
"__type": "AddedToken",
|
4 |
+
"content": "<s>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": true,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
},
|
10 |
+
"cls_token": {
|
11 |
+
"__type": "AddedToken",
|
12 |
+
"content": "<s>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": true,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false
|
17 |
+
},
|
18 |
+
"do_basic_tokenize": true,
|
19 |
+
"do_lower_case": true,
|
20 |
+
"eos_token": {
|
21 |
+
"__type": "AddedToken",
|
22 |
+
"content": "</s>",
|
23 |
+
"lstrip": false,
|
24 |
+
"normalized": true,
|
25 |
+
"rstrip": false,
|
26 |
+
"single_word": false
|
27 |
+
},
|
28 |
"mask_token": {
|
29 |
"__type": "AddedToken",
|
30 |
"content": "<mask>",
|
|
|
34 |
"single_word": false
|
35 |
},
|
36 |
"model_max_length": 512,
|
37 |
+
"never_split": null,
|
38 |
+
"pad_token": {
|
39 |
+
"__type": "AddedToken",
|
40 |
+
"content": "<pad>",
|
41 |
+
"lstrip": false,
|
42 |
+
"normalized": true,
|
43 |
+
"rstrip": false,
|
44 |
+
"single_word": false
|
45 |
+
},
|
46 |
+
"sep_token": {
|
47 |
+
"__type": "AddedToken",
|
48 |
+
"content": "</s>",
|
49 |
+
"lstrip": false,
|
50 |
+
"normalized": true,
|
51 |
+
"rstrip": false,
|
52 |
+
"single_word": false
|
53 |
+
},
|
54 |
"special_tokens_map_file": null,
|
55 |
+
"strip_accents": null,
|
56 |
+
"tokenize_chinese_chars": true,
|
57 |
+
"tokenizer_class": "MPNetTokenizer",
|
58 |
+
"unk_token": {
|
59 |
+
"__type": "AddedToken",
|
60 |
+
"content": "[UNK]",
|
61 |
+
"lstrip": false,
|
62 |
+
"normalized": true,
|
63 |
+
"rstrip": false,
|
64 |
+
"single_word": false
|
65 |
+
}
|
66 |
}
|