LikoKiko commited on
Commit
3a8d54b
·
1 Parent(s): 004309d
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,114 @@
1
  ---
 
 
2
  license: cc-by-sa-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - he
4
  license: cc-by-sa-4.0
5
+ tags:
6
+ - text-classification
7
+ - profanity-detection
8
+ - toxicity
9
+ - hebrew
10
+ - bert
11
+ - alephbert
12
+ library_name: transformers
13
+ base_model: onlplab/alephbert-base
14
+ pipeline_tag: text-classification
15
+ datasets:
16
+ - custom
17
+ metrics:
18
+ - accuracy
19
+ - precision
20
+ - recall
21
+ - f1
22
  ---
23
+
24
+ # OpenCensor-H1-Mini
25
+
26
+ **OpenCensor-H1-Mini** is a lightweight, efficient version of **OpenCensor-H1**, designed to detect profanity, toxicity, and offensive content in Hebrew text. It is fine-tuned on the `onlplab/alephbert-base` architecture.
27
+
28
+ ## Model Details
29
+
30
+ - **Model Name:** OpenCensor-H1-Mini
31
+ - **Base Model:** `onlplab/alephbert-base`
32
+ - **Task:** Binary Classification (0 = Clean, 1 = Toxic/Profane)
33
+ - **Language:** Hebrew
34
+ - **Max Sequence Length:** 256 tokens (optimized for efficiency)
35
+
36
+ ## Performance
37
+
38
+ | Metric | Score |
39
+ | :--- | :--- |
40
+ | **Accuracy** | 0.9826 |
41
+ | **F1-Score** | 0.9823 |
42
+ | **Precision** | 0.9812 |
43
+ | **Recall** | 0.9835 |
44
+
45
+ *Note: Best Threshold = 0.49*
46
+
47
+ ### Training Graphs
48
+
49
+ | Validation F1 | Threshold Analysis |
50
+ | :---: | :---: |
51
+ | ![Validation F1](valf1perepoch.png) | ![Thresholds](thresholdsperepoch.png) |
52
+
53
+ ![Final Test Metrics](testmetrics.png)
54
+
55
+ ## How to Use
56
+
57
+ You can use this model directly with the Hugging Face `transformers` library.
58
+
59
+ ```python
60
+ import torch
61
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
62
+
63
+ # Load the model
64
+ model_id = "LikoKIko/OpenCensor-H1-Mini"
65
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
66
+ model = AutoModelForSequenceClassification.from_pretrained(model_id).eval()
67
+
68
+ def predict(text):
69
+ # Tokenize input
70
+ inputs = tokenizer(
71
+ text,
72
+ return_tensors="pt",
73
+ truncation=True,
74
+ padding=True,
75
+ max_length=256
76
+ )
77
+
78
+ # Predict
79
+ with torch.no_grad():
80
+ logits = model(**inputs).logits
81
+ score = torch.sigmoid(logits).item()
82
+
83
+ return {
84
+ "text": text,
85
+ "score": round(score, 4),
86
+ "is_toxic": score >= 0.49 # Threshold
87
+ }
88
+
89
+ # Example usage
90
+ text = "אני אוהב את כולם" # "I love everyone"
91
+ print(predict(text))
92
+ ```
93
+
94
+ ## Training Info
95
+
96
+ The model was trained using an optimized pipeline featuring:
97
+ - **Gradient Accumulation:** Ensures stable training with larger effective batch sizes.
98
+ - **Smart Text Cleaning:** Removes noise while preserving Hebrew, English, and important symbols (`@#$%*`).
99
+ - **Dynamic Padding:** Uses efficient token lengths based on data distribution.
100
+
101
+ ## License
102
+
103
+ CC-BY-SA-4.0
104
+
105
+ ## Citation
106
+
107
+ ```bibtex
108
+ @misc{opencensor-h1-mini,
109
+ title = {OpenCensor-H1-Mini: Hebrew Profanity Detection Model},
110
+ author = {LikoKIko},
111
+ year = {2025},
112
+ url = {https://huggingface.co/LikoKIko/OpenCensor-H1-Mini}
113
+ }
114
+ ```
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "onlplab/alephbert-base",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "id2label": {
13
+ "0": "LABEL_0"
14
+ },
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 3072,
17
+ "label2id": {
18
+ "LABEL_0": 0
19
+ },
20
+ "layer_norm_eps": 1e-12,
21
+ "max_position_embeddings": 512,
22
+ "model_type": "bert",
23
+ "num_attention_heads": 12,
24
+ "num_hidden_layers": 12,
25
+ "pad_token_id": 0,
26
+ "position_embedding_type": "absolute",
27
+ "torch_dtype": "float32",
28
+ "transformers_version": "4.39.1",
29
+ "type_vocab_size": 1,
30
+ "use_cache": true,
31
+ "vocab_size": 52000
32
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:422b637c5d96c9f944e7e3b1d0cef7aafb396156b918dfa13dd95b9ed8b5fbf6
3
+ size 503932924
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
testmetrics.png ADDED

Git LFS Details

  • SHA256: 41d91c48b30d377c1cdc1ff0fe399d976d67fc9a96945c0a62dcf1b53804f31d
  • Pointer size: 130 Bytes
  • Size of remote file: 73.4 kB
thresholdsperepoch.png ADDED

Git LFS Details

  • SHA256: 9a42782a188395abc21a9c933ce96b98683f693b63f3b43108023c5118b62338
  • Pointer size: 131 Bytes
  • Size of remote file: 148 kB
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "max_len": 512,
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": null,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
valf1perepoch.png ADDED

Git LFS Details

  • SHA256: 6552406472477720b4effebfbdbb58601de22b90180eb65175d6029ea04f03ad
  • Pointer size: 131 Bytes
  • Size of remote file: 123 kB
vocab.txt ADDED
The diff for this file is too large to render. See raw diff