<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Loïs Bilat (ELCA) on Medium]]></title>
        <description><![CDATA[Stories by Loïs Bilat (ELCA) on Medium]]></description>
        <link>https://medium.com/@lois-bilat?source=rss-4d76178cfe6f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_xtYhebUjLjiw2aPwdEQBg.jpeg</url>
            <title>Stories by Loïs Bilat (ELCA) on Medium</title>
            <link>https://medium.com/@lois-bilat?source=rss-4d76178cfe6f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:37:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lois-bilat/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Zero-shot multilingual classification models]]></title>
            <link>https://medium.com/elca-it/zero-shot-multilingual-classification-models-13c3c0f44ad7?source=rss-4d76178cfe6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/13c3c0f44ad7</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[transformers]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Loïs Bilat (ELCA)]]></dc:creator>
            <pubDate>Tue, 06 Apr 2021 06:42:09 GMT</pubDate>
            <atom:updated>2021-11-04T12:22:37.382Z</atom:updated>
            <content:encoded><![CDATA[<h4>Applied to hate speech detection</h4><p>With the increasing use of social media, multilingual text classification models have become very popular recently. On the one hand, these models are advantageous because of the strongly multilingual nature of online content — not only on large social media platforms that reach a worldwide crowd, but also at a smaller scale, in multilingual countries like Switzerland. On the other hand, multilingual classification models are beneficial because they enable transfer learning approaches in situations where labelled training data is not available in the targeted language. This is very common, as for many NLP tasks, training data only exists in a few languages like English or French.</p><p>In this technical note, we present several multilingual classification approaches. While these models can be used in any cross-lingual classification problem, we take the example of hate speech detection to show how they can be used to perform zero-shot classification.</p><h3>Proposed approaches</h3><p>When tackling a multilingual problem, the approach usually taken nowadays is to use a pre-trained multilingual model. Models like <a href="https://arxiv.org/abs/1812.10464">LASER embeddings</a> [2] or <a href="https://arxiv.org/abs/1911.02116">XLM-RoBERTa</a> [3] have been very successful in many tasks and provide an easy and flexible way to create custom multilingual models. We will refer to these types of models as <em>purely multilingual models</em>; they can take input data from many different languages and are able to create good sentence embeddings, even sometimes on languages that were not seen during training.</p><p>A second approach, less common, consists of using classical monolingual models with multilingual data that was translated to a single language beforehand. Doing so allows us to use models such as <a href="https://arxiv.org/abs/1810.04805">BERT</a> [4] or <a href="https://arxiv.org/abs/1907.11692">RoBERTa</a> [5], that perform better than purely multilingual models when applied to a single language. We call these <em>translation-based models.</em></p><p>Those two approaches are illustrated in the following image; we represent here two multilingual models that can detect hate speech and offensive content, that are trained on English and German data, and evaluated on French data. The <em>purely multilingual model</em> (on the left) takes all data as-is, while the <em>translation-based model</em> (on the right) translates the German and French data to English, before using an English model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sDq2a1gdI-1uiZNOSRQrnQ.png" /><figcaption>Purely Multilingual model (left) and Translation-based model (right)</figcaption></figure><p>We will compare the two approaches on a hate speech detection task and introduce joint models that combine elements from both approaches. We will also look at the performance hit introduced by the language gap.</p><h3>Setup</h3><p>We consider a zero-shot experiment to classify content as <em>hateful</em>, <em>offensive </em>or <em>neither</em>; training the model in one language and evaluating its performance on another one. We use two annotated datasets for our experiments, one in French and one in English (we use the <a href="https://arxiv.org/abs/1912.04106">DACHS</a> [6] datasets).</p><h3>Models</h3><h3>Translation models</h3><p>We first compare <em>purely multilingual models</em> — such as LASER embeddings followed by a multi-layer perceptron (referred to as LASER+MLP from now on) or a fine-tuned XLM-RoBERTa classifier — with some <em>translation-based models.</em></p><p>We use two simple <em>translation-based models </em>that follow the same structure: data translation followed by a transformer model (many BERT-based models are available, we present here the models that led to the best results). In one model, all data is translated into English and the RoBERTa model is then used, and in the other model we translate all data into French and use the <a href="https://arxiv.org/abs/1912.05372">FlauBERT</a> [7] model, a French model based on BERT. To translate the data, we use the <a href="https://marian-nmt.github.io/">MarianNMT</a> [8] model trained on the <a href="https://github.com/Helsinki-NLP/Opus-MT">Opus data</a> [9].</p><p>We have an unbalanced multiclass problem: our datasets consist of approximately 6% of hateful content, 24% of offensive content, and 70% of other content. Hence, we use the macro-F1 score, which is the unweighted average of the F1-score of each class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b1UBMZx9CFcYtkhknG9SZA.png" /><figcaption>Macro-F1 scores for purely multilingual and translation-based models</figcaption></figure><p>We see that the best model is in both cases a translation-based model, despite the noise added to the data due to the translation, and the potential loss of meaning that can be encountered with approximate translations.</p><p>In particular, the best approach is to translate the training data to the target language, and then use a monolingual model in that language. This approach has the disadvantage of requiring a translation model, which might not exist in all languages, and it adds some pre-processing time, but it can bring some non-negligible improvements. However, at least with the current setup where there is only one target language, no translations will be needed to evaluate new data, so only the initial training time is increased. This approach would not be as efficient if we wanted to target multiple languages, and in that case a purely multilingual model would be more adapted.</p><h3>Joint models</h3><p>Ensemble learning is a common technique that can help the performance of classifiers, where multiple independent models are used, and a combination of the predictions (e.g. a vote or average) is performed at the end. In line with this idea, we can perform joint learning, that more closely combines multiple classification approaches. The outputs of all joined models are concatenated and passed through multiple neural network layers. The resulting network is then trained jointly, by applying backpropagation to all sub-models. An example of such a joint architecture (we will refer to it as a <em>joint model</em>) is illustrated below, where we use two LASER embeddings networks whose outputs are concatenated and go through a few linear layers.</p><p>To help with the performance, we add some variation to the joint model by assigning a language to each of the joined networks. One network will work with English data (some of it translated from French), and one will work with French data (some of it translated from English). The intuition behind this is that the outputs of both sub-models are complementary and should create a better representation of the input data, leading to a better classification.</p><p>In the example illustrated below, we use English training data, that is given as-is to one of the models, and in parallel translated to French to be given to the other model. Each model consists of LASER embeddings sent through a few linear layers, and is fully independent from the other model. The French data used for evaluation is then directly passed to the French model, and additionally input to the English model after going through translation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xUFFKp7VswsUmig3XxZj9w.png" /><figcaption>Joint model with LASER embeddings and data translation</figcaption></figure><p>We compare the performance of such a network with a simple, purely multilingual model where LASER embeddings are used multilingually with both French and English data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*HTnTsS3g-zGQqEhzBXEv-A.png" /><figcaption>Simple model vs joint model</figcaption></figure><p>The Joint model is clearly useful, although the difference in performance might not be enough to justify the increased complexity.</p><h3>Joint translation models</h3><p>While our first <em>joint model</em> approach solely relies on purely multilingual classifiers, we now propose to join <em>purely multilingual</em> models with <em>translation-based</em> models. We show an example of this architecture in the illustration below; one <em>purely multilingual</em> LASER model and one <em>translation-based</em> FlauBERT model with translation of English data to French.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOU-5JWcZJ0eLkrsU2efBg.jpeg" /><figcaption>Joint model with LASER embeddings, Transformer and data translation</figcaption></figure><p>This approach can be implemented in multiple ways. We use two versions, that were in our experience the best alternatives:</p><ul><li><strong>English training data, French test data:</strong> We combine a LASER model with a FlauBERT model that uses translations to French</li><li><strong>French training data, English test data</strong>: We combine a LASER model with a RoBERTa model that uses translations to English</li></ul><p>For a fair comparison of the performance when using a translation-based model as part of this architecture compared to using only multilingual models, we compare this to another model with similar complexity — also a joint model — where we simply combine the LASER model with a multilingual XLM-RoBERTa. The models with translations will have slightly larger training time as we need to translate the data once, but a similar evaluation time as no further translations are required for inference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dAh_TWp01kvxxgZ6lEORIA.png" /><figcaption>Joint models — purely multilingual vs translation-based</figcaption></figure><p>We see that the joint models that use both the multilingual and the translation approach clearly outperform the models that only use purely multilingual sub-models. This is a viable approach that does not add too much complexity to the models. The translation of the data can be seen as data augmentation; the translated sentences act as synonyms and variations of the original data, which will cover more cases, and help the performance of the model when new data is presented.</p><p>Our experiments show that using translations is a viable alternative to multilingual models, and despite being a little bit more complex to setup can lead to better results. Additionally, joining multiple models can further improve the performance. We have also shown that adding simple sentence embeddings to the output of a complex deep neural network can increase the performance while adding very little complexity.</p><h3>Domain Gap versus Language Gap</h3><p>One major problem with zero-shot learning is the domain gap between the training dataset and the target data. But what about the language gap that occurs when using multilingual models? We look at both with some examples coming from our original use case: Hate speech detection.</p><p>We were able to find multiple datasets that supposedly contained the same type of content: hateful, offensive and other tweets. However, we realized that they often differed in actual content and class distribution, which causes some domain gap. Depending on the country of origin, the topics mentioned in the tweets will be different (e.g. political or social issues). Moreover, the fact that we combine multiple languages together also adds some language gap, as some words (e.g. insults) might not have the same meaning or connotation in different languages. To illustrate this, we explore four scenarios:</p><ol><li><strong>Baseline; no domain gap and no language gap:</strong> Content of the training data is very close to the content of the target data, and in the same language.</li><li><strong>No domain gap but a language gap:</strong> Content of the training data is very close to the content of the target data, but in a different language.</li><li><strong>Domain gap but no language gap:</strong> Content of the training data is not as close to the content of the target data, but they are in the same language.</li><li><strong>Domain gap and language gap:</strong> Content of the training data is not as close to the content of the target data, and they are in a different language.</li></ol><p>To illustrate this problem, we selected two datasets, one in English and one in French, that originated from the same authors (we still use the DACHS dataset), and that contain tweets annotated as hate speech, offensive, or neither.</p><ul><li>To simulate having very similar content but a different language (case 2), we select one dataset, split it into <em>train</em> and <em>test</em> sets, and translate one of the two to another language (e.g. We take the English dataset, and use a subset of it translated to French for the evaluation)</li><li>To simulate having less similar content, but the same language (case 3), we use data from one dataset for training, data from the other dataset for evaluation, but translate one of them to the other language (e.g. take training data in the English dataset, take evaluation data in the French dataset but translate it to English).</li></ul><p>We show here the results of this experiment. In the table, an arrow indicates data translation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*s-SjhHHVNq2dyfYBR7zhow.png" /><figcaption>Comparison of domain gap and language gap</figcaption></figure><p>As expected, the best scores happen when we use very similar data with the same language for training and evaluation. However, we see that we get significantly higher scores when we only have the language gap than when we only have some domain gap. It is important to remember that the datasets used here come from the same authors, and that the same annotation guidelines were used in both languages, but despite this, combining both datasets bring a significant domain gap which has a large impact on the performance.</p><p>The conclusion that comes from this is the following: If for a given problem there are multiple small datasets available, and that one wants to combine them, it is important not to exclude data in other languages; the performance hit brought by the language gap can be significantly lower than the one brought by the domain gap. Translation-based models and multilingual models are able to handle the language gap relatively well.</p><h3>Conclusion</h3><p>We saw that pre-trained multilingual models are not the only way to solve a multilingual problem. If it is possible to translate the data for the given languages, an approach with a monolingual model can be beneficial. It is also important to look at joint models; adding simple sentence embeddings to a complex transformer model is enough to see some improvements. It can provide a significant performance boost without increasing the training time too much. The use of translation-based models with the joint approach can also work very well.</p><p>It is also important not to underestimate the power of current multilingual and translations models, and a dataset that is not in the desired language should never be ignored if there are not many alternatives available.</p><h3>Sources</h3><ul><li>[1] <a href="http://cltd.bilat.xyz/">Cross-lingual Toxicity Detection</a>, Loïs Bilat et. al., 2020</li><li>[2] Massively Multilingual Sentence Embeddings for Zero-Shot Cross-Lingual Transfer and Beyond, Mikel Artetxe et. al., 2019, <a href="https://arxiv.org/abs/1812.10464">arXiv:1812.10464</a></li><li>[3] Unsupervised Cross-lingual Representation Learning at Scale, Alexis Conneau et. al., 2019, <a href="https://arxiv.org/abs/1911.02116">arXiv:1911.02116</a></li><li>[4] BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding, Jacob Devlin et. al., 2019, <a href="https://arxiv.org/abs/1810.04805">arXiv:1810.04805</a></li><li>[5] RoBERTa: A Robustly Optimized BERT Pretraining Approach, Yinhan Liu et. al., 2019, <a href="https://arxiv.org/abs/1907.11692">arXiv:1907.11692</a></li><li>[6] Towards countering hate speech against journalists on social media, Charitidis et. al., 2020, <a href="https://arxiv.org/abs/1912.04106">arXiv:1912.04106</a></li><li>[7] FlauBERT: Unsupervised Language Model Pre-training for French, Hang Le et. al., 2020, <a href="https://arxiv.org/abs/1912.05372">arXiv:1912.05372</a></li><li>[8] <a href="http://www.aclweb.org/anthology/P18-4020">Marian: Fast Neural Machine Translation in {C++}</a>, Junczys-Dowmunt et. al., 2018</li><li>[9] <a href="https://github.com/Helsinki-NLP/Opus-MT">Building open translation services for the World</a>, Jörg Tiedemann et. al., 2020</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13c3c0f44ad7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/elca-it/zero-shot-multilingual-classification-models-13c3c0f44ad7">Zero-shot multilingual classification models</a> was originally published in <a href="https://medium.com/elca-it">ELCA IT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>