11institutetext: INSA Lyon, LIRIS, Lyon, France
11email<EMAIL_ADDRESS>22institutetext: Esker, Lyon, France
22email<EMAIL_ADDRESS>
# Improving Information Extraction on Business Documents with Specific Pre-
Training Tasks

Thibault Douzon  1122 0009-0001-1649-5373 Stefan Duffner  11
0000-0003-0374-3814 Christophe Garcia  11 0000-0001-7997-9837 Jérémy Espinas
22

###### Abstract

Transformer-based Language Models are widely used in Natural Language
Processing related tasks. Thanks to their pre-training, they have been
successfully adapted to Information Extraction in business documents. However,
most pre-training tasks proposed in the literature for business documents are
too generic and not sufficient to learn more complex structures. In this
paper, we use LayoutLM, a language model pre-trained on a collection of
business documents, and introduce two new pre-training tasks that further
improve its capacity to extract relevant information. The first is aimed at
better understanding the complex layout of documents, and the second focuses
on numeric values and their order of magnitude. These tasks force the model to
learn better-contextualized representations of the scanned documents. We
further introduce a new post-processing algorithm to decode BIESO tags in
Information Extraction that performs better with complex entities. Our method
significantly improves extraction performance on both public (from 93.88 to
95.50 F1 score) and private (from 84.35 to 84.84 F1 score) datasets composed
of expense receipts, invoices, and purchase orders.

###### Keywords:

Business Documents Document Understanding Information Extraction Pre-Training
BIESO Decoding Transformer

##  1 Introduction

Business documents are paper-sized files containing useful information about
interactions between companies. They may take the form of invoices, purchase
orders, various reports, and agreements. The exact layout of a document
depends on the issuer, but the contained information is conventionally
structured. For example invoices and purchase orders share the same header,
table, footer structure that almost all issuers have adopted. Because such
documents trace every transaction made by companies, they are the key to
business process automation. With the emergence of modern resource planning
systems, accurate Information Extraction (IE) has become one of the core
problems of Document Intelligence.

Initially, information extraction was done by human operators, but software
solutions have been developed since the early days of document analysis to
tackle the problem. Their intent was to ease the work of human operators with
hard-coded extraction rules. Unfortunately, these rules needed to be adapted
for each and every layout of documents. This limitation has led to the rise of
Machine Learning (ML) models for automatic document IE.

First ML approaches relied on Optical Character Recognition (OCR) systems to
provide the textual content of the document. This transition from image to
text allowed for standard Natural Language Processing (NLP) methods to be
applied by adopting a Sequence Labeling problem. The amount of labeled data
necessary to train accurate NLP models has always been a problem. Business
documents are inherently private which strongly limits the quantity of
publicly available data. Thus, only companies selling business process
automation software are able to collect larger amounts of such data. Moreover,
they often rely on their customer to implicitly label the documents.

Figure 1: LayoutLM architecture.
Token embeddings are enriched with 1D positional encoding and 2D spatial
encoding specific to this architecture. The number of blocks $N$ varies from
12, for the base model, to 24, for the large one.

Most recent proposals often include a pre-training step, where the model is
trained on a pretext task. Those pretext tasks are self-supervised problems
that teach the model many useful “skills” for manipulating the data. Usually,
these tasks are as broad as possible, teaching the model common sense about
language, grammar, and global structure.

In this work, we focus on LayoutLM [31], a pre-trained Transformer that is
specialized in business documents. As shown in Figure 1, it reuses the same
Transformer layer with multi-head attention with the addition of a 2D
positional encoding. Its larger version achieved state-of-the-art performance
in both document classification and information extraction. However, the
required hardware to train it can be repelling. In this paper, we propose new
pre-training tasks specific to business documents that will provide additional
skills to the model. We also propose a new decoding post-processing algorithm
that prevents many errors made by the model due to ambiguities. Combined, our
contributions111Code available here:
https://github.com/thibaultdouzon/business-document-pre-training allow for the
base LayoutLM model to perform on par with the large version.

##  2 Related Work

###  2.1 Information Extraction

Rule-based approaches [10] have been supplanted by Deep Learning models in the
last decade. Document IE first capitalized on the state of the art in Named
Entity Recognition for NLP [8]. Recurrent Neural Networks with Long-Short Term
Memories were first used to encode documents at a word level [16, 22],
allowing a simple classifier to predict each word’s associated label. Instead
of a softmax and cross-entropy loss, a Conditional Random Field [25] model has
been used in addition to BIESO tags. Other architectures have also been
proposed to better adapt to the specificity of the document. For example,
graphs [13, 12, 33, 3] and convolutions over a grid [7, 1, 11] constrained the
model based on the words’ positional information. Because most architectures
relied on textual representations, they benefited from pre-trained word
embeddings like Word2Vec [14] or GloVe [17].

With the emergence of Transformers [26] and text encoders like BERT [2],
attention-based document analysis models [31, 5, 30] evolved quickly, which
resulted in a large improvement of state-of-the-art performance. In line with
[7] which included both textual and visual representations, multi-modal
Transformers [30, 11] superseded conventional textual models.

In parallel to the rise of Transformers, end-to-end IE models tried to reduce
the labeling cost. First using RNNs with attention layers [15, 23], then
shifting to Transformers [19]. Adopting at the same time the Question
Answering [4] (QA) format, instead of the usual Sequence Labeling, provided
more flexibility on the predicted labels.

###  2.2 Pre-Training

Semi-supervised training and pre-trained models were popularised in NLP with
enriched word embeddings [18, 14, 17]. With the emergence of Transformers,
large pre-trained models have been proposed [29]. Thanks to their pre-
training, they can efficiently adapt to various tasks [27, 28] and data types.
In general, these models are pre-trained on large unlabeled datasets in a
self-supervised manner. This self-supervision removes parts of the burden of
data labeling [24] and leverages the huge quantities of available data.

A wide variety of pre-training tasks have been proposed. General-purpose tasks
aiming at learning the language and grammar were used first. Auto-regressive
tasks [20] and Masked Language Modeling [2] are still frequently used in new
pre-trained models as they have proven to be effective in most situations. In
addition to incremental improvements [21, 32], some new pre-training tasks
were designed to align representations of multi-modal inputs [30, 19].

##  3 Models

###  3.1 Architecture

We used the well-established LayoutLM architecture [31] which itself is based
on BERT Transformer [2]. More specifically, we chose the base model222Pre-
trained weights available here: https://huggingface.co/microsoft/layoutlm-
base-uncased with 12 layers and 512 dimensions for token embeddings. This
model is computationally much more efficient compared to the larger version
while still giving very good performance.

Transformer models work on tokens that are in between characters and words.
LayoutLM and BERT both use the WordPiece algorithm. We use the same tokenizer
as LayoutLM in order to compare our performance with the base LayoutLM model.
It uses a vocabulary size of $30000$, and we limit the sequence length to 512
tokens, including the special tokens [CLS] and [SEP]. This limitation due to
GPU memory consumption of self-attention operations often forces us to cut
documents in multiple pieces of 512 tokens and process them separately.

Contrary to RNNs, all positions in the sequence are equivalent in a
Transformer model. To provide information about position inside the sequence,
a linear positional encoding [26] is added for each token. Then LayoutLM
adapted this positional encoding to a 2D version that can represent the
positions of words on a page.

For both pre-training tasks and fine-tuning, we use a simple dense layer to
map each token’s final internal representation to the dimension of the
prediction space. A softmax layer is applied to produce the final model
confidence scores. For training, the cross-entropy loss is used on the model
confidence scores.

###  3.2 ConfOpt Post-Processing

We model the Information Extraction task as sequence tagging on tokens.
Predictions are done at the token level and then aggregated by a lightweight
post-processing step to give the model’s final prediction. In all experiments,
we use BIESO tagging. That is, each field to extract is composed of a sequence
of target tags of the following types: B for the beginning of the entity, I
for inside, E for its end, or otherwise S for a single token entity. O is used
for any token that is outside any target label. BIESO is widely used in IE as
it provides structure to the target sequence that helps the model.

Instead of the trivial post-processing which consists of simply following the
maximum confidence of the model, we decided to decode a model’s prediction by
solving a basic optimization problem. We will refer to this method as ConfOpt
in the remaining of the paper. The predicted sequence for a target label is
the sequence that maximizes model confidence over the whole input sequence.
There is a constraint to decode a prediction: it must match the following
regular pattern: (BI*E) $|$ S where * denotes zero or many occurrences and $|$
denotes an alternative.

This optimisation problem can be solved with a dynamic programming approach.
The model’s predictions for one target label can represented as a $4\times N$
dimensional matrix where $N$ is the sequence length and 4 comes from the 4
tags B,I,E,S. By noting $C_{T,0}$ the model’s confidence in T tag at position
0 and $P_{T,i}$ the best prediction confidence ending at token $i$ with tag T,
the objective is to determine
$S~{}=~{}\underset{T\in\\{E,S\\}}{\underset{0\leq i<N}{\max}}P_{T,i}$ where

$\displaystyle
P_{B,i}=C_{B,i}~{};~{}P_{I,i}=C_{I,i}+\max\begin{cases}P_{B,i-1}\\\
P_{I,i-1}\\\ \end{cases}$ $\displaystyle
P_{S,i}=C_{S,i}~{};~{}P_{E,i}=C_{E,i}+\max\begin{cases}P_{B,i-1}\\\
P_{I,i-1}\\\ \end{cases}$

One drawback of this post-processing is dealing with no prediction and non-
unique predictions. It can be solved with an empirically determined threshold
below which no predictions are made. Though in this paper this is not further
studied because fields are mandatory in a document and always unique.

##  4 Pre-training

Transformer models provide great performance when first pre-trained on pretext
tasks on very large unlabelled datasets. This pre-training is most of the time
done in a self-supervised manner in order to avoid the labeling cost. LayoutLM
uses Masked Visual-Language Modeling [31] which is adapted from BERT’s Masked
Language Modeling [2]. It teaches the model how text and documents are formed
at a token level. In practice, at each training step, 15% of the tokens are
randomly chosen and replaced by either a [MASK] token, a random token, or not
replaced at all. The model tries to guess which token is the most probable
right replacement at those positions.

For all pre-training tasks when a document is too long to be processed at
once, we randomly select a continuous span of words of maximum size and
provide it to the model instead. We expect the model to learn useful features
on various parts of documents thanks to the long training. For very short
documents, the input is padded to the maximum size.

We introduce two new specific pre-training tasks in addition to Masked Visual-
Language Modeling (MVLM). The first one, Numeric Ordering teaches the model
how to compare and order numbers. The second one, Layout Inclusion focuses on
words in the 2D plane and their relative positioning. We chose to avoid
regression tasks, even though their implementation would have been simpler.
For example, simply removing the 2D positioning of some tokens, and asking the
model to predict tokens’ position is an alternative to what we propose. But
this does not behave well for a token that could appear either at the top or
the bottom of the document: the model would learn its mean position – the
middle – where the token would never appear. In the following, we will
describe the two pre-training tasks in detail.

