# IMAD: IMage-Augmented multi-modal Dialogue

Viktor Moskvoretskii
DeepPavlov.ai
<EMAIL_ADDRESS>
&Anton Frolov
DeepPavlov.ai
<EMAIL_ADDRESS>
&Denis Kuznetsov
DeepPavlov.ai
<EMAIL_ADDRESS>

###### Abstract

Currently, dialogue systems have achieved high performance in processing text-
based communication. However, they have not yet effectively incorporated
visual information, which poses a significant challenge. Furthermore, existing
models that incorporate images in dialogue generation focus on discussing the
image itself. Our proposed approach presents a novel perspective on multi-
modal dialogue systems, which interprets the image in the context of the
dialogue. By doing so, we aim to expand the capabilities of current dialogue
systems and transition them from single modality (text) to multi-modality.
However, there is a lack of validated English datasets that contain both
images and dialogue contexts for this task. Thus, we propose a two-stage
approach to automatically construct a multi-modal dialogue dataset. In the
first stage, we utilize text-to-image similarity and sentence similarity to
identify which utterances could be replaced with an image. In the second
stage, we replace those utterances by selecting a subset of relevant images
and filtering them with a visual question answering model. We used this
approach, along with additional labeling, to create the IMage Augmented multi-
modal Dialogue dataset (IMAD), which can serve as a validated dataset for this
task. Furthermore, we propose a baseline model trained on this dataset, which
outperforms model trained on the same data without images and BlenderBot.

_K_ eywords Natural Language Processing $\cdot$ Deep Learning $\cdot$ Machine
Learning $\cdot$ IMAD $\cdot$ Dialogue Dataset $\cdot$ Multi-modal Dataset
$\cdot$ Dialogue Systems $\cdot$ Multi-modality.

##  1 Introduction

Dialogue systems, also known as conversational agents or chatbots, have become
increasingly important in recent years due to their potential to revolutionize
human-computer interaction [1].Furthermore, one can see a high activity in
this field in the recent year, as the usage of ChatGPT [2] serves for a lot of
different goals [3, 4, 5]. Just like with the ChatGPT recently Google has
announced Bard, that is based on LaMDA [6], which serves for the same tasks.
Additionally, dialogue systems provide a challenging problem in AI research,
as they require a deep understanding of natural language and the ability to
generate human-like responses [7]. A good confirmation of this thesis is the
abundance of different natural language products, that are widely used, such
as DeepPavlov [8].

Contemporary dialogue models such as DialoGPT, BLOOM, and DialogBERT are
predominantly text-based [9, 10, 11]. This is reasonable in scenarios where
individuals converse solely through textual communication. However, in real-
life situations, dialogues frequently incorporate images, such as when
individuals respond to questions with photographs, provide offers or express
emotions [12]. As a result, there is a need for dialogue models that can
accommodate multi-modal inputs.

Just as in the dialogues systems high activity is being spotted in the field
of text2image generation [13, 14, 15]. These tools are also helpful in the art
sphere [16], healthcare [17], physics [18] and more. However, these models are
limited to producing only images and taking text information as input.

These problems are solved with multi-modal deep learning models, that are
increasingly important today due to the exponential growth of multimedia data
in various domains [19, 20, 21, 22]. Such models have numerous applications in
various domains. There is a strong potential of incorporating more modalities
to dialogue assistants, such as better emotion recognition [23], visual
question answering [24, 25] and operating with the wide range of tasks [26,
27, 28].

Therefore, one could focus on the task of generating an image description in a
context of dialogue [29, 12]. This task is more general compared to the
response generation [2] or describing a picture [30], because it allows for
better response generation with intention knowledge and knowledge about the
image sense in a certain dialogue context.

Proposal. That brings us to the task of interpreting an image in the context
of dialogue, that is exactly the solution of aforementioned problem. We
present IMage Augmented multi-modal Dialogue dataset (IMAD), that contains
4864 dialogues, where last utterance was replaced with image. To collect it we
utilize multiple sources of dialogue dataset, present novel approach for
image-text dialogue construction and labeled part of it with 3 assessors. We
also present baseline models, based on the BLIP [25], that outperform text-
only BLIP and BlenderBot 400M [31] on this task. Train data included 4154
samples collected with automated approach and 582 samples labeled with
assessors as "Partial Match". Test data included 128 samples, labeled by
assessors and authors as "Perfect Match".

Out dataset and code are published at IMAD Repository

##  2 Related Works

Multi-modal Tasks. Multi-modal models involve multiple modalities, such as
images [25, 15, 32, 33], video [34, 35, 36], or audio [37, 38]. In the field
of text and image modalities there are variety of popular tasks. Visual
question answering [30, 25, 39, 40], Image captioning [41, 42, 43]. As well,
we distinguish as separate task image-text matching, that key is to match
corresponding images and texts [44, 25, 45]

Mutli-modal Embeddings. Modern models [26, 28, 27] focus on connecting
multiple modalities in one model. In contrast, we would like to focus on text
with images data. One of the strongest multi-modal model was CLIP [44], which
uses image embeddings to align with text embeddings for image-text matching
loss [46], so images will correspond to relevant phrases. The same idea was
used in BLIP [25] with matching image and text embeddings [39]. This is a key
idea to filter pairs of text and image.

Multi-modal Data. Current multi-modal data contains images with captions [47,
48, 49, 50, 51, 40]. BLIP, BLIP2 and Flamingo were trained on these. However,
these datasets do not contain dialogue contexts.

Previous research has also encountered a similar challenge, as evidenced by a
study on the topic of image-grounded dialogues [12]. The authors of this study
utilized dialogues from Chinese social media and crowd-sourcing to develop
their model. The authors reported an increase in BLEU [52] scores compared to
generated responses that were not conditioned on image data.

Another study [29] proposes constructing a dataset utilizing image-text
matching via the Visual Semantic Reasoning Network (VSRN) [53] with images
sourced from the MS COCO [51] and Flicker 30k [54] datasets, just as it was
done before [55].

##  3 Dialogue Datasets

To produce clean data, it is important to have dialogues created with humans.
They could be collected either from crowd-sourcing or written by humans, such
as in English books. Therefore, we have chosen the dataset sources listed
below to make our data valid and diverse in terms of dialogue content:
DailyDialog, Persona Chat, MuTual, DREAM, Common-sense dialogues, and
Empathetic Dialogues [56, 57, 58, 59, 60, 61]. Detailed reasons are provided
in Appendix B.

With these sources, we have collected 451,611 pairs of utterances with context
and images. This dataset contains all the features and model predictions
described below.

The filtered version of the dataset is named IMage-Augmented Multi-modal
Dialogue Dataset (IMAD) and is used later for modeling. It is constructed with
a combination of the Text-Image Replacing approach and Human Annotated part.
Basic statistics are shown in Table 3.

##  4 Text-Image Replacing

Previously approach with filter from VSRN did not show well results [29].
Therefore to obtain more precise and appropriate dataset, we utilized a two-
step process to determine the feasibility of replacing an utterance with an
image. The first step involved predicting whether the utterance could be
substituted with an image. The second step focused on matching a better
picture utilizing VQA from BLIP.

###  4.1 Find Replaceable Utterances

The first step is to find utterances that could be replaced with an image. To
accomplish this task, we have labeled a little subset, created features (we
will name them scores) and built Random Forest model [62].

####  4.1.1 Human Annotation.

For the initial step, we labeled 1000 random samples from the DailyDialogue
[57], state them as $U=\\{u_{1}\dots u_{1000}\\}$, that are utterances with
contexts. To label them, we were using a heuristic formulated as "This phrase
potentially can be described with a picture".

####  4.1.2 Replacing Features.

The matching process involves pairing each utterance with an image from the
Unsplash. This is achieved by maximizing the cosine similarity between the
embeddings of the utterance and the image extracted from CLIP [44].

To optimize the matching process, we conducted experiments using various text
and image features that were deemed important for predicting if utterance is
replaceable. The most promising results were obtained when each utterance was
accompanied by the following features: Image Score, Maximum Entity Score,
Sentence Similarity, BLEU Score, Threshold. Detailed description is provided
in Appendix A.

####  4.1.3 ML Labeling.

For classification we employed the Random Forest algorithm, that demonstrated
the best precision[62]. This behavior is likely attributed to the high
variance in the data, as evidenced by the standard deviation.

Multiple tests were conducted with the Stratified K-fold cross-validation with
3 folds and 40 repeats. Precision was deemed to be the key metric, given the
importance of minimizing errors, as even the exclusion of valid utterances is
preferable to making errors.

The resulting model metrics are shown in Table 6 and feature importances are
shown in Fig. 2.

###  4.2 Text-Image Matching

The criterion from the first step, which considers only the text and not the
image, serves as a primary filter for the text-image task. However, it is
insufficient on its own, that is shown by not so high correlation in previous
works [29]. The image dataset limitations impose constraints on the ability to
form a pair of utterance and image, even if the utterance is replaceable. To
overcome this, it is necessary to introduce a step to match utterances with
better images.

####  4.2.1 ML Labeling.

