File size: 782 Bytes
171eb01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from transformers import pipeline

# Candidate: cxllin/roberta-base-chatgpt-detector (Trained on HC3 dataset)
MODEL_NAME = "cxllin/roberta-base-chatgpt-detector"

print(f"Loading {MODEL_NAME}...")
try:
    pipe = pipeline("text-classification", model=MODEL_NAME)

    human_text = "I went to the grocery store today to buy some apples and bananas for my lunch."
    ai_text = "As an AI language model, I can assist you with various tasks including writing code and analyzing data."

    print(f"\n--- Testing Human Text ---\n'{human_text}'")
    result_human = pipe(human_text)
    print(f"Result: {result_human}")

    print(f"\n--- Testing AI Text ---\n'{ai_text}'")
    result_ai = pipe(ai_text)
    print(f"Result: {result_ai}")
except Exception as e:
    print(f"Failed: {e}")