###  4.1 Numeric Ordering Task

Figure 2: A pre-training example with Numeric Ordering task. A random token
containing a number is selected, then the target is to predict whether other
numbers are smaller or bigger. Some random noise can be added by masking
tokens’ textual or spatial representations. Only a small part of the
document’s input is represented in this illustration.

Numeric Ordering (NO) focuses on numeric figures in the document and their
relative values. Contrary to MLM which only relies on self-supervised data, NO
relies on a handcrafted number parser to find and parse all numbers that
appear in a document. Because business documents are mostly made of decimal
numbers written with digits, we ignore those written out in words. The numeric
value of each token is determined by parsing beforehand each word in the
document, looking for numbers and ignoring irrelevant characters.

As shown in Figure 2, the model must predict for every numeric figure in the
document if its parsed value is smaller, equal or greater than a randomly
selected number among the document. The loss is only computed on tokens
starting a new word, but tokens continuing a word are important to determine
the value represented by a word.

We want the model not only to reason on the textual features, but also on the
spatial context surrounding each figure in the document. Therefore, we
randomly mask the textual representations of 15% of the numbers in the
document and replace them with the [MASK] token as shown in Figure 2. For the
same reason, we also mask the spatial encoding of 15% of the numbers and make
sure both text and position are not masked at the same time. All masked
positions are replaced with (1000, 1000, 1000, 1000).

###  4.2 Layout Inclusion Task

Figure 3: A pre-training example with Layout Ordering task. Coordinates of the
purple rectangle are drawn uniformly. Random noise is added by masking the 2D
position of some tokens. Only a small part of the document is represented.

We introduce another pre-training task focusing on the 2D positional encoding,
which we called Layout Inclusion (LI). Its purpose is to provide a better
understanding of document layouts and complex structures. In fact, most
business documents, including invoices, purchase orders, and expense receipts,
contain tables where the meaning of tokens is mostly driven by their position
relative to headers.

As shown in Figure 3, Layout Inclusion is formatted like a question answering
prompt: a question followed by the content of the document. The question is
simply a special token [LAYOUT] positioned at random coordinates
$(x_{1},y_{1},x_{2},y_{2})$. The model must then classify every token in the
document into 2 groups: either inside or outside of the question token. More
precisely, the target answer is whether the middle point of a document token
is inside or outside the rectangle described by the coordinates of the
question.

Again, the objective is for the model to not only reason on the 2D positions
of tokens but also use their textual embedding. In order to force the model to
use both representations, we randomly replace 15% of documents token positions
with (1000, 1000, 1000, 1000). In case of a random position replacement, the
target value is still computed based on the real position of the token, and
the model must make its prediction based on the token’s text and the
neighboring tokens using the classical 1D positional encoding.

##  5 Datasets

We used 2 different collections of documents to build 3 datasets for training
and evaluation as described in the following. They all contain business
documents: invoices and purchase orders for the private collection and expense
receipts for the public one. The largest dataset used for pre-training isn’t
labeled, document samples with their target fields for the others datasets are
shown in Figure 4.

((a)) Receipt from SROIE.

((b)) Purchase Order from BDC-PO.

Figure 4: A document sample for each training dataset annotated with the
expected predictions. For BDC-PO, we replaced the document with a fictive one
due to privacy reasons.

###  5.1 Business Documents Collection

The Business Documents Collection (BDC) is a large private dataset composed of
100k invoices and 300k purchase orders. Those real documents were submitted
and processed on a commercial document automation solution in the last 3
years. It contains English-only documents divided into 70000 different
issuers. All documents sharing the same issuer usually use the same
information template. Therefore, we limited the maximum number of documents of
the same issuer to 50. It is important to keep the number of similar layouts
in the collection low and the variety of examples high. We used this
collection for pre-training language models on business documents that are
closer to our final objective than RVL-CDIP [9].

Textual and positional information have been extracted using a commercial OCR
system. It achieves excellent accuracy on properly scanned documents and
provides accurate word positions. We also use the provided read order to
determine the order of tokens when feeding the network. This order determines
the 1D positional encoding given to each token that complements the 2D
positional encoding.

Because we only used this collection for pre-training models on self-
supervised tasks, most documents do not have extraction labeling. Only a
subset composed of purchase orders is labeled for the IE task.

###  5.2 Business Documents Collection – Purchase Orders

We selected a subset of the Business Documents Collection to build a labeled
dataset of English purchase orders called BDC-PO. It contains almost 9000
different issuers split into training, validation, and test set. In order to
not introduce bias for models pre-trained on the BDC, we removed from BDC all
documents emitted by a supplier contained in the test set. This means that
document layouts contained in the test set have never been seen before by the
model at pre-training or training time.

Long purchase orders are rare but can sometimes be longer than 20 pages. If we
wanted to train models and make predictions on such documents, we would have
to evaluate the model on dozens of inputs for one document. Instead, we chose
to limit documents to one page and crop the remaining. It only concerns
roughly 25% of the dataset and sometimes impacts the prediction because labels
are missing from the input.

The extraction task consists of 3 fields: document number, delivery date, and
total amount. Those fields were chosen because they are mandatory for most
customers and thus are well labeled at the word level by the end-user. We
controlled the labeling quality at the issuer level and rejected from the
dataset some issuers with undesirable labeling practices.

###  5.3 ICDAR 2019 – Scanned Receipts

We also trained and evaluated our model on the public Scanned Receipts OCR and
Information Extraction [6] (SROIE) dataset that was published for ICDAR 2019.
We focus on the third task which consists in extracting information from the
documents. SROIE contains Malaysian receipts split into 626 train and 347 test
documents. Unfortunately, we do not have control over the composition of the
test set, and most of the test layouts also occur in the training set.

We used the OCR text provided with the dataset instead of using our own OCR
system. As others have pointed out [31], it contains numerous little errors
that negatively affect the final performance. For a fair comparison with the
leaderboard, we manually fixed them such that the expected string appears in
the input, at least. These fixes mostly concern addresses and company names.
It almost exclusively involves fixing errors related to white-spaces and
commas.

##  6 Experiments

All experiments were performed on a single machine equipped with two Nvidia
RTX A6000 with 48Go of video memory each. This allowed us to boost the batch
size up to 32 per device on a base transformer model. To further increase the
batch size, we also aggregated 6 batches together before propagating the
gradient for a total batch size of 192. We used the Adam optimizer with a
learning rate of $1e-5$ and 200 linear warm-up steps as it improved our
model’s convergence. We used 1500 training steps for SROIE and 3000 steps for
BDC-PO. Finally, we ran each fine-tuning 10 times in each setup to get a
precise idea of the performance of the models and the variability of the
results. For the different pre-training scenarios, we performed only two runs
and the best model was kept.

###  6.1 Post-Processing

This first set of experiments aims at comparing the post-processing used to
decode the sequence produced by the model. We want to determine whether our
proposed ConfOpt algorithm is competitive with other decoding methods. We
decided to use the LayoutLM base model and compare the proposed ConfOpt
against two other decoding algorithms as shown in Table 1.

We named Ad-Hoc the basic decoding using the label with maximal confidence for
each token. When decoding with this method, a B tag starts a new entity, a I
tag continues the previous entity, a E closes the previous entity, and a S tag
produces a new entity and closes it right away. Ad-Hoc and ConfOpt use the
same model weights in this experiment as they do not introduce any trainable
parameters.

The second decoding algorithm uses a Conditional Random Field (CRF) [25, 8]
that processes LayoutLM’s predictions. In this particular case, we did not use
the classical cross-entropy loss but the score provided by the CRF layer.
Because the CRF required specific training and did not optimize the same loss,
its weights are different from the two other post-processing methods.

| Fine Tuning (F1 score)
---|---
Post Processing | SROIE | BDC-PO
Ad-Hoc | $93.88\pm 0.59$ | $84.35\pm 0.12$
CRF | $94.01\pm 0.55$ | $84.40\pm 0.16$
ConfOpt | $\mathbf{94.94\pm 0.38}$ | $\mathbf{84.57\pm 0.10}$
Table 1: Performance comparison on SROIE and BDC-PO between multiple post-
processing algorithm. Score is computed on the exact match between the
prediction and the target string.

We evaluated these algorithms on both SROIE and BDC-PO. The results in Table 1
show a tiny improvement using a CRF instead of the Ad-Hoc post-processing
(0.13 and 0.05 F1 points) but those differences are always within one standard
deviation range. We would need more evidence to conclude on the effect of
adding a CRF layer for the post-processing.

On both datasets, using ConfOpt significantly increases performance (1.06 and
0.22 F1 points) compared to the Ad-Hoc post-processing, even though the model
is strictly identical. In light of these results, we decided to use the
ConfOpt for the next experiment.

###  6.2 Business Document-Specific Pre-training

We conducted another set of experiments in order to study the effects of the
new business data-specific pre-training tasks on the model performance. At the
same time, we controlled the performance gap obtained by pre-training with the
basic MVLM task on the same new dataset. Both comparisons are insightful to
decide whether it is useful to pre-train on clients’ data and/or with data-
specific pre-training tasks.

For the pre-training part, we always initialize the model’s weights with the
base version [31]. We pre-train models for 20 epochs on 80% of BDC. When using
multiple pre-training tasks at the same time, we chose to provide batches of
single tasks to the model. Gradient aggregation over multiple batches helps
smoothing the update between different tasks. We pre-trained 2 models on the
BDC, one with MVLM only and another with MVLM+NO+LI.

Pre Training |  | Accuracy per field
---|---|---
Task(s) | Dataset | F1 Score | PO Number |  Total |  Date
MVLM | RVL-CDIP | $84.57\pm 0.10$ | $89.98$ | $89.10$ | $93.59$
MVLM | BDC | $84.77\pm 0.12$ | $90.61$ | $89.33$ | $93.59$
MVLM+NO+LI | BDC | $\mathbf{84.84\pm 0.08}$ | $\mathbf{90.71}$ | $\mathbf{89.36}$ | $\mathbf{93.83}$
Table 2: Model performance when fine-tuning on BDC-PO Architecture | Pre Training |  | Accuracy per field
---|---|---|---
| Task(s) | Dataset | F1 Score | Company | Address |  Total |  Date
LayoutLM base * | MVLM | RVL-CDIP | $94.94\pm 0.38$ | $92.91$ | $90.81$ | $89.25$ | $99.48$
LayoutLM base * | MVLM | BDC | $95.18\pm 0.23$ | $\mathbf{93.72}$ | $91.00$ | $89.48$ | $\mathbf{99.68}$
LayoutLM base * | MVLM+NO+LI | BDC | $\mathbf{95.50\pm 0.22}$ | $93.60$ | $\mathbf{91.41}$ | $\mathbf{90.89}$ | $99.57$
LayoutLM base [31] | MVLM | RVL-CDIP | $94.38$ |
LayoutLM large [31] | MVLM | RVL-CDIP | $95.24$ |
LayoutLMv2 large [30] | MVLM+TIA+TIM | RVL-CDIP | $\mathbf{97.81}$ |
Table 3: Model performance when fine-tuning on SROIE. Models name ending with
a * are our contribution. The second part contains published scores of the
original LayoutLM and LayoutLMv2 as a comparison.

