antonn-dromundo commited on
Commit
b85d9e0
·
verified ·
1 Parent(s): 8a9e4e8

Upload 7 files

Browse files
Files changed (7) hide show
  1. README.md +109 -3
  2. config.json +27 -0
  3. model.safetensors +3 -0
  4. special_tokens_map.json +37 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +58 -0
  7. vocab.txt +0 -0
README.md CHANGED
@@ -1,3 +1,109 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: es
3
+ license: apache-2.0
4
+ tags:
5
+ - spanish
6
+ - hate-speech-detection
7
+ - text-classification
8
+ - beto
9
+ - inclusivity
10
+ datasets:
11
+ - manueltonneau/spanish-hate-speech-superset
12
+ metrics:
13
+ - accuracy
14
+ - f1
15
+ - precision
16
+ - recall
17
+ widget:
18
+ - text: "Me encanta este país, la gente es muy amable"
19
+ - text: "Todos los inmigrantes son delincuentes"
20
+ ---
21
+
22
+ # InclusioCheck - Detector de Lenguaje de Odio en Español
23
+
24
+ ## 📋 Descripción del Modelo
25
+
26
+ **InclusioCheck** es un modelo de clasificación de texto fine-tuned desde [BETO](https://huggingface.co/dccuchile/bert-base-spanish-wwm-cased)
27
+ para detectar lenguaje de odio (hate speech) en textos en español.
28
+
29
+ ## 🚀 Uso Rápido
30
+
31
+ ```python
32
+ from transformers import pipeline
33
+
34
+ # Cargar el clasificador
35
+ classifier = pipeline("text-classification", model="antonn-dromundo/InclusioCheck-BETO-HateSpeech")
36
+
37
+ # Predecir
38
+ resultado = classifier("Texto a analizar")
39
+ print(resultado)
40
+ ```
41
+
42
+ ## 💻 Uso Avanzado
43
+
44
+ ```python
45
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
46
+ import torch
47
+
48
+ # Cargar modelo y tokenizer
49
+ tokenizer = AutoTokenizer.from_pretrained("antonn-dromundo/InclusioCheck-BETO-HateSpeech")
50
+ model = AutoModelForSequenceClassification.from_pretrained("antonn-dromundo/InclusioCheck-BETO-HateSpeech")
51
+
52
+ # Función de predicción
53
+ def predecir(texto):
54
+ inputs = tokenizer(texto, return_tensors="pt", truncation=True, max_length=128)
55
+ with torch.no_grad():
56
+ outputs = model(**inputs)
57
+ prediccion = outputs.logits.argmax(-1).item()
58
+ probabilidad = torch.softmax(outputs.logits, dim=-1)[0][prediccion].item()
59
+
60
+ label = "Hate Speech" if prediccion == 1 else "No Hate Speech"
61
+ return {"label": label, "confidence": probabilidad}
62
+
63
+ # Ejemplo
64
+ print(predecir("Los inmigrantes son bienvenidos"))
65
+ ```
66
+
67
+ ## 📊 Métricas de Rendimiento
68
+
69
+ | Métrica | Valor |
70
+ |---------|-------|
71
+ | Accuracy | 0.816 |
72
+ | F1 Score | 0.827 |
73
+ | Precision | 0.777 |
74
+ | Recall | 0.884 |
75
+
76
+ ## 📚 Dataset de Entrenamiento
77
+
78
+ - **Fuente**: [Spanish Hate Speech Superset](https://huggingface.co/datasets/manueltonneau/spanish-hate-speech-superset)
79
+ - **Ejemplos de entrenamiento**: 12,350
80
+ - **Ejemplos de test**: 2,180
81
+ - **Clases**: 2 (No Hate / Hate Speech)
82
+ - **Balanceo**: Sí (undersampling de clase mayoritaria)
83
+
84
+ ## 🎯 Casos de Uso
85
+
86
+ - ✅ Moderación automática de contenido
87
+ - ✅ Filtrado de comentarios en redes sociales
88
+ - ✅ Auditoría de lenguaje inclusivo
89
+ - ✅ Herramienta de apoyo para redacción
90
+
91
+ ## ⚠️ Limitaciones
92
+
93
+ - El modelo está entrenado específicamente para **español**
94
+ - Puede tener sesgos inherentes al dataset de entrenamiento
95
+ - Recomendado como **herramienta de apoyo**, no como única fuente de decisión
96
+ - El contexto cultural y la intención deben considerarse en casos ambiguos
97
+
98
+ ## 👤 Autoría
99
+ Antonio Dromundo
100
+ Creado como parte del proyecto **InclusioCheck** para promover la detección de lenguaje excluyente.
101
+ De Mexico para el mundo
102
+ ## 📄 Licencia
103
+
104
+ Apache 2.0
105
+
106
+ ## 🔗 Enlaces
107
+
108
+ - [Repositorio del proyecto](#)
109
+ - [Demo en Gradio](#)
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "dtype": "float32",
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "output_past": true,
20
+ "pad_token_id": 1,
21
+ "position_embedding_type": "absolute",
22
+ "problem_type": "single_label_classification",
23
+ "transformers_version": "4.57.1",
24
+ "type_vocab_size": 2,
25
+ "use_cache": true,
26
+ "vocab_size": 31002
27
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1ba5f2e2fdc9aea23c4ba2ef5f39977e3aa93eb5e911ba717b7408b7d267bab
3
+ size 439433208
special_tokens_map.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
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": "[MASK]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "[PAD]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "3": {
20
+ "content": "[UNK]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "4": {
28
+ "content": "[CLS]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "5": {
36
+ "content": "[SEP]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": false,
48
+ "extra_special_tokens": {},
49
+ "mask_token": "[MASK]",
50
+ "model_max_length": 512,
51
+ "never_split": null,
52
+ "pad_token": "[PAD]",
53
+ "sep_token": "[SEP]",
54
+ "strip_accents": false,
55
+ "tokenize_chinese_chars": true,
56
+ "tokenizer_class": "BertTokenizer",
57
+ "unk_token": "[UNK]"
58
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff