Elamur Research

Evaluating feature combination strategies for hate-speech detection in Spanish using linguistic features and transformers

Paper · 2022 · José Antonio Garcí­a-Dí­az, Salud María Jiménez-Zafra, Miguel Ángel García Cumbreras et al.

Summary

A post can contain an insult without attacking anyone on the basis of gender, origin, or another attribute. It can also convey hostility through wording that looks ordinary when read in isolation. Both cases complicate efforts to identify hate speech in the volume of material posted to social networks. García-Díaz and colleagues study this problem in Spanish, where the literature they review is smaller than the corresponding body of work in English. They ask what different representations of a tweet contribute to detection and whether those representations work better together.

The authors compare explicit linguistic measurements, pretrained representations of individual words, fixed representations of whole messages, and contextual representations adapted to each dataset. The strongest standalone representation comes from BETO, a Spanish adaptation of BERT. To combine evidence, the authors either feed several representations into a shared neural network or train separate classifiers and combine their predictions. The shared network generally performs better by weighted F1, a score that accounts for how well each class is found and gives more weight to classes with more examples. The best set of inputs depends on the corpus. The shared network reaches 90.52% weighted F1 on Spanish MisoCorpus 2020 with the embedding inputs, 84.72% on AMI 2018 with all feature sets, and 77.27% on HatEval 2019 with linguistic features and BETO. On HaterNet, a logistic regression ensemble of the embedding classifiers reaches 84.34%, ahead of the shared network’s best weighted F1 of 84.08%.

The analysis of the linguistic measurements shows why a feature can help in one collection and be less informative in another. Strongly offensive wording is associated with the labels across the corpora, but spelling, topics, forms of address, and ways of connecting clauses vary in relevance. Argumentative markers are more common in non-misogynous messages in Spanish MisoCorpus 2020 and more common in misogynous messages in AMI 2018. Negation receives a detailed analysis and contributes little overall. These findings describe patterns in the annotated tweets. The combined networks’ reliance on individual cues remains a separate question.

The authors also compare their methods with earlier systems using the metrics that each benchmark emphasized. They report higher scores on those measures, including 76.8% macro F1 for the shared linguistic-feature and BETO network on HatEval 2019. Differences in data splits and evaluation procedures qualify some of the comparisons. The clearest evidence comes from the experiments run within the same pipeline, where BETO supplies a strong starting point and the choice of what to add depends on the dataset and the kinds of errors the evaluation rewards.

Deep dive: Evaluating feature combination strategies for hate-speech detection in Spanish using linguistic features and transformers

A study of Spanish hate speech detection compares linguistic features, BETO embeddings, and ways to combine them across four datasets. · about 34 minutes to read

The problem and its context

Where offensive language and hate speech diverge

The paper treats hate speech as a kind of offensive language distinguished by whom it targets and on what basis. A swear word can convey anger without targeting a person or group. An attack directed at someone on the basis of gender, origin, or sexual orientation presents a different case. A detector trained to recognize unusually crude vocabulary therefore has only part of the information it needs. It also needs to make distinctions about the use of the words and, where possible, the target of the message. Previous work surveyed by the authors treats this boundary as difficult to define consistently. Automated Hate Speech Detection and the Problem of Offensive Language

The paper identifies manual review as a practical constraint. Reviewing every social media post is infeasible at the scale the authors consider. An automatic detector could reduce the number of posts that reviewers have to read. That use gives the two kinds of error different consequences. Flagging an ordinary post adds review work, while overlooking a hateful post keeps it out of the review queue. The same classifier can look dependable when judged by the flags it raises and perform poorly when judged by the harmful material it leaves behind. The experiments make that difference visible by reporting separate measures for each class.

There is also a question about what information is available to a detector in the first place. The authors point to hoaxes as an example where the hostility carried by a post may be difficult to recognize from wording alone. A short message can rely on something outside the string being classified. The datasets give the system text and human-assigned categories, and the study asks how far those inputs take it. The difference between recognizing a pattern associated with an annotation and interpreting a post in its full social context matters throughout the paper. Linguistic annotation

Why compare several Spanish corpora?

The surveys discussed in the paper describe a field with several definitions of abuse, several kinds of annotated data, and a substantial concentration of research on English. The authors situate hate speech near other phenomena such as cyberbullying, toxicity, and discrimination, where related problems can give rise to different labeling rules. They also describe work on multiple platforms, including Facebook and YouTube, with Twitter the most common source in the literature they review. Their own experiments work with Spanish Twitter collections. A Survey on Hate Speech Detection using Natural Language Processing · A Survey on Automatic Detection of Hate Speech in Text

A focus on Spanish still leaves substantial variation in the task. A collection assembled around misogyny gives the positive class a specific target and subject matter. A collection of hateful posts in general can include a wider range of language and a different balance between positive and negative examples. A benchmark covering attacks on both women and immigrants puts those targets under one binary decision, even though performance can differ between them. The paper brings these tasks into a common experimental framework while preserving their label meanings.

The comparison also extends beyond the Spanish datasets emphasized in the earlier work discussed by the authors, which often used HaterNet and HatEval. Including AMI and Spanish MisoCorpus makes it possible to ask whether a pattern recurs even when two collections nominally investigate the same phenomenon. Agreement between those collections can indicate a recurring cue within the study. Disagreement shows where a description of “the language of misogyny” would be too broad for the evidence. The collection procedures are especially relevant because the search terms, accounts, and events used to find posts help determine which kinds of language appear in the first place.