We evaluated each pre-trained model on both datasets, the results are
available in Table 2 for BDC-PO and Table 3 for SROIE . Each cell contains the
means of 10 runs with different seeds and the standard deviation is provided
for the F1 score. There are a few interesting things to notice.

The first important remark is the importance of the pre-training dataset. Pre-
training on BDC significantly improves performance on both SROIE and BDC-PO,
even though the pretext training task is the same as what was used for
LayoutLM. BDC is more homogeneous and focuses on invoices and purchase orders.
Contrary to our expectations, we observe a greater improvement on SROIE than
on BDC-PO (0.24 vs 0.2 F1 points). But the overall improvement by using BDC
can be explained because RVL-CDIP contains a broader panel of document types
and is not specialized like BDC. Even though BDC does not contain expense
receipts, its global structure is similar to invoices.

Next, we can compare the pre-training tasks. Introducing Numeric Ordering (NO)
and Layout Inclusion (LI) tasks also improves the performance over the
previously pre-trained model. We observe a 0.32 F1 point improvement on SROIE
but only 0.07 on BDC-PO. We suspect the small improvement introduced by the
new tasks can be explained because most useful skills to process purchase
orders were learned by pre-training on such documents. The new pre-training
tasks help more for generalizing on new types of documents.

We also can look at the results on a field per-field basis. We observe that
using BDC over RVL-CDIP improved the recognition of all fields except for the
dates in BDC-PO. If introducing new training tasks did not improve all fields,
we notice that some fields were greatly enhanced like the total amount in
SROIE (1.41 F1 points difference). We expected to observe a greater
improvement in the total field with the new pre-training tasks. But it does
not seem to improve performance much on BDC-PO’s total.

Finally it is interesting to compare on Table 3 our results with the published
scores of LayoutLM and LayoutLMv2. Our pre-trained model with NO and LI tasks
performs better than LayoutLM large which contains 3 times more parameters.
However, LayoutLMv2 – which uses both textual and visual information –
performance level is still unreachable for a textual-only model.

##  7 Conclusion

In this work, we showed significant improvements are accessible without
introducing more trainable parameters and computational complexity. Only using
the base transformer architecture, we achieved a performance that is
comparable to the large version which contains 3 times more parameters. Pre-
trained models can be further specialized through in-domain datasets and
specific pretext training tasks. We demonstrated that by introducing a new
collection of business documents and training tasks focusing on documents’
layout and number understanding. We showed that performance improvements can
be imputed to both pre-training tasks (Numeric Ordering and Layout Inclusion)
and new pre-training dataset.

In the future, we will investigate on IE as a Question Answering problem. It
has already been proposed in the past [4] as an alternative to Sequence
Labeling when fine-tuning models. It should improve the model’s generalization
capabilities and enable few-shot learning. But nowadays all models are pre-
trained, and we would like to study the impact on generalization of a QA-only
pre-training.

## References

  * Denk and Reisswig [2019] Timo I. Denk and Christian Reisswig.  BERTgrid: Contextualized Embedding for 2D Document Representation and Understanding.  _arXiv:1909.04948 [cs]_ , September 2019.  URL http://arxiv.org/abs/1909.04948.  arXiv: 1909.04948.
  * Devlin et al. [2019] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova.  BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.  _arXiv:1810.04805 [cs]_ , May 2019.  URL http://arxiv.org/abs/1810.04805.  arXiv: 1810.04805.
  * Gal et al. [2020] Rinon Gal, Shai Ardazi, and Roy Shilkrot.  Cardinal Graph Convolution Framework for Document Information Extraction.  In _Proceedings of the ACM Symposium on Document Engineering 2020_ , pages 1–11, Virtual Event CA USA, September 2020. ACM.  ISBN 978-1-4503-8000-3.  doi: 10.1145/3395027.3419584.  URL https://dl.acm.org/doi/10.1145/3395027.3419584.
  * Gardner et al. [2019] Matt Gardner, Jonathan Berant, Hannaneh Hajishirzi, Alon Talmor, and Sewon Min.  Question Answering is a Format; When is it Useful?  _arXiv:1909.11291 [cs]_ , September 2019.  URL http://arxiv.org/abs/1909.11291.  arXiv: 1909.11291.
  * Garncarek et al. [2020] Lukasz Garncarek, Rafal Powalski, Tomasz Stanislawek, Bartosz Topolski, Piotr Halama, and Filip Graliński.  LAMBERT: Layout-Aware language Modeling using BERT for information extraction.  _arXiv:2002.08087 [cs]_ , March 2020.  URL http://arxiv.org/abs/2002.08087.  arXiv: 2002.08087.
  * Huang et al. [2019] Zheng Huang, Kai Chen, Jianhua He, Xiang Bai, Dimosthenis Karatzas, Shijian Lu, and C. V. Jawahar.  ICDAR2019 Competition on Scanned Receipt OCR and Information Extraction.  In _2019 International Conference on Document Analysis and Recognition (ICDAR)_ , pages 1516–1520, September 2019.  doi: 10.1109/ICDAR.2019.00244.  ISSN: 2379-2140.
  * Katti et al. [2018] Anoop Raveendra Katti, Christian Reisswig, Cordula Guder, Sebastian Brarda, Steffen Bickel, Johannes Höhne, and Jean Baptiste Faddoul.  Chargrid: Towards Understanding 2D Documents.  _arXiv:1809.08799 [cs]_ , September 2018.  URL http://arxiv.org/abs/1809.08799.  arXiv: 1809.08799.
  * Lample et al. [2016] Guillaume Lample, Miguel Ballesteros, Sandeep Subramanian, Kazuya Kawakami, and Chris Dyer.  Neural Architectures for Named Entity Recognition.  _arXiv:1603.01360 [cs]_ , April 2016.  URL http://arxiv.org/abs/1603.01360.  arXiv: 1603.01360.
  * Lewis et al. [2006] David Lewis, Gady Agam, Shlomo Argamon, Ophir Frieder, D Grossman, and Jefferson Heard.  Building a test collection for complex document information processing.  In _Proceedings of the 29th annual international ACM SIGIR conference on Research and development in information retrieval_ , pages 665–666, 2006.
  * Li et al. [2008] Yunyao Li, Rajasekar Krishnamurthy, Sriram Raghavan, Shivakumar Vaithyanathan, and H. V. Jagadish.  Regular Expression Learning for Information Extraction.  In _Proceedings of the 2008 Conference on Empirical Methods in Natural Language Processing_ , pages 21–30, Honolulu, Hawaii, October 2008. Association for Computational Linguistics.  URL https://www.aclweb.org/anthology/D08-1003.
  * Lin et al. [2021] Weihong Lin, Qifang Gao, Lei Sun, Zhuoyao Zhong, Kai Hu, Qin Ren, and Qiang Huo.  ViBERTgrid: A Jointly Trained Multi-Modal 2D Document Representation for Key Information Extraction from Documents.  page 16, 2021.
  * Liu et al. [2019] Xiaojing Liu, Feiyu Gao, Qiong Zhang, and Huasha Zhao.  Graph Convolution for Multimodal Information Extraction from Visually Rich Documents.  _arXiv:1903.11279 [cs]_ , March 2019.  URL http://arxiv.org/abs/1903.11279.  arXiv: 1903.11279.
  * Lohani et al. [2019] D. Lohani, A. Belaïd, and Y. Belaïd.  An Invoice Reading System Using a Graph Convolutional Network.  In Gustavo Carneiro and Shaodi You, editors, _Computer Vision – ACCV 2018 Workshops_ , volume 11367, pages 144–158. Springer International Publishing, Cham, 2019.  ISBN 978-3-030-21073-1 978-3-030-21074-8.  URL http://link.springer.com/10.1007/978-3-030-21074-8_12.  Series Title: Lecture Notes in Computer Science.
  * Mikolov et al. [2013] Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean.  Efficient Estimation of Word Representations in Vector Space.  _arXiv:1301.3781 [cs]_ , September 2013.  URL http://arxiv.org/abs/1301.3781.  arXiv: 1301.3781.
  * Palm [2019] Rasmus Berg Palm.  End-to-end information extraction from business documents.  page 99, 2019.
  * Palm et al. [2017] Rasmus Berg Palm, Ole Winther, and Florian Laws.  CloudScan - A configuration-free invoice analysis system using recurrent neural networks.  _arXiv:1708.07403 [cs]_ , August 2017.  URL http://arxiv.org/abs/1708.07403.  arXiv: 1708.07403.
  * Pennington et al. [2014] Jeffrey Pennington, Richard Socher, and Christopher Manning.  Glove: Global Vectors for Word Representation.  In _Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP)_ , pages 1532–1543, Doha, Qatar, 2014. Association for Computational Linguistics.  doi: 10.3115/v1/D14-1162.  URL http://aclweb.org/anthology/D14-1162.
  * Peters et al. [2018] Matthew E. Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke Zettlemoyer.  Deep contextualized word representations.  _arXiv:1802.05365 [cs]_ , March 2018.  URL http://arxiv.org/abs/1802.05365.  arXiv: 1802.05365.
  * Powalski et al. [2021] Rafal Powalski, Lukasz Borchmann, Dawid Jurkiewicz, Tomasz Dwojak, Michal Pietruszka, and Gabriela Palka.  Going Full-TILT Boogie on Document Understanding with Text-Image-Layout Transformer.  page 18, 2021.
  * Radford et al. [2018] Alec Radford, Karthik Narasimhan, Tim Salimans, and Ilya Sutskever.  Improving Language Understanding by Generative Pre-Training.  page 12, 2018.
  * Raffel et al. [2020] Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu.  Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer.  _arXiv:1910.10683 [cs, stat]_ , July 2020.  URL http://arxiv.org/abs/1910.10683.  arXiv: 1910.10683.
  * Sage et al. [2019] Clément Sage, Alexandre Aussem, Haytham Elghazel, Véronique Eglin, and Jérémy Espinas.  Recurrent Neural Network Approach for Table Field Extraction in Business Documents.  In _2019 International Conference on Document Analysis and Recognition (ICDAR)_ , pages 1308–1313. IEEE, 2019.
  * Sage et al. [2020] Clément Sage, Alex Aussem, Véronique Eglin, Haytham Elghazel, and Jérémy Espinas.  End-to-End Extraction of Structured Information from Business Documents with Pointer-Generator Networks.  In _EMNLP 2020 Workshop on Structured Prediction for NLP_ , Punta Cana (online), Dominican Republic, November 2020.  URL https://hal.archives-ouvertes.fr/hal-02958913.
  * Sage et al. [2021] Clément Sage, Thibault Douzon, Alex Aussem, Véronique Eglin, Haytham Elghazel, Stefan Duffner, Christophe Garcia, and Jérémy Espinas.  Data-Efficient Information Extraction from Documents with Pre-trained Language Models.  In Elisa H. Barney Smith and Umapada Pal, editors, _Document Analysis and Recognition – ICDAR 2021 Workshops_ , pages 455–469, Cham, 2021. Springer International Publishing.  ISBN 978-3-030-86159-9.
  * Sutton and McCallum [2010] Charles Sutton and Andrew McCallum.  An Introduction to Conditional Random Fields.  _arXiv:1011.4088 [stat]_ , November 2010.  URL http://arxiv.org/abs/1011.4088.  arXiv: 1011.4088.
  * Vaswani et al. [2017] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin.  Attention Is All You Need.  _arXiv:1706.03762 [cs]_ , June 2017.  URL http://arxiv.org/abs/1706.03762.  arXiv: 1706.03762.
  * Wang et al. [2019] Alex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman.  GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding.  _arXiv:1804.07461 [cs]_ , February 2019.  URL http://arxiv.org/abs/1804.07461.  arXiv: 1804.07461.
  * Wang et al. [2020] Alex Wang, Yada Pruksachatkun, Nikita Nangia, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman.  SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems.  _arXiv:1905.00537 [cs]_ , February 2020.  URL http://arxiv.org/abs/1905.00537.  arXiv: 1905.00537.
  * Wolf et al. [2020] Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac, Tim Rault, Rémi Louf, Morgan Funtowicz, Joe Davison, Sam Shleifer, Patrick von Platen, Clara Ma, Yacine Jernite, Julien Plu, Canwen Xu, Teven Le Scao, Sylvain Gugger, Mariama Drame, Quentin Lhoest, and Alexander M. Rush.  HuggingFace’s Transformers: State-of-the-art Natural Language Processing.  _arXiv:1910.03771 [cs]_ , July 2020.  URL http://arxiv.org/abs/1910.03771.  arXiv: 1910.03771.
  * Xu et al. [2021] Yang Xu, Yiheng Xu, Tengchao Lv, Lei Cui, Furu Wei, Guoxin Wang, Yijuan Lu, Dinei Florencio, Cha Zhang, Wanxiang Che, Min Zhang, and Lidong Zhou.  LayoutLMv2: Multi-modal Pre-training for Visually-Rich Document Understanding.  _arXiv:2012.14740 [cs]_ , May 2021.  URL http://arxiv.org/abs/2012.14740.  arXiv: 2012.14740.
  * Xu et al. [2020] Yiheng Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei, and Ming Zhou.  LayoutLM: Pre-training of Text and Layout for Document Image Understanding.  _Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining_, pages 1192–1200, August 2020.  doi: 10.1145/3394486.3403172.  URL http://arxiv.org/abs/1912.13318.  arXiv: 1912.13318.
  * Yang et al. [2020] Zhilin Yang, Zihang Dai, Yiming Yang, Jaime Carbonell, Ruslan Salakhutdinov, and Quoc V. Le.  XLNet: Generalized Autoregressive Pretraining for Language Understanding.  _arXiv:1906.08237 [cs]_ , January 2020.  URL http://arxiv.org/abs/1906.08237.  arXiv: 1906.08237.
  * Yu et al. [2020] Wenwen Yu, Ning Lu, Xianbiao Qi, Ping Gong, and Rong Xiao.  PICK: Processing Key Information Extraction from Documents using Improved Graph Learning-Convolutional Networks.  _arXiv:2004.07464 [cs]_ , April 2020.  URL http://arxiv.org/abs/2004.07464.  arXiv: 2004.07464.


