Downloads · 30 days
5
18% of all-time downloads
OguzhanAslann/Roberta-base-ai_human-classifier
Roberta-base-ai_human-classifier is a machine learning model from OguzhanAslann. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a fine-tuned RoBERTa-based model for binary text classification that distinguishes between human-written and AI-generated text. The model is trained using Parameter-Efficient Fine-Tuning (PEFT…
Downloads · 30 days
5
18% of all-time downloads
All-time downloads
28
Public
Parameters
125M
499 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors499 MB · 99%
From the Hugging Face model README
This repository contains a fine-tuned RoBERTa-based model for binary text classification that distinguishes between human-written and AI-generated text. The model is trained using Parameter-Efficient Fine-Tuning (PEFT) with LoRA (Low-Rank Adaptation) for optimal performance and resource efficiency.
roberta-baseHUMAN (label 0): Human-written textAI (label 1): AI-generated text["query", "value"] (attention layers)The model directory contains the following files:
config.json - Model configuration and label mappingsmodel.safetensors - Model weights in SafeTensors formattokenizer.json - Fast tokenizer configurationtokenizer_config.json - Tokenizer configurationvocab.json - Vocabulary mappingsmerges.txt - BPE merge operationsspecial_tokens_map.json - Special token mappingsThe model is trained using the trainer_root/trainer/task.py script, designed for Google Cloud Vertex AI training jobs.
python task.py \
--model-dir gs://your-bucket/model-output \
--lora-dir gs://your-bucket/lora-output \
--train-data gs://your-bucket/train-data.csv \
--valid-data gs://your-bucket/valid-data.jsonl \
--train-data-percentage 1.0 \
--valid-data-percentage 1.0 \
--epochs 3 \
--batch-size 8 \
--create-mar
--model-dir: GCS path for model output--lora-dir: GCS path for LoRA adapter output--train-data: GCS path to CSV training dataset--valid-data: GCS path to JSONL validation dataset--train-data-percentage: Percentage of training data to use (0-1, default: 1.0)--valid-data-percentage: Percentage of validation data to use (0-1, default: 1.0)--epochs: Number of training epochs (default: 3)--batch-size: Training batch size (default: 8)--create-mar: Flag to create TorchServe .mar file for deploymentThe training dataset should be in CSV format with the following columns:
text: The input text to classifylabel: The ground truth label (HUMAN or AI)The validation dataset should be in JSONL format with each line containing:
{"text": "Sample text content", "label": "HUMAN"}
The training script tracks the following metrics:
from transformers import RobertaTokenizerFast, RobertaForSequenceClassification
# Load model and tokenizer
model = RobertaForSequenceClassification.from_pretrained('./model')
tokenizer = RobertaTokenizerFast.from_pretrained('./model')
# Classify text
def classify_text(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
outputs = model(**inputs)
predictions = torch.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1)
label_map = {0: "HUMAN", 1: "AI"}
return label_map[predicted_class.item()]
The training script can generate a .mar file for TorchServe deployment when the --create-mar flag is used. This creates a production-ready model archive with:
roberta_handler.py)# Start TorchServe with the model
torchserve --start --model-store /path/to/model-store --models roberta_classifier=roberta_classifier.mar
# Make predictions
curl -X POST http://localhost:8080/predictions/roberta_classifier \
-H "Content-Type: application/json" \
-d '{"text": "Your text to classify here"}'
The model is designed for deployment on Google Cloud Vertex AI:
AIP_MODEL_DIR, AIP_CHECKPOINT_DIR, AIP_TENSORBOARD_LOG_DIR)transformerstorchdatasetspeftscikit-learnpandasgoogle-cloud-storagetorch-model-archivertorchserveThe training script includes several memory optimization techniques:
DataCollatorWithPadding for efficient batchingThe model outputs logits for binary classification:
[human_score, ai_score]This model is designed for research and production use in AI content detection. Please ensure compliance with your organization's AI ethics guidelines when deploying in production environments.
For training-related issues, refer to the training script documentation in trainer_root/trainer/task.py. For deployment issues, consult the TorchServe or Vertex AI documentation based on your deployment method.