Text Classification
Transformers
Safetensors
ONNX
English
distilbert
ai-detection
education
text-embeddings-inference
Instructions to use darwinkernelpanic/ai-detector-pgx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use darwinkernelpanic/ai-detector-pgx with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="darwinkernelpanic/ai-detector-pgx")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("darwinkernelpanic/ai-detector-pgx") model = AutoModelForSequenceClassification.from_pretrained("darwinkernelpanic/ai-detector-pgx", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 893 Bytes
e79434e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #!/usr/bin/env python3
"""AI Detector Example - Python Inference"""
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
def detect_ai(text, model_id="darwinkernelpanic/ai-detector-pgx"):
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512, padding=True)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
ai_prob = probs[0][1].item()
return {"ai_prob": ai_prob, "is_ai": ai_prob > 0.5}
if __name__ == "__main__":
text = "The mitochondria is the powerhouse of the cell..."
result = detect_ai(text)
print(f"AI Probability: {result['ai_prob']:.2%}")
print(f"Verdict: {'AI' if result['is_ai'] else 'Human'}")
|