In order to improve the quality of the images, we utilized the BLIP VQA [63].
To select proper images we use confidence of the model output, which is
defined as sum of the log probabilities of each token in the utterance.
$\operatorname{Confidence}(out,u)=\sum\limits_{i=1}^{length\,token(u)}out_{i,token(u)_{i}}$.

The process of selecting a better image for an utterance was carried out using
the following steps:

  1. 1.

Create scoring for all images. For each utterance we have cosine similarity
with every image in dataset
$\Bigl{\\{}\operatorname{cosine}(\operatorname{emb}_{CLIP}(u),\operatorname{emb}_{CLIP}(i))\quad\forall
i\Bigr{\\}}=:ISS_{u}$.

  2. 2.

Create set of N images. From all that set we take set of N images, which are
the top-N for cosine similarity
$\Bigl{\\{}i\,|\,\operatorname{cosine}(\operatorname{emb}_{CLIP}(u),\operatorname{emb}_{CLIP}(i))\geq
ISS_{u_{(N)}}\Bigr{\\}}=:TopImg_{u,N}$

  3. 3.

Query the VQA. The model was queried with the text input "Which phrase can
describe this image?" for each image in the aforementioned set.

  4. 4.

Calculate confidences. For each image in aforementioned set we calculate
confidence
$\Bigl{\\{}\operatorname{Confidence(out,u)}\,\big{|}\,out=\operatorname{VQA}(quest,i)\quad\forall
i\in TopImg_{u,N}\Bigr{\\}}=:ConfSet_{u,N}$.

  5. 5.

Select the most confident. Then we select image with the highest confidence
score $\operatorname{argmax}\\{ConfSet_{u,N}\\}=:img_{N}$.

We conducted a test of our methodology by labeling image-text matching in the
context of dialogue pairs that were previously identified as replaceable. The
labeling process involved 3 classes: "Image matches", "Image does not match"
and "Unknown" in cases where determination was difficult. Our results, as
presented in Table 3, confirm that our initial assumptions were correct.
Specifically, our findings indicate that, at best, only half of the pairs with
replaceable utterances were found to have matching images.

####  4.2.2 Human Annotation.

With the above method we obtained a subset of 4154 samples. In order to
enlarge the dataset, samples with lower RF scores were selected and labeled by
three expert assessors, resulting in the addition of 4644 more samples to the
dataset. The labeled dataset was organized into 4 distinct categories:
"Perfect Match", "Partial Match", "Undefined" and "No Match". Detailed
description and labeling instructions provided in Appendix D.

The inter-rater reliability of their annotations were evaluated using Fleiss-
kappa statistic. The refined version of the IMage Augmented multi-modal
Dialogue dataset (IMAD) is constructed from samples obtained with our initial
approach and samples from dataset labeled with assessors, that had label
"Perfect Match" or "Partial Match". Basic statistics are shown in Table 3,
number of samples from different sources and Fleiss’s Kappa are shown in Table
1.

Table 1: Accuracy for each data source for each label in assessor’s validation dataset, where ground true labeling were done with authors. Fleiss Kappa across assessors for each data source. Number of samples in resulting dataset from each data source. Dataset | 1 class | 2 class | 3 class | 4 class | Fleiss Kappa | # of samples
---|---|---|---|---|---|---
PersonaChat | 0.29 | 0.43 | 0.82 | 1.0 | 0.83 | 2483
DailyDialog | - | 0.50 | - | - | 0.80 | 899
EmpatheticDialogues | - | - | - | - | 0.76 | 754
Commonsense-Dialogues | - | - | 1.0 | - | 0.83 | 220
MuTual | - | - | - | - | 0.88 | 333
DREAM | - | - | - | - | 0.81 | 175
Mean Across All Sources | 0.29 | 0.46 | 0.9 | 1.0 | 0.82 | 810.67

Table 2: Number of image-text matches for different N in VQA image-text
matching approach

N | Image Matches | No Match | Unknown
---|---|---|---
1 | 37 | 51 | 8
5 | 46 | 46 | 4
10 | 48 | 44 | 4
15 | 47 | 45 | 4
50 | 42 | 51 | 3

Table 3: Basic Statistics of Dataset

Total Dialogues | 4864
---|---
Average Speaker Turns Per Context | 5.1
Average Number of Tokens Per Context | 56.4
Average Number of Tokens Per Replaced Utterance | 14.5
Size of Context Vocabulary | 12375
Size of Replaced Utterances Vocabulary | 7962

##  5 Multi-modal Dialogue Language Model

To validate our approach we train a model on the proposed dataset using both
image and text data and compare it to text-only models. We choose the task of
reconstructing the substituted utterance as visual signal is clearly
beneficial in such setting.

###  5.1 Model architecture

We choose a pre-trained BLIP [25] model for experiments as it is one of the
best open source models utilising both visual and text modalities and has a
handy interface in LAVIS library [64]. The model consists of a visual
transformer [65] for image encoding and a BERT [66] with a language modeling
head for text decoding, both initialised from a BLIP checkpoint. Training
details shown in Appendix C.

To validate the composed dataset we finetuned two BLIP models from a pre-
trained checkpoint. These models consist of ViT-B/16 image encoder and BERT
text decoder with 12 layers, 12 attention heads, hidden size of 768,
intermediate size of 3072, and GeLU activations [67]. Total number of
parameters is 224M.

###  5.2 Evaluation

For evaluation we use 128 well annotated samples by both us and the assessors.
For each trained model we choose the best checkpoint using validation metrics
and use it to compute metrics on the test split. We compare BLIP finetuned on
the proposed dataset to zero-shot performance of a distilled BlenderBot 400M
[31] and BLIP finetuned in text-only setting. We choose BLEU [52] with n-grams
lengths from 1 to 4 as quality metrics and also report perplexity for the
models we trained. During evaluation we use beam search sampling with 3 beams.
We also divide the test split of the dataset into parts corresponding to the
source dialog corpuses and report the metrics for each of them in Table 5 and
for the whole set in Table 4.

###  5.3 Generation examples

Figure 1 show some examples of model generation results. We find that the
model finetuned using visual data uses that information in its answers as
opposed to the one finetuned using constant visual inputs. As we have only one
ground truth label for one sample sometimes model outputs do not exactly align
with them, but usually make sense and come close.

Figure 1: Examples of finetuend models generation: grey blobs represent the
context, white blobs represent ground truth utterances, and dashed blobs
represent model generation outputs with or without using visual input. Table
4: Test split metrics for both finetuned models and BlenderBot 400M.

| BLEU-1 | BLEU-2 | BLEU-3 | BLEU-4 | Perplexity
---|---|---|---|---|---
image+text |  23.73 $\pm$ 1.25 |  14.37 $\pm$ 1.06 |  9.19 $\pm$ 0.84 |  6.33 $\pm$ 0.77 |  44.19 $\pm$ 1.00
text-only | 10.63 $\pm$ 0.60 | 5.76 $\pm$ 0.35 | 4.01 $\pm$ 0.28 | 3.23 $\pm$ 0.24 | 90.21 $\pm$ 1.04
BlenderBot | 10.93 | 4.75 | 2.62 | 1.61 | -

Table 5: Metrics on test split by source for both finetuned models and
BlenderBot 400M. We report metrics for top-3 most frequent sources.

| Persona-Chat | DailyDialog | EmpatheticDialogues
---|---|---|---
| BLEU-1 | BLEU-4 | BLEU-1 | BLEU-4 | BLEU-1 | BLEU-4
image+text | 22.81 | 5.52 | 26.51 | 6.27 | 27.64 | 9.23
text-only | 9.73 | 2.68 | 13.81 | 3.79 | 8.98 | 0.00
BlenderBot | 13.29 | 2.83 | 12.17 | 0.00 | 10.24 | 1.62

##  6 Results and Discussion

Dataset. We have presented a dataset (IMAD) with a considerable amount of
multi-modal dialogues, sourced from validated text-only datasets. The creation
of our dataset is automated with a two-step process, involving the filtering
of the most relevant utterances and the selection of the most suitable image.
Additionally, we developed a methodology for labeling the data, which proved
to be well-understood and valid. This is demonstrated by the high Fleiss Kappa
score, which measures the consistency between 3 assessors, as shown in Table
1. The basic statistics of our dataset are presented in Table 3, and the
statistics per dialogue are quite similar to those of DailyDialogue, which is
a well-validated dataset.

Baseline Model. In this study, we propose a model for the task of generating
an utterance that is replaced with an image, using the IMAD. It is based on
the BLIP architecture and achieves a relatively high BLEU score compared to
other models that use only text information (as shown in Table 4). This result
demonstrates the validity of our dataset, which is consistent across different
sources of data (as shown in Table 5). We have overcame the issue of noisy and
irrelevant pairs of utterances and images by incorporating a filtering stage
and creating the IMAD, resulting in a model that potentially could outperform
a previous approach due to cleaner data [12].

Further Work. These promising findings are expected to significantly
contribute to the advancement of research in the field of multi-modal dialogue
models. The methodology presented in this paper could aid researchers in the
creation of more accurate filters for dialogue data, which could lead to
improvements in the quality and efficiency of collecting multi-modal
dialogues. We were limited with resources and yet tested model accuracy with a
lot of repeats on a subset, that could have led to distribution bias across
datasets. As well, low recall means we do not include a lot of valid samples,
which reduces our total dataset size. Therefore, the approach presented in
this work could facilitate the development of more effective multi-modal
models. There is also potential to further improve the size of the dataset
through labeling or model upgrades, as mentioned above.