The scope of classification is narrower than that of some of the original shared tasks. The paper discusses guidelines that distinguish the presence of offensive speech from its type and target. AMI and HatEval also offer ways to ask more detailed questions about a message. The experiments here reduce the decision to a binary label. This makes it possible to apply the same evaluation machinery to the different corpora, while a positive decision has the meaning assigned by the particular benchmark. Predicting the Type and Target of Offensive Posts in Social Media · HatEval

What earlier systems represented

The authors describe earlier Spanish shared-task entries using support vector machines and inputs such as sequences of tokens and term weights. A support vector machine learns a decision boundary from numerical representations of labeled examples. A bag of words records which terms appear, leaving their original sequence aside. An n-gram retains a short run of consecutive items, which allows a representation to capture some local wording. TF-IDF weights terms using their occurrence within a document and their distribution across documents. Other inputs described in the paper include offensive-word lexicons and counts based on grammatical categories.

Earlier neural approaches often used convolutional or recurrent networks. A convolutional network can learn to detect patterns in nearby words, while a recurrent network builds a representation as it reads through a sequence. Both can start with word embeddings, which encode words as vectors of numbers learned from other text. The paper's comparison of related work distinguishes these word vectors from sentence embeddings, which summarize a whole text in a fixed-length vector, and from contextual embeddings, which can assign different vectors to the same word in different sentences.

By the time of the study, earlier Spanish work had compared multilingual and Spanish-specific pretrained systems on HaterNet and HatEval. As the authors describe it, that work preferred BETO overall, but the best precision for the hate class depended on the benchmark. Logistic regression with TF-IDF recorded higher positive-class precision on HaterNet, while pretrained word embeddings with a convolutional network did so on HatEval. This metric-specific variation helps explain the paper's design. It compares feature families in isolation before combining them, and it asks which errors change as well as which system has the highest aggregate score.

The study thus connects two questions that can be answered with different evidence. A benchmark comparison can establish how well a system reproduces labeled decisions on its test split. An analysis of named linguistic properties can show what distinguishes the labeled groups in a corpus. The authors use both because embeddings can give good predictions without a readily identifiable explanation for each coordinate, while a measure such as the proportion of misspelled words has an interpretation even if its predictive contribution is small.

The method, step by step

From a tweet to several kinds of input

The pipeline begins with a labeled corpus. It puts the posts and labels into a common format, prepares the text for the different representations, and obtains training, validation, and test splits. It then produces several feature sets from each message. The experiments can use one set at a time, learn from several sets together, or let separately trained classifiers make predictions and combine their outputs. The authors identify the source code and its requirements in the CAIS-HateSpeeechDetectionInSpanish-2021 repository.

From Spanish tweets to evaluated predictions

The steps in order.

From Spanish tweets to evaluated predictionsStep 1: Load a corpus and standardize its labels1. Load a corpus and standardize its labelsStep 2: Prepare original and cleaned text variants2. Prepare original and cleaned text variantsStep 3: Obtain training, validation, and test splits3. Obtain training, validation, and test splitsStep 4: Generate and select features using training data4. Generate and select features using training dataStep 5: Train classifiers with individual or combined inputs5. Train classifiers with individual or combined inputsStep 6: Combine predictions when using an ensemble6. Combine predictions when using an ensembleStep 7: Score the selected system on the test split7. Score the selected system on the test split

Each representation makes a different tradeoff. A count of misspellings is easy to interpret, but it describes only one property of a message. A sequence of word vectors preserves which vector came before which, so a classifier can look for patterns across neighbors or across the tweet. A fixed sentence vector makes texts of different lengths comparable as inputs to the same classifier. A contextual representation adds another distinction by letting a word’s numerical description depend on its surroundings. The paper compares how much class information these alternatives retain and whether the information in one is still useful when another is already available.

Cleaning text and preserving the splits

The authors create two cleaned versions and also retain the raw tweet. The first cleaned version removes URLs, hashtags, mentions, emojis, and punctuation. Digits become the placeholder [NUMBER], and certain repeated letters are reduced. This version preserves capitalization for linguistic processing that benefits from case. A Spanish surname such as Rubio or Herrero, for example, can also be read as an ordinary word. Capital letters can help a part-of-speech tagger interpret the word as a proper name.

The second cleaned version lowercases the first, and the paper describes it as the input for word and sentence embeddings. Keeping the original gives the feature extractor access to patterns such as unusual capitalization and spelling that cleaning can obscure. This separation also helps explain how the study can discuss hashtags, mentions, hyperlinks, and emojis in its linguistic analysis even though those elements are removed from a cleaned variant. A representation built from normalized words and one built from properties of the original post can use different evidence from the same tweet.

The split procedure depends on what a corpus already supplies. Where training, validation, and test parts exist, the authors use them. Where there is a training split and a test split, they randomly take 20% of the training split for validation and leave the test split intact. For an unpartitioned corpus, they use a random 60–20–20 split, taking class balance into account when forming the partitions. These rules allow the pipeline to use existing test sets while giving each experiment a development partition.

The partitions have separate jobs. Training data supply the label information used to learn classifier parameters, fit feature processing, and rank features. Validation supports decisions among configurations. Test data furnish the report for the selected system. That division matters particularly for mutual information, since a ranking based on all labels would let information from test examples inform feature selection. The pipeline description assigns fitting of feature generation and selection to the training partition.

Four representations of the same post

