Views
No views yet
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Human (0) | 99.72% | 98.89% | 99.30% | 7,500 |
| AI (1) | 98.91% | 99.72% | 99.31% | 7,500 |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2from peft import PeftModel
3import torch
4
5# Load tokenizer and base model
6tokenizer = AutoTokenizer.from_pretrained("srikanthgali/paradetect-deberta-v3-lora")
7base_model = AutoModelForSequenceClassification.from_pretrained(
8 "microsoft/deberta-v3-large",
9 num_labels=2
10)
11
12# Load LoRA adapter
13model = PeftModel.from_pretrained(base_model, "srikanthgali/paradetect-deberta-v3-lora")
14
15# Prediction function
16def predict_text_origin(text):
17 inputs = tokenizer(
18 text,
19 return_tensors="pt",
20 truncation=True,
21 max_length=512,
22 padding=True
23 )
24
25 with torch.no_grad():
26 outputs = model(**inputs)
27 probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
28 prediction = torch.argmax(probabilities, dim=-1)
29
30 human_prob = probabilities[0][0].item()
31 ai_prob = probabilities[0][1].item()
32
33 return {
34 "prediction": "AI" if prediction.item() == 1 else "Human",
35 "confidence": max(human_prob, ai_prob),
36 "human_probability": human_prob,
37 "ai_probability": ai_prob
38 }
39
40# Example usage
41text = "Your text here..."
42result = predict_text_origin(text)
43print(f"Prediction: {result['prediction']} (Confidence: {result['confidence']:.1%})")
44
45Gradio Interface
46
47import gradio as gr
48
49# Create interface (see full notebook for complete implementation)
50demo = gr.Interface(
51 fn=predict_text_origin,
52 inputs=gr.Textbox(lines=10, placeholder="Enter text to analyze..."),
53 outputs=[
54 gr.Textbox(label="Prediction"),
55 gr.Label(label="Confidence Scores")
56 ],
57 title="ParaDetect - AI vs Human Text Detection",
58 description="Detect whether text is written by humans or generated by AI"
59)
60
61demo.launch()
62## Technical Specifications
63
64- **Input**: Text (up to 512 tokens)
65- **Output**: Binary classification with confidence scores
66- **Inference Speed**: ~100ms per text
67- **Memory Usage**: Optimized with LoRA (reduced by ~94%)
68- **GPU Support**: CUDA-enabled for faster inference
69
70## Training Dataset
71
72- **Source**: artem9k/ai-text-detection-pile (cleaned)
73- **Size**: 100,000 samples (subset for efficient training)
74- **Split**: 70% train, 15% validation, 15% test
75- **Balance**: Equal distribution of human vs AI text
76- **Text Length**: 10-512 tokens, optimized for 50-500 words
77
78## Limitations and Considerations
79
80- **Language**: Optimized for English text
81- **Text Length**: Best performance on 50-500 word texts
82- **Domain**: May not generalize to very recent AI models
83- **Context**: Performance may vary on highly technical or domain-specific content
84- **Updates**: Regular retraining recommended as AI models evolve
85
86## Intended Use Cases
87
88### Primary Applications
89- Academic integrity verification
90- Content authenticity checking
91- Research and analysis
92- Educational demonstrations
93- Journalism and fact-checking
94
95### Not Recommended For
96- Legal evidence without human verification
97- Automated content moderation decisions
98- High-stakes authentication without additional validation
99
100## Ethical Considerations
101
102- **Bias**: Model trained on specific dataset; may not represent all text types
103- **Fairness**: Regular evaluation across different demographics recommended
104- **Transparency**: Predictions are probabilistic, not definitive
105- **Human Oversight**: Critical decisions should involve human judgment
106
107## Model Card Authors
108
109- **Developer**: Srikanth Gali
110- **Organization**: Independent Research
111- **Contact**: [GitHub Repository](https://github.com/srikanthgali/ParaDetect)
112
113## Citation
114@misc{paradetect2024,
115 title={ParaDetect: AI vs Human Text Detection with DeBERTa-v3-Large},
116 author={Srikanth Gali},
117 year={2024},
118 url={https://github.com/srikanthgali/ParaDetect},
119 note={Fine-tuned using LoRA for efficient parameter adaptation}
120}
121
122## Additional Resources
123- **📁 GitHub Repository**: ParaDetect
124- **📊 Dataset**: AI Text Detection Pile - Cleaned
125- **🎯 Demo:**: Gradio Interface
126- **📈 Training Notebook**: Fine-tuning Details
127- **🔍 EDA**: Data Analysis
128## Version History
129- **v1.0**: Initial release with DeBERTa-v3-Large + LoRA
130- **Training Date**: 2025-10-06
131- **Model Size**: ~28M trainable parameters
132- **Performance**: 99.31% test accuracy