AI vs Human Text Detector

This model can detect whether a text was written by a human or generated by AI.

Model description

This AI text detector is built by fine-tuning RoBERTa-base on a dataset containing both human-written and AI-generated text samples. The model has been trained with data augmentation techniques to improve its robustness.

Performance

The model achieves the following performance on the validation set:

  • Accuracy: 0.9999
  • F1-Score (Human): 1.0000
  • F1-Score (AI): 0.9999

How to use

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

# Load model and tokenizer
model_name = "Abuzaid01/Ai_Human_Text_Detector"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)

# Prepare text for classification
text = "Your text to classify goes here."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512, padding=True)

# Run inference
with torch.no_grad():
    outputs = model(**inputs)
    logits = outputs.logits
    
# Get the predicted class and probabilities
probabilities = torch.nn.functional.softmax(logits, dim=1)
predicted_class_idx = torch.argmax(probabilities, dim=1).item()
confidence = probabilities[0][predicted_class_idx].item()

# Map class index to label
labels = ["Human-written", "AI-generated"]
predicted_label = labels[predicted_class_idx]

print(f"Prediction: {predicted_label}")
print(f"Confidence: {confidence:.4f}")
Downloads last month
13
Safetensors
Model size
0.1B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support