The authors denote the linguistic feature set by LF. Its main source is UMUTextStats, a Spanish text-analysis tool with 365 features. It covers properties of sound patterns, vocabulary, grammar, spelling and style, language register, and social media conventions, among other categories. The representation can record, for example, whether a tweet contains strongly offensive vocabulary, whether it includes certain classes of discourse connectors, and how much of its text is misspelled. Assigning a name to each measurement makes it possible to inspect which properties are associated with a corpus label.

The authors extend LF with a more detailed representation of negation. They count cues that consist of a single word, such as no, continuous expressions such as en mi vida, and discontinuous expressions such as ni … ni. A discontinuous expression can have other words between its parts. By retaining distinctions among expressions as well as a total count, the analysis can ask whether a specific form is associated with the label even if negation as a whole is weak. The feature procedure described in the paper records the cues present, leaving their function in a particular statement for a different kind of analysis.

WE denotes the word-embedding input. The experiments consider pretrained vectors from word2vec, GloVe, and fastText, as well as learning word embeddings from scratch. Pretraining means the classifier begins with word representations learned elsewhere. Each word in the input sequence receives a vector, giving networks that operate over sequences access to word order. The static embeddings described in the paper assign a word the same representation across its uses. That is convenient for reusing the vectors, but it leaves the downstream classifier to make distinctions among the word’s senses from the surrounding sequence. word2vec · GloVe · fastText

SE denotes the fixed sentence representation obtained from Spanish fastText. Every document receives a vector of length 300. The classifier can therefore process a short post and a longer one using the same input dimensions. This representation differs from WE because its interface to the classifier is already a whole-document vector. In the word-level experiments, an architecture can process the sequence of word vectors itself. The paper describes the fixed sentence representation and the pretrained word vectors as sharing the limitation of static word senses. Learning Word Vectors for 157 Languages

BF denotes the contextual input used in the combination experiments. Its source is BETO, the Spanish adaptation of BERT. The paper evaluates BETO alongside BERTIN, multilingual BERT, and the Spanish RoBERTa system trained from National Library of Spain material, which the comparisons call BNE. BERT’s bidirectional transformer uses the surrounding words in both directions when producing contextual representations. The same surface word can consequently receive different vectors in different sentences. Transformer and attention · BERT

The authors use Hugging Face to adapt BETO separately to each corpus through fine-tuning. This adapts the pretrained parameters to the dataset’s labeled classification task. They then take the contextualized word vectors and apply mean pooling, averaging across positions to obtain a vector of length 768 for the document. The sequence matters before the average, when the transformer determines the contextual representation of each position. Once pooled, the result has the fixed size needed to sit alongside the other inputs to a classifier. The paper draws the pooling approach from Sentence-BERT.

Selecting features and training the individual classifiers

The linguistic measurements include raw counts and percentages with different ranges. The authors rescale each LF dimension to the interval from 0 to 1. That puts, for example, a measurement expressed as a percentage and a count of occurrences on a common numerical range before training. The normalization changes the scale of each feature while preserving what that dimension measures.

The next step ranks features by mutual information with the class label. Mutual information measures how much knowing a feature reduces uncertainty about the label. A high rank means that the feature’s values help distinguish the labeled groups in that corpus. The rank alone leaves open which class tends to have the higher values, and it leaves open how useful the feature will be after other variables enter the classifier. The authors discard the last quartile of ranked LF and SE features. They retain all BF dimensions because they found feature selection ineffective for that representation.

The individual-feature experiments train a classifier separately for each feature set. Fixed vectors lend themselves to a multilayer perceptron, where dense layers transform the input into a prediction. Word vectors can also be passed to a convolutional network or a recurrent network. The authors explore bidirectional long short-term memory and gated recurrent units for the sequential setting. A convolution can bring together neighboring words, while a bidirectional recurrent network can use the preceding and following parts of the sequence when it reads a position.

Their search includes shallow networks with one or two hidden layers and deeper architectures with between three and eight. It varies the number of units, the way layer widths change through the network, dropout, activation functions, and learning rates. A constant-width or brick-shaped network uses the same width across its hidden layers. A funnel changes width as processing approaches the output. Dropout removes some activations during training to limit overfitting. The learning rate controls the size of parameter updates, and the two rates described in the paper are 10e−3 and 10e−4, with time-based decay.

The standard batch sizes considered are 32 and 64, with 128, 256, and 512 also explored for HaterNet. A batch is the group of examples used for a training update. The paper connects the larger HaterNet options to the scarcity of hateful posts relative to non-hateful ones and the desire to see enough positive examples in a batch. Training runs for at most 1000 epochs with early stopping. An epoch is a pass through the training data, and early stopping can end a run before it reaches the cap.

Combining representations before or after a prediction

In the authors’ knowledge integration strategy, Keras is used to construct a neural network with a separate input for each feature set. Each input goes through a dense layer before the branches are brought together for the final decision. The network can learn how to use properties from several inputs when classifying the same example. The authors repeat the hyper-parameter search for these combined networks. A classifier receiving a contextual vector and a linguistic vector can therefore have a different architecture from the classifiers trained on either vector alone.

The integrated configurations pair LF and BF, combine SE, WE, and BF, or include all the feature sets. Every combined configuration contains the contextual BETO representation. The pair with LF tests whether an explicit description of the tweet helps alongside BETO. The embedding combination tests whether the other numerical text representations add information alongside BETO. The full configuration brings both routes together. These are comparisons between collections of features, with optimized classifiers for each collection.