Moreover, it is essential to conduct extensive research to compare multi-modal
approaches for solving this task. This involves comparing models using cross-
attention and concatenation of embeddings to that task, as well as conducting
experiments with different Language Models and Visual Encoders. Such an
investigation can lead to the development of more effective and accurate
multi-modal models.

##  7 Conclusion

In conclusion, our work presents a new task of interpreting images in the
context of dialogue and proposes a novel approach to construct a multi-modal
dialogue dataset to tackle this challenge. We utilized a two-stage process
that involves identifying utterances that can be replaced with images and
selecting relevant images using visual question answering models. Through this
process, we created the IMage Augmented multi-modal Dialogue dataset (IMAD),
which is validated and labeled, providing a valuable resource for further
research in this area. Additionally, we proposed a baseline model trained on
IMAD, which outperformed existing models that do not incorporate images. Our
work demonstrates the potential of incorporating visual information in
dialogue systems and highlights the need for more research in this area.
Future work can explore the use of more advanced techniques for identifying
relevant images and developing more sophisticated models that can effectively
incorporate visual information into dialogue systems.

## References

  * [1] Quim Motger, Xavier Franch, and Jordi Marco.  Software-based dialogue systems: Survey, taxonomy, and challenges.  ACM Comput. Surv., 55(5), dec 2022.
  * [2] OpenAI.  Chatgpt: Optimizing language models for dialogue., 2022.
  * [3] A. Baki Kocaballi.  Conversational ai-powered design: Chatgpt as designer, user, and product, 2023.
  * [4] Dominik Dellermann, Adrian Calma, Nikolaus Lipusch, Thorsten Weber, Sascha Weigel, and Philipp Ebel.  The future of human-ai collaboration: a taxonomy of design knowledge for hybrid intelligence systems, 2021.
  * [5] Brady D Lund and Ting Wang.  Chatting about chatgpt: how may ai and gpt impact academia and libraries?  Library Hi Tech News, 2023.
  * [6] Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, YaGuang Li, Hongrae Lee, Huaixiu Steven Zheng, Amin Ghafouri, Marcelo Menegali, Yanping Huang, Maxim Krikun, Dmitry Lepikhin, James Qin, Dehao Chen, Yuanzhong Xu, Zhifeng Chen, Adam Roberts, Maarten Bosma, Vincent Zhao, Yanqi Zhou, Chung-Ching Chang, Igor Krivokon, Will Rusch, Marc Pickett, Pranesh Srinivasan, Laichee Man, Kathleen Meier-Hellstern, Meredith Ringel Morris, Tulsee Doshi, Renelito Delos Santos, Toju Duke, Johnny Soraker, Ben Zevenbergen, Vinodkumar Prabhakaran, Mark Diaz, Ben Hutchinson, Kristen Olson, Alejandra Molina, Erin Hoffman-John, Josh Lee, Lora Aroyo, Ravi Rajakumar, Alena Butryna, Matthew Lamm, Viktoriya Kuzmina, Joe Fenton, Aaron Cohen, Rachel Bernstein, Ray Kurzweil, Blaise Aguera-Arcas, Claire Cui, Marian Croak, Ed Chi, and Quoc Le.  Lamda: Language models for dialog applications, 2022.
  * [7] Hongshen Chen, Xiaorui Liu, Dawei Yin, and Jiliang Tang.  A survey on dialogue systems.  ACM SIGKDD Explorations Newsletter, 19(2):25–35, nov 2017.
  * [8] Mikhail S Burtsev, Alexander V Seliverstov, Rafael Airapetyan, Mikhail Arkhipov, Dilyara Baymurzina, Nickolay Bushkov, Olga Gureenkova, Taras Khakhulin, Yuri Kuratov, Denis Kuznetsov, et al.  Deeppavlov: Open-source library for dialogue systems.  In ACL (4), pages 122–127, 2018.
  * [9] Yizhe Zhang, Siqi Sun, Michel Galley, Yen-Chun Chen, Chris Brockett, Xiang Gao, Jianfeng Gao, JJ (Jingjing) Liu, and Bill Dolan.  Dialogpt: Large-scale generative pre-training for conversational response generation.  In arXiv:1911.00536, November 2019.
  * [10] BigScience Workshop, :, Teven Le Scao, Angela Fan, Christopher Akiki, Ellie Pavlick, Suzana Ilić, Daniel Hesslow, Roman Castagné, Alexandra Sasha Luccioni, and et. Al Yvon.  Bloom: A 176b-parameter open-access multilingual language model, 2022\.
  * [11] Xiaodong Gu, Kang Min Yoo, and Jung-Woo Ha.  Dialogbert: Discourse-aware response generation via learning to recover and rank utterances, 2020.
  * [12] Yinhe Zheng, Guanyi Chen, Xin Liu, and Jian Sun.  Mmchat: Multi-modal chat dataset on social media, 2021.
  * [13] Chitwan Saharia, William Chan, Saurabh Saxena, Lala Li, Jay Whang, Emily Denton, Seyed Kamyar Seyed Ghasemipour, Burcu Karagol Ayan, S. Sara Mahdavi, Rapha Gontijo Lopes, Tim Salimans, Jonathan Ho, David J Fleet, and Mohammad Norouzi.  Photorealistic text-to-image diffusion models with deep language understanding, 2022.
  * [14] Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, and Björn Ommer.  High-resolution image synthesis with latent diffusion models, 2021.
  * [15] Aditya Ramesh, Mikhail Pavlov, Gabriel Goh, Scott Gray, Chelsea Voss, Alec Radford, Mark Chen, and Ilya Sutskever.  Zero-shot text-to-image generation, 2021.
  * [16] Nantheera Anantrasirichai and David Bull.  Artificial intelligence in the creative industries: a review.  Artificial Intelligence Review, 55(1):589–656, jul 2021.
  * [17] Yizhou Chen, Xu-Hua Yang, Zihan Wei, Ali Asghar Heidari, Nenggan Zheng, Zhicheng Li, Huiling Chen, Haigen Hu, Qianwei Zhou, and Qiu Guan.  Generative adversarial networks in medical image augmentation: a review.  Computers in Biology and Medicine, page 105382, 2022.
  * [18] Omey M Manyar, Junyan Cheng, Reuben Levine, Vihan Krishnan, Jernej Barbič, and Satyandra K Gupta.  Physics informed synthetic image generation for deep learning-based detection of wrinkles and folds.  Journal of Computing and Information Science in Engineering, 23(3):030903, 2023.
  * [19] Tadas Baltrušaitis, Chaitanya Ahuja, and Louis-Philippe Morency.  Multimodal machine learning: A survey and taxonomy, 2017.
  * [20] Jabeen Summaira, Xi Li, Amin Muhammad Shoib, Songyuan Li, and Jabbar Abdul.  Recent advances and trends in multimodal deep learning: A review, 2021\.
  * [21] Gargi Joshi, Rahee Walambe, and Ketan Kotecha.  A review on explainability in multimodal deep neural nets.  IEEE Access, 9:59800–59821, 2021.
  * [22] Jing Gao, Peng Li, Zhikui Chen, and Jianing Zhang.  A Survey on Deep Learning for Multimodal Data Fusion.  Neural Computation, 32(5):829–864, 05 2020.
  * [23] Jing Chen, Chenhui Wang, Kejun Wang, Chaoqun Yin, Cong Zhao, Tao Xu, Xinyi Zhang, Ziqiang Huang, Meichen Liu, and Tao Yang.  HEU emotion: a large-scale database for multimodal emotion recognition in the wild.  Neural Computing and Applications, 33(14):8669–8685, jan 2021.
  * [24] Yuling Xi, Yanning Zhang, Songtao Ding, and Shaohua Wan.  Visual question answering model based on visual relationship detection.  Signal Processing: Image Communication, 80:115648, 2020.
  * [25] Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi.  Blip: Bootstrapping language-image pre-training for unified vision-language understanding and generation, 2022.
  * [26] Scott Reed, Konrad Zolna, Emilio Parisotto, Sergio Gómez Colmenarejo, Alexander Novikov, Gabriel Barth-maron, Mai Giménez, Yury Sulsky, Jackie Kay, Jost Tobias Springenberg, Tom Eccles, Jake Bruce, Ali Razavi, Ashley Edwards, Nicolas Heess, Yutian Chen, Raia Hadsell, Oriol Vinyals, Mahyar Bordbar, and Nando de Freitas.  A generalist agent.  Transactions on Machine Learning Research, 2022.  Featured Certification.
  * [27] Jean-Baptiste Alayrac, Jeff Donahue, Pauline Luc, Antoine Miech, Iain Barr, Yana Hasson, Karel Lenc, Arthur Mensch, Katie Millican, Malcolm Reynolds, Roman Ring, Eliza Rutherford, Serkan Cabi, Tengda Han, Zhitao Gong, Sina Samangooei, Marianne Monteiro, Jacob Menick, Sebastian Borgeaud, Andrew Brock, Aida Nematzadeh, Sahand Sharifzadeh, Mikolaj Binkowski, Ricardo Barreira, Oriol Vinyals, Andrew Zisserman, and Karen Simonyan.  Flamingo: a visual language model for few-shot learning, 2022.
  * [28] Shaohan Huang, Li Dong, Wenhui Wang, Yaru Hao, Saksham Singhal, Shuming Ma, Tengchao Lv, Lei Cui, Owais Khan Mohammed, Barun Patra, Qiang Liu, Kriti Aggarwal, Zewen Chi, Johan Bjorck, Vishrav Chaudhary, Subhojit Som, Xia Song, and Furu Wei.  Language is not all you need: Aligning perception with language models, 2023.
  * [29] Nyoungwoo Lee, Suwon Shin, Jaegul Choo, Ho-Jin Choi, and Sung-Hyun Myaeng.  Constructing multi-modal dialogue dataset by replacing text with semantically relevant images, 2021.
  * [30] Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi.  Blip-2: Bootstrapping language-image pre-training with frozen image encoders and large language models, 2023.
  * [31] Stephen Roller, Emily Dinan, Naman Goyal, Da Ju, Mary Williamson, Yinhan Liu, Jing Xu, Myle Ott, Kurt Shuster, Eric M. Smith, Y-Lan Boureau, and Jason Weston.  Recipes for building an open-domain chatbot, 2020.
  * [32] Zirui Wang, Jiahui Yu, Adams Wei Yu, Zihang Dai, Yulia Tsvetkov, and Yuan Cao.  Simvlm: Simple visual language model pretraining with weak supervision, 2021.
  * [33] Xiaowei Hu, Zhe Gan, Jianfeng Wang, Zhengyuan Yang, Zicheng Liu, Yumao Lu, and Lijuan Wang.  Scaling up vision-language pre-training for image captioning, 2021.
  * [34] Antoine Yang, Antoine Miech, Josef Sivic, Ivan Laptev, and Cordelia Schmid.  Zero-shot video question answering via frozen bidirectional language models, 2022.
  * [35] Jie Lei, Tamara L. Berg, and Mohit Bansal.  Revealing single frame bias for video-and-language learning, 2022.
  * [36] Shen Yan, Tao Zhu, Zirui Wang, Yuan Cao, Mi Zhang, Soham Ghosh, Yonghui Wu, and Jiahui Yu.  Videococa: Video-text modeling with zero-shot transfer from contrastive captioners, 2022.
  * [37] Rafael Valle, Kevin Shih, Ryan Prenger, and Bryan Catanzaro.  Flowtron: an autoregressive flow-based generative network for text-to-speech synthesis, 2020.
  * [38] Xu Tan, Jiawei Chen, Haohe Liu, Jian Cong, Chen Zhang, Yanqing Liu, Xi Wang, Yichong Leng, Yuanhao Yi, Lei He, Frank Soong, Tao Qin, Sheng Zhao, and Tie-Yan Liu.  Naturalspeech: End-to-end text to speech synthesis with human-level quality, 2022.
  * [39] Junnan Li, Ramprasaath R. Selvaraju, Akhilesh Deepak Gotmare, Shafiq Joty, Caiming Xiong, and Steven Hoi.  Align before fuse: Vision and language representation learning with momentum distillation, 2021.
  * [40] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc V. Le, Yunhsuan Sung, Zhen Li, and Tom Duerig.  Scaling up visual and vision-language representation learning with noisy text supervision.  2021\.
  * [41] Ankur Kumar.  The illustrated image captioning using transformers.  ankur3107.github.io, 2022.
  * [42] Peng Wang, An Yang, Rui Men, Junyang Lin, Shuai Bai, Zhikang Li, Jianxin Ma, Chang Zhou, Jingren Zhou, and Hongxia Yang.  Ofa: Unifying architectures, tasks, and modalities through a simple sequence-to-sequence learning framework, 2022.
  * [43] Chenliang Li, Haiyang Xu, Junfeng Tian, Wei Wang, Ming Yan, Bin Bi, Jiabo Ye, Hehong Chen, Guohai Xu, Zheng Cao, Ji Zhang, Songfang Huang, Fei Huang, Jingren Zhou, and Luo Si.  mplug: Effective and efficient vision-language learning by cross-modal skip-connections, 2022.
  * [44] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever.  Learning transferable visual models from natural language supervision, 2021.
  * [45] Xiao Xu, Chenfei Wu, Shachar Rosenman, Vasudev Lal, Wanxiang Che, and Nan Duan.  Bridgetower: Building bridges between encoders in vision-language representation learning, 2022.
  * [46] Aaron van den Oord, Yazhe Li, and Oriol Vinyals.  Representation learning with contrastive predictive coding, 2018.
  * [47] Christoph Schuhmann, Richard Vencu, Romain Beaumont, Robert Kaczmarczyk, Clayton Mullis, Aarush Katta, Theo Coombes, Jenia Jitsev, and Aran Komatsuzaki.  Laion-400m: Open dataset of clip-filtered 400 million image-text pairs, 2021.
  * [48] Vicente Ordonez, Girish Kulkarni, and Tamara Berg.  Im2text: Describing images using 1 million captioned photographs.  In J. Shawe-Taylor, R. Zemel, P. Bartlett, F. Pereira, and K.Q. Weinberger, editors, Advances in Neural Information Processing Systems, volume 24. Curran Associates, Inc., 2011.
  * [49] Ranjay Krishna, Yuke Zhu, Oliver Groth, Justin Johnson, Kenji Hata, Joshua Kravitz, Stephanie Chen, Yannis Kalantidis, Li-Jia Li, David A. Shamma, Michael S. Bernstein, and Fei-Fei Li.  Visual genome: Connecting language and vision using crowdsourced dense image annotations, 2016.
  * [50] Soravit Changpinyo, Piyush Sharma, Nan Ding, and Radu Soricut.  Conceptual 12m: Pushing web-scale image-text pre-training to recognize long-tail visual concepts, 2021.
  * [51] Tsung-Yi Lin, Michael Maire, Serge Belongie, Lubomir Bourdev, Ross Girshick, James Hays, Pietro Perona, Deva Ramanan, C. Lawrence Zitnick, and Piotr Dollár.  Microsoft coco: Common objects in context, 2014.
  * [52] Matt Post.  A call for clarity in reporting BLEU scores.  In Proceedings of the Third Conference on Machine Translation: Research Papers, pages 186–191, Belgium, Brussels, October 2018. Association for Computational Linguistics.
  * [53] Kunpeng Li, Yulun Zhang, Kai Li, Yuanyuan Li, and Yun Fu.  Visual semantic reasoning for image-text matching.  In ICCV, 2019.
  * [54] Peter Young, Alice Lai, Micah Hodosh, and Julia Hockenmaier.  From image descriptions to visual denotations: New similarity metrics for semantic inference over event descriptions.  Transactions of the Association for Computational Linguistics, 2:67–78, 2014.
  * [55] Young-Jun Lee, Byungsoo Ko, Han-Gyu Kim, and Ho-Jin Choi.  Dialogcc: Large-scale multi-modal dialogue dataset, 2022.
  * [56] Saizheng Zhang, Emily Dinan, Jack Urbanek, Arthur Szlam, Douwe Kiela, and Jason Weston.  Personalizing dialogue agents: I have a dog, do you have pets too?  2018\.
  * [57] Yanran Li, Hui Su, Xiaoyu Shen, Wenjie Li, Ziqiang Cao, and Shuzi Niu.  Dailydialog: A manually labelled multi-turn dialogue dataset.  2017\.
  * [58] Leyang Cui, Yu Wu, Shujie Liu, Yue Zhang, and Ming Zhou.  MuTual: A dataset for multi-turn dialogue reasoning.  In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 1406–1416, Online, July 2020. Association for Computational Linguistics.
  * [59] Pei Zhou, Karthik Gopalakrishnan, Behnam Hedayatnia, Seokhwan Kim, Jay Pujara, Xiang Ren, Yang Liu, and Dilek Hakkani-Tur.  Commonsense-focused dialogues for response generation: An empirical study, 2021.
  * [60] Hannah Rashkin, Eric Michael Smith, Margaret Li, and Y-Lan Boureau.  Towards empathetic open-domain conversation models: a new benchmark and dataset, 2018.
  * [61] Kai Sun, Dian Yu, Jianshu Chen, Dong Yu, Yejin Choi, and Claire Cardie.  Dream: A challenge dataset and models for dialogue-based reading comprehension, 2019.
  * [62] F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay.  Scikit-learn: Machine learning in Python.  Journal of Machine Learning Research, 12:2825–2830, 2011.
  * [63] Junnan Li, Dongxu Li, Caiming Xiong, and Steven Hoi.  Blip: Bootstrapping language-image pre-training for unified vision-language understanding and generation.  In ICML, 2022.
  * [64] Dongxu Li, Junnan Li, Hung Le, Guangsen Wang, Silvio Savarese, and Steven C. H. Hoi.  Lavis: A library for language-vision intelligence, 2022.
  * [65] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby.  An image is worth 16x16 words: Transformers for image recognition at scale, 2020.
  * [66] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova.  Bert: Pre-training of deep bidirectional transformers for language understanding, 2018.
  * [67] Dan Hendrycks and Kevin Gimpel.  Gaussian error linear units (gelus), 2016.
  * [68] Alejandro Jesús Castañeira Rodríguez, Daniel Castro Castro, and Silena Herold García.  Noun-based attention mechanism for fine-grained named entity recognition.  Expert Systems with Applications, 193:116406, 2022.
  * [69] Nils Reimers and Iryna Gurevych.  Sentence-bert: Sentence embeddings using siamese bert-networks.  In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing. Association for Computational Linguistics, 11 2019\.
  * [70] Sergey Shkarin.  ruTS, a library for statistics extraction from texts in Russian.  Moscow, 2023.

