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
- 📍 Overview
- 📁 Project Structure
- 🚀 Getting Started
- 🙌 Acknowledgments
| 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
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
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)
Install AIDetector using the following steps:
1. Clone the repository:
❯ git clone https://github.com/AnhMinh-Le/AIDetector
❯ cd AIDetector2. Install dependencies:
For ConsDetector:
❯ cd AIDetector/ConsDetector/algorithm
❯ pip install -r requirements.txtFor HeadDetector:
❯ cd AIDetector/HeadDetector/training
❯ pip install torch transformers datasets scikit-learn lightningFor Baselines:
❯ pip install torch transformers scikit-learn tqdm❯ cd AIDetector/ConsDetector
❯ unzip data.zipThis 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)
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-5Generate vector database:
❯ python gen_database.py \
--data_path ../data/AISet \
--model_path model/model_best.pth \
--database_path databaseTest on AISet:
❯ python test_from_database.py \
--test_dataset_path ../data/AISet \
--test_dataset_name test \
--database_path database \
--model_path model/model_best.pthTest 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.pthFine-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-5Note: HeadDetector expects consolidated JSONL files (train.jsonl, valid.jsonl, test.jsonl) in the data directory with text and label fields.
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 64Traditional 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 10000Deep 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-4We 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.