Add model
Browse files- .gitattributes +1 -0
- README.md +7 -44
- config.json +9 -4
- model_head.pkl +1 -1
- pytorch_model.bin +2 -2
- sentence_bert_config.json +1 -1
- sentencepiece.bpe.model +3 -0
- special_tokens_map.json +1 -1
- tokenizer.json +0 -0
- tokenizer_config.json +7 -54
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
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,37 +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 |
-
## Authors
|
72 |
-
|
73 |
## BibTeX entry and citation info
|
74 |
|
75 |
```bibtex
|
@@ -83,4 +46,4 @@ publisher = {arXiv},
|
|
83 |
year = {2022},
|
84 |
copyright = {Creative Commons Attribution 4.0 International}
|
85 |
}
|
86 |
-
```
|
|
|
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,11 +1,13 @@
|
|
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 |
"eos_token_id": 2,
|
|
|
9 |
"hidden_act": "gelu",
|
10 |
"hidden_dropout_prob": 0.1,
|
11 |
"hidden_size": 768,
|
@@ -13,12 +15,15 @@
|
|
13 |
"intermediate_size": 3072,
|
14 |
"layer_norm_eps": 1e-05,
|
15 |
"max_position_embeddings": 514,
|
16 |
-
"model_type": "
|
17 |
"num_attention_heads": 12,
|
18 |
"num_hidden_layers": 12,
|
|
|
19 |
"pad_token_id": 1,
|
20 |
-
"
|
21 |
"torch_dtype": "float32",
|
22 |
"transformers_version": "4.27.4",
|
23 |
-
"
|
|
|
|
|
24 |
}
|
|
|
1 |
{
|
2 |
"_name_or_path": "/home/mserras/Downloads/setfit-model/backup-model-setfit-unprocessable/",
|
3 |
"architectures": [
|
4 |
+
"XLMRobertaModel"
|
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 |
"intermediate_size": 3072,
|
16 |
"layer_norm_eps": 1e-05,
|
17 |
"max_position_embeddings": 514,
|
18 |
+
"model_type": "xlm-roberta",
|
19 |
"num_attention_heads": 12,
|
20 |
"num_hidden_layers": 12,
|
21 |
+
"output_past": true,
|
22 |
"pad_token_id": 1,
|
23 |
+
"position_embedding_type": "absolute",
|
24 |
"torch_dtype": "float32",
|
25 |
"transformers_version": "4.27.4",
|
26 |
+
"type_vocab_size": 1,
|
27 |
+
"use_cache": true,
|
28 |
+
"vocab_size": 250002
|
29 |
}
|
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:fad7d4c0ce4f486ba42180d19aa1647bcde1c0847b6b8b29004c86ab4d1b98de
|
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:7130a90b18531f9303ffac78c1a02fbf97be1098c86ae7b584de8a9c425580d8
|
3 |
+
size 1112242989
|
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": 128,
|
3 |
"do_lower_case": false
|
4 |
}
|
sentencepiece.bpe.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
|
3 |
+
size 5069051
|
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
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
CHANGED
@@ -1,30 +1,7 @@
|
|
1 |
{
|
2 |
-
"bos_token":
|
3 |
-
|
4 |
-
|
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,33 +11,9 @@
|
|
34 |
"single_word": false
|
35 |
},
|
36 |
"model_max_length": 512,
|
37 |
-
"
|
38 |
-
"
|
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 |
-
"
|
56 |
-
"
|
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 |
}
|
|
|
1 |
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
"mask_token": {
|
6 |
"__type": "AddedToken",
|
7 |
"content": "<mask>",
|
|
|
11 |
"single_word": false
|
12 |
},
|
13 |
"model_max_length": 512,
|
14 |
+
"pad_token": "<pad>",
|
15 |
+
"sep_token": "</s>",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
"special_tokens_map_file": null,
|
17 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
18 |
+
"unk_token": "<unk>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|