8000 GitHub - brianminhle/AIDetector · GitHub
[go: up one dir, main page]

Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AIDetector

This project was conducted as part of the course Introduction to Deep Learning 2025.1 under the guidance of Dr. Dinh Viet Sang.


📋 Table of Contents


👥 Group Members

Name ID Role
Le Anh Minh 20235530 Leader
Pham Ngoc Trinh 20230092 Member
Ngo Van Dong 20235486 Member
Doan Truong Giang 20235494 Member
Nguyen Tien Phat 20235544 Member

Supervisor: Dr. Dinh Viet Sang


📍 Overview

AIDetector is a comprehensive project for detecting AI-generated content using multiple approaches:

  • ConsDetector: Contrastive learning-based detection using SimCLR
  • HeadDetector: Fine-tuned transformer-based classifier
  • Baseline Methods: TF-IDF + MLP, TF-IDF + SVM, Frozen Backbone + Head

All methods classify text into 3 categories:

  • Human (label 0): Human-written text
  • AI (label 1): AI-generated text
  • Collab (label 2): Human-AI collaboration

🚀 Getting Started

☑️ Prerequisites

Before getting started with AIDetector, ensure your runtime environment meets the following requirements:

  • Programming Language: Python 3.8+
  • Package Manager: Pip
  • GPU: CUDA-compatible GPU (recommended for deep learning methods)

⚙️ Installation

Install AIDetector using the following steps:

1. Clone the repository:

❯ git clone https://github.com/AnhMinh-Le/AIDetector
❯ cd AIDetector

2. Install dependencies:

For ConsDetector:

❯ cd AIDetector/ConsDetector/algorithm
❯ pip install -r requirements.txt

For HeadDetector:

❯ cd AIDetector/HeadDetector/training
❯ pip install torch transformers datasets scikit-learn lightning

For Baselines:

❯ pip install torch transformers scikit-learn tqdm

📊 Dataset

❯ cd AIDetector/ConsDetector 
❯ unzip data.zip

This will create:

  • data/AISet/: Balanced training/validation/test sets (train.jsonl, valid.jsonl, test.jsonl)
  • data/Unseen_Generator/: Out-of-domain test set with unseen AI models (test.jsonl)

🤖 Usage

ConsDetector

Contrastive learning approach using SimCLR with XLM-RoBERTa backbone.

Train the contrastive model:

❯ cd AIDetector/ConsDetector/algorithm
❯ python train_classifier.py \
    --data_path ../data/AISet \
    --model_name FacebookAI/xlm-roberta-base \
    --batch_size 64 \
    --epochs 50 \
    --lr 1e-5

Generate vector database:

❯ python gen_database.py \
    --data_path ../data/AISet \
    --model_path model/model_best.pth \
    --database_path database

Test on AISet:

❯ python test_from_database.py \
    --test_dataset_path ../data/AISet \
    --test_dataset_name test \
    --database_path database \
    --model_path model/model_best.pth

Test on Unseen Generator:

❯ python test_from_database.py \
    --out_domain 1 \
    --out_domain_mode ../data/Unseen_Generator \
    --test_dataset_name test \
    --database_path database \
    --model_path model/model_best.pth

HeadDetector

Fine-tuned transformer classifier with XLM-RoBERTa backbone.

Train the classifier:

❯ cd AIDetector/HeadDetector/training
❯ python train.py \
    --datasource local \
    --data_dir ../../ConsDetector/data/AISet \
    --model_dir ./model \
    --epochs 50 \
    --batch_size 64 \
    --learning_rate 2e-5

Note: HeadDetector expects consolidated JSONL files (train.jsonl, valid.jsonl, test.jsonl) in the data directory with text and label fields.


Baseline Methods

1. TF-IDF + MLP

Simple baseline using TF-IDF features with Multi-Layer Perceptron.

❯ cd AIDetector/baseline/tfidf_mlp
❯ python train.py \
    --aiset_path ../../ConsDetector/data/AISet \
    --unseen_path ../../ConsDetector/data/Unseen_Generator \
    --max_features 10000 \
    --epochs 50 \
    --batch_size 64

2. TF-IDF + SVM

Traditional ML baseline using TF-IDF with Support Vector Machine.

❯ cd AIDetector/baseline/tfidf_svm
❯ python train.py \
    --aiset_path ../../ConsDetector/data/AISet \
    --unseen_path ../../ConsDetector/data/Unseen_Generator \
    --kernel rbf \
    --C 1.0 \
    --max_features 10000

3. Frozen Backbone + Head

Deep learning baseline with frozen XLM-RoBERTa and trainable head.

❯ cd AIDetector/baseline/frozen_backbone
❯ python train.py \
    --aiset_path ../../ConsDetector/data/AISet \
    --unseen_path ../../ConsDetector/data/Unseen_Generator \
    --backbone FacebookAI/xlm-roberta-base \
    --batch_size 16 \
    --epochs 20 \
    --learning_rate 2e-4

🙌 Acknowledgments

We would like to express our gratitude to Dr. Dinh Viet Sang for his guidance and support throughout this project as part of the Introduction to Deep Learning course.


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0