--- license: mit language: - fa library_name: pytorch pipeline_tag: text-classification tags: - ai-generated-text-detection - persian - farsi - text-classification - stylometry - ensemble - bilstm - textcnn - transformer - parsbert - gpt2 - laya --- # AITextD — Persian AI-Generated Text Detection Models Trained checkpoints for the [AITextDetection](https://github.com/ehsan-torabi/AITextDetection) project: detecting whether **Persian** text was written by a human or generated by AI. This repository mirrors the `models/` directory of the source project one-to-one, so a single download drops every serving artifact into place: ```bash # from the project root, after cloning the GitHub repo hf download ehsantorabi/aitextd-models --local-dir models/ ``` ## What is inside Sixteen registered models cover four families — classical ML on TF-IDF (+ stylometric features), deep networks trained from scratch, fine-tuned LLMs, and a System One decision model — plus the shared serving artifacts (`tfidf_vectorizer.joblib`, the GPT-2 and ParsBERT tokenizers, the raw Persian GPT-2 LM used for the training-free perplexity signal, and the fine-tuned Laya decision model). The weighted **ensemble** is computed live by the serving stack from these checkpoints; it is not a file. | Model | id | Artifact | Architecture | Family | Ensemble weight | Test accuracy | Test F1 | |---|---|---|---|---|---|---|---| | BiLSTM | `bilstm` | `lstmModel.pt` | BiLSTM | Deep learning | 0.7 | 0.9832 | 0.9831 | | TextCNN | `textcnn` | `textcnnModel.pt` | TextCNN | Deep learning | 0.5 | 0.9905 | 0.9905 | | TextCNN (RLCD fine-tune) | `textcnn_rlcd` | `textcnnRlcdModel.pt` | TextCNN + RLCD fine-tune | Deep learning | 0.0 | 0.9900 | 0.9900 | | Attention BiLSTM | `attention_bilstm` | `attnBilstmModel.pt` | BiLSTM + additive attention pooling | Deep learning | 0.5 | 0.9881 | 0.9881 | | GPT-2 Transformer (fine-tuned) | `gpt2_transformer` | `gpt2ClassifierModel.pt` | GPT2ForSequenceClassification (full fine-tune) | Deep learning | 3.0 | 0.9969 | 0.9969 | | ParsBERT (Bidirectional Encoder) | `parsbert` | `parsbertClassifierModel.pt` | BertModel + linear head on [CLS] | Deep learning | 3.0 | 0.9983 | 0.9983 | | System One (Decision Head) | `system_one` | `systemOneModel.pt` | ParsBERT (fine-tuned encoder) + typed decision heads (choice/score/noul) | Deep learning | 0.6 | 0.9893 | 0.9893 | | SVM | `svm` | `svModel.joblib` | LinearSVC | Classical ML | 1.0 | 0.9967 | 0.9967 | | Logistic Regression | `logreg` | `logregModel.joblib` | LogisticRegression | Classical ML | 1.0 | 0.9964 | 0.9964 | | Naive Bayes | `naive_bayes` | `nbModel.joblib` | MultinomialNB | Classical ML | 1.0 | 0.9810 | 0.9809 | | Random Forest | `random_forest` | `rfModel.joblib` | RandomForestClassifier | Classical ML | 1.0 | 0.9886 | 0.9886 | | Gradient Boosting | `gradient_boosting` | `gbModel.joblib` | GradientBoostingClassifier | Classical ML | 1.0 | 0.9912 | 0.9912 | | Laya (System One, fine-tuned) | `laya` | `laya_persian` (directory) | Laya multilingual (mmBERT-base) + typed decision heads (RLCD fine-tune) | Deep learning | 2.0 | 0.9993 | 0.9993 | | MLP | `mlp` | `mlpModel.pt` | MLP (2 hidden layers) | Deep learning | 0.5 | 0.9964 | 0.9965 | | CharCNN | `charcnn` | `charcnnModel.pt` | CharCNN (character-level TextCNN) | Deep learning | 0.5 | 0.9983 | 0.9983 | | Tiny Transformer (from scratch) | `tinytransformer` | `tinyTransformerModel.pt` | Transformer encoder (2 layers, from scratch) | Deep learning | 0.5 | 0.9891 | 0.9891 | ## Artifacts not included - `models/laya_multilingual/` — the untouched [convaiinnovations/laya](https://huggingface.co/convaiinnovations/laya) *multilingual* (mmBERT-base) base checkpoint; only needed to re-run the fine-tuning notebook, so it is not duplicated here. Serving uses the fine-tuned `laya_persian/` above. - `models/laya_persian/checkpoint_latest/` — a redundant mid-training checkpoint of `laya_persian` (identical final weights); skipped. ## Evaluation protocol Metrics above are test-set results from the project's leak-free v2 protocol (group-aware splits, paraphrase-attack and domain-shift conditions). Frozen evidence, per-model confusion matrices and full tables live in the GitHub repo under `reports/` and `models.json`. ## Base-model attribution - ParsBERT classifier → [HooshvareLab/bert-fa-base-uncased](https://huggingface.co/HooshvareLab/bert-fa-base-uncased) - GPT-2 classifier + perplexity LM → [HooshvareLab/gpt2-fa](https://huggingface.co/HooshvareLab/gpt2-fa) - Laya System One decision model → [convaiinnovations/laya](https://huggingface.co/convaiinnovations/laya) (multilingual, Apache-2.0) ## Usage The checkpoints are consumed by the project's FastAPI serving stack (`aitextd/`, `models.json`), not by a single `pipeline(...)`. See the [GitHub repo](https://github.com/ehsan-torabi/AITextDetection) for the serving API, the six training notebooks, the web front end and tests: ```bash uv sync hf download ehsantorabi/aitextd-models --local-dir models/ uv run python server.py # API on :8000 ```