Views
No views yet
FacebookAI/roberta-base designed to detect whether a given text is generated by AI or written by a human. It has been sequentially fine-tuned distinct datasets to enhance its robustness and generalization capabilities across various text domains. The model aims to achieve high accuracy in distinguishing between human-produced and machine-generated content, making it a valuable tool for applications requiring AI text detection.artem9k/ai-text-detection-pile:train-00000-of-00007-bc5952562e004d67.parquet and 10,000 rows from train-00006-of-00007-3d8a471ba0cf1c8d.parquet. This dataset contains a variety of text samples labeled as AI-generated or human-written.Ateeqq/AI-and-Human-Generated-Text:NicolaiSivesind/human-vs-machine:wiki-labeled.csv and research-abstracts-labeled.csv. This further enhances the model's ability to distinguish between human-produced and machine-generated content, particularly focusing on Wikipedia articles and research abstracts.FacebookAI/roberta-base.artem9k/ai-text-detection-pile: 1 hour 12 minutes 14 secondsAteeqq/AI-and-Human-Generated-Text: 0 hours 30 minutes 36 secondsNicolaiSivesind/human-vs-machine: 1 hour 04 minutes 22 seconds1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4# Define the model name/path
5model_name = "MonkeyDAnh/my-awesome-ai-detector-roberta-base"
6
7# Load tokenizer and model
8tokenizer = AutoTokenizer.from_pretrained(model_name)
9model = AutoModelForSequenceClassification.from_pretrained(model_name)
10
11# Move model to GPU if available
12device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13model.to(device)
14
15# Define label mapping (ensure this matches your model's config.id2label if available)
16# Based on your ClassLabel definition (0: human-produced, 1: machine-generated)
17id_to_label = model.config.id2label if hasattr(model.config, 'id2label') else {0: "human-produced", 1: "machine-generated"}
18
19# Example text for inference
20text = "This is a sample text to detect AI generation. It is written to sound very robotic and unnatural."
21
22# Tokenize the input text
23# Using max_length=512 for standard RoBERTa, adjust if your MAX_LENGTH_CHUNK was different
24inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512).to(device)
25
26# Perform inference
27outputs = model(**inputs)
28
29# Get predicted label ID and convert to integer
30predictions_id = outputs.logits.argmax(-1).item()
31
32# Map ID to the human-readable label
33predicted_label = id_to_label[predictions_id]
34
35print(f"Text: \"{text}\"")
36print(f"Predicted Label ID: {predictions_id}")
37print(f"Predicted Label: {predicted_label}")
38# Expected output examples:
39# Predicted Label: human-produced
40# Predicted Label: machine-generated