Ensemble learning moves the combination point to the outputs. The best individual classifier for each feature set produces its own prediction, and the ensemble makes its decision from those predictions. The paper evaluates hard voting, which uses the individual class decisions, and two strategies based on probabilities. The highest-probability strategy uses the most confident prediction, while the average-probability strategy combines the classifiers’ probability estimates. The paper also trains a logistic regression classifier on probabilities from the training split, so the combination can learn how much to rely on the different outputs.

This distinction matters even when the input feature sets have exactly the same names. The shared network receives numeric properties of the text. The logistic regression ensemble receives the evidence that the individual classifiers have already compressed into class probabilities. If an individual classifier mostly ignores a useful property when forming its prediction, the ensemble has limited access to that property. Conversely, using existing predictions allows the authors to compare several combination rules while reusing the individual classifiers.

What the reported scores count

The paper reports precision and recall with respect to each class. The class of interest can be the hateful or misogynous class, or the corresponding negative class if the counts are taken from its perspective. That convention matters because precision and recall for the negative class answer a different question from precision and recall for the class a reviewer wants to flag.

Precision = TP / (TP + FP)

TP counts true positives, examples correctly assigned to the class being scored. FP counts false positives, examples predicted to belong to that class whose human annotation assigns them elsewhere. The plus sign adds the two counts to obtain the total number predicted for the class. Division gives the proportion of those predictions that agree with the annotations.

Recall = TP / (TP + FN)

TP again counts correctly assigned examples of the class. FN counts false negatives, examples that human annotators assigned to the class but the classifier missed. Adding the two gives the number that should have been found. Division gives the share of that class the classifier recovered.

F1-score = 2 × (Precision × Recall) / (Precision + Recall)

Precision and Recall are the fractions defined above. The multiplication sign forms their product, 2 is the multiplier in the harmonic mean, and the denominator adds the two scores. A very low value on either measure pulls F1 down, so a system needs to find examples of a class and keep its predictions for that class reasonably accurate.

Accuracy = (TP + TN) / (TP + TN + FP + FN)

TP counts correct positive decisions and TN counts true negatives, or correct negative decisions. FP and FN are the two kinds of error. The numerator adds the correct decisions, and the denominator adds all the decisions. Division gives the proportion classified correctly.

The paper reports weighted precision, recall, and F1 for overall comparisons. In a weighted average, the score for a more common class has more influence. Macro F1 gives the class F1 scores equal influence, which is useful when both kinds of performance matter independently of their frequency. The historical comparisons use accuracy for the misogyny corpora, hateful-class F1 for HaterNet, and macro F1 for HatEval. The headline score can therefore refer to a different quantity in different parts of the study. Evaluation & benchmarks

Experiments and results

The test collections differ in target and balance

Spanish MisoCorpus 2020 contains 8390 tweets in the full version used here. It includes material on violence toward women in politics and the media, variation between Spanish from Spain and Latin America, and more general misogyny. Three annotators labeled the material. Earlier experiments on the corpus removed some non-misogynous examples to achieve balance. The authors keep the complete corpus, where non-misogynous posts are somewhat more frequent, and evaluate on a held-out test partition. That means the experiment includes the class distribution that the earlier sub-sampling changed.

AMI 2018 comes from the Automatic Misogyny Identification shared task at IberEval. The paper describes the multilingual resource as containing 4138 tweets in Spanish and English. It uses the binary misogyny task for its Spanish investigation. The broader shared task also looks at types of misogynistic behavior and at whether that behavior targets a person or a group. The binary experiment asks for the presence of misogyny, allowing a comparison with MisoCorpus without requiring their finer categories to match.

HaterNet covers hate speech generally. Its creators started with 2 million tweets, applied automatic filtering, and used four human annotators. The resulting dataset includes 1567 hateful documents and 3600 non-hateful documents. The paper identifies it as the most imbalanced of the evaluated collections. That gives separate importance to the hateful-class F1 and recall figures. Being good at the more frequent class can preserve a respectable overall score even when many hateful posts are missed.

The Spanish portion of HatEval 2019 has 6599 tweets across training, validation, and test data. It concerns hate directed toward women and immigrants. The paper uses the binary task, and it separately inspects the two targets when interpreting selected outcomes. The authors highlight overlap in the sources of the misogyny material and AMI. Their detailed linguistic analysis therefore also considers the immigrant subset on its own. HatEval

BETO provides the strongest individual input

The first comparison trains with LF, SE, WE, and BF individually. BETO-based BF gives the highest test weighted F1 among these feature sets on each corpus. Table 4 reports 89.80 for Spanish MisoCorpus 2020, 82.67 for AMI 2018, 83.25 for HaterNet, and 75.84 for HatEval 2019, on the paper’s percentage scale. These are the reference scores for judging what happens when the authors add other representations. Word embeddings come closest on Spanish MisoCorpus 2020 by this measure, with weighted F1 of 83.67. Fixed sentence embeddings are the strongest of the remaining feature sets on HatEval 2019, at 70.19.

Individual feature sets on the HaterNet test split by weighted F1

The contextual BETO input leads the standalone comparison, while linguistic features alone rank last.

Individual feature sets on the HaterNet test split by weighted F1Linguistic features: 71.36Linguistic features71.36Fixed sentence embeddings: 77.88Fixed sentence embeddings77.88Word embeddings: 79.77Word embeddings79.77Fine-tuned BETO embeddings (this paper): 83.25Fine-tuned BETO embeddings (this paper)83.25
The numbers
System or settingWeighted F1 %
Linguistic features71.36
Fixed sentence embeddings77.88
Word embeddings79.77
Fine-tuned BETO embeddings (this paper)83.25

