agentlans commited on
Commit
53ffcaf
·
verified ·
1 Parent(s): a0a78af

Upload 8 files

Browse files
README.md CHANGED
@@ -1,3 +1,118 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model Card: DeBERTa v3 for Text Quality Assessment
2
+
3
+ ## Model Details
4
+
5
+ - **Model Architecture:** DeBERTa v3 (xsmall and base variants)
6
+ - **Task:** Text quality assessment (regression)
7
+ - **Training Data:** Text Quality Meta-Analysis Dataset at [agentlans/text-quality-v2](https://huggingface.co/datasets/agentlans/text-quality-v2)
8
+ - **Output:** Single continuous value representing text quality
9
+
10
+ ## Intended Use
11
+
12
+ These models are designed to assess the quality of English text, where "quality" refers to legible sentences that are not spam and contain useful information. They can be used for:
13
+
14
+ - Content moderation
15
+ - Spam detection
16
+ - Information quality assessment
17
+ - Text filtering
18
+
19
+ ## Usage
20
+
21
+ The models accept text input and return a single continuous value representing the assessed quality. Higher values indicate higher perceived quality. Example usage is provided in the code snippet.
22
+
23
+ ```
24
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
25
+ import torch
26
+
27
+ model_name="agentlans/deberta-v3-base-quality-v2"
28
+
29
+ # Put model on GPU or else CPU
30
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
31
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
32
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
33
+ model = model.to(device)
34
+
35
+ def quality(text):
36
+ """Processes the text using the model and returns its logits.
37
+ In this case, it's interpreted as the the combined quality score for that text."""
38
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
39
+ with torch.no_grad():
40
+ logits = model(**inputs).logits.squeeze().cpu()
41
+ return logits.tolist()
42
+
43
+ # Example usage
44
+ text = [x.strip() for x in """
45
+ Congratulations! You've won a $1,000 gift card! Click here to claim your prize now!!!
46
+ Page 1 2 3 4 5 Next Last>>
47
+ Urgent: Your account has been compromised! Click this link to verify your identity and secure your account immediately!!!
48
+ Today marks a significant milestone in our journey towards sustainability! 🌍✨ We’re excited to announce our partnership with local organizations to plant 10,000 trees in our community this fall. Join us in making a positive impact on our environment!
49
+ In recent years, the impact of climate change has become increasingly evident, affecting ecosystems and human livelihoods across the globe.
50
+ The mitochondria is the powerhouse of the cell.
51
+ Exclusive discount on Super MitoMax Energy Boost! Recharge your mitochondria today!
52
+ Everyone is talking about this new diet that guarantees weight loss without exercise!
53
+ Discover five tips for improving your productivity while working from home.
54
+ """.strip().split("\n")]
55
+
56
+ result = quality(text)
57
+ for x, s in zip(text, result):
58
+ print(f"Text: {x}\nQuality: {round(s, 2)}\n")
59
+ ```
60
+
61
+ Example output for the `base` size model:
62
+ ```
63
+ Text: Congratulations! You've won a $1,000 gift card! Click here to claim your prize now!!!
64
+ Quality: -1.25
65
+
66
+ Text: Page 1 2 3 4 5 Next Last>>
67
+ Quality: -1.54
68
+
69
+ Text: Urgent: Your account has been compromised! Click this link to verify your identity and secure your account immediately!!!
70
+ Quality: -2.01
71
+
72
+ Text: Today marks a significant milestone in our journey towards sustainability! 🌍✨ We’re excited to announce our partnership with local organizations to plant 10,000 trees in our community this fall. Join us in making a positive impact on our environment!
73
+ Quality: -1.72
74
+
75
+ Text: In recent years, the impact of climate change has become increasingly evident, affecting ecosystems and human livelihoods across the globe.
76
+ Quality: 0.45
77
+
78
+ Text: The mitochondria is the powerhouse of the cell.
79
+ Quality: 1.32
80
+
81
+ Text: Exclusive discount on Super MitoMax Energy Boost! Recharge your mitochondria today!
82
+ Quality: -1.16
83
+
84
+ Text: Everyone is talking about this new diet that guarantees weight loss without exercise!
85
+ Quality: -0.27
86
+
87
+ Text: Discover five tips for improving your productivity while working from home.
88
+ Quality: -0.42
89
+ ```
90
+
91
+ ## Performance Metrics
92
+
93
+ Root mean squared error (RMSE) on 20% held-out evaluation set:
94
+ - **DeBERTa v3 xsmall:** 0.6296
95
+ - **DeBERTa v3 base:** 0.5038
96
+
97
+ The base model outperforms the xsmall variant in terms of accuracy.
98
+
99
+ ## Limitations and Biases
100
+
101
+ - The models are trained on a specific dataset and may not generalize well to all types of text or domains.
102
+ - "Quality" is a subjective concept, and the models' assessments may not align with all human judgments.
103
+ - The models may exhibit biases present in the training data.
104
+ - For example, there is a bias against self-help, promotional, and public relations material.
105
+ - They do not assess factual correctness or grammatical accuracy.
106
+
107
+ ## Ethical Considerations
108
+
109
+ - These models should not be used as the sole determinant for content moderation or censorship.
110
+ - Care should be taken to avoid reinforcing existing biases in content selection or promotion.
111
+ - The models' outputs should be interpreted as suggestions rather than definitive judgments.
112
+
113
+ ## Caveats and Recommendations
114
+
115
+ - Use these models in conjunction with other tools and human oversight for content moderation.
116
+ - Regularly evaluate the models' performance on your specific use case and data.
117
+ - Be aware that the models may not perform equally well across all text types or domains.
118
+ - Consider fine-tuning the models on domain-specific data for improved performance in specialized applications.
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "[MASK]": 128000
3
+ }
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "microsoft/deberta-v3-base",
3
+ "architectures": [
4
+ "DebertaV2ForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "id2label": {
11
+ "0": "LABEL_0"
12
+ },
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 3072,
15
+ "label2id": {
16
+ "LABEL_0": 0
17
+ },
18
+ "layer_norm_eps": 1e-07,
19
+ "max_position_embeddings": 512,
20
+ "max_relative_positions": -1,
21
+ "model_type": "deberta-v2",
22
+ "norm_rel_ebd": "layer_norm",
23
+ "num_attention_heads": 12,
24
+ "num_hidden_layers": 12,
25
+ "pad_token_id": 0,
26
+ "pooler_dropout": 0,
27
+ "pooler_hidden_act": "gelu",
28
+ "pooler_hidden_size": 768,
29
+ "pos_att_type": [
30
+ "p2c",
31
+ "c2p"
32
+ ],
33
+ "position_biased_input": false,
34
+ "position_buckets": 256,
35
+ "relative_attention": true,
36
+ "share_att_key": true,
37
+ "torch_dtype": "float32",
38
+ "transformers_version": "4.45.1",
39
+ "type_vocab_size": 0,
40
+ "vocab_size": 128100
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:866d40d1666d9ac713717d76de8afe5275e764e072ecb867c84fb24a6e6e73d8
3
+ size 737716196
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "[CLS]",
3
+ "cls_token": "[CLS]",
4
+ "eos_token": "[SEP]",
5
+ "mask_token": "[MASK]",
6
+ "pad_token": "[PAD]",
7
+ "sep_token": "[SEP]",
8
+ "unk_token": {
9
+ "content": "[UNK]",
10
+ "lstrip": false,
11
+ "normalized": true,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ }
15
+ }
spm.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c679fbf93643d19aab7ee10c0b99e460bdbc02fedf34b92b05af343b4af586fd
3
+ size 2464616
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": "[CLS]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[SEP]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[UNK]",
29
+ "lstrip": false,
30
+ "normalized": true,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "128000": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "[CLS]",
45
+ "clean_up_tokenization_spaces": false,
46
+ "cls_token": "[CLS]",
47
+ "do_lower_case": false,
48
+ "eos_token": "[SEP]",
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 1000000000000000019884624838656,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "sp_model_kwargs": {},
54
+ "split_by_punct": false,
55
+ "tokenizer_class": "DebertaV2Tokenizer",
56
+ "unk_token": "[UNK]",
57
+ "vocab_type": "spm"
58
+ }