# SeGA: Preference-Aware Self-Contrastive Learning with Prompts for Anomalous
User Detection on Twitter

Ying-Ying Chang, Wei-Yao Wang, Wen-Chih Peng

###### Abstract

In the dynamic and rapidly evolving world of social media, detecting anomalous
users has become a crucial task to address malicious activities such as
misinformation and cyberbullying. As the increasing number of anomalous users
improves the ability to mimic normal users and evade detection, existing
methods only focusing on bot detection are ineffective in terms of capturing
subtle distinctions between users. To address these challenges, we proposed
SeGA, preference-aware self-contrastive learning for anomalous user detection,
which leverages heterogeneous entities and their relations in the
Twittersphere to detect anomalous users with different malicious strategies.
SeGA utilizes the knowledge of large language models to summarize user
preferences via posts. In addition, integrating user preferences with prompts
as pseudo-labels for preference-aware self-contrastive learning enables the
model to learn multifaceted aspects for describing the behaviors of users.
Extensive experiments on the proposed TwBNT benchmark demonstrate that SeGA
significantly outperforms the state-of-the-art methods (+3.5% $\sim$ 27.6%)
and empirically validate the effectiveness of the model design and pre-
training strategies. Our code and data are publicly available at
https://github.com/ying0409/SeGA.

##  1 Introduction

The exploration of anomalous user detection has broad applicability across
various domains. Whether it involves developing strategies for network
security (Bilot et al. 2023), financial transactions (Chai et al. 2022), or
social media analytics (Agarwal et al. 2022; Wang and Peng 2022), these
scenarios can be effectively framed as anomalous user detection systems
characterized by intricate relations between users. Twitter serves as one of
the most widely-used social media platforms; however, the widespread features
in recent years have also led to the rapid growth of anomalous users. For
instance, abnormal users often initiate campaigns to pursue malicious goals,
which violates the principles of healthy online discussions on social media
platforms (Alieva, Moffitt, and Carley 2022). One of the most common types of
anomalous users is bots, identified at 9% to 15% of active users (Varol et al.
2017). In late 2017, the US Congress disclosed a list of 2.7k Twitter accounts
that were identified as Russian trolls (Zannettou et al. 2019), which is an
emerging type of anomalous user. As the variety of anomalous user types
increases, and their potential negative impact on social media becomes more
pronounced, it is crucial to emphasize the significance of advancing anomaly
detection methods capable of identifying not only bots but also trolls.

Previous works primarily focused on identifying bots and achieved
effectiveness by leveraging the topology with graph neural networks (GNNs)
(Kipf and Welling 2017; Velickovic et al. 2018) and heterogeneous information
networks (HINs) (Feng et al. 2021c, 2022a). However, as the diversity of
anomalous users and the evolutionary strategies for malicious activities
continue to expand, such as spreading fake news through lists111A list is a
curated selection of Twitter accounts for organizing., existing methods lack
the ability to effectively distinguish various types of anomalous users like
both bots and trolls. The main difference in detecting trolls and bots is that
the former is controlled by humans, resulting in similar behavior to normal
users compared with the latter.

Figure 1: An example of anomalous user behavior in social media, where the
edges connecting entities represent diverse relationships.

Figure 1 illustrates an example of anomalous user behavior with other entities
on social media, where anomaly users are able to not only interact with other
users, but also own lists and add other anomalous users as members to carry
out malicious activities such as spreading fake news. For example, a bot might
create a list and add trolls as members. If a normal user follows this list,
they may receive misinformation that is spread by anomalous users within the
list. Therefore, a challenging problem arises with this problem: How to
capture the subtle difference between users when troll users may behave
similarly to normal users?

To tackle these issues, we propose a novel framework SeGA, a preference-aware
self-contrastive learning approach for anomalous user detection on Twitter,
which encodes the heterogeneous relations of various entities on Twitter with
the heterogeneous encoder. We introduce self-contrastive learning with pseudo-
labels to discern subtle differences between users based on user preferences
via the corresponding posts. Specifically, we construct an HIN that
incorporates various edge types between node types including users and lists
to model users with diverse activities. In order to learn about discrepancies
between users, the pre-training strategy incorporates the knowledge of large
language models (LLMs) to capture user-preferred topics and emotions for
preference-aware self-contrastive learning with prompts. To evaluate the
effectiveness of our proposed method, we propose a new anomalous user
detection benchmark, TwBNT, which demonstrates a significant improvement of at
least 3.5% compared with the state-of-the-art baselines in terms of F1 score.

Our main contributions are summarized as follows:

  * •

We propose SeGA to address the challenging but emerging anomalous user
detection task on Twitter. To the best of our knowledge, this is the first
work that jointly distinguishes normal, troll, and bot users on social media.

  * •

We introduce preference-aware self-contrastive learning to learn user
behaviors via the corresponding posts. In addition, we incorporate prompt
templates with user preferences as pseudo-labels to capture the user-preferred
topics and emotions.

  * •

We collected a large-scale Twitter dataset named TwBNT for anomalous user
detection including normal users, troll users, and bots. Extensive experiments
were conducted to evaluate the performance of our proposed model, which
demonstrated superior improvement of between 3.5% and 27.6%.

##  2 Preliminaries

###  2.1 Related Work

#### Anomalous User Detection on Twitter

Early Twitter anomalous user detection models focused on detecting bot
accounts with user features or tweets (Miller et al. 2014; Cresci et al.
2016). With the advent of graph neural networks, an increasing number of
graph-based bot detectors have been proposed by representing users and their
interactions as a social graph, and utilizing aggregation techniques to gather
information from neighboring nodes. For example, GCN (Kipf and Welling 2017)
aggregates features equally from neighboring users to learn representations,
while GAT (Velickovic et al. 2018) models user influence using attention
mechanisms. On the other hand, heterogeneous graphs are also utilized for bot
detection due to their effectiveness in representing social networks with
diverse node and edge types. Lv et al. (2021) adopted different strategies to
enhance GAT on the heterogeneous graph, and Feng et al. (2022a) proposed
relational graph transformers to model heterogeneous relations and influence
heterogeneity between users. Nonetheless, previous methods failed to detect
another important facet of anomalous users: trolls, which react similarly to
normal users to avoid detection. Therefore, we introduce preference-aware
self-contrastive learning to differentiate user preferences from posts with
pseudo-labels.

#### Self-Supervised Learning

In recent years, self-supervised learning (SSL) has been proven to be a
powerful and effective approach in various domains for learning contextualized
representations via pretext tasks, such as natural language processing (Gao,
Yao, and Chen 2021) and computer vision (Lv et al. 2021; Bardes, Ponce, and
LeCun 2022). Predictive learning serving as a branch of SSL has also been
applied for bot detection with promising results. Feng et al. (2021a)
incorporated follower count as a self-supervised learning signal to enhance
the model’s performance in bot detection. However, relying on a single feature
as a self-supervised indicator overlooks the diversity among anomalous users
and falls short of adequately representing different users. For instance,
troll users are able to construct artificial follower counts followed by other
troll users. Therefore, we adopt user preferences acquired by LLMs with the
corresponding posts to summarize multifaceted behaviors (topics and emotions
in this paper) to describe users for self-contrastive learning.

###  2.2 Problem Formulation

