Text Classification
PyTorch
Joblib
Safetensors
Laya
Persian
ai-generated-text-detection
persian
farsi
stylometry
ensemble
bilstm
textcnn
transformer
parsbert
gpt2
Instructions to use ehsantorabi/aitextd-models with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Laya
How to use ehsantorabi/aitextd-models with Laya:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- fa
|
| 5 |
+
library_name: pytorch
|
| 6 |
+
pipeline_tag: text-classification
|
| 7 |
+
tags:
|
| 8 |
+
- ai-generated-text-detection
|
| 9 |
+
- persian
|
| 10 |
+
- farsi
|
| 11 |
+
- text-classification
|
| 12 |
+
- stylometry
|
| 13 |
+
- ensemble
|
| 14 |
+
- bilstm
|
| 15 |
+
- textcnn
|
| 16 |
+
- transformer
|
| 17 |
+
- parsbert
|
| 18 |
+
- gpt2
|
| 19 |
+
- laya
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
# AITextD — Persian AI-Generated Text Detection Models
|
| 23 |
+
|
| 24 |
+
Trained checkpoints for the [AITextDetection](https://github.com/ehsan-torabi/AITextDetection)
|
| 25 |
+
project: detecting whether **Persian** text was written by a human or generated by AI.
|
| 26 |
+
|
| 27 |
+
This repository mirrors the `models/` directory of the source project one-to-one, so a
|
| 28 |
+
single download drops every serving artifact into place:
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
# from the project root, after cloning the GitHub repo
|
| 32 |
+
hf download ehsantorabi/aitextd-models --local-dir models/
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
## What is inside
|
| 36 |
+
|
| 37 |
+
Sixteen registered models cover four families — classical ML on TF-IDF (+ stylometric
|
| 38 |
+
features), deep networks trained from scratch, fine-tuned LLMs, and a System One
|
| 39 |
+
decision model — plus the shared serving artifacts (`tfidf_vectorizer.joblib`, the
|
| 40 |
+
GPT-2 and ParsBERT tokenizers, the raw Persian GPT-2 LM used for the training-free
|
| 41 |
+
perplexity signal, and the fine-tuned Laya decision model). The weighted **ensemble**
|
| 42 |
+
is computed live by the serving stack from these checkpoints; it is not a file.
|
| 43 |
+
|
| 44 |
+
| Model | id | Artifact | Architecture | Family | Ensemble weight | Test accuracy | Test F1 |
|
| 45 |
+
|---|---|---|---|---|---|---|---|
|
| 46 |
+
| BiLSTM | `bilstm` | `lstmModel.pt` | BiLSTM | Deep learning | 0.7 | 0.9832 | 0.9831 |
|
| 47 |
+
| TextCNN | `textcnn` | `textcnnModel.pt` | TextCNN | Deep learning | 0.5 | 0.9905 | 0.9905 |
|
| 48 |
+
| TextCNN (RLCD fine-tune) | `textcnn_rlcd` | `textcnnRlcdModel.pt` | TextCNN + RLCD fine-tune | Deep learning | 0.0 | 0.9900 | 0.9900 |
|
| 49 |
+
| Attention BiLSTM | `attention_bilstm` | `attnBilstmModel.pt` | BiLSTM + additive attention pooling | Deep learning | 0.5 | 0.9881 | 0.9881 |
|
| 50 |
+
| GPT-2 Transformer (fine-tuned) | `gpt2_transformer` | `gpt2ClassifierModel.pt` | GPT2ForSequenceClassification (full fine-tune) | Deep learning | 3.0 | 0.9969 | 0.9969 |
|
| 51 |
+
| ParsBERT (Bidirectional Encoder) | `parsbert` | `parsbertClassifierModel.pt` | BertModel + linear head on [CLS] | Deep learning | 3.0 | 0.9983 | 0.9983 |
|
| 52 |
+
| 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 |
|
| 53 |
+
| SVM | `svm` | `svModel.joblib` | LinearSVC | Classical ML | 1.0 | 0.9967 | 0.9967 |
|
| 54 |
+
| Logistic Regression | `logreg` | `logregModel.joblib` | LogisticRegression | Classical ML | 1.0 | 0.9964 | 0.9964 |
|
| 55 |
+
| Naive Bayes | `naive_bayes` | `nbModel.joblib` | MultinomialNB | Classical ML | 1.0 | 0.9810 | 0.9809 |
|
| 56 |
+
| Random Forest | `random_forest` | `rfModel.joblib` | RandomForestClassifier | Classical ML | 1.0 | 0.9886 | 0.9886 |
|
| 57 |
+
| Gradient Boosting | `gradient_boosting` | `gbModel.joblib` | GradientBoostingClassifier | Classical ML | 1.0 | 0.9912 | 0.9912 |
|
| 58 |
+
| 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 |
|
| 59 |
+
| MLP | `mlp` | `mlpModel.pt` | MLP (2 hidden layers) | Deep learning | 0.5 | 0.9964 | 0.9965 |
|
| 60 |
+
| CharCNN | `charcnn` | `charcnnModel.pt` | CharCNN (character-level TextCNN) | Deep learning | 0.5 | 0.9983 | 0.9983 |
|
| 61 |
+
| Tiny Transformer (from scratch) | `tinytransformer` | `tinyTransformerModel.pt` | Transformer encoder (2 layers, from scratch) | Deep learning | 0.5 | 0.9891 | 0.9891 |
|
| 62 |
+
|
| 63 |
+
## Artifacts not included
|
| 64 |
+
|
| 65 |
+
- `models/laya_multilingual/` — the untouched
|
| 66 |
+
[convaiinnovations/laya](https://huggingface.co/convaiinnovations/laya) *multilingual*
|
| 67 |
+
(mmBERT-base) base checkpoint; only needed to re-run the fine-tuning notebook, so it is
|
| 68 |
+
not duplicated here. Serving uses the fine-tuned `laya_persian/` above.
|
| 69 |
+
- `models/laya_persian/checkpoint_latest/` — a redundant mid-training checkpoint of
|
| 70 |
+
`laya_persian` (identical final weights); skipped.
|
| 71 |
+
|
| 72 |
+
## Evaluation protocol
|
| 73 |
+
|
| 74 |
+
Metrics above are test-set results from the project's leak-free v2 protocol
|
| 75 |
+
(group-aware splits, paraphrase-attack and domain-shift conditions). Frozen evidence,
|
| 76 |
+
per-model confusion matrices and full tables live in the GitHub repo under `reports/`
|
| 77 |
+
and `models.json`.
|
| 78 |
+
|
| 79 |
+
## Base-model attribution
|
| 80 |
+
|
| 81 |
+
- ParsBERT classifier → [HooshvareLab/bert-fa-base-uncased](https://huggingface.co/HooshvareLab/bert-fa-base-uncased)
|
| 82 |
+
- GPT-2 classifier + perplexity LM → [HooshvareLab/gpt2-fa](https://huggingface.co/HooshvareLab/gpt2-fa)
|
| 83 |
+
- Laya System One decision model → [convaiinnovations/laya](https://huggingface.co/convaiinnovations/laya) (multilingual, Apache-2.0)
|
| 84 |
+
|
| 85 |
+
## Usage
|
| 86 |
+
|
| 87 |
+
The checkpoints are consumed by the project's FastAPI serving stack (`aitextd/`,
|
| 88 |
+
`models.json`), not by a single `pipeline(...)`. See the
|
| 89 |
+
[GitHub repo](https://github.com/ehsan-torabi/AITextDetection) for the serving API,
|
| 90 |
+
the six training notebooks, the web front end and tests:
|
| 91 |
+
|
| 92 |
+
```bash
|
| 93 |
+
uv sync
|
| 94 |
+
hf download ehsantorabi/aitextd-models --local-dir models/
|
| 95 |
+
uv run python server.py # API on :8000
|
| 96 |
+
```
|
| 97 |
+
|