Text Classification
Transformers
Safetensors
Spanish
bert
hate-speech
toxicity
spanish
el-salvador
mbert
Eval Results (legacy)
text-embeddings-inference
Instructions to use caeher/mbert-sv with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use caeher/mbert-sv with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="caeher/mbert-sv")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("caeher/mbert-sv") model = AutoModelForSequenceClassification.from_pretrained("caeher/mbert-sv", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add mBERT-SV checkpoint-1072 (F1-macro 0.7777)
Browse files- README.md +99 -0
- config.json +46 -0
- inference_contract.json +6 -0
- model.safetensors +3 -0
- test_metrics.json +38 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
- train_metrics.json +9 -0
- training_args.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- es
|
| 4 |
+
license: apache-2.0
|
| 5 |
+
base_model: google-bert/bert-base-multilingual-cased
|
| 6 |
+
tags:
|
| 7 |
+
- text-classification
|
| 8 |
+
- hate-speech
|
| 9 |
+
- toxicity
|
| 10 |
+
- spanish
|
| 11 |
+
- el-salvador
|
| 12 |
+
- mbert
|
| 13 |
+
pipeline_tag: text-classification
|
| 14 |
+
library_name: transformers
|
| 15 |
+
metrics:
|
| 16 |
+
- f1
|
| 17 |
+
- accuracy
|
| 18 |
+
model-index:
|
| 19 |
+
- name: mbert-sv
|
| 20 |
+
results:
|
| 21 |
+
- task:
|
| 22 |
+
type: text-classification
|
| 23 |
+
name: Toxicidad en español salvadoreño
|
| 24 |
+
dataset:
|
| 25 |
+
name: Corpus tesina (test, n=460)
|
| 26 |
+
type: custom
|
| 27 |
+
metrics:
|
| 28 |
+
- type: f1
|
| 29 |
+
value: 0.7777
|
| 30 |
+
name: F1-macro
|
| 31 |
+
- type: accuracy
|
| 32 |
+
value: 0.7826
|
| 33 |
+
name: Accuracy
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
# mBERT-SV — Clasificación de toxicidad (El Salvador)
|
| 37 |
+
|
| 38 |
+
Fine-tuning de [`bert-base-multilingual-cased`](https://huggingface.co/google-bert/bert-base-multilingual-cased) para clasificación **multiclase** de toxicidad en redes sociales en español salvadoreño.
|
| 39 |
+
|
| 40 |
+
Checkpoint de auditoría: **`checkpoint-1072`** (época 4, semilla 42).
|
| 41 |
+
|
| 42 |
+
## Etiquetas
|
| 43 |
+
|
| 44 |
+
| id | etiqueta |
|
| 45 |
+
|----|----------|
|
| 46 |
+
| 0 | No Tóxico |
|
| 47 |
+
| 1 | Lenguaje Ofensivo |
|
| 48 |
+
| 2 | Discurso de Odio |
|
| 49 |
+
| 3 | Amenazas/Violencia |
|
| 50 |
+
|
| 51 |
+
## Contrato de inferencia
|
| 52 |
+
|
| 53 |
+
| Campo | Valor |
|
| 54 |
+
|-------|-------|
|
| 55 |
+
| `max_length` | 128 |
|
| 56 |
+
| Columna de texto | `texto_modelo` |
|
| 57 |
+
| Normalizador | `normalize_for_model` v1.1 |
|
| 58 |
+
|
| 59 |
+
Si el texto no está preprocesado, hay que aplicar el mismo normalizador del repositorio de la tesina.
|
| 60 |
+
|
| 61 |
+
## Métricas oficiales (test, n = 460)
|
| 62 |
+
|
| 63 |
+
| Métrica | Valor |
|
| 64 |
+
|---------|-------|
|
| 65 |
+
| F1-macro | **0.7777** |
|
| 66 |
+
| Accuracy | 0.7826 |
|
| 67 |
+
| Precision-macro | 0.7809 |
|
| 68 |
+
| Recall-macro | 0.7757 |
|
| 69 |
+
| QWK | 0.7362 |
|
| 70 |
+
|
| 71 |
+
F1 por clase: No Tóxico 0.814 · Lenguaje Ofensivo 0.795 · Discurso de Odio 0.746 · Amenazas/Violencia 0.756.
|
| 72 |
+
|
| 73 |
+
## Uso
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 77 |
+
import torch
|
| 78 |
+
|
| 79 |
+
repo_id = "caeher/mbert-sv"
|
| 80 |
+
tokenizer = AutoTokenizer.from_pretrained(repo_id)
|
| 81 |
+
model = AutoModelForSequenceClassification.from_pretrained(repo_id)
|
| 82 |
+
|
| 83 |
+
text = "ejemplo de comentario"
|
| 84 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
|
| 85 |
+
with torch.no_grad():
|
| 86 |
+
logits = model(**inputs).logits
|
| 87 |
+
pred = int(logits.argmax(dim=-1))
|
| 88 |
+
print(model.config.id2label[pred])
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
## Archivos
|
| 92 |
+
|
| 93 |
+
- `model.safetensors`, `config.json`, `tokenizer.json`, `tokenizer_config.json`
|
| 94 |
+
- `inference_contract.json` — contrato de preprocesamiento
|
| 95 |
+
- `test_metrics.json` / `train_metrics.json` — métricas del checkpoint
|
| 96 |
+
|
| 97 |
+
## Limitaciones
|
| 98 |
+
|
| 99 |
+
Modelo de tesina, no un moderador autónomo. El corpus es de El Salvador; el desempeño puede caer en otros dialectos o en jerga adversarial. FPR sobre jerga no tóxica y cortes por plataforma están documentados en el informe del proyecto.
|
config.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_cross_attention": false,
|
| 3 |
+
"architectures": [
|
| 4 |
+
"BertForSequenceClassification"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"bos_token_id": null,
|
| 8 |
+
"classifier_dropout": null,
|
| 9 |
+
"directionality": "bidi",
|
| 10 |
+
"dtype": "float32",
|
| 11 |
+
"eos_token_id": null,
|
| 12 |
+
"hidden_act": "gelu",
|
| 13 |
+
"hidden_dropout_prob": 0.1,
|
| 14 |
+
"hidden_size": 768,
|
| 15 |
+
"id2label": {
|
| 16 |
+
"0": "No Tóxico",
|
| 17 |
+
"1": "Lenguaje Ofensivo",
|
| 18 |
+
"2": "Discurso de Odio",
|
| 19 |
+
"3": "Amenazas/Violencia"
|
| 20 |
+
},
|
| 21 |
+
"initializer_range": 0.02,
|
| 22 |
+
"intermediate_size": 3072,
|
| 23 |
+
"is_decoder": false,
|
| 24 |
+
"label2id": {
|
| 25 |
+
"No Tóxico": 0,
|
| 26 |
+
"Lenguaje Ofensivo": 1,
|
| 27 |
+
"Discurso de Odio": 2,
|
| 28 |
+
"Amenazas/Violencia": 3
|
| 29 |
+
},
|
| 30 |
+
"layer_norm_eps": 1e-12,
|
| 31 |
+
"max_position_embeddings": 512,
|
| 32 |
+
"model_type": "bert",
|
| 33 |
+
"num_attention_heads": 12,
|
| 34 |
+
"num_hidden_layers": 12,
|
| 35 |
+
"pad_token_id": 0,
|
| 36 |
+
"pooler_fc_size": 768,
|
| 37 |
+
"pooler_num_attention_heads": 12,
|
| 38 |
+
"pooler_num_fc_layers": 3,
|
| 39 |
+
"pooler_size_per_head": 128,
|
| 40 |
+
"pooler_type": "first_token_transform",
|
| 41 |
+
"tie_word_embeddings": true,
|
| 42 |
+
"transformers_version": "5.14.1",
|
| 43 |
+
"type_vocab_size": 2,
|
| 44 |
+
"use_cache": false,
|
| 45 |
+
"vocab_size": 119547
|
| 46 |
+
}
|
inference_contract.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"max_length": 128,
|
| 3 |
+
"text_column": "texto_modelo",
|
| 4 |
+
"normalizer": "normalize_for_model",
|
| 5 |
+
"normalizer_version": "1.1"
|
| 6 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b2de91405b7c094368073b9b15e5a61287a987f7a4e308e1acd414dfbf36451f
|
| 3 |
+
size 711449584
|
test_metrics.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"accuracy": 0.782608695652174,
|
| 3 |
+
"balanced_accuracy": 0.7757451391051162,
|
| 4 |
+
"f1_macro": 0.7777194765714894,
|
| 5 |
+
"f1_weighted": 0.7828842207289413,
|
| 6 |
+
"precision_macro": 0.7808732555624674,
|
| 7 |
+
"recall_macro": 0.7757451391051162,
|
| 8 |
+
"ordinal_mae": 0.3239130434782609,
|
| 9 |
+
"ordinal_rmse": 0.7561343335907864,
|
| 10 |
+
"large_error_pct": 8.91304347826087,
|
| 11 |
+
"qwk": 0.7361556982343499,
|
| 12 |
+
"kappa_linear": 0.7182345879992764,
|
| 13 |
+
"mcc": 0.7035845189708845,
|
| 14 |
+
"precision_No Tóxico": 0.8495575221238938,
|
| 15 |
+
"recall_No Tóxico": 0.7804878048780488,
|
| 16 |
+
"f1_No Tóxico": 0.8135593220338984,
|
| 17 |
+
"support_No Tóxico": 123,
|
| 18 |
+
"precision_Lenguaje Ofensivo": 0.7738095238095238,
|
| 19 |
+
"recall_Lenguaje Ofensivo": 0.8176100628930818,
|
| 20 |
+
"f1_Lenguaje Ofensivo": 0.7951070336391437,
|
| 21 |
+
"support_Lenguaje Ofensivo": 159,
|
| 22 |
+
"precision_Discurso de Odio": 0.7346938775510204,
|
| 23 |
+
"recall_Discurso de Odio": 0.7578947368421053,
|
| 24 |
+
"f1_Discurso de Odio": 0.7461139896373057,
|
| 25 |
+
"support_Discurso de Odio": 95,
|
| 26 |
+
"precision_Amenazas/Violencia": 0.7654320987654321,
|
| 27 |
+
"recall_Amenazas/Violencia": 0.7469879518072289,
|
| 28 |
+
"f1_Amenazas/Violencia": 0.7560975609756098,
|
| 29 |
+
"support_Amenazas/Violencia": 83,
|
| 30 |
+
"roc_auc_ovr_macro": 0.9221629865233141,
|
| 31 |
+
"log_loss": 0.8721387005957749,
|
| 32 |
+
"ece": 0.15694192051887512,
|
| 33 |
+
"brier_macro": 0.09395594522356987,
|
| 34 |
+
"classification_report": " precision recall f1-score support\n\n No Tóxico 0.85 0.78 0.81 123\n Lenguaje Ofensivo 0.77 0.82 0.80 159\n Discurso de Odio 0.73 0.76 0.75 95\nAmenazas/Violencia 0.77 0.75 0.76 83\n\n accuracy 0.78 460\n macro avg 0.78 0.78 0.78 460\n weighted avg 0.78 0.78 0.78 460\n",
|
| 35 |
+
"f1_bootstrap_mean": 0.7775980516278476,
|
| 36 |
+
"f1_bootstrap_lo": 0.7357670523307825,
|
| 37 |
+
"f1_bootstrap_hi": 0.8143980633933287
|
| 38 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": false,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 512,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "BertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|
train_metrics.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"eval_loss": 0.8894229531288147,
|
| 3 |
+
"eval_f1_macro": 0.771461875533477,
|
| 4 |
+
"eval_accuracy": 0.7712418300653595,
|
| 5 |
+
"eval_runtime": 86.7344,
|
| 6 |
+
"eval_samples_per_second": 5.292,
|
| 7 |
+
"eval_steps_per_second": 0.334,
|
| 8 |
+
"epoch": 4.0
|
| 9 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:be351f95ce0b99bab71f3fe9f100d435804bd29fc6ce4f857bce35a9a1603d7c
|
| 3 |
+
size 5201
|