We denote $G=\\{V,E,A,R,\phi,\psi\\}$ as the input heterogeneous information
network (HIN) with different types of nodes $V$ and edges $E$, and it is
associated with a node mapping function $\phi:V\rightarrow A$ and an edge
mapping function $\psi:E\rightarrow R$, where $A$ and $R$ denote the sets of
all node types and edge types. The nodes in HIN are categorized into either
user type $u$ or list type $l$ as $v^{A}_{i}\in V$, where $A=\\{u,l\\}$ is the
node type of node $i$ representing user and list, respectively. The edges are
denoted as $(v^{A}_{i},r,v^{A}_{j})\in E$, where $r\in R$ represents the
relation between node $i$ and node $j$.

For each node $i$, node features are categorized into three types: indicator
features $C_{i}=\\{c_{i_{1}},c_{i_{2}},...,c_{i_{k}}\\}$ indicating if
matching the indication, numerical features (e.g., number of posts)
$N_{i}=\\{n_{i_{1}},n_{i_{2}},...,n_{i_{m}}\\}$ and textual features
$T_{i}=\\{des_{i},twe_{i}\\}$, where
$des_{i}=\\{w^{des}_{i_{1}},w^{des}_{i_{2}},...,w^{des}_{i_{s}}\\}$ denotes
the description with $s$ words for a user or a list, and
$twe_{i}=\\{{twe}_{i_{j}}\\}_{j=1}^{q}$ denotes $q$ tweets posted from a user
or contained in a list, while each tweet $j$ contains $L$ words denoted as
${twe}_{i_{j}}=\\{w^{twe}_{i_{j_{1}}},w^{twe}_{i_{j_{2}}},\cdots,w^{twe}_{i_{j_{L}}}\\}$.
We formulate anomalous user detection as a multi-class classification problem,
where users are classified into three classes based on past activities and
relations with society. Given a learned HIN $G$, we aim to learn an anomalous
user detection function $f(G)\rightarrow\hat{y}$ to predict whether the user
$v^{u}_{i}$ is a troll, bot, or normal user.

##  3 The Proposed Method

Figure 2: Overview of our proposed framework, SeGA, consisting of three
stages: 1) Node feature encoding to initialize node embeddings from
heterogeneous information; 2) The pre-training stage to pre-train the encoder
with pseudo-aware self-contrastive learning to capture the differences in user
preferences; and 3) The fine-tuning stage to classify anomalous users.

The overview of SeGA is shown in Figure 2, which consists of three stages:
node feature encoding, the pre-training stage, and the fine-tuning stage. SeGA
leverages users and lists as nodes within an HIN to capture diverse
relationships among these entities. We first encode three types of node
features (i.e., indicator, numerical, and textual) to encode representations
for each node type. In the pre-training stage, the encoder is pre-trained with
preference-aware self-contrastive learning to learn the user preferences
summarized by LLMs from posts. In the fine-tuning stage, we fine-tune the pre-
trained model to classify anomalous users.

###  3.1 Model Architecture

#### Node Feature Encoding

Similar to the process of feature encoding as (Feng et al. 2022a), we first
concatenate each indicator feature for each node $i$ with node type $A$:

$x^{A_{ind}}_{i}=c_{i_{1}}\oplus c_{i_{2}}\oplus\cdots\oplus c_{i_{k}},$ (1)

where $\oplus$ is the concatenation operator, and
$x^{A_{ind}}_{i}\in\mathbb{R}^{k}$ is the indicator embedding concatenated by
$k$ features.

Similarly, the numerical features are concatenated as:

$x^{A_{num}}_{i}=n_{i_{1}}\oplus n_{i_{2}}\oplus...\oplus n_{i_{m}},$ (2)

where $x^{A_{num}}_{i}\in\mathbb{R}^{m}$ is the numerical embedding for node
$i$ concatenated by $m$ features.

To encode textual features, we applied pre-trained RoBERTa (Liu et al. 2019)
for encoding with $s$ words:

$x^{A_{des}}_{i}=RoBERTa(\\{w^{des}_{i_{j}}\\}^{s}_{j=1}),$ (3)

where $x^{A_{des}}_{i}\in\mathbb{R}^{d_{des}}$ denotes the description
embedding. Likewise, we obtain the tweet embedding
$x^{A_{twe}}_{i_{j}}\in\mathbb{R}^{d_{twe}}$ by averaging all embeddings
encoded from each tweet with pre-trained RoBERTa:

$x^{A_{twe}}_{i_{j}}=RoBERTa(\\{w^{twe}_{i_{j_{y}}}\\}^{L}_{y=1}),$ (4)
$x^{A_{twe}}_{i}=AVG(x^{A_{twe}}_{i_{1}},x^{A_{twe}}_{i_{2}},\cdots,x^{A_{twe}}_{i_{q}}).$
(5)

Afterwards, we transform them separately:

$x^{\prime A_{F}}_{i}=\sigma(W_{x}\cdot
x^{A_{F}}_{i}+b_{x}),F\in\\{ind,num,des,twe\\}$ (6)

where $x^{\prime A_{F}}_{i}\in\mathbb{R}^{d_{h}}$, $W_{x}$, $b_{x}$ are
trainable parameters, and $\sigma$ is denoted as LeakyReLU.

For each user or list node $i$, we obtain the user/list embeddings
$x^{A}_{i}\in\mathbb{R}^{4*d_{h}}$ by concatenating the indicator $x^{\prime
A_{ind}}_{i}$, numerical $x^{\prime A_{num}}_{i}$, description $x^{\prime
A_{des}}_{i}$ and tweet $x^{\prime A_{twe}}_{i}$ embeddings:

$x^{A}_{i}=x^{\prime A_{ind}}_{i}\oplus x^{\prime A_{num}}_{i}\oplus x^{\prime
A_{des}}_{i}\oplus x^{\prime A_{twe}}_{i}.$ (7)

We then transform the user/list embeddings $x^{A}_{i}$ as the initial node
embedding $z^{A,(0)}_{i}\in\mathbb{R}^{4*d_{h}}$ for the heterogeneous
encoder:

$z^{A,(0)}_{i}=\sigma(W_{I}\cdot x^{A}_{i}+b_{I}),$ (8)

where $W_{I}$ and $b_{I}$ are trainable parameters.

#### Heterogeneous Encoder

To model the various entities and their diverse relation with different
importance to enrich the embeddings of users, we applied a relational graph
transformer (RGT) following (Feng et al. 2022a) and an MLP with activation
function as the heterogeneous encoder:

$z^{u,(g)}_{i},z^{l,(g)}_{i}=RGT^{(g)}(z^{u,(g-1)}_{i},z^{l,(g-1)}_{i}),$ (9)
$z^{u}_{i}=\sigma(W_{z}\cdot z^{u,(g)}_{i}+b_{z}),$ (10)

where $z^{u,(g)}_{i},z^{l,(g)}_{i}\in\mathbb{R}^{d_{out}}$ is the $i$-th node
embedding learned from the $g$-th layer, $z^{u}_{i}\in\mathbb{R}^{d_{u}}$ is
the $i$-th user representations, and $W_{z}$ and $b_{z}$ are trainable
parameters. We note that as the task is to classify user categories, we adopt
aggregated user embeddings $z^{u}_{i}$ for preference learning and anomaly
detection.

###  3.2 Pre-Training Stage: Learning User Preferences via Posts

User preferences represent the behavior of an individual as they showcase a
person’s choices in various aspects, which is beneficial for detecting users’
behavior patterns. Therefore, we introduce the pseudo-preference generation,
which is summarized from LLMs based on users’ historical posts. In order to
describe and learn user preferences, we designed a prompt template to
represent the majority and minority topic-emotion pairs of user posts for
preference-aware self-contrastive learning.

#### Pseudo-Preference Generation

Given the success paradigms of leveraging LLMs in natural language
applications (Wu, Zhang, and Huang 2023), we incorporate the powerful
knowledge of LLMs to retrieve user preferences from posts. Specifically, we
opt for the preferred topic and emotion to represent the preference of each
user from the corresponding posts since anomalous users may exploit them to
achieve malicious intentions (Ghanem, Buscaldi, and Rosso 2019;
Balasubramanian et al. 2022). The 10 recent posts of user $i$ are used as the
prompt for LLM to generate the topic $t$ and the emotion $e$ used in each
tweet $j$:

$\\{(t^{u}_{i_{j}},e^{u}_{i_{j}})_{j=1}^{10}\\}=LLM(P(twe^{u}_{i_{1}}\oplus\cdots\oplus
twe^{u}_{i_{10}})),$ (11)

where $P()$ is an instruction prompt to acquire the user preference from LLMs
described in Appendix A.1, and $LLM$ is ChatGPT (Liu et al. 2023) in this
paper. The topics are derived from 16 categories based on Twitter topics (Jim
and Ann 2020), and the 8 emotions are based on Plutchik’s emotions (Ghanem,
Buscaldi, and Rosso 2019).

#### Preference-Aware Self-Contrastive Learning

After obtaining the topic-emotion pairs for each user, we aim to pre-train the
model with this pseudo-information to describe user preferences. An intuitive
approach is to predict all topics and emotions of each post by a user, which
can be formulated as a multi-label classification task. However, this fails to
effectively capture the user-preferred topics and emotions since the model
treats all labels equally without considering their relative importance. For
example, a user may post mainly on a news topic with anger and seldom post on
a news topic with joy.

To tackle this issue, we propose a preference-aware self-contrastive learning
approach that incorporates preferences with prompts for learning enhancement.
We define the preference of a user as the integration of the most frequently
used topic-emotion pair $(t^{u}_{i_{max}},e^{u}_{i_{max}})$ and the least
frequently used pair $(t^{u}_{i_{min}},e^{u}_{i_{min}})$ to reflect the user’s
interest and emotional behavior. We then generate the pseudo-label $p^{u}_{i}$
for each user $i$ by leveraging the designed prompt template $PT()$ filled
with the most and the least frequently used topic emotion pairs as:

$p^{u}_{i}=PT((t^{u}_{i_{max}},e^{u}_{i_{max}}),(t^{u}_{i_{min}},e^{u}_{i_{min}})).$
(12)

The prompt template is designed as: “The majority of the posts express
$t^{u}_{i_{max}}$ with $e^{u}_{i_{max}}$ emotion, while a minority of them
express $t^{u}_{i_{min}}$ with $e^{u}_{i_{min}}$.”. Experiments with different
templates are discussed in Section 4.4.

Afterwards, pseudo-labels of user $i$ are encoded with the prompt encoder
using SimCSE RoBERTa (Gao, Yao, and Chen 2021), which learns sentence
embeddings from contrastive learning:

$p^{\prime u}_{i}=SimCSE(p^{u}_{i}),$ (13)

where $p^{\prime u}_{i}\in\mathbb{R}^{d_{p}}$ is the pseudo-label embedding of
user $i$. Then, we transform the user embedding $z^{u}_{i}$ and pseudo-label
embedding $p^{\prime u}_{i}$ with the contrastive classifier:

$\tilde{z}^{u}_{i}=W_{\tilde{z}}\cdot z^{u}_{i}+b_{\tilde{z}},$ (14)
$\tilde{p}^{u}_{i}=W_{\tilde{p}}\cdot p^{\prime u}_{i}+b_{\tilde{p}},$ (15)