## Appendix A. Implementation details

Formally pairs of utterance and images are made this way.

Giver set of images $I$, we created pairs

$\forall u\quad\exists\,(u,img):img=\operatorname{argmax}_{i\in
I}\\{\operatorname{cosine}(\operatorname{emb}_{CLIP}(u),\operatorname{emb}_{CLIP}(i))\\}$

, where $\operatorname{emb}_{CLIP}(u)$ is taking embedding from CLIP for
utterance and $\operatorname{emb}_{CLIP}(i)$ is taking embedding from CLIP for
images and $\operatorname{cosine}(a,b)=\frac{a\cdot b}{\|a\|\cdot\|b\|}$ is
calculating cosine similarity between vectors in a usual sense.

Main features are described in depth below:

Image Score. For utterance $\operatorname{IS}(u)$ is the maximum cosine
similarity between utterance and all images embeddings extracted from CLIP.

$\displaystyle\max_{i\in
I}\\{\operatorname{cosine}(\operatorname{emb}_{CLIP}(u),\operatorname{emb}_{CLIP}(i))\\}$

Maximum Entity Score. We follow the idea, that most of entities in the NER
datasets are nouns [68]. First, each utterance undergoes a noun extraction
process and has corresponding noun set $ENT_{u}=\\{noun\,|\,\forall noun\in
u\\}$. Second, for each entity in the set Image Score is calculated
$\operatorname{IS}(entity)$. That forms set of Image Scores of utterance nouns
which we call Entity Scores for utterance
$ES_{u}=\\{\operatorname{IS}(entity)\,|\,\forall entity\in ENT_{u}\\}$.
Finally, we take maximum of Entity Scores $\operatorname{MES}(u)=\max ES_{u}$.

