---
title: "Sentiment Classification in Swahili Language Using Multilingual"
description: "How multilingual BERT classifies positive and negative Swahili text, what its reported accuracy captures, and where its predictions struggle."
canonical: "https://research.elamur.ai/free/en/papers/martin-2021-sentiment-classification-swahili-language-multilingual/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/martin-2021-sentiment-classification-swahili-language-multilingual/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2021](https://md.research.elamur.ai/free/en/papers/2021/) / Sentiment Classification in Swahili Language Using Multilingual BERT

# Sentiment Classification in Swahili Language Using Multilingual BERT

Paper · 2021 · Gati Lother Martin, Medard Edmund Mswahili and Young-Seob Jeong

**Authors:** Gati Lother Martin, [Medard Edmund Mswahili](https://md.research.elamur.ai/free/en/authors/medard-edmund-mswahili/) and [Young-Seob Jeong](https://md.research.elamur.ai/free/en/authors/young-seob-jeong/) · **Year:** 2021 · **Venue:** arXiv (Cornell University) · **Licence:** [CC BY-NC-ND 4.0 (arXiv)](https://creativecommons.org/licenses/by-nc-nd/4.0/)

[Cited by **12** papers in our library of more than 163,000 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/martin-2021-sentiment-classification-swahili-language-multilingual/cited-by/) · arXiv (Cornell University) · [licence](https://creativecommons.org/licenses/by-nc-nd/4.0/)

- [arXiv 2104.09006](https://arxiv.org/abs/2104.09006)

## Summary

People express opinions in Swahili in forum discussions, social media posts and comments. Sorting those opinions into positive and negative categories can help someone make sense of more text than they could read individually. It requires examples that show how people express approval, dissatisfaction and other reactions in the language they actually use online. The authors assemble such examples and use multilingual BERT, or mBERT, to test whether a system that has already learned from text in many languages can be adapted to Swahili [sentiment classification](https://md.research.elamur.ai/free/en/topics/sentiment-emotion/).

The collection contains a reported 8.2k items. It brings together text from online sources, including JamiiForum and DW Kiswahili, with material from the ISEAR emotion dataset. The two sources contribute labels in different ways. Native Swahili speakers judge the polarity of the online material, resolving disagreements and excluding neutral or uncertain items. ISEAR supplies emotion categories, which the authors convert to polarity by treating joy as positive and assigning the remaining categories to negative. The retained collection contains more negative examples than positive ones.

The authors start from mBERT parameters learned from Wikipedia in 104 languages, including Swahili. They add a classification layer and use the labeled Swahili examples for [fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/), the process of adapting an already trained system to a particular task. A shared vocabulary lets the system represent unfamiliar written forms through smaller pieces. That feature matters to the authors because the online material includes informal spellings and words drawn from other languages. The experiment tests the whole classification pipeline together, so its result covers the combined effect of data preparation, text representation and supervised training.

The classifier achieves 87.59% accuracy on the held-out 10% of the collection. The authors report better class-level scores for negative sentiment and draw attention to positive examples assigned to the negative class. They relate this pattern to the prominence of negative examples in the data. The study establishes a result for the authors’ binary Swahili task and selected test items. Their proposed comparisons with other classifiers and experiments with a different class balance remain open, as does the question of how the approach handles neutral, ambiguous or harder-to-interpret language encountered online.

## Deep dive: Sentiment Classification in Swahili Language Using Multilingual BERT

How multilingual BERT classifies positive and negative Swahili text, what its reported accuracy captures, and where its predictions struggle. · about 31 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### From online discussion to a polarity judgment

A person reading an online comment can ask whether the writer expresses a favorable or unfavorable reaction. Doing the same thing across a large collection turns that reading judgment into a recurring task. The paper treats customer feedback, social media monitoring and responses to products or services as settings where those judgments can help readers see patterns across many messages. Its experiment makes the task concrete by asking for a polarity label for each retained text item. This is a form of [text classification](https://md.research.elamur.ai/free/en/concepts/text-classification/).

The papers discussed by the authors use both binary and ternary sentiment labels. A binary scheme assigns positive or negative polarity. A ternary scheme gives neutral content a category of its own. The choice affects both how a dataset is assembled and what a system can be asked to do with it. An account of events, a question or an equivocal response might be difficult to assign to either polarity. Under the paper’s binary scheme, the annotators can set such material aside during dataset construction. An input accepted for classification is then judged within the narrower set of outcomes that the experiment defines.

The paper also keeps the unit of analysis at the level of the text item. Its labels record the overall polarity assigned to that item. They carry no separate fields for the target of the opinion, the reason for it or the strength with which it was expressed. That distinction helps connect the task to the applications in the introduction. A polarity prediction can be aggregated to describe a collection. Understanding what people liked about a particular service would require the reader to recover information beyond the label returned here.

#### Why the data matter for Swahili

The authors frame the work as an example of the gap between the availability of [natural language processing](https://md.research.elamur.ai/free/en/concepts/natural-language-processing/) methods and the availability of material for training and evaluating them in a particular language. Their account emphasizes that advances had been concentrated in English and other languages with more resources. Researchers can have access to the same general architecture while facing very different choices about what labeled examples to use, which varieties of writing to include and how to judge whether an approach works. That is the sense in which the paper places Swahili among [low-resource languages](https://md.research.elamur.ai/free/en/topics/low-resource-languages/).

The authors describe Swahili as a Bantu language spoken across multiple African countries and highlight Tanzania, Kenya and Uganda. They note borrowing from Arabic, English and other Bantu languages. They also discuss variation within Tanzania, citing Sukuma, Konde and Maasai accents when explaining why the language people use can vary across communities. Their concern for the sentiment experiment is that variation appears in informal writing as well as speech. Online discussions can include forms that a reader familiar only with standard written Swahili would encounter less often.

It is possible to recognize that a message is written in Swahili while finding words in it that originated elsewhere or take a locally adapted spelling. An approach that expects every word it sees to match an entry learned from more formal text can have difficulty representing those forms. Covering forms in a vocabulary is also only part of the classification problem. A system has to use the surrounding message to make the polarity decision, since an unfamiliar spelling or a borrowed word may occur in messages of either polarity.

The authors therefore had two practical tasks. They needed a collection with examples of written Swahili as people use it online, and they needed a way to use those examples without first training an entire language system from scratch. The collection answers the question of where task supervision will come from. Multilingual pretraining offers parameters and a vocabulary with which to start the adaptation. The study sits at that intersection of data collection and [multilingual natural language processing](https://md.research.elamur.ai/free/en/topics/multilingual-nlp/).

#### How earlier studies represented text

The paper traces the move from conventional classifiers to neural approaches through the question of how to represent a text. It discusses support vector machines, Naïve Bayes and logistic regression as examples of the conventional approaches used for sentiment. A useful distinction in the authors’ account is between the learning algorithm and the features it receives. A learning algorithm may be able to find associations between input features and polarity while still depending heavily on what the researcher has chosen to represent about the input.

The camera-review example in the related work shows how conventional classifiers can be compared within a shared task. The same account reviews a study of pandemic-related tweets in which the authors compared Naïve Bayes with logistic regression. The Swahili paper describes that comparison in terms of shorter and longer tweets. The examples put subject matter and input length alongside the choice of classifier as parts of the experimental setting. A product review and a public discussion about a crisis supply different kinds of evidence for polarity, even under the same positive and negative labels.

Neural approaches give the system a greater role in learning features from the data. The authors discuss convolutional and recurrent methods, including long short-term memory, in studies of reviews and social media. Some of those studies asked whether text length or readability influenced a classifier’s performance. Another compared inputs represented by learned word vectors with inputs represented by weights based on term frequency and inverse document frequency. These comparisons belong to the paper’s account of how sentiment research has studied both the input representation and the machinery that learns from it. [Word embeddings](https://md.research.elamur.ai/free/en/concepts/word-embeddings/) and [TF-IDF](https://md.research.elamur.ai/free/en/concepts/tf-idf/) are the two kinds of input representation in that comparison.

The authors identify two issues with conventional pretrained word vectors such as Word2Vec. A word outside the vocabulary may have no stored vector, and a word that does have a vector generally receives the same one across its occurrences. The second issue concerns the role of context. The same written form can be surrounded by different cues to meaning in different messages. The authors turn to BERT because its use of attention allows the representation of a piece of text to depend on the other pieces around it. Context-sensitive representation and the ability to divide a word into smaller units address different parts of the problem. The former lets the representation vary with use, and the latter gives the system pieces it can process when the whole spelling is unfamiliar.

#### Why start from multilingual BERT

In the authors’ account of earlier BERT research, the range of tasks includes classification of stock-related reviews, sentiment in Chinese social media discussions and the polarity of sentences in software development posts. These are examples of BERT being adapted to specific text sources. The paper also gives closer precedents for work with a smaller pool of task resources. It discusses classification of Tunisian social media comments with mBERT and a study of adaptation techniques on Filipino sentiment data.

The precedents give the Swahili experiment a rationale. A pretrained system can supply an initial representation of text, and a set of labeled examples can teach it how polarity is defined in a particular study. For Swahili, the authors choose a multilingual system whose pretraining already includes the language. Its shared vocabulary also makes it a plausible starting point for writing that contains borrowed and modified forms. These are reasons to test the system under the authors’ conditions. How it performs for Tunisian or Filipino data is evidence about those studies and their own conditions.

The gap the authors identify is specifically a BERT-based Swahili sentiment study. They qualify the claim as the state of research known to them. Their design pairs a new labeled collection with an existing pretrained system. That choice allows them to investigate a task they see as underrepresented without making the experiment depend on building a new general-purpose Swahili system first. It also makes the construction of the labeled collection central to understanding the experiment. The quality of the eventual prediction depends partly on what the authors count as an example of positive or negative sentiment.

### The method, step by step

From Swahili text sources to sentiment evaluation The steps in order.

#### Assemble the texts

The authors gather text from online discussions and social media. JamiiForum and DW Kiswahili are among the named sources, and the dataset account also lists Twitter and YouTube. They collect the material by hand except for tweets, which they obtain with Tweepy. Tweepy is the Python library they use to reach Twitter through its application programming interface. The topics include politics and aspects of daily life. The other major source, ISEAR, brings in material connected to psychology.

The mix serves the authors’ interest in variation. A forum discussion and a social media comment can provide examples of language written for different conversational settings. The authors also expect online material to include language from people of different ages and locations. These are motivations for seeking material across sources. The unit that ultimately enters the dataset is still a text with a polarity label, regardless of whether it came from a discussion or from an emotion collection.

ISEAR starts with a different label vocabulary. The paper describes it as an emotion dataset with 7 categories. It names joy, anger, sadness, disgust, shame and guilt as examples. The authors use joy as the positive class and map all other ISEAR emotions to negative. The conversion gives these examples the same output label vocabulary as the online items. It also means an ISEAR item can receive its positive or negative label by inheritance from an existing emotion category. The experiment describes this mapping and the use of ISEAR, while leaving the language preparation of its entries unspecified.

The conversion reduces distinctions among the emotion labels. Anger and sadness, for example, remain distinct in the emotion scheme but fall into the same category for this experiment. A prediction of negative for such an item is correct if it matches the polarity derived from ISEAR. A reader examining the resulting data should therefore understand negative as the experiment’s shared category. Depending on the item’s origin, it comes from either a reader’s direct polarity judgment or the rule that converts an emotion into polarity.

#### Establish the polarity labels

The online examples require [linguistic annotation](https://md.research.elamur.ai/free/en/concepts/annotation/). The authors work with two Tanzanians whose first language is Swahili. Each annotator makes a judgment about the sentiment of the text, and the judgments are compared afterward. When their labels differ, the annotators revisit the item and agree on a label if they can resolve the disagreement. The authors exclude neutral items and cases where a clear label cannot be settled. The procedure gives the classifier a set of examples for which the authors are willing to treat a polarity assignment as the expected answer.

There are two distinct outcomes when an initial reading is difficult. Discussion can lead to an agreed positive or negative label, in which case the item can contribute to training or testing. An item can remain uncertain, in which case it is removed. The distinction matters because the final collection reflects the decisions reached after review. It does not record every initial disagreement as a feature for the learning system to predict. The test later measures agreement with the labels on retained items, including any that gained a clear label through adjudication.

The procedure also defines how neutral material relates to the experiment. Neutrality can matter greatly when reading a conversation, where many messages may be informative without expressing an opinion. Here it operates as an exclusion criterion. Once an item passes that filter, the question posed to the classifier is which of the two retained labels fits. The binary decision is the result of an earlier human decision about what belongs in the task.

The paper reports 8.2k items in total, including 2.7k positive and 5.4k negative examples. These are the corpus counts at the precision the authors give them. They establish that the task has more negative examples than positive ones. They also matter for understanding the supervision supplied during training. Positive and negative are the available output categories, yet the collection offers different amounts of example material for learning them.

#### Clean the texts and reserve the test set

Online messages can contain parts that identify a user, point to another page or otherwise come from the platform rather than from the main text. The authors describe removing usernames, links and some punctuation during preprocessing. They motivate the cleanup by the unstructured character of social media material and the possibility that noise will interfere with classification. Their account gives these examples of removed material while leaving the full inventory of rules unspecified.

This cleanup takes place before [tokenization](https://md.research.elamur.ai/free/en/concepts/tokenization/), the division of text into units the system can process. Both stages change how the original message is presented to the classifier, and they serve different purposes. Cleanup discards selected material. Tokenization represents the remaining material using entries in a vocabulary. For example, deleting a username changes what reaches the system, whereas dividing an informal word into pieces changes how retained text reaches it. Performance belongs to the pipeline that includes both choices.

After preparing the collection, the authors use 90% for the training process and hold out 10% for testing. Training examples supply a text and its expected polarity so the classifier can adapt its predictions. For evaluation, the expected labels serve as answers against which predictions on the held-out items are checked. The paper gives the proportions for this division. It leaves the method for allocating examples to the splits and the distribution of each source within them unspecified.

The distinction between training and test here is also a distinction between uses of the labels. During training, a known label can influence classifier parameters. During testing, it is used to assess a prediction. A held-out test supports an assessment beyond the examples used to fit the classifier, within the particular collection that supplied both splits. Holding out a platform, a topic or a way of obtaining labels would create a different split and answer a different question.

#### Represent the input with WordPiece

BERT accepts sequences of vocabulary indices. To get from a written message to those indices, the authors use WordPiece, a form of [subword tokenization](https://md.research.elamur.ai/free/en/concepts/subword-tokenization/). Its vocabulary contains frequently occurring words, smaller word pieces and individual characters. A form found as a whole can be represented by its own entry. If the whole form is unavailable, the tokenizer can divide it into smaller pieces that have entries. This makes vocabulary coverage depend on what pieces can be represented as well as which complete words have been seen.

In the authors’ description, a piece marked with `##` continues a preceding portion of the word. The marker carries information about where a piece occurs within a written form. The tokenizer turns its output into indices by identifying the corresponding entry for each piece. Those indices identify units for BERT to process. They do not by themselves describe what the units mean in the particular message. The contextual processing in BERT happens after this conversion.

The authors illustrate the motivation with `ccta`, used for sister, for which they give the Swahili equivalent `dada`, and `faza`, used for father, with `baba` as the counterpart. These examples show modified forms that might be encountered in informal Swahili writing. The paper uses them to motivate accommodating unfamiliar strings and borrowing. The argument is about the ability to supply a representation for such input even if its entire written form lacks a vocabulary entry. Recognizing which vocabulary pieces are present is a separate step from connecting the spelling to a familiar kinship term.

The classifier needs to use any information those pieces provide together with information from the rest of the message. A term for a family member does not supply a polarity on its own. Likewise, a segmentation that permits the input to be processed need not produce parts that a human recognizes as meaningful components of the intended word. The study’s prediction target is the polarity of the item. It does not require the system to recover a standard spelling or demonstrate that it understands every informal expression.

The paper describes two structural markers used in BERT input. `[CLS]` marks the beginning, and `[SEP]` marks a boundary at the end of a segment or between segments when the input consists of a pair. BERT can accept either a single sequence or paired input. The sentiment experiment poses the classification problem at the level of an item, with no paired-text task described. These markers give the input a standard structure as it is converted to the indexed sequence that the encoder receives.

Length is measured in tokens, so splitting a word into several pieces can occupy several positions in a sequence. The paper gives 512 tokens as the general input limit for BERT and reports a maximum sequence length of 64 in its experimental settings. The latter is the length setting relevant to the reported experiment. It limits how much tokenized input is available to a classifier on any one item. The paper gives no count of items whose tokenized lengths exceeded that setting and no account of how those cases were distributed across the two labels.

#### Start from an already trained encoder

BERT is introduced as a neural [language model](https://md.research.elamur.ai/free/en/concepts/language-model/) that forms contextual representations of text. It is bidirectional in the sense that a representation can draw on surrounding text on either side of a position. The paper motivates this property through the earlier issue of context-independent word vectors. A single piece does not need to carry a fixed interpretation through every occurrence. The encoder can process it in relation to the other pieces present in the input, using [Transformer attention](https://md.research.elamur.ai/free/en/concepts/transformer/).

The authors distinguish the general BERT description from the multilingual setup used in the experiment. For the original English BERT, they describe pretraining on BooksCorpus, with 800M words, and English Wikipedia, with 2,500M words. They also describe BERT Base and BERT Large as having 12 and 24 encoder layers, respectively. These figures explain the architecture and training background in the introductory method discussion. For mBERT, the pretraining material they identify is Wikipedia in 104 languages, with Swahili among them and a vocabulary shared across the languages.

Pretraining provides the starting parameters. It precedes the use of the Swahili polarity labels and has a different purpose. In the paper’s account, pretraining learns representations from text without labels from the eventual task. The task adaptation then starts with the acquired parameters and uses examples with expected positive or negative labels. This order permits the classifier to use representations acquired before the authors’ sentiment collection existed. The experiment’s training labels instruct the system about the output decision it must make on that collection.

The authors emphasize that Swahili already contributed to mBERT pretraining. This is important when characterizing what transfers. The experiment uses a representation learned in a multilingual setting that already included the target language, then supplies Swahili supervision for the narrower task. Learning Swahili polarity from labeled examples is part of its setup. The study therefore concerns supervised adaptation of a multilingual encoder, with both earlier Swahili exposure and later Swahili task labels available to it.

#### Adapt the output to sentiment

The authors place a dense layer above the pretrained network. A dense layer combines the values it receives from the preceding representation to produce values suitable for the next decision. Here the decision is whether to assign positive or negative polarity. The representation underneath it comes from the text processing that mBERT was already trained to perform. The labeled examples enable the combined system to adjust to the classification task.

The training account names the HuggingFace PyTorch library as the means of initializing the system with pretrained parameters. The reported setup lists a GeForce GTX 1080 Ti, batches of 16, and a sequence length capped at 64. Batch size is the number of examples grouped for a training step. The sequence limit controls a different dimension, the number of token positions allowed for an input. The paper uses pretraining terminology in the sentence listing hardware, batch size and sequence length, within a section otherwise describing initialization and sentiment adaptation. Its method identifies multilingual Wikipedia pretraining as the source of the starting parameters and presents the experimental settings in connection with adapting the classifier.

The optimizer is Adam. An optimizer specifies how to use the training signal to update parameter values. The paper reports a learning rate of 5e-5, which sets the scale for updates, and an epsilon parameter of 1e-8, a small constant used for numerical stability in the optimizer. The authors say that other hyper-parameters follow the BERT setup. They describe the architecture and training settings without a mathematical formula for the encoder, the classification layer or the loss. The implementation is therefore specified at the level of the starting system, the added layer and the named settings.

At evaluation, the result of this sequence of operations is a polarity prediction for each held-out item. The score reflects the entire procedure from selecting items to normalizing the classifier’s inputs and adapting its parameters. The figures supplied for training settings tell the reader how the authors configured important parts of that procedure. They do not identify how much each part contributes to the final result, a separate question that would call for matched comparisons.

### Experiments and results

#### What the test set measures

The experiment evaluates the adapted mBERT classifier on the 10% test share of the prepared Swahili collection. The training process uses the remaining 90%. The collection combines online examples judged by annotators with ISEAR examples whose emotion categories are mapped to polarity. This means the evaluation is defined jointly by the sources and the way a correct answer is assigned. A success on an online example agrees with the retained annotation. A success on an ISEAR example agrees with the conversion from emotion to polarity.

The headline metric is accuracy, the share of all test predictions that match the expected labels. The authors report 87.59% accuracy for mBERT on that held-out split. Each test item contributes to this metric through whether its prediction is correct. If one class has more members in the test set, then the performance on that class has more influence on the overall score. The collection as a whole is skewed towards negative examples. The paper does not give exact class counts for the held-out split, so the aggregate accuracy should be read together with the authors’ description of performance by category.

The paper also discusses precision, recall and F1 for each class. For a given class, precision asks how often the system is right among the items it predicts to belong to that class. Recall asks how frequently it finds the class among items known to belong to it. F1 brings precision and recall together in a score that favors their joint strength. These class-level metrics distinguish errors hidden by an overall accuracy value. A classifier can make many correct negative predictions while still missing a substantial share of the positive items, for instance.

The authors report that the negative class receives higher scores and use a confusion matrix to examine the direction of errors. Such a matrix groups test examples by their expected label and predicted label. The off-diagonal entries distinguish positive items predicted as negative from negative items predicted as positive. The authors single out the tendency to send positive items to the negative class. They describe the direction of the pattern and report overall accuracy in the results narrative. The class-level metric values and confusion counts are unspecified there.

That pattern matters if the predictions are used to read a collection. Positive items assigned to negative are lost from the set a reader would retrieve by looking for favorable messages. At the same time, they enter the set retrieved as negative. The discussion thus connects a classification error to a practical consequence for either use of the output. The paper demonstrates this qualitatively through the direction of the observed errors. Its headline score cannot supply the magnitude of the two effects on its own.

#### How to read the comparisons with earlier studies

The Swahili experiment trains and evaluates mBERT. It gives no same-split result from a conventional classifier, from another pretrained system or from a rule that predicts the prevalent class. Accuracy on the Swahili test items is therefore a measure of the reported system’s agreement with the expected labels. The paper also reviews comparisons that other researchers conducted within their respective datasets. Those comparisons can illustrate the kinds of alternatives that have been studied while keeping their metrics attached to the tasks on which they were measured.

The chart shows the camera-review comparison reported in the related work. It compares classifiers on a single review setting, with the stronger of the two reported settings marked. Both rows concern camera reviews from Amazon. The study of Swahili uses its own collection and supplies a separate result.

Classifier accuracy on Amazon camera reviews in a study discussed by the authors The support vector machine has the higher reported accuracy on camera reviews.

**The numbers**

| System or setting | accuracy % |
| --- | --- |
| Naïve Bayes | 93.54 |
| Support vector machine (this paper) | 98.17 |

Another comparison in the related work concerns short tweets about COVID-19. The authors cite accuracy of 91% for Naïve Bayes and 74% for logistic regression in that short-tweet setting, and describe poor performance for both on longer tweets. This example is useful for interpreting what a within-study comparison can establish. The cited tweet study examines the effect of using different classifiers with a length condition. The Swahili study supplies an input length setting but does not separate its own test scores by text length.

The paper also cites a multilingual BERT result on 9k Tunisian social media comments. It reports accuracy of 93.8% for binary sentiment in that study. In spite of the shared architecture name and positive or negative task, the systems are adapted and assessed on their own data. The headline figures answer questions about agreement with different test labels. Training examples and test items, language and source composition all belong to the stated condition of each result.

The same caution applies to measures with different names. The paper reports that an earlier study of sentences from Stack Overflow posts attained an F1 score of 87% for its sentiment task. That study considers a neutral class alongside positive and negative. F1 on that task expresses a different property from overall accuracy on the retained Swahili examples. The main score for Swahili is most informative with its own description attached, as held-out accuracy for a binary task on the authors’ mixed-source collection.

#### What the experiment establishes

The reported result demonstrates successful adaptation under the study’s conditions. The authors assembled a labeled collection, encoded items with the shared WordPiece vocabulary, used the pretrained multilingual parameters as their starting point and evaluated the resulting classifier on held-out items. The accuracy quantifies how often that classifier reproduced the binary labels in the test split. The discussion of errors further identifies the category for which the results were weaker.

The status of that evidence matters in relation to the paper’s aim. The authors set out to investigate whether mBERT could be used for Swahili sentiment with a new collection. A working classifier and held-out result answer that feasibility question under their setup. Establishing superiority over other approaches would require their predictions on the same test items, with access to comparable training material and a common scoring procedure. The paper treats such comparisons as further work.

The split also defines the scale of the generalization shown by the experiment. The classifier predicts on items withheld from its supervised fitting, and those items come from the same prepared collection. This provides evidence about prediction beyond the fitting examples. The experiment does not separately sample unfamiliar platforms or define a new topic as the test condition. A reader interested in transferring the classifier to another source would need to know how much the incoming text and its label conventions resemble those in this collection.

### What the ablations show

The paper reports no ablations or controlled component comparisons and instead analyzes its classifier through class-level scores and the direction of errors in a confusion matrix.

#### Why the direction of the errors matters

The comparison between positive and negative performance is descriptive. The two classes are judged using predictions from the same fitted classifier. The authors see higher scores for negative sentiment and emphasize cases where a positive text is predicted as negative. This tells the reader which errors help shape the aggregate result. A report consisting only of correct versus incorrect predictions would leave those two directions combined.

The class counts provide the authors’ explanation for the pattern. There are substantially more negative examples in the collection, so they argue that the classifier becomes more inclined to assign negative polarity. The explanation follows a plausible connection between the examples available for supervised training and the output behavior. The study observes those features of the setup together. It does not vary the class proportions while holding other relevant choices fixed, so the attribution to imbalance remains an interpretation of the observed error pattern.

There are reasons to keep the frequency of a class and the diversity of its examples analytically distinct. The negative label receives data from multiple emotions in ISEAR, as well as from annotated online material. The positive side of ISEAR comes from joy. The counts describe how many items occupy the categories across the full collection. They leave open how consistently polarity is expressed within each class or how much the domains differ. The reported analysis is pooled, so it cannot resolve whether particular source or label conventions are associated with the directional errors.

A positive message misclassified as negative affects the evaluation of both classes. From the standpoint of positive recall, it is a positive item the classifier missed. From the standpoint of negative precision, it is a negative prediction that was assigned to an item with a different expected label. Reading the confusion matrix gives this kind of explanation without requiring an overall score to change its meaning. The authors’ observation explains which type of mistake a reader should keep in mind when interpreting the class-wise comparison.

#### Which explanations remain open

The method motivates mBERT in part through its treatment of informal spelling and borrowed words. The experiment does not separate messages with those features from messages without them. There is no score specifically for the example forms discussed in the method or for inputs containing words that had to be split into smaller pieces. The tokenizer makes it possible to present segmented input to the classifier. The overall score leaves open where that mechanism helped the polarity decision.

The same distinction applies to pretraining. The authors use an encoder trained on several languages, with Swahili among them. They do not run a version trained without Swahili or compare matched multilingual and Swahili-only encoders on their split. The result thus reflects an encoder with that pretraining history. How much of the outcome is associated with direct exposure to Swahili, shared vocabulary entries or experience with text in other languages remains unresolved.

The reported preprocessing choices also form part of a single pipeline. The authors remove selected material and use a specific input length. Performance with usernames, links or different punctuation treatment is not reported. Neither is performance at a different maximum length. In an ablation of one such choice, the two conditions would use the same evaluation examples and differ in the selected component. The comparison would then bear on that choice. In the reported experiment, the cleanup and length cap contribute to the conditions under which the classifier was tested.

For the data sources, a controlled comparison could ask how including emotion-derived examples changes predictions on manually labeled online items. The paper pools the sources and gives one overall result. That design addresses how the classifier performs on the combined task and allows observations about positive and negative predictions across it. It leaves the contribution of the ISEAR material to the final results unidentified. The distinction is consequential because the paper defines expected polarity differently for the two kinds of material.

The class analysis is therefore the clearest evidence about performance variation within the actual test. It identifies uneven results between the categories without attributing a quantified benefit to any individual design choice. The authors’ discussion of data balance, linguistic variation and pretraining supplies reasons for following up on those choices. The evidence from this experiment describes the behavior of the complete classifier operating on the complete task.

### Limitations

#### Limits identified by the authors

The authors point to the character of freely accessible social media material as a limitation. They mention sarcasm, inconsistent data quality and problems of meaning. Sarcasm is a concrete difficulty for polarity annotation and prediction because a writer can use words ordinarily associated with praise to express dissatisfaction. The relevant cues can fall outside the immediate phrase. The paper names this issue without presenting an evaluation subset for sarcastic items. There is no separate estimate of its frequency or of the classifier’s performance on it.

The authors identify dataset size and the ratio of labels as important for performance. The prominence of negative examples already figures in their interpretation of the test. They say that the study is ongoing and include the class ratio among the issues they intend to address. The available evidence shows the outcome for the original distribution and the associated direction of errors. It gives no test score under an alternative distribution or under a different approach to handling the existing one.

The authors also name comparison with other approaches as pending work. Their related-work discussion makes several possibilities visible, from conventional classifiers to neural methods and alternative pretrained systems. Each comparison would be informative only with its conditions specified, including what text and labels were available to each system. The paper sets up one side of such a comparison through its multilingual BERT result.

Finally, the authors point to work suggesting that language-specific BERT systems can be effective and propose training a Swahili-specific BERT. They want to accommodate linguistic features of Swahili and support tasks beyond the sentiment experiment. Their paper presents that direction as future work. Its results concern adaptation of the existing multilingual system and contain no measured outcome for the Swahili-specific alternative they propose.

#### What follows from the selection and labeling of examples

The population being measured consists of texts admitted by the dataset procedure. A text that the annotators regarded as neutral or left unresolved was excluded. A conversation sampled without that filter would contain a broader set of cases, including items for which the classifier’s available responses provide no neutral option. The 87.59% test accuracy applies to the retained task. It does not estimate accuracy on an unfiltered stream of messages.

The annotation procedure gives a way to reach agreed labels and obtain a workable dataset. The paper does not quantify initial agreement, report how frequently discussion resolved disagreements or give the number of examples discarded for neutrality or uncertainty. Those details would help a reader distinguish a collection with largely straightforward assignments from one in which a substantial share of texts was revisited or removed. Since only the final labels are evaluated, the reported performance offers no way to reconstruct the difficulty of those earlier judgments.

There is also a limit to equivalence between the ISEAR labels and the online labels. The mapping from joy and the remaining emotions defines polarity for ISEAR. The native speakers’ judgments define polarity for the online material. A system can agree with both conventions overall and still achieve different results under each one. The paper gives no separate scores by method of labeling. It remains unclear how much of the headline result is carried by examples with emotion-derived labels and how much is carried by manually judged online examples.

The named sources and varied topics make clear that the data cover more than one online setting. They do not establish the balance of topics, regional varieties or informal language features. Two annotators from Tanzania supply the judgments for the online material. No comparison across annotator groups or communities is reported. The result measures agreement with the study’s adopted labels. The authors’ interest in variation motivates the source collection, while the evaluation leaves performance across specific varieties unresolved.

The task granularity is another boundary. A message might praise one person while criticizing another or express different views about different aspects of a service. The classifier is asked for one polarity label per retained item. The paper neither defines a benchmark for individual opinion targets nor evaluates whether the system recognizes multiple attitudes in a message. The tasks described in the introduction can involve such distinctions, but the experiment measures a more specific kind of output.

#### What the split and reporting leave uncertain

The use of a held-out share makes it possible to score the classifier on texts outside the training portion. The report leaves out how the partition was created, whether it grouped similar messages, and whether source proportions stayed fixed. Each detail affects what would count as a substantially unfamiliar test item. A split by platform would test transfer between platforms. A split within a pooled collection can include examples drawn under similar collection conditions on both sides. The paper describes the training and test shares and reports the pooled outcome.

The account also gives no score variation across repeated runs or alternative divisions of the data. Its accuracy is a point result under the reported setup. A different membership of the test set could change the distribution of messages that are easy or difficult to classify. A comparison among scores for different classifiers would also benefit from knowing how much the score varies for a single classifier. The paper’s result supplies a starting measurement with those sources of variation unspecified.

The training description specifies which library was used, what pretrained starting point was chosen, which layer was added, what hardware was used and which hyper-parameters were selected. They leave the number of training passes, the choice of checkpoint and the handling of long inputs unspecified. The last point bears directly on the relation between online language and the system’s view of it. If an item exceeds the input limit, the prediction can depend on which text is retained. The paper does not report how often that situation arose, so readers cannot attribute errors to lost context or conclude that the length limit was sufficient for all items.

Finally, the study’s overall accuracy and qualitative class analysis answer different questions. Accuracy states how many decisions agree with the test labels in aggregate. The directional errors show that the categories did not receive equally strong treatment. Neither kind of evidence identifies which linguistic cues the classifier relied on when making individual predictions. That is particularly relevant to the authors’ motivation concerning unusual spellings and borrowed forms. The experiment establishes performance on a collection where the authors say such variation occurs, with no separate evaluation of those features.

### What came after

#### Swahili-specific pretraining

The paper ends by proposing a BERT system trained specifically with Swahili in mind. The later SwahBERT work takes up that language-specific direction. Its title identifies a system for Swahili itself, whereas the sentiment study begins with parameters shared across many languages and adapts them to Swahili labels. The connection is the choice of what text representation to give a Swahili application before teaching it the application’s labels. SwahBERT’s focus establishes a continuation of the language-specific line of work. Whether it surpasses mBERT on the same held-out sentiment items would require a result for that comparison. [SwahBERT](https://md.research.elamur.ai/free/en/papers/martin-2022-swahbert-language-model-swahili/)

#### Sentiment as a shared benchmark

AfriSenti develops the data and evaluation side of the problem. It is a Twitter sentiment benchmark for African languages. The earlier Swahili experiment built a collection that combined several online sources with an emotion dataset, then evaluated a classifier on a held-out share. AfriSenti’s subject is a benchmark centered on one platform and a wider set of languages. The relation between the works is the need for task-specific labels and a defined evaluation set when investigating sentiment in languages with fewer resources. A benchmark makes that evaluation setup a contribution in its own right. The citing relationship leaves the provenance of individual benchmark items and the use of the Swahili study’s label conversion unspecified. [AfriSenti](https://md.research.elamur.ai/free/en/papers/muhammad-2023-afrisenti-twitter-sentiment-analysis-benchmark/)

GMNLP’s work for SemEval-2023 Task 12 addresses sentiment classification with phylogeny-based adapters. This puts relationships among languages into the framing of adaptation. The Swahili study uses a shared multilingual starting point and adds a layer for the polarity decision. The later work names adapters organized around linguistic relatedness as its approach to sentiment. Both studies address how to adapt a language representation for classification, with different information guiding that adaptation. The title identifies the technical direction of the later work. It does not establish whether the authors trained with the Swahili collection or compared their adapters with its classifier. [GMNLP at SemEval-2023 Task 12](https://md.research.elamur.ai/free/en/papers/alam-2023-gmnlp-semeval-2023-task-12/)

#### A parallel question for Kwanyama

The Kwanyama study brings sentiment analysis and pretrained language systems together for another language. This continues the broad research question raised by the Swahili work. A researcher needs to define the sentiment task for the language being studied, choose a starting representation and evaluate its adaptation against examples in that language. The existence of a Swahili result establishes how the earlier authors set up one such experiment. The Kwanyama work takes up the combination of sentiment and language representation with a new target language. Its title and citation relationship support that connection without establishing shared labels, data sources or preprocessing. [Sentiment Analysis and Language Models for Kwanyama](https://md.research.elamur.ai/free/en/papers/nakashole-2026-sentiment-analysis-language-models-kwanyama/)

## Cite

Cite as Gati Lother Martin, Medard Edmund Mswahili and Young-Seob Jeong. 2021. Sentiment Classification in Swahili Language Using Multilingual BERT. arXiv (Cornell University).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.48550/arxiv.2104.09006](https://doi.org/10.48550/arxiv.2104.09006) · [arXiv 2104.09006](https://arxiv.org/abs/2104.09006)

```bibtex
@misc{martin2021sentiment,
  title = {{Sentiment Classification in Swahili Language Using Multilingual BERT}},
  author = {Gati Lother Martin, Medard Edmund Mswahili and Young-Seob Jeong},
  year = {2021},
  doi = {10.48550/arxiv.2104.09006},
  eprint = {2104.09006},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.2104.09006}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