where $\tilde{z}^{u}_{i}\in\mathbb{R}^{d_{a}}$ denotes the anchor user
embedding for user $i$ and $\tilde{p}^{u}_{i}\in\mathbb{R}^{d_{a}}$ denotes
the corresponding positive sample embedding, $W_{\tilde{z}}$, $b_{\tilde{z}}$,
$W_{\tilde{p}}$ and $b_{\tilde{p}}$ are trainable parameters.

To compute the contrastive loss $L_{pre}$, we define the embedding
$\tilde{p}^{u}_{i}$ as the positive pair of the anchor user’s embedding
$\tilde{z}^{u}_{i}$, and embeddings transformed from other pseudo-labels are
considered as the negative pairs of the anchor user:

$L_{pre}=-\sum_{i\in
U}log\frac{exp(sim(\tilde{z}^{u}_{i}\cdot\tilde{p}^{u}_{i})/\tau)}{\sum_{j\in
S(i)}exp(sim(\tilde{z}^{u}_{i}\cdot\tilde{p}^{u}_{j})/\tau)},$ (16)

where $U$ is the set of indices of all user nodes, $S(i)$ is the set of a
positive pair, and negative pairs are randomly sampled from all negative
pairs. When minimizing the contrastive loss, the user embeddings with the same
pseudo-label tend to be closer together, while simultaneously encouraging the
encoder to learn user-preferred topics and emotions.

This generic pre-training objective with pseudo-labels and the prompt template
reinforces the model to learn user behavior with at least two advantages:

  * •

User preferences can also be utilized in other social media-related tasks,
such as user recommendation (Wang et al. 2022) and community detection (Wu et
al. 2021), since posts play a crucial role in user interactions within social
media.

  * •

Incorporating user post preference enables an effective representation of
users, as posting content is the primary avenue through which individuals
pursue their objectives and express themselves on social media.

###  3.3 Fine-Tuning Stage: Anomalous User Detection

To achieve the goal of anomalous user detection, the user embedding
$z^{u}_{i}$ from the pre-trained model is used in the detection classifier
with a softmax layer to predict the class $\hat{y}$ for each user $i$:

$\hat{y}_{i}=softmax(W_{y}\cdot z^{u}_{i}+b_{y}),$ (17)

where $W_{y}$, $b_{y}$ are trainable parameters.

Finally, we jointly fine-tune the pre-trained embedders, pre-trained encoder,
and the detection classifier for anomalous user detection. The fine-tuning
process incorporates both the cross-entropy loss and an L2 regularization term
as follows:

$L_{fine}=-\sum_{i\in
U}[y_{i}\log(\hat{y}_{i})]+\lambda\sum_{\omega\in\theta}\omega^{2},$ (18)

where $U$ is the set of indices of all user nodes, $y_{i}$ represents the
ground-truth label of user $i$, $\lambda$ is a hyper-parameter, and $\theta$
encompasses all the trainable parameters.

##  4 Experiments

###  4.1 Experiment Settings

#### Proposed Benchmark: TwBNT Dataset

Since there is no public dataset consisting of trolls, bots, and normal users,
we proposed a new dataset, TwBNT, by extending the bot detection benchmark
Twibot-22 (Feng et al. 2022b) with automatic troll annotations. Twibot-22 is a
bot detection dataset that provides graph structures with various entities and
relations within the Twitter network, which evaluates graph-based approaches
to bot detection. Nonetheless, Twibot-22 annotates users as either bots or
humans, but excludes the critical category for trolls. To this end, we sample
users from Twibot-22 using a breadth-first search algorithm for user
collection following (Feng et al. 2021b) to ensure the sampled users include
different types of bots, trolls, and normal users. Then, the list nodes
connected to the sampled users are employed to construct the TwBNT dataset.
Since trolls are controlled by real human users, we automatically identify
them by obtaining a troll score $scr\in[0,1]$ for each user labeled in
Twibot-22 with the widely recognized platform Bot
Sentinel222https://botsentinel.com/. Users with a score greater than the
threshold value $scr=0.5$ are labeled as trolls, while others are labeled as
normal users following the spreading intent detection (Zhou et al. 2022).
Table 1 summarizes the statistics of our collected datasets.

#### Baselines

Due to the lack of baselines for the proposed anomaly user detection tasks
that also distinguish troll users, we compared the proposed model with 6
baselines of bot detection methods to verify its effectiveness: GCN (Kipf and
Welling 2017), GAT (Velickovic et al. 2018), SimpleHGN (Lv et al. 2021), SATAR
(Feng et al. 2021a), BotRGCN (Feng et al. 2021c), and RGT (Feng et al. 2022a).
More details of baselines are given in Appendix B.

#### Implementation Details

The numbers of indicator features $k$ for the user and list node are 3 and 1,
and the numbers of numerical features $m$ for the user and list nodes are 5
and 4. Detailed features are described in Appendix A.2. The numerical features
$N$ are applied with z-score normalization. The dimensions of $d_{des}$,
$d_{twe}$ and $d_{p}$ are 768, the dimension of $d_{h}$ is 32, the dimension
of $d_{out}$ is 128, and the dimensions of $d_{u}$ and $d_{a}$ are 64. The
number of layers $g$ of the relational graph transformer is 2. Following (Feng
et al. 2022a), the max number of tweets $q$ for each user and list is set to
20 for representing the recent 20 tweets from each user and list. The max
lengths for description $s$ and each tweet $L$ are set to 50 words, and
padding with zeros is applied if the length is insufficient. In the pre-
training stage, we ask ChatGPT to classify each tweet into 16 topics and 8
emotions by providing the instructions depicted in Appendix A.2. As there
remain some results that do not belong to these categories, we treat them as
“others”. We randomly sample 100 prompts with other pseudo-labels as negative
samples and set the temperature $\tau$ as 0.1 for computing the pre-training
loss. In the fine-tuning stage, $\lambda$ is set to $3\times 10^{-5}$. The
training epochs of the pre-training and fine-tuning stages are set to 100 and
150, respectively. The dropout rate is set to 0.3. We employ the AdamW
optimizer (Loshchilov and Hutter 2019) using the learning rate of 0.001 and
the batch size is set to 2048. All experiments were conducted with a Nvidia
RTX A5000 GPU and all parameters were tuned based on the validation set. The
analysis of the hyper-parameter is discussed in Appendix C.1.

Table 1: Statistics of the proposed benchmark TwBNT. Types | Item | Count | Total
---|---|---|---
2 node types ($A$) | # user | 100,001 | 120,789
# list | 20,788
5 edge types ($R$) | # following | 751,927 | 1,312,929
# followers | 148,250
# membership | 365,593
# followed | 39,258
# own | 7,901
3 classes | # troll | 896 | 100,001
# bot | 5,047
# normal | 94,058
3 splits | # train | 70,000 | 100,001
# valid | 20,000
# test | 10,001
Table 2: Performance of all baseline methods and our proposed SeGA. All
methods are evaluated by precision, recall, and Macro F1. The best results are
highlighted in boldface, and the second-best results are underlined. The
strategies employed by each method are marked as ✓.

Methods Attention Mechanism Edge Heterogeneity Node Heterogeneity Self
Supervision Precision Recall F1 GCN 67.43$\pm$1.24 42.76$\pm$1.14
47.57$\pm$1.54 GAT ✓ 66.40$\pm$2.19 45.54$\pm$0.84 50.75$\pm$0.66 SimpleHGN ✓
✓ 79.84$\pm$2.54 45.68$\pm$1.19 52.22$\pm$1.54 SATAR ✓ ✓ ✓ 55.31$\pm$7.69
44.77$\pm$2.35 46.98$\pm$1.06 BotRGCN ✓ 65.85$\pm$12.55 43.51$\pm$5.20
47.94$\pm$7.20 RGT ✓ ✓ 75.55$\pm$1.27 52.10$\pm$1.25 58.61$\pm$0.92 SeGA
(Ours) ✓ ✓ ✓ ✓ 68.13$\pm$0.97 56.58$\pm$1.50 60.69$\pm$0.72

#### Evaluation Metrics

As the numbers of troll and bot users are more imbalanced than normal users,
as shown in Table 1, macro F1 scores are utilized as principal indicators to
evaluate the overall performance of the model. Additionally, precision and
recall are employed to evaluate the results of anomaly user classification. We
evaluate all baselines and our model by computing the mean and standard
deviation for the results obtained with 3 different random seeds.

###  4.2 Quantitative Performance

Table 2 summarizes the overall performance of anomalous user detection
methods, demonstrating that our proposed model surpasses all baselines, which
are extended to classify trolls. Quantitatively, SeGA achieves at least a 3.5%
improvement in F1-score compared with the best-performing baseline. We
summarize the observations as follows:

Compared with the homogeneous graph-based methods, GCN and GAT, SeGA achieves
a significant improvement on Macro F1 with 27.6% and 19.6%, demonstrating the
capability of heterogeneous graphs to classify various anomalous and normal
users. Additionally, SeGA outperforms other heterogeneous graph-based methods
such as SimpleHGN, BotRGCN, and RGT, ranging from 3.5% to 26.6%, which is
attributed to considering diverse entities not only from edges but also from
nodes. This also highlights the capability of leveraging topic-emotion pairs
via posts with prompts as pseudo-labels to model user preferences.

Although SATAR also adopts the follower count as a self-supervised objective,
we can observe that the performance of SATAR deteriorates substantially since
troll users can manipulate the follower count followed by other troll users to
act as normal users. The comparison of SeGA and SATAR reveals the importance
of considering user preferences for distinguishing anomalous users, where the
user preference not only behaves as a task-agnostic objective but also
describes the user profile based on the corresponding posts.

Figure 3: Ablation study including removing the list nodes and the pre-
training stage from SeGA.

###  4.3 Ablation Study

To analyze the contributions of different designs of SeGA, we conducted an
ablation study by removing different node types and the pre-training stage as
shown in Figure 3. As expected, removing both types of information (w/o list &
pre-train) significantly hinders the performance. Moreover, we can observe
that the F1 score decreases when removing list information (w/o list) for
constructing the graph, which signifies that considering user relations with
lists helps in detecting anomalous users with various malicious activities.
The deleterious performance of removing the pre-training stage (w/o pre-train)
suggests the advantage of learning user preferences as the pre-training
objective.

Table 3: Performance of SeGA with different pre-training settings, including
modifications in the prompt encoder (A1), prompt design (A2), and pre-training
task (A3).

Methods Precision Recall F1 A1 RoBERTa 68.32 55.39 59.84 A2 Short 65.86 54.16
58.26 Topic 66.03 55.53 59.27 Emotion 65.59 55.19 58.80 Tandem 72.87 53.53
59.83 A3 Multi-label 71.95 52.59 58.74 SeGA (Ours) 68.13 56.58 60.69

###  4.4 Pre-Training Strategies Study

To further validate the effectiveness of the pre-training design, we conducted
extensive experiments with three aspects: prompt encoder (A1), prompt design
(A2), and pre-training task (A2), as illustrated in Table 3.

