File size: 5,436 Bytes
62f1654
c2c4690
62f1654
c2c4690
 
 
 
 
 
 
 
 
 
 
 
 
62f1654
c2c4690
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
language: bn
license: mit
tags:
  - text-classification
  - bangla
  - bengali
  - ai-detection
  - human-vs-ai
  - fine-tuned
base_model: csebuetnlp/banglabert

metrics:
  - accuracy
  - f1
pipeline_tag: text-classification
---

# Bangla AI vs Human Writing Detector — BanglaBERT

Fine-tuned [BanglaBERT](https://huggingface.co/csebuetnlp/banglabert) for **binary classification of Bangla text as AI-generated or human-written**. Developed as part of the *Onneshon* thesis project at Bangladesh University of Professionals (BUP).

Given the full text of a Bangla resume, the model predicts whether it was written by a human or generated by an AI system, along with a confidence score.

---

## Model Details

| Property | Value |
|---|---|
| Base model | `csebuetnlp/banglabert` |
| Architecture | ElectraForSequenceClassification (ELECTRA-based BERT) |
| Parameters | 12 layers, 768 hidden dim, 12 attention heads, vocab 32,000 |
| Language | Bengali (bn) |
| Task | Binary sequence classification |
| Labels | `0` → Human, `1` → AI |
| Max input tokens | 512 |
| Training data | 70 resumes (35 AI + 35 Human) |
| Validation data | ~15 resumes (stratified) |
| Test data | ~15 resumes (stratified) |
| Epochs | 5 (with EarlyStoppingCallback, patience=2) |
| Learning rate | 2e-5 |
| Batch size | 8 |
| Warmup ratio | 0.1 |
| Weight decay | 0.01 |
| Mixed precision | fp16 |
| Best model metric | F1 (binary) |

---

## Dataset

Trained on **Onneshon** — an original Bangla resume dataset:

- **Human resumes:** 50 resumes written by Bangladeshi professionals (resume_51–resume_100)
- **AI resumes:** 50 resumes generated by AI systems (resume_1–resume_50)
- **Total:** 100 resumes, split 70/15/15 (train/val/test), stratified

Published on Mendeley Data: [DOI: 10.17632/4md7bx6fd7.1](https://doi.org/10.17632/4md7bx6fd7.1)

---

## Labels

| ID | Label | Description |
|---|---|---|
| 0 | Human | Resume written by a human |
| 1 | AI | Resume generated by an AI system |

---

## Usage

```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

tokenizer = AutoTokenizer.from_pretrained("your-username/bangla-ai-detector")
model     = AutoModelForSequenceClassification.from_pretrained("your-username/bangla-ai-detector")
model.eval()

def predict(text):
    inputs  = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
    with torch.no_grad():
        logits = model(**inputs).logits
    probs  = torch.softmax(logits, dim=1)[0]
    label  = model.config.id2label[logits.argmax().item()]
    return {
        "label":        label,
        "confidence":   f"{probs.max().item()*100:.1f}%",
        "P(Human)":     f"{probs[0].item()*100:.1f}%",
        "P(AI)":        f"{probs[1].item()*100:.1f}%",
    }

# Example
resume_text = "আমি একজন অভিজ্ঞ সফ্টওয়্যার ইঞ্জিনিয়ার। গত পাঁচ বছর ধরে জাভা এবং স্প্রিং বুট দিয়ে কাজ করছি।"
print(predict(resume_text))
# Output: {'label': 'Human', 'confidence': '87.3%', 'P(Human)': '87.3%', 'P(AI)': '12.7%'}
```

---

## Preprocessing

Before passing text to the model, strip any annotation tags if present (these are specific to the Onneshon dataset format):

```python
import re

def clean_resume(text):
    text = re.sub(r'\[Info_Start\].*?\[Info_End\]', '', text, flags=re.DOTALL)
    text = re.sub(r'\[(Objective|Experience|Expericence|Education|Skill|section)\]', '', text)
    text = re.sub(r'\s+', ' ', text).strip()
    return text
```

---

## Limitations

- **Small dataset:** Only 100 resumes (70 training). Binary accuracy estimates have high variance — results should be interpreted with caution.
- **Domain-specific:** Trained exclusively on Bangla resumes. Performance on other Bangla document types (news, social media, etc.) is untested.
- **AI source unknown:** The AI resumes were generated by a specific AI system. The model may not generalize to resumes generated by different LLMs not seen during training.
- **Token limit:** Resumes longer than 512 tokens are truncated. Very long resumes may lose tail content.
- **Binary only:** Cannot distinguish *which* AI system generated the text — only Human vs AI.

---

## Citation

```bibtex
@misc{onneshon2026,
  title     = {Onneshon: A Bangla Resume NLP Dataset},
  author    = {Tanvir and Shruti Khisa and Shaira Akther Diba and Fazli Rabbi Noor},
  year      = {2026},
  doi       = {10.17632/4md7bx6fd7.1},
  publisher = {Mendeley Data}
}

@inproceedings{bhattacharjee-etal-2022-banglabert,
  title     = {BanglaBERT: Language Model Pretraining and Benchmarks for Low-Resource Language Understanding Evaluation in Bangla},
  author    = {Bhattacharjee, Abhik and Hasan, Tahmid and Ahmad, Wasi and Mubasshir, Kazi Samin and Islam, Md Saiful and Iqbal, Anindya and Rahman, M. Sohel and Shahriyar, Rifat},
  booktitle = {Findings of the Association for Computational Linguistics: NAACL 2022},
  year      = {2022},
  pages     = {1318--1327}
}
```

---

## Project

Part of the **Onneshon** thesis project — a Bangla NLP pipeline for resume processing.

- Dataset: [Mendeley Data DOI: 10.17632/4md7bx6fd7.1](https://doi.org/10.17632/4md7bx6fd7.1)
- Institution: Bangladesh University of Professionals (BUP), Dhaka, Bangladesh
- Supervisor: Rumana Yasmin, Lecturer, CSE Department, BUP