For HaterNet, the class-level scores explain what the weak LF result means. The linguistic-only classifier has hateful-class precision of 74.65 and recall of 17.15 on the test split. There is useful evidence in the tweets it labels hateful, but it finds few of the posts human annotators assigned to that class. Its recall for the non-hateful class is 97.98. The same classifier can thus look strong on the frequent class and have limited value for recovering hateful material. BETO alone records hateful-class recall of 62.46 and F1 of 66.21. Its advantage in the aggregate comes with a different balance of errors.

The authors compare contextual representations separately to decide which one to carry forward. On the Spanish MisoCorpus 2020 test set, the weighted F1 scores are 89.80 for BETO, 88.44 for multilingual BERT, 83.83 for BNE, and 83.70 for BERTIN. BETO also leads the weighted F1 comparisons in AMI, HaterNet, and HatEval. This supports choosing it for the combination experiments. The result is about the evaluated systems and corpora. In particular, the second-place finish of multilingual BERT on MisoCorpus shows that the ranking cannot be explained simply by treating Spanish specialization as a sufficient condition for success.

A shared network helps with different inputs on different corpora

On Spanish MisoCorpus 2020, combining fixed sentence embeddings, word embeddings, and BF gives the highest integrated test weighted F1, at 90.52%. Combining LF with BF yields 90.40%, and all the inputs yield 90.44%. The comparison favors adding some information to the contextual input, but it gives little basis for saying the full feature collection is essential. Each integrated option is close to the others on this measure.

AMI 2018 favors a different combination. The full network reaches 84.72% weighted F1 on the test split. The LF and BF network reaches 83.27%, and the embedding combination reaches 83.39%. The full network also gives the highest test F1 for both the misogynous and non-misogynous classes among those integrated settings. The improvement is consequently visible in the class-level results as well as in the weighted average.

On HaterNet, the full feature network has the highest integrated weighted F1 at 84.08%. The embedding-only combination gives weighted F1 of 84.01 and hateful-class F1 of 69.32 on the test split. All input types together give hateful-class F1 of 66.67. This is a case where the weighted ranking and the ranking on the class of particular interest diverge. Including linguistic features alongside the embeddings corresponds to better results on the non-hateful class in this comparison. The overall weighting gives those results enough influence for the full system to finish slightly ahead.

HatEval 2019 favors the more compact pairing of LF and BF, at 77.27% weighted F1. This combination also shifts the class tradeoff relative to BETO alone. The test results for the pair give hateful-class precision of 69.50 and recall of 79.39. BETO alone has precision of 66.15 and recall of 84.09. With linguistic features included, a larger share of flags agree with the annotations, and fewer of the actual hateful tweets are flagged. The combined classifier’s non-hateful-class F1 is 79.48, which also contributes to its weighted result.

Standalone, integrated, and ensemble settings on the HatEval 2019 test split by weighted F1

The shared network using linguistic features and BETO leads the tested configurations on this measure.

Standalone, integrated, and ensemble settings on the HatEval 2019 test split by weighted F1BETO alone: 75.84BETO alone75.84Shared network with all inputs: 74.96Shared network with all inputs74.96Shared network with embedding inputs: 75.22Shared network with embedding inputs75.22Shared network with linguistic features and BETO (this paper): 77.27Shared network with linguistic featuresand BETO (this paper)77.27Logistic regression ensemble with linguistic features and BETO: 76.66Logistic regression ensemble withlinguistic features and BETO76.66
The numbers
System or settingWeighted F1 %
BETO alone75.84
Shared network with all inputs74.96
Shared network with embedding inputs75.22
Shared network with linguistic features and BETO (this paper)77.27
Logistic regression ensemble with linguistic features and BETO76.66

The relative positions of the shared networks on HatEval are important because each has access to BETO. Adding the other embeddings to the successful linguistic and BETO pairing produces a lower weighted F1 even after the authors search for a suitable architecture for the combination. The extra inputs may offer useful evidence on some examples. Their test score shows that whatever they offer did not translate into a higher aggregate for the selected configuration.

Ensemble results expose the cost of high confidence

On Spanish MisoCorpus 2020, the best ensemble uses all feature sets with logistic regression, at 90.14% test weighted F1. Knowledge integration comes out ahead for each corresponding input combination. With LF and BF, averaging probabilities yields weighted F1 of 89.90, ahead of logistic regression’s 89.74 for the same inputs. Logistic regression becomes the stronger overall ensemble when it can use predictions from all four feature sets, so the preferred decision rule depends in part on which predictions it receives.

AMI 2018 again differs from MisoCorpus. Here the best ensemble averages the probabilities from LF and BF and records 83.30% weighted F1 on the test split. With all inputs, selecting the highest-probability prediction gives misogynous-class precision of 92.90% and recall of 53.50%. The averaged LF and BF setting has misogynous-class precision of 82.40 and recall of 84.60 on the same percentage scale. The comparison is between different input sets as well as different rules, but it makes clear how high precision can coexist with a much lower rate of finding misogynous posts.

HaterNet gives the best weighted F1 ensemble for that corpus to logistic regression over SE, WE, and BF, at 84.34%. The comparable all-input logistic regression ensemble reaches 84.25%. The sharpest illustration of the precision and recall tradeoff is the highest-probability ensemble with all features. Its test precision for hateful posts is 100.00 and its recall is 12.60. Every tweet given the hateful label in that setting agrees with the annotation, while most annotated hateful tweets are left unflagged. The class F1 of that setting is 22.40 on the paper’s percentage scale, so the perfect precision offers little evidence of broad detection.