#### A1: Variant of Prompt Encoder

We changed the prompt encoder in Eq. (13) from SimCSE RoBERTa to RoBERTa for
preference-aware self-contrastive learning, which can be observed that
replacing the prompt encoder with RoBERTa slightly decreases the performance.
As shown in Figure 4, we further compute the cosine similarity between prompt
embeddings using these prompt encoders separately to analyze the discrepancies
of different topic-emotion prompts. The result shows that SimCSE RoBERTa
provides more diverse discrepancies with different topic-emotion pairs in the
same prompt template, while RoBERTa is inferior to separate different
representations of topic-emotion pairs. In addition, the minimum cosine
similarity is 0.9795 with pre-trained RoBERTa and 0.3083 with SimCSE RoBERTa.
These results indicate that SimCSE RoBERTa is able to capture subtle
differences between prompts arising from the replacement of emotions, whereas
RoBERTa produces similar representations with different pseudo-labels. The
distinguishable embeddings enable performance enhancement for self-contrastive
learning, which again raises the need for incorporating this for contrastive
learning with prompts.

Figure 4: The first, second, and third quartiles of the cosine similarity
results between prompt embeddings from RoBERTa and SimCSE.

#### A2: Variants of Prompt Design

To analyze different designs of the prompt template for self-contrastive
learning, we evaluate SeGA with four variants: 1) Short prompt: Majority:
$t^{u}_{i_{max}}$ \- $e^{u}_{i_{max}}$, minority: $t^{u}_{i_{min}}$ \-
$e^{u}_{i_{min}}$. 2) Topic prompt: The majority of the posts express
$t^{u}_{i_{max}}$, while a minority of them express $t^{u}_{i_{min}}$. 3)
Emotion prompt: The majority of the posts express $e^{u}_{i_{max}}$, while a
minority of them express $e^{u}_{i_{min}}$. 4) Tandem prompt: The majority of
the posts express $t^{u}_{i_{max}}$, while a minority of them express
$t^{u}_{i_{min}}$. The majority of the posts express $e^{u}_{i_{max}}$, while
a minority of them express $e^{u}_{i_{min}}$. For topic and emotion prompts,
we calculate the corresponding preference frequencies independently, and the
tandem prompt is an integration of topic and emotion prompts, which can be
viewed as the prompt based on independent frequencies.

Adopting the short prompts for learning leads to an inferior performance
compared with the proposed design, which implies that taking the semantics of
natural language into account to form a prompt is essential for preference-
aware self-contrastive learning compared to forming the template naively and
structurally. From topic and emotion prompts, the inclined effects indicate
that considering the information of either topic of emotion to describe users
is insufficient to differentiate normal, troll, and bot users. Moreover, the
performance decreases when applying tandem prompts, which illustrates that
capturing the paired relationship between topics and emotions is more
meaningful than considering them separately. Meanwhile, our proposed prompt
still outperforms the tandem prompt, which showcases the strength of not only
jointly considering the frequencies, but also describing topic-emotion pairs
together to form a prompt.

#### A3: Variant of Pre-Training Task

To delve into the learning strategies for incorporating topic-emotion pairs
via posts, we modify the preference-aware self-contrastive learning to the
multi-label classification task (Multi-label), which aims to predict all
potential topic-emotion pairs of a user with the same model architecture. We
can see that the proposed self-contrastive learning outperforms predictive
learning, which highlights that multi-label classification fails to capture
users’ preferred emotions associated with specific topics since it treats all
labels as being equally important. In contrast, preference-aware self-
contrastive learning mitigates this limitation through the prompt design,
leading to a substantial improvement in anomaly user detection.

(a) SimpleHGN

(b) SATAR

(c) RGT

(d) SeGA (Ours)

Figure 5: The visualization of user embeddings produced by the heterogeneous
encoder and baselines.

###  4.5 Case Study

In order to investigate the efficacy of embeddings acquired from preference-
aware self-contrastive learning related to anomaly user detection, we sampled
users who primarily expressed anger in their general posts (i.e., others) to
reflect the normal behavior of a user. We note that extensive topics related
to news are discussed in Appendix C.2. We visualize the t-SNE embedding
results of our approach against three baselines: RGT, SimpleHGN, and SATAR as
illustrated in Figure 5. The embeddings of SATAR and RGT show ambiguous
collocation for groups of normal, bot, and troll users, while troll and bot
users of SimpleHGN have more distinguishable distances but mix with normal
users. Nonetheless, our proposed SeGA is able to describe different categories
of users with clearer boundaries, which is attributed to preference-aware
self-contrastive learning to describe user behaviors via the corresponding
posts. It is worth noting that the generic preference-aware objective is not
directly intended to address the anomaly user detection task, but definite
boundaries help group various user behaviors.

##  5 Conclusion

This paper proposes SeGA, novel preference-aware self-contrastive learning
with pseudo-preference generations for anomalous user detection on Twitter,
including more challenging troll users. Distinct from existing works that only
focus on bot detection, our proposed method is able to distinguish various
anomalous and normal users by learning similarities and discrepancies of
topic-emotion pairs from posts of users summarized by LLMs, allowing the
capability of capturing user-preferred behaviors. Meanwhile, our prompt design
considers the context of the multifaceted preferences of users to avoid the
model being biased by only considering the most-appearance preferences. We
propose a new benchmark for distinguishing anomalous and normal users on
Twitter, which shows that SeGA significantly outperforms state-of-the-art
approaches by between 3.5% and 27.6%. We believe that SeGA serves as a general
framework for social media due to the flexible design for incorporating user
preferences from external knowledge of LLMs as well as for the self-
contrastive learning approach, and multiple interesting directions could be
further explored within the framework, such as more metadata for user
preferences, few-shot examples, etc.

##  Appendix A Dataset Collection

Table 4: The instruction prompt and an example of the output of ChatGPT.

Instruction prompt Example output Please classify each tweet into the topics
and corresponding emotions for the following ten posts. The available topics
are arts & culture, business & finance, careers, entertainment, fashion &
beauty, food, gaming, hobbies & interests, movies & TV, music, news, outdoors,
science, sports, technology, and travel. The emotions to consider are joy,
sadness, anger, fear, trust, disgust, surprise, and anticipation. Please
provide the classification for each post in the format ’topic - emotion’.
Limit the response to less than 100 words. Following are the ten tweets
numbered with ’#’. \n 1: news - anger 2: news - anger 3: news - anger 4: news
- anger 5: news - anger 6: news - anticipation 7: news - anticipation 8: news
- joy 9: news - anger 10: news - anger

We provide parts of the proposed TwBNT benchmark in the supplementary file due
to the large-scale size of the dataset.

###  A.1 Prompts for Acquiring Topic-Emotion Pairs from ChatGPT

The instruction prompt P() in Eq. (11) and example output of topic-emotion
pairs from ChatGPT are shown in Table 4. This instruction prompt template is
produced by ChatGPT by asking “If I want ChatGPT to classify 10 tweets into
the topic and the corresponding emotion for each tweet, which prompt should I
use?”. Afterwards, topic-emotion pairs are adopted for representing user
preferences for preference-aware self-contrastive learning.

###  A.2 Feature Descriptions

Table 5: Metadata of each entity. Entity | Metadata
---|---
User |  | created at, description, entities
---
location, name, profile image url
protected, url, username
verified, withheld, followers count
following count, tweet count, listed count
List |  | private, created at, description
---
name, follower count, member count
Table 6: The 16 categories of topics based on Twitter topics (Jim and Ann 2020), and 8 emotions based on Plutchik’s emotions (Ghanem, Buscaldi, and Rosso 2019). Type | Categories
---|---
Topic |  | arts & culture, business & finance,
---
careers, entertainment, fashion & beauty,
food, gaming, hobbies & interests,
movies & TV, music, news, outdoors,
science, sports, technology, travel
Emotion |  | joy, sadness, anger, fear, trust,
---
disgust, surprise, anticipation

The metadata in our proposed dataset TwBNT is shown in Table 5. In the node
feature encoding stage, the numbers of indicator features k for the user and
list node are 3 and 1, and the numbers of numerical features m for the user
and list nodes are 5 and 4. For users, the 3 categorical features are: 1)
profile image ownership, 2) protected status, and 3) verification status. The
5 numerical features are: 1) account creation timestamp, 2) user name length,
3) the number of followers, 4) the number of followings, and 5) the number of
tweets. For lists, the categorical feature is privacy status, and 4 numerical
features encompass: 1) the list creation timestamp, 2) list name length, 3)
the number of followers, and 4) the number of members. Table 6 summarizes the
16 topics and 8 emotions for LLMs to classify each tweet with the
corresponding topic and emotion.

##  Appendix B Details and Setups of Baselines

###  B.1 Baselines

The details of the baseline methods are depicted as follows:

  * •

GCN (Kipf and Welling 2017) learns the user embedding by aggregating features
from neighbor users equally.

  * •

GAT (Velickovic et al. 2018) aggregates features with the attention mechanism
to model the different importance between users.

  * •

SimpleHGN (Lv et al. 2021) adopts different strategies (e.g., learnable edge-
type embeddings) to enhance GAT on the heterogeneous graph.

  * •

SATAR (Feng et al. 2021a) jointly leverages tweets, metadata, and neighborhood
information with a self-supervised representation learning framework to
improve the user representation for bot detection.

  * •

BotRGCN (Feng et al. 2021c) constructs a heterogeneous graph and applies
relational GCN (Schlichtkrull et al. 2018) to capture diverse user
relationships.

  * •

RGT (Feng et al. 2022a) proposes relational graph transformers to model the
relation and influence heterogeneity between users and learn representations
for bot detection.

###  B.2 Implementation Details

We initialize the node embeddings for GCN, GAT, and SimpleHGN with the same
node feature encoding strategies as RGT. All baselines follow the same hyper-
parameter settings as the TwiBot-22 (Feng et al. 2022b) evaluation framework.

##  Appendix C Addition Experiments

###  C.1 Hyper-Parameters Sensitivity

Table 7: The hyper-parameter sensitivity of SeGA. Type | Parameters | Precition | Recall | F1
---|---|---|---|---
SeGA |  | 68.13 | 56.58 | 60.69
batch size | 256 | 72.11 | 51.96 | 58.08
512 | 66.51 | 55.48 | 59.28
1024 | 70.84 | 53.59 | 59.24
2048 | 68.13 | 56.58 | 60.69
4096 | 70.04 | 52.39 | 58.12
dropout | 0.1 | 65.68 | 55.58 | 59.34
0.2 | 65.10 | 56.86 | 60.11
0.3 | 68.13 | 56.58 | 60.69
0.4 | 70.39 | 51.61 | 57.14
$d_{out}$ | 64 | 75.03 | 50.91 | 57.40
128 | 68.13 | 56.58 | 60.69
256 | 70.97 | 53.86 | 59.40
$d_{a}$ | 16 | 69.80 | 53.79 | 58.92
32 | 66.37 | 55.64 | 59.49
64 | 68.13 | 56.58 | 60.69
128 | 65.76 | 52.67 | 57.23
Figure 6: The effect of different numbers of negative samples.

