Downloads · 30 days
2.4K
5% of all-time downloads
SuperAnnotate/ai-detector
ai-detector is a text classification model from SuperAnnotate. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as other.
<p align="center" <img src="SAlogo.png" alt="SuperAnnotate Logo" width="100" height="100"/ </p
Downloads · 30 days
2.4K
5% of all-time downloads
All-time downloads
48.7K
Public
Parameters
354M
2.8 GB on disk
Likes
23
Public
Click a slice to open those files.
.safetensors1.4 GB · 100%
From the Hugging Face model README
The model designed to detect generated/synthetic text.
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.
Couple of articles about this problem: Problems with Synthetic Data | Risk of LLMs in Education
The training dataset for this version includes 44k pairs of text-label samples, split equally between two parts:
Custom Generation: The first half of the dataset was generated using custom specially designed prompts and human version sourced from three domains:
Texts were generated by 14 different models across four major LLM families (GPT, LLaMA, Anthropic, and Mistral). Each sample consists of a single prompt paired with one human-written and one generated response, though prompts were excluded from training inputs.
RAID Train Data Stratified Subset: The second half is a carefully selected stratified subset from the RAID train dataset, ensuring equal representation across domains, model types, and attack methods. Each example pairs a human-authored text with a corresponding machine-generated response (produced by a single model with specific parameters and attacks applied).
This balanced dataset structure maintains approximately equal proportions of human and generated text samples, ensuring that each prompt aligns with one authentic and one generated answer.
[!NOTE] 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.
During training, one of the priorities was not only maximizing the quality of predictions but also avoiding overfitting and obtaining an adequately confident predictor.
We are pleased to achieve the following state of model calibration and high acccuracy prediction.
Pre-requirements:
Install generated_text_detector
Run following command: pip install git+https://github.com/superannotateai/[email protected]
from generated_text_detector.utils.model.roberta_classifier import RobertaClassifier
from generated_text_detector.utils.preprocessing import preprocessing_text
from transformers import AutoTokenizer
import torch.nn.functional as F
model = RobertaClassifier.from_pretrained("SuperAnnotate/ai-detector")
tokenizer = AutoTokenizer.from_pretrained("SuperAnnotate/ai-detector")
model.eval()
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."
text_example = preprocessing_text(text_example)
tokens = tokenizer.encode_plus(
text_example,
add_special_tokens=True,
max_length=512,
padding='longest',
truncation=True,
return_token_type_ids=True,
return_tensors="pt"
)
_, logits = model(**tokens)
proba = F.sigmoid(logits).squeeze(1).item()
print(proba)
from generated_text_detector.utils.text_detector import GeneratedTextDetector
detector = GeneratedTextDetector(
"SuperAnnotate/ai-detector",
device="cuda",
preprocessing=True
)
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."
res = detector.detect_report(text_example)
print(res)
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.
Training Arguments:
This solution has been validated on strytify subset from RAID train dataset.
This benchmark, which includes a diverse dataset covering:
The performance of detector
| Model | Accuracy |
|---|---|
| Human | 0.731 |
| ChatGPT | 0.992 |
| GPT-2 | 0.649 |
| GPT-3 | 0.945 |
| GPT-4 | 0.985 |
| LLaMA-Chat | 0.980 |
| Mistral | 0.644 |
| Mistral-Chat | 0.975 |
| Cohere | 0.823 |
| Cohere-Chat | 0.906 |
| MPT | 0.757 |
| MPT-Chat | 0.943 |
| Average | 0.852 |