For HatEval, the best ensemble is logistic regression using LF and BF, at 76.66% weighted F1. Its hateful-class F1 is 74.60, with precision of 67.32 and recall of 83.64. The corresponding shared network has higher weighted F1, while this ensemble has higher F1 on the hateful class. Even with the same feature families, the choice about where to combine evidence changes which class benefits.

Comparisons with earlier systems use each benchmark’s own metric

The paper’s historical comparison emphasizes two configurations that are competitive across corpora. Both use LF and BF. One combines the features inside a shared network and the other uses logistic regression to combine predictions. These configurations need to be distinguished from the best weighted-F1 setting chosen separately for every corpus. The historical question is how a common pair of approaches compares with previously reported scores on the metrics used by the different benchmarks.

For Spanish MisoCorpus 2020, the historical comparison table lists earlier accuracy of 85.2% for an SVM approach. The paper reports test accuracy of 90.4% for the LF and BF shared network and 89.7% for the corresponding ensemble. The two new systems are evaluated using the authors’ held-out split. The older corpus work used cross-validation, so these figures compare reported results under different evaluation procedures.

For AMI 2018, the shared-task winner is reported at 81.4681% accuracy and a later SVM-based result at 81.5217%. The paper reports test accuracy of 83.3% for the shared LF and BF network and 82.5% for the logistic regression ensemble using the same inputs. The authors regard the improvements as modest in view of the change in representations and architecture. The comparison also shows why the paper gives individual and integrated results separately. The best accuracy figure here describes the selected pair used in the historical comparison, while the best integrated weighted F1 belongs to the full feature collection.

On HaterNet the historical metric is hateful-class F1. The authors list 61.1% for the recurrent network and multilayer perceptron approach associated with the original dataset and 65.8% for an earlier BETO system. Their shared LF and BF network gives 65.9%, and their logistic regression ensemble using both features gives 68.3%. The comparison table uses that precision in its reporting. The earlier BETO system used a different split, while the original work’s evaluation procedure also differs from the new held-out test experiment. The ranking is a comparison of reported results.

Reported HatEval 2019 Spanish binary-task results by macro F1

The integrated linguistic-feature and BETO approach leads the entries in the paper’s historical comparison.

Reported HatEval 2019 Spanish binary-task results by macro F1Shared-task SVM approaches: 73.0Shared-task SVM approaches73.0Earlier SVM with linguistic features and embeddings: 75.4Earlier SVM with linguistic features andembeddings75.4Earlier BETO system: 75.5Earlier BETO system75.5Logistic regression ensemble with linguistic features and BETO: 76.5Logistic regression ensemble withlinguistic features and BETO76.5Shared network with linguistic features and BETO (this paper): 76.8Shared network with linguistic featuresand BETO (this paper)76.8
The numbers
System or settingMacro F1 %
Shared-task SVM approaches73.0
Earlier SVM with linguistic features and embeddings75.4
Earlier BETO system75.5
Logistic regression ensemble with linguistic features and BETO76.5
Shared network with linguistic features and BETO (this paper)76.8

For HatEval the comparison uses macro F1, as recorded in the paper’s benchmark table. The result gives each class equal influence, whereas the weighted-F1 chart gives the more frequent class more influence. The paper records an earlier BETO hateful-class F1 of 77.6 in the same table that reports its macro F1 of 75.5. The shared network’s leading macro F1 of 76.8 therefore establishes an advantage on that aggregate among the listed approaches. A reader seeking the strongest result on hateful posts alone has a different column to consult.

What the ablations show

Removing or adding a feature family changes different errors

The closest experiments to ablations compare systems trained with individual feature sets and with different combinations of those sets. This isolates feature availability at the level of a whole input family. It gives evidence about how useful an input is when the authors build and tune a classifier around it. Since the hyper-parameters can change with the inputs, the comparison includes the effect of choosing an architecture suited to each particular setting.

The results make two kinds of comparison possible. One is between BETO alone and a network that also receives linguistic measurements. HatEval is the clearest case where the pair is favored by weighted F1. The other is between shared networks that contain BETO and the same static embeddings, with linguistic measurements added to the second network. AMI favors the version with the extra LF branch, Spanish MisoCorpus slightly favors the embedding-only version, and the HaterNet ranking depends on the metric. This is more specific evidence than a general statement that engineered features help or that contextual representations make them unnecessary.

The best individual settings selected in the architecture search are shallow. The paper finds effective networks with one or two hidden layers despite allowing considerably deeper ones. The selected architecture is typically a multilayer perceptron, with convolutional networks chosen for word embeddings in AMI and HatEval. The combined networks also tend to have few layers, though the authors observe that combining feature families frequently uses more units and AMI is an exception to some of the simpler architecture patterns. These are observations about the configurations selected in the tested search. The tables make it possible to see where depth, width, and input type vary together.

Changing the decision rule changes what gets through

The ensemble comparison offers a different control. For a given set of feature families, the authors reuse the same individual classifiers and change how their decisions or probabilities are combined. Hard voting uses each member’s class choice, so two forecasts on the same side of the decision can count the same despite different confidence. Highest probability concentrates the decision on the strongest score. Averaging probabilities spreads the contribution across the members, and logistic regression learns a combination using labeled training examples.

