Downloads · 30 days
7
20% of all-time downloads
ArtemBelogur/ai_detector_model
ai_detector_model is a machine learning model from ArtemBelogur. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
The model is used to predict the probability that essay is generated by AI
Downloads · 30 days
7
20% of all-time downloads
All-time downloads
35
Public
Parameters
435M
1.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.7 GB · 99%
From the Hugging Face model README
The model is used to predict the probability that essay is generated by AI
import torch
from torch import nn
from transformers import AutoTokenizer, AutoModel, AutoModelForSequenceClassification, TrOCRProcessor, VisionEncoderDecoderModel
from typing import List, Union
from tqdm import tqdm
import numpy as np
import gc
from craft_text_detector import Craft
from PIL import Image
import cv2
import time
import os
import warnings
warnings.filterwarnings('ignore')
def ai_detector(essay):
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
CHECKPOINT_PATH = "ArtemBelogur/ai_detector_model"
MAX_LEN = 512
tokenizer = AutoTokenizer.from_pretrained(CHECKPOINT_PATH)
model = AutoModelForSequenceClassification.from_pretrained(
CHECKPOINT_PATH, max_position_embeddings=MAX_LEN
).to(device)
y_pred = []
with torch.no_grad():
inputs = tokenizer(
essay,
padding=True,
truncation=True,
max_length=MAX_LEN,
return_tensors="pt",
).to(device)
logits = model(**inputs).logits.cpu().numpy()
y_pred.extend(
(np.exp(logits) / np.sum(np.exp(logits), axis=-1, keepdims=True))[:, 1]
)
return y_pred[0]
full_text = [
'Travel to the past is a common plot in modern literature or movies. Sometimes, people do it with an aim to change present where they encountered with unstandable obstacles or to sutisfy own inquisitivity. When the first one has too many side effects, the second desire is very natural for me. However, if I’m limited by time and opportunities, there is not any point to do it.\n\nThe first problem for me is that twenty four hours is too short period to do anything. I do not think that in that time I would be able to understand or percept the age where I am. Therefore I would prefer to reject the idea. But it is only the first reason.\n\nThe second thing that seems me strage is our confidence in being able to be alive and have a possibility to explore the world of the chosen time. The farther time ago we take, the harder for us to live there. I am pretty sure that If I chase the sixteen century and travelled to there, it would be very difficult to make any contact with the people that could not even understand me normally. So I am not talking about earlier periods of human history.\n\nTo summarize, the trip to the past sounds amazing and fascinating but only with the several conditions. Firstly, I want to be unlimited in time to be able to spend more than twenty four hours there. Second, I want to be unlimited in space to be able to visit different places, because you can not percept the age if you see only one small point of land. Third, there should be some mechanism to supply my basics human needs that I can not sutisfy in that time. It might seem that I want too much, but I really think that without all the conditions, the time travelling would be useless or only one directional.'
]
print('The probability that the essay is generated: ', ai_detector(essay))