Sentence Similarity. It is obtained from comparing image caption and initial
utterance. First, for each corresponding image captions are generated
$\operatorname{caption}(img)$. We do this with VIT-GPT2 model [41]. Then we
find similarity between utterance and generated caption with cosine distance
between their embeddings from SentenceBert
$\operatorname{SS}(u,img)=\operatorname{cosine}(\operatorname{emb}_{SB}(u),\operatorname{emb}_{SB}(\operatorname{caption}(img))$
[69] .

BLEU Score. BLEU [52] metric for only unigrams between generated caption and
utterance $\operatorname{BLEU_{1}}(u,\operatorname{caption}(img))$.

Threshold. Binary feature that shows if utterances features listed above are
greater than founded thresholds. We found thresholds for Image Score $t_{IS}$,
Sentence Similarity $t_{SS}$ and Maximum Entity Score $t_{MES}$ by maximizing
precision on labeled subset $U$ via grid-search on triplets
$(t_{IS},t_{SS},t_{MES})$. To reduce the computations, each threshold was
chosen as k-th statistic in set of train values sorted in descending order.
Therefore we were grid searching through k-th statistic for each parameter
with step equals 10. Formally, threshold is
$THR_{u,img}=\mathbbm{1}\\{\operatorname{SS}(u,img)>=t_{SS}\\}\mathbbm{1}\\{\operatorname{MES}(u)>=t_{MES}\\}\mathbbm{1}\\{\operatorname{IS}(u)>=t_{IS}\\}$

The hyperparameters were determined through a grid-search that maximized the
precision score. The resulting model consisted of 500 estimators with class
weights of 5 to 1 for not-replaceable and replaceable, respectively. The model
used the Gini criterion, a maximum depth of 2, and the square root of the
number of features in each estimator.

Thresholds features were tested on labeled dataset and brute forced on the 10
step grid. We report on listed below thresholds, that results in precision =
0.921171 and recall = 0.068.

  * •

Image Score = 0.33265801843083337

  * •

Sentence Similarity = 0.12116438820166667

  * •

Maximum Entity Score = 0.3103302687291667

There is a list of pictorialization features that were tested, but resulted in
worse metrics.

  * •

Embedding representations from SentenceBERT and subsets of embeddings
representation

  * •

Image-text matching loss from BLIP

  * •

Answers from VQA model to the question "does statement *utterance* describe
picture well?" transitioned to binary feauture for model output "yes" and "no"

  * •

Answers from VQA model to the question "Can the utterance *utterance* be
described by the picture?" transitioned to binary feauture for model output
"yes" and "no"

  * •

Cardinality of intersection between nouns from utterance and objects that VQA
answers to the question "what objects are in the picture?"

  * •

Confidence of model on "The picture shows *utterance*". It was calculated as
sum of logarithmic probabilities of tokenized phrase without taking in account
pattern phrase "The picture shows".

  * •

Text feauteres: Number of parts of speech in utterance, punctuation in
utterance, utterance length, number of words, SMOG Index, LIX Index,
Flesch–Kincaid readability tests, Coleman–Liau index. Lexical diversity
metrics: TTR, RTTR, CTTR, HTTR, STTR, MTTR, DTTR, MATTR, MSTTR, MTLD, MAMTLD,
HD-D [70]

Figure 2: Feature Importance in Random Forest Model for predicting if an utterance could be replaced with an image. Image Score is maximum cosine similarity between utterance and images embeddings from CLIP. Threshold is binary feature, indicating if Image Score, Sentence Similarity and Maximum Entity Score is bigger than empirically founded values. Sentence Similarity is cosine distance similarity between utterance embedding and caption embedding, that were generated from corresponding image with VIT-GPT2, where embeddings come from SentenceBert. BLEU is calculated between utterance and generated caption with taking only unigrams into account. Maximum Entity Score is maximum out of Image Scores for each noun in utterance. Table 6: Metrics for best (in terms of Precision) Random Forest model for predicting if utterance is replaceable Metric | Mean | Standart Deviation | Median
---|---|---|---
Precision | 0.975000 | 0.156125 | 1.000000
Recall | 0.030990 | 0.006374 | 0.031250
F1 | 0.060042 | 0.012072 | 0.060606
Table 7: Comparison for different ML Algorithms in terms of Precision and Recall Algorithm | Precision | Recall
---|---|---
Random Forest | 0.975000 | 0.030990
Kernel SVM | 0.958333 | 0.037500
Gradient Boosting | 0.816667 | 0.026302
KNN | 0.500188 | 0.035677

## Appendix B. Dataset Reasoning

DailyDialog [57]. Daily Dialog is a popular source of human-written dialogues,
contains 76k utterances with context. Moreover, dialogues stick to the certain
topic or object and they end after reasonable turn. These features are
essential for building context related models.

Mutual dataset [58]. This dataset was crawled from English students books,
writtend with expert linguists and contains dialogues with reasonings.
Contains 18k utterance with context.

Common Sense Dialogues [59]. This dataset focuses on real-life common sense
dialogues. It contains 43k utterances with context from human-written
dialogues, collected from assessors on Amazon Mechanical Turk (MTurk).

Empathetic Dialogues [60]. This dataset was also collected via MTurk. The main
goal is to focus on emotional and personal dialogues. It contains 76k
utterances with context.

Dream Dataset [61]. This dataset contains 14k utterances with context from
dialogues from English students books. The goal is to make wide range of
dialogues, that would include both common knowledge and reasoning.

Persona Chat [56]. We have utilized Persona Chat because it was collected
using assessors and contains 223k utterances with context from small real life
dialogues. It was well validated and contains dialogues with personas.

## Appendix C. Training Details

To evaluate the contribution of visual information into solving the task we
finetune two models in different settings: using both image and context as
input and replacing image feature vector with constant input. We expect the
model which has access to visual modality to perform better, which would mean
that images in the composed dataset are actually relevant and useful for
utterance prediction.

To train our models we utilise a prefix LM learning paradigm as opposed to
usual next token prediction used to finetune BLIP on captioning tasks. We use
the image and the last utterance before the image as inputs for the model and
aim to predict the substituted utterance. We let the decoder use a square
attention mask for the context tokens and a triangular attention mask for the
utterance tokens we want to predict.

For both models we freeze the image encoder part during training for
efficiency and to reduce compute cost.

Both models are trained on 4336 samples from the composed dataset, leaving 400
samples for validation, for 20 epochs with batch size of 10 samples, learning
rate of 1e-5, and cosine learning rate scheduler with linear warmup (Figure
3). For each setting we train 5 models initializing from different seeds for
better quality estimation.

Figure 3: Training metrics: left figure shows train and validation loss for
both finetuned BLIP models during training, right figure shows BLEU-1 metrics
on validation during training.

## Appendix D. Labeling methodology

The detailed description for classes are the following:

  1. 1.

Perfect Match. This label is assigned when utterance has only 1 sense, and it
is fully transferred with an image. If image could not transfer fully the
sense of utterance and it could be done only with context knowledge, then also
this label is assigned. There should be no factual mistakes, image should not
be specific to cultural differences. The heuristic rule was to question
yourself "Could i possibly came to this phrase, knowing image and context?".

  2. 2.

Partial Match. This label is assigned when utterance has 2 or more distinct
senses and image transfers one of them fully. It also should not be specific
to culture or contain mistakes. In fact rules are the same as for Perfect
Match, but applied to one of the senses in the utterances contains 2 or more
senses.

  3. 3.

Undefined. This label is assigned when image is specific to cultural
differences or when image can not transfer one of the senses of the utterance
and the context could not help to recover untransferred sense.

  4. 4.

No Match. This label is assigned when image contains factual errors about
utterance or when none of the entities from utterance present in the image.

A decision tree was designed as the primary instruction for the labeling
process, which aimed to assist the assessors in assigning appropriate labels
to the samples. The decision tree was presented in Figure 4 and consisted of
closed questions at each node, or terminal nodes containing the desired label.
The assessors were instructed to follow the decision tree, starting from the
root node and answering the questions until the label for each sample was
reached. This strategy yielded high inter-rater reliability among the 3
assessors, indicating its efficacy in achieving consistent labeling outcomes.

Figure 4: Labeling Methodology


11institutetext: Indian Institute of Technology, Kharagpur, West Bengal, India
11email: {kamalojasv181, adarshkumar712.ak<EMAIL_ADDRESS>
# Hostility Detection in Hindi leveraging Pre-Trained Language Models††thanks:
Shared Task in CONSTRAINT 2021

Ojasv Kamal Equal Contribution Adarsh Kumar† Tejas Vaidhya

###### Abstract

Hostile content on social platforms is ever increasing. This has led to the
need for proper detection of hostile posts so that appropriate action can be
taken to tackle them. Though a lot of work has been done recently in the
English Language to solve the problem of hostile content online, similar works
in Indian Languages are quite hard to find. This paper presents a transfer
learning based approach to classify social media (i.e Twitter, Facebook, etc.)
posts in Hindi Devanagari script as Hostile or Non-Hostile. Hostile posts are
further analyzed to determine if they are Hateful, Fake, Defamation, and
Offensive. This paper harnesses attention based pre-trained models fine-tuned
on Hindi data with Hostile-Non hostile task as Auxiliary and fusing its
features for further sub-tasks classification. Through this approach, we
establish a robust and consistent model without any ensembling or complex pre-
processing. We have presented the results from our approach in CONSTRAINT-2021
Shared Task[21] on hostile post detection where our model performs extremely
well with 3rd runner up in terms of Weighted Fine-Grained F1 Score111refer
Section 4.3 for description of Weighted Fine-grained f1-score.

###### Keywords:

Hostility Detection Pre-trained Models Natural Language Processing Social
media Hindi Language

##  1 Introduction

Social media is undoubtedly one of the greatest innovations of all time. From
connecting with people across the globe to sharing of information and
knowledge in a minuscule of a second, social media platforms have tremendously
changed the way of our lives. This is accompanied by an ever-increasing usage
of social media, cheaper smartphones, and the ease of internet access, which
have further paved the way for the massive growth of social media. To put this
into numbers, as per a recent
report222https://datareportal.com/reports/digital-2020-october-global-
statshot, more than 4 billion people around the world now use social media
each month, and an average of nearly 2 million new users are joining them
every day.

While social media platforms have allowed us to connect with others and
strengthen relationships in ways that were not possible before, sadly, they
have also become the default forums for holding high-stakes conversations,
blasting polarizing opinions, and making statements with little regard for
those within the screenshot. The recent increase in online toxicity instances
has given rise to the dire need for adequate and appropriate guidelines to
prevent and curb such activities. The foremost task in neutralising them is
hostile post detection. So far, many works have been carried out to address
the issue in English [18, 28] and several other languages [2, 16]. Although
Hindi is the third largest language in terms of speakers and has a significant
presence on social media platforms, considerable research on hate speech or
fake content is still quite hard to find. A survey of the literature suggests
a few works related to hostile post detection in Hindi, such as [9, 25];
however, these works are either limited by inadequate number of samples, or
restricted to a specific hostility domain.

A comprehensive approach for hostile language detection on hostile posts,
written in Devanagari script, is presented in [1], where the authors have
emphasized multi-dimensional hostility detection and have released the dataset
as a shared task in Constraint-2021 Workshop. This paper presents a transfer
learning based approach to detect Hostile content in Hindi leveraging Pre-
trained models, with our experiments based on this dataset. The experiments
are subdivided into two tasks, Coarse Grained task: Hostile vs. Non-Hostile
Classification and Fine Grained subtasks: Sub-categorization of Hostile posts
into fake, hate, defamation, and offensive.

Our contribution comprises of improvements upon the baseline in the following
ways:

1\. We fine-tuned transformer based pre-trained, Hindi Language Models for
domain-specific contextual embeddings, which are further used in
Classification Tasks.
2\. We incorporate the fine-tuned hostile vs. non-hostile detection model as
an auxiliary model, and fuse it with the features of specific subcategory
models (pre-trained models) of hostility category, with further fine-tuning.

Apart from this, we have also presented a comparative analysis of various
approaches we have experimented on, using the dataset. The code and trained
models are available at this https
url333https://github.com/kamalojasv181/Hostility-Detection-in-Hindi-Posts.git

##  2 Related Work

In this section, we discuss some relevant work in NLP for Pre-Trained Model
based Text Classification and Hostile Post Detection, particularly in the
Indian Languages.

### Pretrained-Language Models in Text Classification

Pre-trained transformers serve as general language understanding models that
can be used in a wide variety of downstream NLP tasks. Several transformer-
based language models such as GPT [23], BERT [5], RoBERTa [14], etc. have been
proposed. Pre-trained contextualized vector representations of words, learned
from vast amounts of text data have shown promising results in the task of
text classification. Transfer learning from these models has proven to be
particularly useful in tasks where there is a lack of undisputed labeled data
and the inability of surface features to capture the subtle semantics in the
text as in the case of hate speech [15]. However, all these pre-trained models
require large amounts of monolingual corpus to train on. Nonetheless, Indic-
NLP [11] and Indic-Transformers [8] have curated datasets, trained embeddings,
and created benchmarks for classification in multiple Indian languages
including hindi. [10] presented a comparative study of various classification
techniques for Hindi, where they have demonstrated the effectiveness of Pre-
trained sentence embedding in classification tasks.

### Hostile Post Detection

Researchers have been studying hate speech on social media platforms such as
Twitter [29], Reddit [17], and YouTube [19] in the past few years.
Furthermore, researchers have recently focused on the bias derived from the
hate speech training datasets [3]. Among other notable works on hostility
detection, Davidson et al. [4] studied the hate speech detection for English.
They argued that some words might reflect hate in one region; however, the
same word can be used as a frequent slang term. For example, in English, the
term ‘dog’ does not reveal any hate or offense, but in Hindi (ku##a) is
commonly referred to as a derogatory term in Hindi. Considering the severity
of the problem, some efforts have been made in Non-English languages as well
[16, 2, 7, 25]. Bhardwaj et al. [1] proposed a multi-dimensional hostility
detection dataset in Hindi which we have focused on, in our experiments. Apart
from this, there are also a few attempts at Hindi-English code-mixed hate
speech [26].

##  3 Methodology

In the following subsections, we briefly discuss the various methodologies
used in our experiments. Each subsection describes an independent approach
used for classification and sub-classification tasks. Our final approach is
discussed in Section 3.4.

###  3.1 Single Model Multi-Label Classification

In this approach, we treat the problem as a Multi-label classification task.
We use a single model with shared parameters for all classes to capture
correlations amongst them. We fine tuned the pre-trained BERT transformer
model to get contextualized embedding or representation by using attention
mechanism. We experimented with three different versions of pre-trained BERT
transformer blocks, namely Hindi BERT(a compressed form of BERT)[6], Indic
BERT(based on the ALBERT architecture)[11], and a HindiBERTa model[24]. The
loss function used in this approach can be formulated mathematically as:

$L(\hat{y},y)=-\sum_{j=1}^{c}y_{j}log\hat{y_{j}}+(1-y_{j})log(1-\hat{y_{j}})$
$J(W^{(1)},b^{(1)},...)=1/m\sum_{i=1}^{m}L(\hat{y^{i}},y^{(i)})$

where, c is total number of training examples and m is number of different
classes (i.e. non-hostile, fake, hate, defamation, offensive)

###  3.2 Multi-Task Classification

In this approach, we considered the classification tasks as a Multi-task
Classification problem. As described in Figure 1, we use a shared BERT model
and individual classifier layers, trained jointly with heuristic loss. This is
done so as to capture correlations between tasks and subtasks in terms of
contextualized embeddings from shared BERT model while maintaining
independence in classification tasks. We experimented with Indic-BERT and
HindiBERTa (we dropped the Hindi BERT model in this approach as the
performance was poor compared to the other two models because of shallow
architecture). The heuristic loss can be formulated mathematically as:

$L=l(x,y)={\\{l_{1},...,l_{N}\\}}^{T}$

where,

$l_{n}=-w_{n}[y_{n}\cdot log\sigma(x_{n})+(1-y_{n})\cdot
log(1-\sigma(x_{n}))]$

$L_{total}=L_{(hostile/non-hostile)}+\lambda\cdot
1/N\\{L_{(hurt,defame,fake,offensive)}\\}$

if post is Hostile $\lambda=0.5$ (contributing to fine grain task ), otherwise
$\lambda=0$

###  3.3 Binary Classification

Unlike the previous two approaches, here we consider each classification task
as an individual binary classification problem based on fine tuned
contextualised embedding. We fine tuned the BERT transformer block and the
classifier layer above it using the binary target labels for individual
classes. Same as in Multi-task approach, we experimented this approach with
Indic-BERT and HindiBERTa. Binary cross-entropy loss used in this approach can
be mathematically formulated as follows:

$L_{i}(\hat{y},y)=-\sum_{j=1}^{c}y_{j}log\hat{y_{j}}+(1-y_{j})log(1-\hat{y_{j}})$

where, c is total number of training examples and i is number of independent
models for each task

###  3.4 Auxiliary Task Based Binary Sub-Classification

Similar to the previous approach, each classification task is considered as an
individual binary classification problem. However, as an improvement over the
previous approach, we treat the coarse-grained task as an Auxiliary task and
then fuse its logits to each of the fine-grained subtasks. The motivation is
that a hostile sub-class specific information shall be present in a post only
if the post belongs to hostile class[12]. So, treating it as an Auxiliary task
allow us to exploit additional hostile class-specific information from the
logits of Auxiliary model. The loss function used in this case was same as
described in Binary Classification. The model is described in Figure 1.

Figure 1: (a) Multi-Task Classification Model (b)Auxiliary Task Based Binary
sub classification model.

##  4 Experiment

In this section, we first introduce the dataset used and then provide
implementation details of our experiments in their respective subsections.

###  4.1 Dataset Description

As already mentioned in Section 1, we evaluate our approach based on the
dataset proposed in [1]. As described in the dataset paper, the objective of
the task is a classification of posts as Hostile and Non-Hostile and further
Multi-label classification of Hostile posts into _fake_ , _hate_ , _offensive_
, and _defame_ classes. The dataset consists of 8192 online posts out of which
4358 samples belong to the non-hostile category, while the rest 3834 posts
convey one or more hostile dimensions. There are 1638, 1132, 1071, and 810
posts for fake, hate, offensive, and defame classes in the annotated dataset,
respectively. Same as in the paper [1], we split the dataset into 70:10:20 for
train, validation, and test, by ensuring the uniform label distribution among
the three sets, respectively.

###  4.2 Pre-Processing

Prior to training models, we perform the following pre-processing steps:

  * $\bullet$

We remove all non-alphanumeric characters except full stop punctuation marks (
$|$ , ? ) in Hindi, but we keep all stop words because our model trains the
sequence of words in a text directly.

  * $\bullet$

We replace all user mentions and hashtags with a blank space.

  * $\bullet$

We skip emojis, emoticons, flags etc from the posts.

  * $\bullet$

We replace the URLs with the string ‘http‘.

###  4.3 Experimental Setup

All the experiments were performed using Pytorch [20] and HuggingFace [30]
Transformers library. As the implementation environment, we used Google
Colaboratory tool which is a free research tool with a Tesla K80 GPU and 12GB
RAM. Optimization was done using Adam [13] with a learning rate of 1e-5. As
discussed earlier in section 3, in our experiments, we used pre-trained
HindiBert[6], IndicBert[11] and HindiBERTa [24] Models available in
HuggingFace library. Input sentences were tokenized using respective
tokenizers for each model, with maximum sequence length restricted to 200
tokens. We trained each classifier model with a batch size of 16. In all the
approaches, we used only the first token output provided by each model as
input to classifier layer. Each classifier layer has 1 dropout layer with
dropout of 0.3 and 1 fully connected layer. Each sub-classification task (fine
grained task) was trained only on the hostile labeled examples, i.e. the posts
that had at least one label of hostile class, so as to avoid extreme class-
imbalance caused by including non-hostile examples. For the evaluation, we
have used weighted f1 score [22] as a metric for measuring the performance in
both the classification tasks. As suggested in the CONSTRAINT-2021 shared
task[21], to measure the combined performance of 4 individual fine-grained
sub-tasks together, we have used weighted fine-grained f1 score as the metric,
where the weights for the scores of individual classes are the fraction of
their positive examples.

##  5 Results

Table 1: Results obtained using various methods and models used. Here, Baseline: as described in the dataset paper [1], MLC: Multi Label Classification, MTL: Multitask Learning, BC: Binary Classification and AUX: Auxiliary Model Method | Model | Hostile | Defamation | Fake | Hate | Offensive | Weighted
---|---|---|---|---|---|---|---
Baseline | - | 0.8422 | 0.3992 | 0.6869 | 0.4926 | 0.4198 | 0.542
MLC | Hindi-BERT | 0.952 | 0.0 | 0.7528 | 0.4206 | 0.5274 | 0.4912
| Indic-BERT | 0.9581 | 0.3787 | 0.7228 | 0.3094 | 0.5152 | 0.513
| HindiBERTa | 0.9507 | 0.3239 | 0.7317 | 0.4120 | 0.4106 | 0.5122
MTL | Indic-BERT | 0.9284 | 0.0513 | 0.3296 | 0.0 | 0.0 | 0.1260
| HindiBERTa | 0.9421 | 0.31 | 0.6647 | 0.2353 | 0.5545 | 0.4738
BC | Hindi-BERT | 0.9359 | 0.130 | 0.7164 | 0.47698 | 0.5388 | 0.5169
| Indic-BERT | 0.9520 | 0.3030 | 0.757 | 0.4745 | 0.5446 | 0.5618
| HindiBERTa | 0.9421 | 0.2707 | 0.6596 | 0.3175 | 0.6098 | 0.4960
AUX | Indic-BERT | 0.9583 | 0.42 | 0.7741 | 0.5725 | 0.6120 | 0.6250
| HindiBERTa | 0.9486 | 0.3855 | 0.7612 | 0.5663 | 0.5933 | 0.6086

In this section, we discuss the results from the different approaches proposed
in section 3. Table 1 summarizes the obtained results for different
approaches, along with the baseline [1]. Since hostile/non-hostile posts are
real phenomenon, we did not perform oversampling and undersampling techniques
to adjust class distribution and tried to supply the dataset as realistic as
possible. This was done to avoid overfitting (in case of oversampling) and the
loss of crucial data (in case of undersampling). As it’s clear from Table 1,
our best model based on approach described in section 3.4 with Indic-BERT
model outperforms the baseline as well as other approaches in both the tasks,
i.e. Coarse Grained Task of Hostile vs. Non-Hostile Classification and Fine
Grained Task of Hostile Sub-Classification. Moreover, our best model stands as
the 3rd runner up in terms of Weighted fine grained f1 score in the
CONSTRAINT-2021 shared task on Hostile Post detection ( Results can be viewed
here444Our team name is Monolith).

##  6 Error Analysis

Table 2:  Misclassified Samples from the dataset
---

Although we have received some interesting results, there are certain
dimensions where our approach does not perform as expected. Through this
section we try to better understand the obtained f1 scores through some
general observations and some specific examples (refer Table 2). Our model did
perform comparatively better in fake dimension which implies the model was
able to capture patterns in fake samples from dataset to a large extent.
However, as can be seen in the example 1, the fake / non-fake classification
of posts in certain cases largely context / knowledge based. Therefore, in
absence of any external knowledge, the method is quite inefficient,
particularly in those kind of samples which are under-represented in the
dataset. Apart from this, we observe that the defamation scores are the lowest
in general. This could be mainly attributed to the overall under-
representation of the class in the dataset. Hence a more balanced dataset is
critical to boost the defamation f1 score.

Another important observation to note is the existence of metaphorical data in
the dataset, which implies meaning different from what semantic information is
absent. For example, consider example 2 in the Table 2. This tweet has been
inspired by the Hindi idiom which means a person after committing every sin in
the rule book looks to God for atonement and is used to refer to a
hypocritical person indirectly. Such examples lead to mis-classification by
models which are primarily based on contextualized embeddings training on
simple datasets, as in our case. However, this could be eliminated if the
models are pre-trained / fine-tuned on datasets which contain more such
examples of metaphorical samples. From our manual inspection, we also observed
that the dataset includes some examples, the labels of which are not even
apparent to us. For instance, consider example 4. This example simply urges
people to speak up and for some cause. Such type of sentence are quite often
noticeable in hindi literature. It is impossible to conclude that it is an
offensive post with the given data. However, the fact that it is correctly
classified by our model reflects bias in the dataset with respect to certain
kind of examples, against a generalization of the ”Offensive” dimension. Apart
from this, we also found some examples which, in our opinion are labeled
incorrectly or are possibly ambiguous to be categorised in dimensions being
considered. Example 5 means we do not want a favour we only ask for what we
deserve which is labeled as defamation however according to us, it is
ambiguous to classify it into any of the considered dimensions and largely
dependent on the context. Similarly in example 6, someone is being referred as
ku##e which means a dog, according to us it should be hate but is not labeled
as hate.

##  7 Conclusion and Future Work

In this paper, we have presented a transfer learning based approach leveraging
the pre-trained language models, for Multi-dimensional Hostile post detection.
As the evaluation results indicate, our final approach outperforms baseline,
by a significant margin in all dimensions. Furthermore, examining the results
shows the ability of our model to detect some biases and ambiguities in the
process of collecting or annotating dataset.

There is a lot of scope of improvement for fine Grained with few positive
labels. Pre-training on relevant data (such as offensive or hate speech) is a
promising direction. In case of Fake news detection, it is very difficult to
verify the claim without the use of external knowledge. In future, we would
like to extend the approach purposed in paper [27], by using processed-
wikipedia knowledge it is possible to significantly improve fake news
detection accuracy.

## Acknowledgement

We are very grateful for the invaluable suggestions given by Ayush Kaushal. We
also thank the organizers of the Shared Task.

## References

  * [1] Bhardwaj, M., Akhtar, M.S., Ekbal, A., Das, A., Chakraborty, T.: Hostility detection dataset in hindi (2020), http://arxiv.org/abs/2011.03588
  * [2] Chowdhury, S.A., Mubarak, H., Abdelali, A., Jung, S.g., Jansen, B.J., Salminen, J.: A multi-platform Arabic news comment dataset for offensive language detection. In: Proceedings of the 12th Language Resources and Evaluation Conference. pp. 6203–6212. European Language Resources Association, Marseille, France (May 2020), https://www.aclweb.org/anthology/2020.lrec-1.761
  * [3] Davidson, T., Bhattacharya, D., Weber, I.: Racial bias in hate speech and abusive language detection datasets. In: Proceedings of the Third Workshop on Abusive Language Online. pp. 25–35. Association for Computational Linguistics, Florence, Italy (Aug 2019). https://doi.org/10.18653/v1/W19-3504, https://www.aclweb.org/anthology/W19-3504
  * [4] Davidson, T., Warmsley, D., Macy, M.W., Weber, I.: Automated hate speech detection and the problem of offensive language. CoRR abs/1703.04009 (2017), http://arxiv.org/abs/1703.04009
  * [5] Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: BERT: Pre-training of deep bidirectional transformers for language understanding. In: Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). pp. 4171–4186. Minneapolis, Minnesota (Jun 2019), https://www.aclweb.org/anthology/N19-1423
  * [6] Doiron, N.: https://huggingface.co/monsoon-nlp/hindi-bert
  * [7] Hossain, M.Z., Rahman, M.A., Islam, M.S., Kar, S.: BanFakeNews: A dataset for detecting fake news in Bangla. In: Proceedings of the 12th Language Resources and Evaluation Conference. pp. 2862–2871. European Language Resources Association, Marseille, France (May 2020), https://www.aclweb.org/anthology/2020.lrec-1.349
  * [8] Jain, K., Deshpande, A., Shridhar, K., Laumann, F., Dash, A.: Indic-transformers: An analysis of transformer language models for indian languages (2020)
  * [9] Jha, V.K., P, H., P N, V., Vijayan, V., P, P.: Dhot-repository and classification of offensive tweets in the hindi language. Procedia Computer Science 171, 2324 – 2333 (2020), http://www.sciencedirect.com/science/article/pii/S1877050920312448, third International Conference on Computing and Network Communications (CoCoNet’19)
  * [10] Joshi, R., Goel, P., Joshi, R.: Deep learning for hindi text classification: A comparison. Lecture Notes in Computer Science p. 94–101 (2020), http://dx.doi.org/10.1007/978-3-030-44689-5_9
  * [11] Kakwani, D., Kunchukuttan, A., Golla, S., N.C., G., Bhattacharyya, A., Khapra, M.M., Kumar, P.: IndicNLPSuite: Monolingual corpora, evaluation benchmarks and pre-trained multilingual language models for Indian languages. In: Findings of the Association for Computational Linguistics: EMNLP 2020. pp. 4948–4961. Online (Nov 2020), https://www.aclweb.org/anthology/2020.findings-emnlp.445
  * [12] Kaushal, A., Vaidhya, T.: Winners at w-nut 2020 shared task-3: Leveraging event specific and chunk span information for extracting covid entities from tweets. Proceedings of the Sixth Workshop on Noisy User-generated Text (W-NUT 2020) (2020). https://doi.org/10.18653/v1/2020.wnut-1.79, http://dx.doi.org/10.18653/v1/2020.wnut-1.79
  * [13] Kingma, D.P., Ba, J.: Adam: A method for stochastic optimization (2017)
  * [14] Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., Stoyanov, V.: Roberta: A robustly optimized BERT pretraining approach. CoRR abs/1907.11692 (2019), http://arxiv.org/abs/1907.11692
  * [15] Malmasi, S., Zampieri, M.: Challenges in discriminating profanity from hate speech. CoRR abs/1803.05495 (2018), http://arxiv.org/abs/1803.05495
  * [16] Mitrović, J., Handschuh, S.: upinf - offensive language detection in german tweets. In: Proceedings of the GermEval 2018 Workshop 14th Conference on Natural Language Processing (09 2018)
  * [17] Mittos, A., Zannettou, S., Blackburn, J., Cristofaro, E.D.: ”and we will fight for our race!” A measurement study of genetic testing conversations on reddit and 4chan. CoRR abs/1901.09735 (2019), http://arxiv.org/abs/1901.09735
  * [18] Nobata, C., Tetreault, J., Thomas, A., Mehdad, Y., Chang, Y.: Abusive language detection in online user content. Proceedings of the 25th International Conference on World Wide Web (2016)
  * [19] Ottoni, R., Cunha, E., Magno, G., Bernardina, P., Meira, W., Almeida, V.: Analyzing right-wing youtube channels: Hate, violence and discrimination (2018)
  * [20] Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., Desmaison, A., Köpf, A., Yang, E., DeVito, Z., Raison, M., Tejani, A., Chilamkurthy, S., Steiner, B., Fang, L., Bai, J., Chintala, S.: Pytorch: An imperative style, high-performance deep learning library. CoRR abs/1912.01703 (2019), http://arxiv.org/abs/1912.01703
  * [21] Patwa, P., Bhardwaj, M., Guptha, V., Kumari, G., Sharma, S., PYKL, S., Das, A., Ekbal, A., Akhtar, M.S., Chakraborty, T.: Overview of constraint 2021 shared tasks: Detecting english covid-19 fake news and hindi hostile posts. In: Proceedings of the First Workshop on Combating Online Hostile Posts in Regional Languages during Emergency Situation (CONSTRAINT). Springer (2021)
  * [22] Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., Duchesnay, E.: Scikit-learn: Machine learning in Python. Journal of Machine Learning Research 12, 2825–2830 (2011)
  * [23] Radford, A.: Improving language understanding by generative pre-training (2018)
  * [24] Romero, M.: https://huggingface.co/mrm8488/HindiBERTa
  * [25] Safi Samghabadi, N., Patwa, P., PYKL, S., Mukherjee, P., Das, A., Solorio, T.: Aggression and misogyny detection using BERT: A multi-task approach. In: Proceedings of the Second Workshop on Trolling, Aggression and Cyberbullying. pp. 126–131. European Language Resources Association (ELRA), Marseille, France (May 2020), https://www.aclweb.org/anthology/2020.trac-1.20
  * [26] Sreelakshmi, K., Premjith, B., Soman, K.: Detection of hate speech text in hindi-english code-mixed data. Procedia Computer Science 171, 737 – 744 (2020). https://doi.org/https://doi.org/10.1016/j.procs.2020.04.080, http://www.sciencedirect.com/science/article/pii/S1877050920310498, third International Conference on Computing and Network Communications (CoCoNet’19)
  * [27] Thorne, J., Vlachos, A., Christodoulopoulos, C., Mittal, A.: Fever: a large-scale dataset for fact extraction and verification (2018), http://arxiv.org/abs/1803.05355
  * [28] Waseem, Z., Davidson, T., Warmsley, D., Weber, I.: Understanding abuse: A typology of abusive language detection subtasks. In: Proceedings of the First Workshop on Abusive Language Online. pp. 78–84. Association for Computational Linguistics, Vancouver, BC, Canada (Aug 2017). https://doi.org/10.18653/v1/W17-3012, https://www.aclweb.org/anthology/W17-3012
  * [29] Wijesiriwardene, T., Inan, H., Kursuncu, U., Gaur, M., Shalin, V.L., Thirunarayan, K., Sheth, A., Arpinar, I.B.: Alone: A dataset for toxic behavior among adolescents on twitter (2020)
  * [30] Wolf, T., Debut, L., Sanh, V., Chaumond, J., Delangue, C., Moi, A., Cistac, P., Rault, T., Louf, R., Funtowicz, M., Brew, J.: Huggingface’s transformers: State-of-the-art natural language processing. CoRR abs/1910.03771 (2019), http://arxiv.org/abs/1910.03771