Model Description

The model is used to predict the probability that essay is generated by AI

Uses

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))
Downloads last month
7
Safetensors
Model size
0.4B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support