Algoritmo de detección de odio en español (Algorithm for detection of hate speech in Spanish)
收藏DataCite Commons2025-08-29 更新2024-08-26 收录
下载链接:
https://figshare.com/articles/dataset/Algorithm_for_classifying_hate_expressions_in_Spanish/24574906/2
下载链接
链接失效反馈官方服务:
资源简介:
Modelo de detección de discursos de odioEste código implementa un sistema de clasificación de discurso de odio utilizando el modelo RoBERTuito (una versión en español de RoBERTa) para detectar discurso de odio en tuits.Arquitectura del ModeloEl modelo se basa en <code>pysentimiento/robertuito-base-uncased</code> con las siguientes modificaciones:Se añadió una capa de clasificación densa sobre el modelo base.Utiliza IDs de entrada y máscaras de atención como entradas.Genera una clasificación binaria (odio vs. no odio).Datasets<b>Conjunto de Datos de Preentrenamiento</b>: Conjunto de datos multilingüe de sentimiento de tuits de Cardiff NLP (parte en español).Convertido a clasificación binaria:Tweets negativos (etiqueta original 0) → Odio (1).Tweets positivos (etiqueta original 2) → No odio (0).Tweets neutrales (etiqueta original 1) → No odio (0).<b>Conjunto de Datos HATEMEDIA</b>: Conjunto de datos personalizado de discurso de odio.Clasificación binaria:Odio (1).No odio (0).Training ProcessPre-entrenamientoBatch size: 16Epochs: 5Learning rate: 2e-5 with 10% warmup stepsEarly stopping with patience=2Fine-tuningBatch size: 128Epochs: 5Learning rate: 2e-5 with 10% warmup stepsEarly stopping with patience=2Métricas personalizadas:Recall for non-hate classPrecision for hate classF1-score (weighted)AUC-PRRecall at precision=0.9 (non-hate)Precision at recall=0.9 (hate)Métricas de EvaluaciónEl modelo se evalúa utilizando:Macro recall, precision, and F1-scoreOne-vs-Rest AUCAccuracyMétricas por claseMatriz de confusiónRequerimientosSe requiere los siguientes paquetes de Python (consulte requirements.txt para ver la lista completa):TensorFlowTransformersscikit-learnpandasdatasetsmatplotlibseabornUsoEl modelo espera datos de entrada con las siguientes especificaciones:<b>Formato de datos</b>:Archivo CSV o DataFrame de PandasNombre de columna obligatorio: <code>text</code> (tipo cadena)Nombre de columna opcional: <code>label</code> (tipo entero, 0 o 1) si está disponible para la evaluación<b>Preprocesamiento de texto</b>:El texto se convertirá automáticamente a minúsculas durante el procesamientoLongitud máxima: 128 tokens (los textos más largos se truncarán)Los caracteres especiales, las URL y los emojis deben permanecer en el texto (el tokenizador los gestiona)<b>Codificación de etiquetas</b>:<code>0</code> = Sin contenido de odio (incluido contenido neutral/positivo)<code>1</code> = Incitación al odioEl proceso de creación de este algoritmo se expone en el informe técnico localizado en: Blanco-Valencia, X., De Gregorio-Vicente, O., Ruiz Iniesta, A., & Said-Hung, E. (2025). Algoritmos de detección de odio/no odio, tipo e intensidad – Hatemedia V.2.0 (Version 2). Hatemedia Project. https://doi.org/10.5281/zenodo.16996080Autores:Elias Said-HungJulio Montero-DíazOscar De GregorioAlmudena RuizXiomara BlancoJuan José CubillasDaniel Pérez PalauFinanciado por: MCIN/AEI /10.13039/501100011033Como citar: Said-Hung, E., Montero-Diaz, J., De Gregorio Vicente, O., Ruiz-Iniesta, A., Blanco Valencia, X., José Cubillas, J., and Pérez Palau, D. (2023), “Algorithm for classifying hate expressions in Spanish”, figshare. https://doi.org/10.6084/m9.figshare.24574906.Más información:https://www.hatemedia.es/ o contactar con: elias.said@unir.netEste algoritmo está relacionado con el algoritmo de clasificación de expresiones de odio por intensidad en español, desarrollado también por los autores: https://github.com/esaidh266/Algorithm-for-classifying-hate-expressions-by-intensities-in-SpanishEste algoritmo está relacionado con el algoritmo de clasificación de expresiones de odio por tipo en español, desarrollado también por los autores: https://github.com/esaidh266/Algorithm-for-classifying-hate-expressions-by-type-in-Spanish----Hate Speech Detection ModelThis code implements a hate speech classification system using the RoBERTuito model (a Spanish version of RoBERTa) to detect hate speech in tweets.Model ArchitectureThe model is based on <code>pysentimiento/robertuito-base-uncased</code> with the following modifications:A dense classification layer has been added over the base model.It uses input IDs and attention masks as inputs.It generates a binary classification (hate vs. non-hate).Datasets<b>Pre-training Dataset</b>: Cardiff NLP multilingual tweet sentiment dataset (Spanish part).Converted to binary classification:Negative tweets (original label 0) → Hate (1).Positive tweets (original label 2) → Non-hate (0).Neutral tweets (original label 1) → No hate (0).<b>HATEMEDIA Dataset</b>: Custom hate speech dataset.Binary classification:Hate (1).No hate (0).Training ProcessPre-workoutBatch size: 16Epochs: 5Learning rate: 2e-5 with 10% warmup stepsEarly stopping with patience=2Fine-tuningBatch size: 128Epochs: 5Learning rate: 2e-5 with 10% warmup stepsEarly stopping with patience=2Custom metrics:Recall for non-hate classPrecision for hate classF1-score (weighted)AUC-PRRecall at precision=0.9 (non-hate)Precision at recall=0.9 (hate)Evaluation MetricsThe model is evaluated using:Macro recall, precision, and F1-scoreOne-vs-Rest AUCAccuracyMetrics by classConfusion matrixRequirementsThe following Python packages are required (see requirements.txt for the full list):TensorFlowTransformersscikit-learnpandasdatasetsmatplotlibseabornUsageThe model expects input data with the following specifications:<b>Data Format</b>:CSV file or Pandas DataFrameMandatory column name: <code>text</code> (type string)Optional column name: <code>label</code> (type integer, 0 or 1) if available for evaluation<b>Text Preprocessing</b>:Text will be automatically converted to lowercase during processingMaximum length: 128 tokens (longer texts will be truncated)Special characters, URLs, and emojis must remain in the text (the tokenizer handles these)<b>Label Encoding</b>:<code>0</code> = No hateful content (including neutral/positive content)1 = Hate speechThe process of creating this algorithm is explained in the technical report located at:Blanco-Valencia, X., De Gregorio-Vicente, O., Ruiz Iniesta, A., & Said-Hung, E. (2025). Algoritmos de detección de odio/no odio, tipo e intensidad – Hatemedia V.2.0 (Version 2). Hatemedia Project. https://doi.org/10.5281/zenodo.16996080 Authors:Elias Said-HungJulio Montero-DíazOscar De GregorioAlmudena RuizXiomara BlancoJuan José CubillasDaniel Pérez PalauFunded by: MCIN/AEI/10.13039/501100011033How to cites: Said-Hung, E., Montero-Diaz, J., De Gregorio Vicente, O., Ruiz-Iniesta, A., Blanco Valencia, X., José Cubillas, J., and Pérez Palau, D. (2023), “Algorithm for classifying hate expressions in Spanish”, figshare. https://doi.org/10.6084/m9.figshare.24574906.More information:https://www.hatemedia.es/ or contact: elias.said@unir.netThis algorithm is related to the algorithm for classifying hate expressions by intensity in Spanish, also developed by the authors: https://github.com/esaidh266/Algorithm-for-classifying-hate-expressions-by-intensities-in-SpanishThis algorithm is related to the algorithm for classifying hate expressions by type in Spanish, also developed by the authors: https://github.com/esaidh266/Algorithm-for-classifying-hate-expressions-by-type-in-Spanish
提供机构:
figshare
创建时间:
2024-07-17