The authors see a recurring precision and recall tradeoff in the highest-probability results. HaterNet shows how extreme it can become, with very few of the hateful examples retrieved in the all-feature configuration. The Spanish MisoCorpus 2020 results show that the problem is visible even before reaching that extreme. In its all-feature setting, highest probability records misogynous-class precision of 95.50 and recall of 52.50, whereas logistic regression gives precision of 90.34 and recall of 86.77. Each value is a percentage-scale test score. The decision rules produce different coverage while using predictions from the same feature families.

The paper also separates HatEval posts about women from those about immigrants when inspecting the ensembles. The subset about women generally has higher hateful-class precision and limited recall. For the immigrant subset, the authors report lower precision and higher recall. The same broad label and the same ensemble therefore hide variation by target. The authors advise caution in comparing the subsets because some misogyny material also occurs in AMI. The analysis describes an observed difference and leaves its source open.

What the linguistic rankings establish

The authors use mutual information for a second purpose beyond feature selection. They rank named linguistic measurements by their association with labels and display leading features within categories, using groups of 5 where available. This presentation lets a reader compare register, grammar, social media behavior, and other categories without requiring every category to contribute the same number of available features. It also creates a corpus description independent of the trained classifier’s internal weights.

Strongly offensive register is the clearest recurring result. It is a leading discriminator in both misogyny corpora and in HaterNet and HatEval. Swearing and colloquial language also appear, though their relevance varies. The HatEval analysis restricted to posts about immigrants again identifies strong offensive wording, alongside colloquialisms and milder offensive language. The recurrence helps explain why register is worth measuring. The interpretation still has to respect the task definition, where offensive language and hate speech overlap and the identity or status of a target can matter.

The two misogyny corpora give a useful comparison of spelling. Misspelled words distinguish the annotated classes in both Spanish MisoCorpus 2020 and AMI 2018. The authors find a broader role for correction and style in MisoCorpus, while they report no similar class distinction for AMI’s orthographic-error feature. The measures belong to the same category but describe properties with different observed relevance. The paper’s cross-corpus discussion finds the misspelling result less prominent in HatEval and absent as a comparable pattern in HaterNet.

The corpora also differ in the language surrounding the offensive wording. MisoCorpus highlights grammatical feminine forms and features associated with replies or mentions involving accounts with female names. It also shows some association with the use of hashtags, quotations, markers of readability, and length. AMI features include masculine forms, some verb categories, and lexical topics such as animals, people, sex, and risk. The authors give more weight to social media conventions in their interpretation of MisoCorpus than in AMI. A feature’s ease of interpretation makes this divergence visible, even when neither feature has been shown to account for an individual decision.

Topic differences are particularly sensitive to how the authors of the corpora found their tweets. The paper says AMI drew on offensive expressions, accounts of potential victims, and accounts that openly expressed hostility toward women. MisoCorpus also drew attention to public events, including Greta Thunberg’s arrival in Madrid for a climate conference. Locations and organizations are informative lexical categories in MisoCorpus, and the paper suggests their prominence may reflect that collection strategy. The appearance of animal-related terms in AMI and their limited relevance in MisoCorpus give a parallel example. The same type of insult can be available in the language while varying in how frequently it distinguishes the particular collections.

Direction matters for discourse and grammatical cues

Mutual information can flag a cue when it is associated with either class. The paper’s discourse analysis shows the importance of checking this direction. Argumentative markers occur more often in MisoCorpus’s non-misogynous tweets, while they are more common in AMI’s misogynous tweets. A high rank for an argumentative cue therefore has a different interpretation in each corpus. Other types of connectors, including ones used to state consequences or organize text, also appear in the authors’ discussion of non-hateful documents.

HaterNet gives a different profile of grammar and style. The authors single out intransitive and indicative verbs, impersonal pronouns, and articles among the morphosyntactic features. They also identify language used for reformulating or arguing, along with similes and idioms. Hyperlinks and social media jargon have some relevance in the corpus-specific discussion. In the comparison across all corpora, the authors treat social media features as less prominent in HaterNet and HatEval than in MisoCorpus. The relative importance depends on the category and on whether the discussion is about one corpus or about patterns repeated across the study.

HatEval contributes further target-specific results. When the authors remove texts about women and focus on immigrants, the lexical analysis points to subjects including home, friendship, and discrepancies. In the complete dataset, the authors also identify anger and negative emojis among the patterns that distinguish the classes. Replies to women are more relevant in the misogyny subset, where replies to men are also informative. These observations can guide interpretation of what the corpus contains, but a reply feature alone does not establish the target or stance of the reply.

The authors examine 121 simple, continuous, and discontinuous negation cues. Some particular expressions appear high enough to discuss even where the category as a whole is weak. HatEval is the only evaluated dataset where the total number of negations is identified as discriminatory, and the authors characterize even that effect as limited. They report more statements containing negation in its hateful class. This is association with the presence of a cue. Establishing which part of a statement is negated, or whether the negation rejects or expresses a hostile position, would require evidence beyond that occurrence count.

Limitations

Limits identified by the authors

The authors qualify their historical comparisons because the older systems and the study’s systems were evaluated under different procedures. Earlier work on HaterNet and Spanish MisoCorpus 2020 used ten-fold cross-validation, while the paper’s systems are scored on a held-out test set. The later HaterNet comparison cited in the paper also used a training-test split distinct from the one used here. Different partitions can change both which examples the system learns from and which examples determine the score. The authors propose adding cross-validation to their pipeline as future work.

The comparisons also depend on which metric a dataset uses. Accuracy rewards correct decisions across all examples. Hateful-class F1 focuses on precision and recall for the positive class, while macro F1 averages performance across classes equally. The authors report the available metrics in their comparison table. Historical comparisons are strongest when the evaluation target and protocol match. A headline such as “best on HatEval” has a narrower meaning once it is tied to macro F1 and the systems in that table.

