Edit model card

0xnu/AGTD-v0.1

The 0xnu/AGTD-v0.1 model represents a significant breakthrough in distinguishing between text written by humans and one generated by Artificial Intelligence (AI). It is rooted in sophisticated algorithms and offers exceptional accuracy and efficiency in text analysis and classification. I detailed the findings in a study, and it is accessible here.

Instruction Format

<BOS> [CLS] [INST] Instruction [/INST] Model answer [SEP] [INST] Follow-up instruction [/INST] [SEP] [EOS]

Pseudo-code for tokenizing instructions with the new format:

def tokenize(text):
    return tok.encode(text, add_special_tokens=False)

[BOS_ID] + 
tokenize("[CLS]") + tokenize("[INST]") + tokenize(USER_MESSAGE_1) + tokenize("[/INST]") +
tokenize(BOT_MESSAGE_1) + tokenize("[SEP]") +
…
tokenize("[INST]") + tokenize(USER_MESSAGE_N) + tokenize("[/INST]") +
tokenize(BOT_MESSAGE_N) + tokenize("[SEP]") + [EOS_ID]

Notes:

  • [CLS], [SEP], [PAD], [UNK], and [MASK] tokens are integrated based on their definitions in the tokenizer configuration.
  • [INST] and [/INST] are utilized to encapsulate instructions.
  • The tokenize method should not automatically add BOS or EOS tokens but should add a prefix space.
  • The do_lower_case parameter indicates that text should be in lowercase for consistent tokenization.
  • clean_up_tokenization_spaces remove unnecessary spaces in the tokenization process.
  • The tokenize_chinese_chars parameter indicates special handling for Chinese characters.
  • The maximum model length is set to 512 tokens.

Installing Libraries

pip install torch transformers

Run the model

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

model_id = "0xnu/AGTD-v0.1"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)

# Input text
text = "This model trains on a diverse dataset and serves functions in applications requiring a mechanism for distinguishing between human and AI-generated text."

# Preprocess the text
inputs = tokenizer(text, return_tensors='pt')

# Run the model
outputs = model(**inputs)

# Interpret the output
logits = outputs.logits

# Apply softmax to convert logits to probabilities
probabilities = torch.softmax(logits, dim=1)

# Assuming the first class is 'human' and the second class is 'ai'
human_prob, ai_prob = probabilities.detach().numpy()[0]

# Print probabilities
print(f"Human Probability: {human_prob:.4f}")
print(f"AI Probability: {ai_prob:.4f}")

# Determine if the text is human or AI-generated
if human_prob > ai_prob:
    print("The text is likely human-generated.")
else:
    print("The text is likely AI-generated.")

Citation

Please cite the paper if you are using the resource for your work.

@misc{abiodunfinbarrsoketunji-agtd2023,
  doi = {10.48550/arXiv.2311.15565},
  url = {https://arxiv.org/abs/2311.15565},
  author = {Abiodun Finbarrs Oketunji},
  title = {Evaluating the Efficacy of Hybrid Deep Learning Models in Distinguishing AI-Generated Text},
  publisher = {arXiv},
  year = {2023},
  copyright = {arXiv.org perpetual, non-exclusive license}
}
Downloads last month
531
Safetensors
Model size
109M params
Tensor type
F32
·
Inference Examples
Inference API (serverless) has been turned off for this model.

Dataset used to train 0xnu/AGTD-v0.1