| 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}") | |