The paper explicitly calls attention to the relationship between HatEval and earlier misogyny collections. Some documents concerning women in HatEval also appear in AMI. That makes recurrence across those two collections weaker evidence of independent replication. An immigrant-only analysis helps establish that an association such as strongly offensive register also appears in a different part of HatEval. It does not answer how findings from the misogyny material would change in a separately collected benchmark.

The authors also distinguish their measurement of linguistic association from explaining predictions inside a neural network. They evaluate the features outside the network and propose a later analysis using SHAP to estimate how individual features contribute to outputs. They plan error analysis to discover which posts each feature family misclassifies and whether combining inputs corrects those errors. The experiments in this paper can point to a difference between two systems’ scores. The proposed error analysis would be needed to show which decisions changed and to investigate why. Interpretability

The remaining future work clarifies the scope of the current task. The authors want to analyze longer documents, determine targets, and incorporate context or media such as images and linked content. Here the unit is the tweet, the outcome is binary, and the pipeline works from the text and its derived features. Counting a hyperlink as a linguistic or social media feature gives the system a signal that a link is present. Reading what the link points to would be a different input and a different test.

Limits that follow from the experimental design

The corpus comparisons evaluate within-dataset generalization. BETO is fine-tuned separately for each dataset, and the classifiers are chosen and tested in those separate settings. Repeating that procedure across corpora establishes that the approach can be trained in several Spanish hate speech settings. It leaves unanswered how a system trained on one collection performs on an independently collected one, or how its predictions change on a platform with different writing conventions. Divergence in the linguistic rankings makes these open questions consequential.

The feature comparisons change more than the availability of the features. A combined network can have different width, dropout, activation, or learning rate from the best standalone network. This is appropriate when the goal is to compare the best systems the search can find. It limits how precisely an improvement can be attributed to a feature family itself. Even a drop from adding an input could reflect the interaction of its representation with the chosen configuration. The ensemble comparison holds the individual classifiers fixed and isolates the effect of the output combination rule more closely.

The linguistic analysis has a different attribution problem. A highly ranked term or grammatical feature might be associated with the label through the topics used to collect the data, the types of accounts sampled, or the conventions used to annotate posts. Correlated features can also carry overlapping information. An association between misspellings and a label, for example, does not establish that misspellings cause a classification decision or that the same relationship applies to every Spanish-speaking community. The paper’s corpus-specific rankings are most informative when read alongside the collection methods and label definitions.

A high precision result also has a limited operational interpretation without its recall. HaterNet provides the direct example because the perfect test precision setting identifies only a small part of the annotated hateful class. The authors discuss adjusting the threshold to change this balance. The experiments compare fixed reported settings and show class-level consequences for those settings. An evaluation of a live review process would need evidence about how much flagged content reviewers can handle and the consequence of posts that escape it. The paper measures agreement with benchmark annotations, and it does not establish performance under those operational conditions.

Finally, the study’s social motivation goes beyond the measured outcome. The experiments count correct and incorrect labels for Spanish tweets. They do not measure how automatic flagging would affect the people targeted by hate speech or the language people post in response. Claims about the quality of a representation can rest on the benchmark comparisons. Claims about the broader effects of using it would require a different study.

What came after

One citing study takes a related detection problem into Tamil and defines it around comments targeting people on the basis of sexual orientation or gender identity. This gives it a connection to the Spanish paper’s distinction between general hate detection and detection for a particular target. The tasks also differ in language and in the hostility they are set up to identify. The citing work’s stated subject establishes the extension in task and language, while the transfer of a particular feature set or combination rule remains unspecified. Detecting homophobic and transphobic comments in Tamil

A second citing work focuses directly on UMUTextStats, the Spanish feature extractor that supplies the linguistic measurements in the hate speech study. Its subject is the extraction tool itself. The connection is concrete because the detection paper depends on those measurements both as classifier inputs and as interpretable descriptions of the corpora. The paper on UMUTextStats places that component in its own right at the center of the investigation. UMUTextStats

A third citing study asks how excluding emojis affects Arabic sarcasm detection. The connection is through the treatment of a specific social media cue. The Spanish paper strips emojis from a cleaned text variant and discusses negative emojis in its linguistic analysis of HatEval. The Arabic work makes exclusion itself the object of a performance comparison, in a different language and for sarcasm. Its stated question identifies which input it varies. The direction of the effect and any reuse of the Spanish classification pipeline are unspecified. Impact of emoji exclusion on Arabic sarcasm detection

Cite

Cite as José Antonio Garcí­a-Dí­az, Salud María Jiménez-Zafra, Miguel Ángel García Cumbreras and Rafael Valencia‐García. 2022. Evaluating feature combination strategies for hate-speech detection in Spanish using linguistic features and transformers. Complex & Intelligent Systems.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.1007/s40747-022-00693-x

@inproceedings{garciadiaz2022evaluating,
  title = {{Evaluating feature combination strategies for hate-speech detection in Spanish using linguistic features and transformers}},
  author = {José Antonio Garcí­a-Dí­az, Salud María Jiménez-Zafra, Miguel Ángel García Cumbreras and Rafael Valencia‐García},
  booktitle = {Complex \& Intelligent Systems},
  year = {2022},
  doi = {10.1007/s40747-022-00693-x},
  url = {https://doi.org/10.1007/s40747-022-00693-x}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/az-2022-evaluating-feature-combination-strategies-hate/