Upload 8 files
Browse files- README.md +128 -3
- added_tokens.json +3 -0
- config.json +41 -0
- model.safetensors +3 -0
- special_tokens_map.json +15 -0
- spm.model +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +58 -0
README.md
CHANGED
|
@@ -1,3 +1,128 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- agentlans/text-quality-v2
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
base_model:
|
| 8 |
+
- microsoft/deberta-v3-xsmall
|
| 9 |
+
pipeline_tag: text-classification
|
| 10 |
+
---
|
| 11 |
+
# DeBERTa v3 for Text Quality Assessment
|
| 12 |
+
|
| 13 |
+
## Model Details
|
| 14 |
+
|
| 15 |
+
- **Model Architecture:** DeBERTa v3 (xsmall and base variants)
|
| 16 |
+
- **Task:** Text quality assessment (regression)
|
| 17 |
+
- **Training Data:** Text Quality Meta-Analysis Dataset at [agentlans/text-quality-v2](https://huggingface.co/datasets/agentlans/text-quality-v2)
|
| 18 |
+
- **Output:** Single continuous value representing text quality
|
| 19 |
+
|
| 20 |
+
## Intended Use
|
| 21 |
+
|
| 22 |
+
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:
|
| 23 |
+
|
| 24 |
+
- Content moderation
|
| 25 |
+
- Spam detection
|
| 26 |
+
- Information quality assessment
|
| 27 |
+
- Text filtering
|
| 28 |
+
|
| 29 |
+
## Usage
|
| 30 |
+
|
| 31 |
+
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.
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 35 |
+
import torch
|
| 36 |
+
|
| 37 |
+
model_name="agentlans/deberta-v3-xsmall-quality-v2"
|
| 38 |
+
|
| 39 |
+
# Put model on GPU or else CPU
|
| 40 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 41 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 42 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 43 |
+
model = model.to(device)
|
| 44 |
+
|
| 45 |
+
def quality(text):
|
| 46 |
+
"""Processes the text using the model and returns its logits.
|
| 47 |
+
In this case, it's interpreted as the the combined quality score for that text."""
|
| 48 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True).to(device)
|
| 49 |
+
with torch.no_grad():
|
| 50 |
+
logits = model(**inputs).logits.squeeze().cpu()
|
| 51 |
+
return logits.tolist()
|
| 52 |
+
|
| 53 |
+
# Example usage
|
| 54 |
+
text = [x.strip() for x in """
|
| 55 |
+
Congratulations! You've won a $1,000 gift card! Click here to claim your prize now!!!
|
| 56 |
+
Page 1 2 3 4 5 Next Last>>
|
| 57 |
+
Urgent: Your account has been compromised! Click this link to verify your identity and secure your account immediately!!!
|
| 58 |
+
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!
|
| 59 |
+
In recent years, the impact of climate change has become increasingly evident, affecting ecosystems and human livelihoods across the globe.
|
| 60 |
+
The mitochondria is the powerhouse of the cell.
|
| 61 |
+
Exclusive discount on Super MitoMax Energy Boost! Recharge your mitochondria today!
|
| 62 |
+
Everyone is talking about this new diet that guarantees weight loss without exercise!
|
| 63 |
+
Discover five tips for improving your productivity while working from home.
|
| 64 |
+
""".strip().split("\n")]
|
| 65 |
+
|
| 66 |
+
result = quality(text)
|
| 67 |
+
for x, s in zip(text, result):
|
| 68 |
+
print(f"Text: {x}\nQuality: {round(s, 2)}\n")
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
Example output for the `xsmall` size model:
|
| 72 |
+
```
|
| 73 |
+
Text: Congratulations! You've won a $1,000 gift card! Click here to claim your prize now!!!
|
| 74 |
+
Quality: -0.77
|
| 75 |
+
|
| 76 |
+
Text: Page 1 2 3 4 5 Next Last>>
|
| 77 |
+
Quality: -1.36
|
| 78 |
+
|
| 79 |
+
Text: Urgent: Your account has been compromised! Click this link to verify your identity and secure your account immediately!!!
|
| 80 |
+
Quality: -1.17
|
| 81 |
+
|
| 82 |
+
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!
|
| 83 |
+
Quality: -0.59
|
| 84 |
+
|
| 85 |
+
Text: In recent years, the impact of climate change has become increasingly evident, affecting ecosystems and human livelihoods across the globe.
|
| 86 |
+
Quality: 0.58
|
| 87 |
+
|
| 88 |
+
Text: The mitochondria is the powerhouse of the cell.
|
| 89 |
+
Quality: 0.39
|
| 90 |
+
|
| 91 |
+
Text: Exclusive discount on Super MitoMax Energy Boost! Recharge your mitochondria today!
|
| 92 |
+
Quality: -1.01
|
| 93 |
+
|
| 94 |
+
Text: Everyone is talking about this new diet that guarantees weight loss without exercise!
|
| 95 |
+
Quality: 0.57
|
| 96 |
+
|
| 97 |
+
Text: Discover five tips for improving your productivity while working from home.
|
| 98 |
+
Quality: 0.45
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## Performance Metrics
|
| 102 |
+
|
| 103 |
+
Root mean squared error (RMSE) on 20% held-out evaluation set:
|
| 104 |
+
- **DeBERTa v3 xsmall:** 0.6296
|
| 105 |
+
- **DeBERTa v3 base:** 0.5038
|
| 106 |
+
|
| 107 |
+
The base model outperforms the xsmall variant in terms of accuracy.
|
| 108 |
+
|
| 109 |
+
## Limitations and Biases
|
| 110 |
+
|
| 111 |
+
- The models are trained on a specific dataset and may not generalize well to all types of text or domains.
|
| 112 |
+
- "Quality" is a subjective concept, and the models' assessments may not align with all human judgments.
|
| 113 |
+
- The models may exhibit biases present in the training data.
|
| 114 |
+
- For example, there is a bias against self-help, promotional, and public relations material.
|
| 115 |
+
- They do not assess factual correctness or grammatical accuracy.
|
| 116 |
+
|
| 117 |
+
## Ethical Considerations
|
| 118 |
+
|
| 119 |
+
- These models should not be used as the sole determinant for content moderation or censorship.
|
| 120 |
+
- Care should be taken to avoid reinforcing existing biases in content selection or promotion.
|
| 121 |
+
- The models' outputs should be interpreted as suggestions rather than definitive judgments.
|
| 122 |
+
|
| 123 |
+
## Caveats and Recommendations
|
| 124 |
+
|
| 125 |
+
- Use these models in conjunction with other tools and human oversight for content moderation.
|
| 126 |
+
- Regularly evaluate the models' performance on your specific use case and data.
|
| 127 |
+
- Be aware that the models may not perform equally well across all text types or domains.
|
| 128 |
+
- 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-xsmall",
|
| 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": 384,
|
| 10 |
+
"id2label": {
|
| 11 |
+
"0": "LABEL_0"
|
| 12 |
+
},
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 1536,
|
| 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": 6,
|
| 24 |
+
"num_hidden_layers": 12,
|
| 25 |
+
"pad_token_id": 0,
|
| 26 |
+
"pooler_dropout": 0,
|
| 27 |
+
"pooler_hidden_act": "gelu",
|
| 28 |
+
"pooler_hidden_size": 384,
|
| 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:debce6a9b98d46b742e9f5ecdd6e6359a4f3283a01bc64c69c133f4671af85a1
|
| 3 |
+
size 283345892
|
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 |
+
}
|