(a) Analysis of $\tau$ with {0.05, 0.07, 0.10, 0.13}.

(b) Analysis of $\tau$ with {0.1, 0.3, 0.5, 0.7, 0.9}.

Figure 7: The effects of the different numbers of temperature $\tau$.

To test the sensitivity of hyper-parameters, we report various settings of
SeGA as shown in Table 7. The batch size is chosen from {256, 512, 1024, 2048,
4096}, and the dimension of embeddings $d_{out}$ and $d_{a}$ is chosen from
{16, 32, 64, 128} and {64, 128,256} respectively. The dropout rate is chosen
from {0.1, 0.2, 0.3, 0.4}. It is observed that SeGA demonstrates robustness in
terms of different hyper-parameter settings.

We further evaluate our model with different numbers of negative samples and
temperatures $\tau$ for preference-aware self-contrastive learning. Figure 6
shows the performance of different numbers of negative samples with {10, 50,
100, 500, 1000}. We observe a significant decrease in the F1 score when
employing an excessively large number of negative samples, due to the model
increased difficulty in converging for learning. The impacts of different
numbers of temperature $\tau$ are shown in Figure 7, which can see that the
performance of the F1 score is stable, which again illustrates the robust
capability of our proposed framework.

###  C.2 Extra Case Study

(a) SimpleHGN

(b) SATAR

(c) RGT

(d) SeGA (Ours)

Figure 8: The visualization of user embeddings with different minor user
preferences produced by the heterogeneous encoder and baselines.

We further visualize the t-SNE embedding results with an extreme case shown in
Figure 8. We sampled users who predominantly post content related to angry
news since topics related to news are often manipulated for malicious
activities, and selected normal users who post minority topic-emotion pairs
distinct from those of anomalous users. Given this clear distinction, the
model ideally should be capable of distinguishing between normal and anomalous
users. However, we can observe that existing methods (i.e., SimpleHGN, SATAR,
and RGT) have struggled to effectively differentiate anomalous users. In
contrast, our proposed SeGA can effectively differentiate between anomalous
users and normal users and establish a distinct boundary by leveraging these
subtle differences in their preferences.

## References

  * Agarwal et al. (2022) Agarwal, P.; Srivastava, M.; Singh, V.; and Rosenberg, C. 2022.  Modeling User Behavior With Interaction Networks for Spam Detection.  In _SIGIR_ , 2437–2442. ACM.
  * Alieva, Moffitt, and Carley (2022) Alieva, I.; Moffitt, J. D.; and Carley, K. M. 2022.  How disinformation operations against Russian opposition leader Alexei Navalny influence the international audience on Twitter.  _Soc. Netw. Anal. Min._ , 12(1): 80.
  * Balasubramanian et al. (2022) Balasubramanian, S. K.; Bilgic, M.; Culotta, A.; Hemphill, L.; Nikolich, A.; and Shapiro, M. A. 2022.  Leaders or Followers? A Temporal Analysis of Tweets from IRA Trolls.  In _ICWSM_ , 2–11. AAAI Press.
  * Bardes, Ponce, and LeCun (2022) Bardes, A.; Ponce, J.; and LeCun, Y. 2022.  VICRegL: Self-Supervised Learning of Local Visual Features.  In _NeurIPS_.
  * Bilot et al. (2023) Bilot, T.; Madhoun, N. E.; Agha, K. A.; and Zouaoui, A. 2023.  Graph Neural Networks for Intrusion Detection: A Survey.  _IEEE Access_ , 11: 49114–49139.
  * Chai et al. (2022) Chai, Z.; You, S.; Yang, Y.; Pu, S.; Xu, J.; Cai, H.; and Jiang, W. 2022.  Can Abnormality be Detected by Graph Neural Networks?  In _IJCAI_ , 1945–1951. ijcai.org.
  * Cresci et al. (2016) Cresci, S.; Pietro, R. D.; Petrocchi, M.; Spognardi, A.; and Tesconi, M. 2016.  DNA-Inspired Online Behavioral Modeling and Its Application to Spambot Detection.  _IEEE Intell. Syst._ , 31(5): 58–64.
  * Feng et al. (2022a) Feng, S.; Tan, Z.; Li, R.; and Luo, M. 2022a.  Heterogeneity-Aware Twitter Bot Detection with Relational Graph Transformers.  In _AAAI_ , 3977–3985. AAAI Press.
  * Feng et al. (2022b) Feng, S.; Tan, Z.; Wan, H.; Wang, N.; Chen, Z.; Zhang, B.; Zheng, Q.; Zhang, W.; Lei, Z.; Yang, S.; Feng, X.; Zhang, Q.; Wang, H.; Liu, Y.; Bai, Y.; Wang, H.; Cai, Z.; Wang, Y.; Zheng, L.; Ma, Z.; Li, J.; and Luo, M. 2022b.  TwiBot-22: Towards Graph-Based Twitter Bot Detection.  In _NeurIPS_.
  * Feng et al. (2021a) Feng, S.; Wan, H.; Wang, N.; Li, J.; and Luo, M. 2021a.  SATAR: A Self-supervised Approach to Twitter Account Representation Learning and its Application in Bot Detection.  In _CIKM_ , 3808–3817. ACM.
  * Feng et al. (2021b) Feng, S.; Wan, H.; Wang, N.; Li, J.; and Luo, M. 2021b.  TwiBot-20: A Comprehensive Twitter Bot Detection Benchmark.  In _CIKM_ , 4485–4494. ACM.
  * Feng et al. (2021c) Feng, S.; Wan, H.; Wang, N.; and Luo, M. 2021c.  BotRGCN: Twitter bot detection with relational graph convolutional networks.  In _ASONAM_ , 236–239. ACM.
  * Gao, Yao, and Chen (2021) Gao, T.; Yao, X.; and Chen, D. 2021.  SimCSE: Simple Contrastive Learning of Sentence Embeddings.  In _EMNLP (1)_ , 6894–6910. Association for Computational Linguistics.
  * Ghanem, Buscaldi, and Rosso (2019) Ghanem, B.; Buscaldi, D.; and Rosso, P. 2019.  TexTrolls: Identifying Russian Trolls on Twitter from a Textual Perspective.  _CoRR_ , abs/1910.01340.
  * Jim and Ann (2020) Jim; and Ann. 2020.  twitter topics – the mega list.  https://inboundfound.com/twitter-topics-list/.
  * Kipf and Welling (2017) Kipf, T. N.; and Welling, M. 2017.  Semi-Supervised Classification with Graph Convolutional Networks.  In _ICLR (Poster)_. OpenReview.net.
  * Liu et al. (2023) Liu, Y.; Han, T.; Ma, S.; Zhang, J.; Yang, Y.; Tian, J.; He, H.; Li, A.; He, M.; Liu, Z.; Wu, Z.; Zhu, D.; Li, X.; Qiang, N.; Shen, D.; Liu, T.; and Ge, B. 2023.  Summary of ChatGPT/GPT-4 Research and Perspective Towards the Future of Large Language Models.  _CoRR_ , abs/2304.01852.
  * Liu et al. (2019) Liu, Y.; Ott, M.; Goyal, N.; Du, J.; Joshi, M.; Chen, D.; Levy, O.; Lewis, M.; Zettlemoyer, L.; and Stoyanov, V. 2019.  RoBERTa: A Robustly Optimized BERT Pretraining Approach.  _CoRR_ , abs/1907.11692.
  * Loshchilov and Hutter (2019) Loshchilov, I.; and Hutter, F. 2019.  Decoupled Weight Decay Regularization.  In _ICLR (Poster)_. OpenReview.net.
  * Lv et al. (2021) Lv, Q.; Ding, M.; Liu, Q.; Chen, Y.; Feng, W.; He, S.; Zhou, C.; Jiang, J.; Dong, Y.; and Tang, J. 2021.  Are we really making much progress?: Revisiting, benchmarking and refining heterogeneous graph neural networks.  In _KDD_ , 1150–1160. ACM.
  * Miller et al. (2014) Miller, Z.; Dickinson, B.; Deitrick, W.; Hu, W.; and Wang, A. H. 2014.  Twitter spammer detection using data stream clustering.  _Inf. Sci._ , 260: 64–73.
  * Schlichtkrull et al. (2018) Schlichtkrull, M. S.; Kipf, T. N.; Bloem, P.; van den Berg, R.; Titov, I.; and Welling, M. 2018.  Modeling Relational Data with Graph Convolutional Networks.  In _ESWC_ , volume 10843 of _Lecture Notes in Computer Science_ , 593–607. Springer.
  * Varol et al. (2017) Varol, O.; Ferrara, E.; Davis, C. A.; Menczer, F.; and Flammini, A. 2017.  Online Human-Bot Interactions: Detection, Estimation, and Characterization.  In _ICWSM_ , 280–289. AAAI Press.
  * Velickovic et al. (2018) Velickovic, P.; Cucurull, G.; Casanova, A.; Romero, A.; Liò, P.; and Bengio, Y. 2018.  Graph Attention Networks.  In _ICLR (Poster)_. OpenReview.net.
  * Wang et al. (2022) Wang, S.; Xu, X.; Zhang, X.; Wang, Y.; and Song, W. 2022.  Veracity-aware and Event-driven Personalized News Recommendation for Fake News Mitigation.  In _WWW_ , 3673–3684. ACM.
  * Wang and Peng (2022) Wang, W.; and Peng, W. 2022.  Team Yao at Factify 2022: Utilizing Pre-trained Models and Co-attention Networks for Multi-Modal Fact Verification (short paper).  In _DE-FACTIFY@AAAI_ , volume 3199 of _CEUR Workshop Proceedings_. CEUR-WS.org.
  * Wu, Zhang, and Huang (2023) Wu, D.; Zhang, J.; and Huang, X. 2023.  Chain of Thought Prompting Elicits Knowledge Augmentation.  In _ACL (Findings)_ , 6519–6534. Association for Computational Linguistics.
  * Wu et al. (2021) Wu, J.; Zhao, C.; Yu, T.; Li, J.; and Li, S. 2021.  Clustering of Conversational Bandits for User Preference Learning and Elicitation.  In _CIKM_ , 2129–2139. ACM.
  * Zannettou et al. (2019) Zannettou, S.; Caulfield, T.; Cristofaro, E. D.; Sirivianos, M.; Stringhini, G.; and Blackburn, J. 2019.  Disinformation Warfare: Understanding State-Sponsored Trolls on Twitter and Their Influence on the Web.  In _WWW (Companion Volume)_ , 218–226. ACM.
  * Zhou et al. (2022) Zhou, X.; Shu, K.; Phoha, V. V.; Liu, H.; and Zafarani, R. 2022.  ”This is Fake! Shared it by Mistake”: Assessing the Intent of Fake News Spreaders.  In _WWW_ , 3685–3694. ACM.