[up]: Update README and load model
Browse files- README.md +109 -1
- SA_logo.png +0 -0
- config.json +13 -0
- merges.txt +0 -0
- model.safetensors +3 -0
- special_tokens_map.json +15 -0
- tokenizer.json +0 -0
- tokenizer_config.json +58 -0
- vocab.json +0 -0
README.md
CHANGED
@@ -15,4 +15,112 @@ tags:
|
|
15 |
- genereted_text_detection
|
16 |
- llm_content_detection
|
17 |
- AI_detection
|
18 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
- genereted_text_detection
|
16 |
- llm_content_detection
|
17 |
- AI_detection
|
18 |
+
---
|
19 |
+
|
20 |
+
<p align="center">
|
21 |
+
<img src="SA_logo.png" alt="SuperAnnotate Logo" width="100" height="100"/>
|
22 |
+
</p>
|
23 |
+
|
24 |
+
<h1 align="center">SuperAnnotate</h1>
|
25 |
+
<h3 align="center">
|
26 |
+
LLM Content Detector V2<br/>
|
27 |
+
Fine-Tuned RoBERTa Large<br/>
|
28 |
+
</h3>
|
29 |
+
|
30 |
+
## Description
|
31 |
+
|
32 |
+
The model designed to detect generated/synthetic text. \
|
33 |
+
At the moment, such functionality is critical for determining the author of the text. It's critical for your training data, detecting fraud and cheating in scientific and educational areas. \
|
34 |
+
Couple of articles about this problem: [*Problems with Synthetic Data*](https://www.aitude.com/problems-with-synthetic-data/) | [*Risk of LLMs in Education*](https://publish.illinois.edu/teaching-learninghub-byjen/risk-of-llms-in-education/)
|
35 |
+
|
36 |
+
## Model Details
|
37 |
+
|
38 |
+
### Model Description
|
39 |
+
|
40 |
+
- **Model type:** The custom architecture for binary sequence classification based on pre-trained RoBERTa, with a single output label.
|
41 |
+
- **Language(s):** Primarily English.
|
42 |
+
- **License:** [SAIPL](https://huggingface.co/SuperAnnotate/roberta-large-llm-content-detector-V2/blob/main/LICENSE)
|
43 |
+
- **Finetuned from model:** [RoBERTa Large](https://huggingface.co/FacebookAI/roberta-large)
|
44 |
+
|
45 |
+
### Model Sources
|
46 |
+
|
47 |
+
- **Repository:** [GitHub](https://github.com/superannotateai/generated_text_detector) for HTTP service
|
48 |
+
|
49 |
+
### Training Data
|
50 |
+
|
51 |
+
The training data with 'human' label was sourced from three open datasets with equal proportions:
|
52 |
+
|
53 |
+
1. [**Wikipedia**](https://huggingface.co/datasets/wikimedia/wikipedia)
|
54 |
+
1. [**Reddit ELI5 QA**](https://huggingface.co/datasets/rexarski/eli5_category)
|
55 |
+
1. [**Scientific Papers**](https://www.tensorflow.org/datasets/catalog/scientific_papers) extended version with full text of sections
|
56 |
+
|
57 |
+
The second half of the dataset was obtained by generating answers to the corresponding human texts.
|
58 |
+
For generation, 14 models from 4 different families were used, namely: GPT, LLaMA, Anthropic and Mistral
|
59 |
+
|
60 |
+
As a result, the training dataset contained approximately ***36k*** pairs of text-label with an approximate balance of classes. \
|
61 |
+
It's worth noting that the dataset's texts follow a logical structure: \
|
62 |
+
Human-written and model-generated texts refer to a single prompt/instruction, though the prompts themselves were not used during training.
|
63 |
+
|
64 |
+
> [!NOTE]
|
65 |
+
> Furthermore, key n-grams (n ranging from 2 to 5) that exhibited the highest correlation with target labels were identified and subsequently removed from the training data utilizing the chi-squared test.
|
66 |
+
|
67 |
+
### Peculiarity
|
68 |
+
|
69 |
+
During training, one of the priorities was not only maximizing the quality of predictions but also avoiding overfitting and obtaining an adequately confident predictor. \
|
70 |
+
We are pleased to achieve the following state of model calibration:
|
71 |
+
|
72 |
+
**TODO** Change graph or this section in general.
|
73 |
+
|
74 |
+
## Usage
|
75 |
+
|
76 |
+
**Pre-requirements**: \
|
77 |
+
Install *generated_text_detector* \
|
78 |
+
Run following command: ```pip install git+https://github.com/superannotateai/generated_text_detector.git@v1.0.0```
|
79 |
+
|
80 |
+
```python
|
81 |
+
from generated_text_detector.utils.model.roberta_classifier import RobertaClassifier
|
82 |
+
from transformers import AutoTokenizer
|
83 |
+
import torch.nn.functional as F
|
84 |
+
|
85 |
+
|
86 |
+
model = RobertaClassifier.from_pretrained("SuperAnnotate/roberta-large-llm-content-detector-V2")
|
87 |
+
tokenizer = AutoTokenizer.from_pretrained("SuperAnnotate/roberta-large-llm-content-detector-V2")
|
88 |
+
|
89 |
+
text_example = "It's not uncommon for people to develop allergies or intolerances to certain foods as they get older. It's possible that you have always had a sensitivity to lactose (the sugar found in milk and other dairy products), but it only recently became a problem for you. This can happen because our bodies can change over time and become more or less able to tolerate certain things. It's also possible that you have developed an allergy or intolerance to something else that is causing your symptoms, such as a food additive or preservative. In any case, it's important to talk to a doctor if you are experiencing new allergy or intolerance symptoms, so they can help determine the cause and recommend treatment."
|
90 |
+
|
91 |
+
tokens = tokenizer.encode_plus(
|
92 |
+
text_example,
|
93 |
+
add_special_tokens=True,
|
94 |
+
max_length=512,
|
95 |
+
padding='longest',
|
96 |
+
truncation=True,
|
97 |
+
return_token_type_ids=True,
|
98 |
+
return_tensors="pt"
|
99 |
+
)
|
100 |
+
|
101 |
+
_, logits = model(**tokens)
|
102 |
+
|
103 |
+
proba = F.sigmoid(logits).squeeze(1).item()
|
104 |
+
|
105 |
+
print(proba)
|
106 |
+
```
|
107 |
+
|
108 |
+
## Training Detailes
|
109 |
+
|
110 |
+
A custom architecture was chosen for its ability to perform binary classification while providing a single model output, as well as for its customizable settings for smoothing integrated into the loss function.
|
111 |
+
|
112 |
+
**Training Arguments**:
|
113 |
+
|
114 |
+
- **Base Model**: [FacebookAI/roberta-large](https://huggingface.co/FacebookAI/roberta-large)
|
115 |
+
- **Epochs**: 20
|
116 |
+
- **Learning Rate**: 5e-05
|
117 |
+
- **Weight Decay**: 0.001
|
118 |
+
- **Label Smoothing**: 0.27
|
119 |
+
- **Warmup Epochs**: 2
|
120 |
+
- **Optimizer**: SGD
|
121 |
+
- **Gradient Clipping**: 3.0
|
122 |
+
- **Scheduler**: Cosine with hard restarts
|
123 |
+
|
124 |
+
## Performance
|
125 |
+
|
126 |
+
**TODO** RAID Leaderboard should be here
|
SA_logo.png
ADDED
config.json
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"pretrain_checkpoint": "FacebookAI/roberta-large",
|
3 |
+
"classifier_dropout": 0.1,
|
4 |
+
"num_labels": 1,
|
5 |
+
"id2label": {
|
6 |
+
"0": "GENERATED"
|
7 |
+
},
|
8 |
+
"label2id": {
|
9 |
+
"GENERATED": 0
|
10 |
+
},
|
11 |
+
"label_smoothing": 0.27,
|
12 |
+
"transformers_version": "4.45.0"
|
13 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:29f34aac13e42e030bb661c1b60ca6bd9a1f601d53b7b3fe45e0352926741616
|
3 |
+
size 1417292644
|
special_tokens_map.json
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": "<s>",
|
3 |
+
"cls_token": "<s>",
|
4 |
+
"eos_token": "</s>",
|
5 |
+
"mask_token": {
|
6 |
+
"content": "<mask>",
|
7 |
+
"lstrip": true,
|
8 |
+
"normalized": false,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false
|
11 |
+
},
|
12 |
+
"pad_token": "<pad>",
|
13 |
+
"sep_token": "</s>",
|
14 |
+
"unk_token": "<unk>"
|
15 |
+
}
|
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 |
+
"add_prefix_space": false,
|
3 |
+
"added_tokens_decoder": {
|
4 |
+
"0": {
|
5 |
+
"content": "<s>",
|
6 |
+
"lstrip": false,
|
7 |
+
"normalized": true,
|
8 |
+
"rstrip": false,
|
9 |
+
"single_word": false,
|
10 |
+
"special": true
|
11 |
+
},
|
12 |
+
"1": {
|
13 |
+
"content": "<pad>",
|
14 |
+
"lstrip": false,
|
15 |
+
"normalized": true,
|
16 |
+
"rstrip": false,
|
17 |
+
"single_word": false,
|
18 |
+
"special": true
|
19 |
+
},
|
20 |
+
"2": {
|
21 |
+
"content": "</s>",
|
22 |
+
"lstrip": false,
|
23 |
+
"normalized": true,
|
24 |
+
"rstrip": false,
|
25 |
+
"single_word": false,
|
26 |
+
"special": true
|
27 |
+
},
|
28 |
+
"3": {
|
29 |
+
"content": "<unk>",
|
30 |
+
"lstrip": false,
|
31 |
+
"normalized": true,
|
32 |
+
"rstrip": false,
|
33 |
+
"single_word": false,
|
34 |
+
"special": true
|
35 |
+
},
|
36 |
+
"50264": {
|
37 |
+
"content": "<mask>",
|
38 |
+
"lstrip": true,
|
39 |
+
"normalized": false,
|
40 |
+
"rstrip": false,
|
41 |
+
"single_word": false,
|
42 |
+
"special": true
|
43 |
+
}
|
44 |
+
},
|
45 |
+
"bos_token": "<s>",
|
46 |
+
"clean_up_tokenization_spaces": true,
|
47 |
+
"cls_token": "<s>",
|
48 |
+
"do_lower_case": true,
|
49 |
+
"eos_token": "</s>",
|
50 |
+
"errors": "replace",
|
51 |
+
"mask_token": "<mask>",
|
52 |
+
"model_max_length": 1000000000000000019884624838656,
|
53 |
+
"pad_token": "<pad>",
|
54 |
+
"sep_token": "</s>",
|
55 |
+
"tokenizer_class": "RobertaTokenizer",
|
56 |
+
"trim_offsets": true,
|
57 |
+
"unk_token": "<unk>"
|
58 |
+
}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|