Multi-head Span-based Detector for AI-generated Fragments in Scientific Papers (2024)

Abstract: This paper describes a system designed to distinguish between AI-generated and humanwritten scientific excerpts in the DAGPap24 competition hosted within the Fourth Workshop on Scientific Document Processing. In this competition the task is to find artificially generated token-level text fragments in documents of a scientific domain. Our work focuses on the use of a multi-task learning architecture with two heads. The application of this approach is justified by the specificity of the task, where class spans are continuous over several hundred characters. We considered different encoder variations to obtain a state vector for each token in the sequence, as well as a variation in splitting fragments into tokens to further feed into the input of a transform-based encoder. This approach allows us to achieve a 9% quality improvement relative to the baseline solution score on the development set (from 0.86 to 0.95) using the average macro F1-score, as well as a score of 0.96 on a closed test part of the dataset from the competition.

heading: 1 Introduction
text: Modern advances in the field of text generation models provide high quality artificial texts that are hardly distinguishable from human-written texts at fluent reading. Text generation systems such as Llama (Touvron et al., 2023), ChatGPT (Ray, 2023), Mistral (Jiang et al., 2023) are increasing the list of successfully solved problems in updated benchmarks (Li et al., 2023) with the release of each newer version of the product. Although the progress of such models is impressive, it poses new challenges for scientists, as the development of these systems implies the emergence and spread of generated fragments in texts of the scientific domain. In the field of Natural Language Processing there are already a large number of methodologies for detecting texts generated by machine learning models (Jawahar et al., 2020), including
approaches for the scientific domain (Liyanage and Buscaldi, 2023; Gritsay and Chekhovich, 2023). Therefore, the improvement of artificial text detection techniques occurs simultaneously with the improvement of text generation methods. In order to prevent the gap between quality generation and precision of detection from growing, it is necessary to periodically update and modernise existing detection approaches with newly generated fragments. Indeed, increasing the appearance of generated fragments in scientific papers carries with it a potential increase in plagiarism (Bakhteev et al., 2022), fake studies (Bakhteev et al., 2020) and missinformation.
The DAGPap24 competition allowed us to perform a further cycle of updates and make a reliable AI-generated scientific text detection system. The challenge is to build a detection system that is robust to generated fragments from fundamentally different frameworks and diverse scientific domains.
In this paper, we present a solution that was developed for the DAGPap24 competition by our team. We propose a method to find artificially generated fragments at the token level using a multitask architecture. Our model has two classifiers for each token, that are trained jointly and allow the model to have a higher generalisation capability and to process the text sequences arriving at the input faster. We introduce the aforementioned architecture in this paper and conduct experiments to tune its components to obtain the best result.

heading: 2 Data and task description
text: The DAGPap24 competition has been formulated as one classification task for the English language. Participants had to identify intervals in the scientific text that were human-written or machinegenerated accordingly. The intervals are not fixed in advance and have to be labelled automatically by
220
the detection algorithm based on the context. The problem has been proposed to be solved by token classification approaches from the competition organisers. A large number of works on artificial text detection is dealing with the classification problem at sequence level (Ippolito et al., 2020). However, the approach of token classification and their subsequent grouping into intervals of the same class is also able to show a competitive performance in this task, in some cases producing better results than the established approach (Jafari, 2022). According to the organisers the task contains scientific texts whose tokens should be classified into one of four classes: human, generated by ChatGPT, generated using synonyms from NLTK (Loper and Bird, 2002), generated using an unnamed summarisation model.

heading: 2.1 Task Definition
text: In this competition, it is expected that the problem of detecting machine-generated fragments will be solved as a token classification task. There is a given dataset D = {(xi, yi)}Ni=1, where each document xi is represented by a finite combination of tokens:
xi = {x1i , . . . , xmi }, xji ∈ W, j ∈ {1, . . . ,m},
yi = {y1i , . . . , ymi }, yji ∈ {0, 1, 2, 3},
where W corresponds to chosen tokens vocabulary. The labels yji ∈ {1, 2, 3} correspond to tokens that are likely machine-generated with synonymreplacement, ChatGPT-generated or summarized respectively and yji = 0 corresponds to humanwritten ones.
Formally, the task is to find a multiclass classifier that minimizes the empirical risk on the dataset D:
ĝ = argmin g∈F
N∑
i=1
Mi∑
j
[g(xji ) ̸= y j i ], (1)
where Mi is a number of tokens in i-th document, F is a set of all considered classification models.

heading: 2.2 Data
text: The organisers of the competition provided a training dataset that contained 5000 samples. Each sample was represented by text, annotations, tokens of the corresponding text and labels for each token. Example rows from the dataset can be seen in Table 1.
All texts in the rows of the dataset are documents from the scientific domain in which some parts have been replaced by machine-generated sequences. Fake text can even start in the middle of a sentence, so it is important to take the context into account when doing classification.
Before starting to build a model solution to the problem, we analysed the provided dataset. Some of its statistics can be seen in Table 2. The texts written by humans are equalled by the remaining three classes in terms of quantity, so to balance the classes all the artificially generated samples could be combined into one group. The human-written texts remain, understandably, longer in terms of average length for both tokens and characters. What is also notable is the length and quality of the generated texts under the summarised label. The excerpts of this class are shorter than the others and when analysed visually they immediately catch the eye due to the lack of postprocessing of the summarization model, the texts are contaminated with unnecessary symbols.

heading: 3 Approach

heading: 3.1 Model
text: There are several ways to solve the given problem, we have chosen the token classification approach. One of its subfields is Grammatical Error Correction (GEC) (Bryant et al., 2023), which aims to correct as many errors as possible in a given passage. It correlates with our task, where, for example, the junction from one class to another can be in an uncommon place and of any length, so we need to identify the boundaries very precisely. One state-of-the-art solution is the approach described by (Omelianchuk et al., 2020). Their GECToR model has a custom multi-head transformer-based architecture with and solves the GEC problem with sequence tagging. We decided to use a similar architecture with our extension in the machinegenerated fragments detection domain where we need to solve the problem at the token level. The architecture we use is shown in Figure 1.

heading: 3.2 Training and inference stages
text: The token sequence that comes to the input of the algorithm is vectorised using a BERT-like encoder (Devlin et al., 2018), further the vector for each token is fed in parallel to the input of two linear layers with dropout. The major difference from the standard BERT-like approach for this task is the
presence of two classification heads and multi-task learning. In our approach, one head (Linear A) is responsible for binary classification - human or machine-generated, while the second head (Linear B) solves the multi-class classification for the 4 classes that have been posed in the current competition. Thus, when training such a network, the loss function aggregates the error values from both heads and sums them up.
Previous studies have captured that the multitask learning approach reduces the probability of overfitting and increases the generalisability of the trained system (Crawshaw, 2020). As for inference, we calculate the probability for each token of a given sequence to contain machine-generated data using Linear A and softmax. If the maximum probability among all tokens of the sequence has a value that is higher than a predefined threshold, then classification of each token of the given sequence is performed by multiclass layer - Linear B, otherwise we produce a label of human class. This approach on inference reflects the specificity of the current task, where, based on the statistics obtained in the previous section, it can be seen that texts are not interrupted by single insertions of a token from another class, and most often spans have long continuity intervals. Among the classes present, the length of human texts is most often higher than the others. Due to the limited number of charac-
ters that can be included in one sequence and fed to the BERT-like encoder input, sequences in this paradigm will most often contain only tokens of the same class.

heading: 4 Experiments
text: The organisers of the competition presented a basic solution: DistilBERT (Sanh et al., 2019) and SciBERT (Beltagy et al., 2019). Both models were finetuned with the classical architecture and pipeline of the token classification task. Considering the limited time of the competition, we planned experiments with the architecture described in the previous section: varying the input sequence length, changing BERT-like encoders and selecting hyper-
parameters.

heading: 4.1 Varying the input sequence length
text: BERT-like models have a constraint on the length of the input sequence. In earlier studies in the machine-generated fragment detection task, we analysed the effect of input length on detection quality (Gritsay et al., 2022). In the current task, each example was accompanied by a sentence partitioning into word tokens. However, depending on the choice of tokeniser, these token-words can be broken down into different numbers of smaller tokens to feed into the model input. For example, the dictionaries of the tokeniser adapted for this domain - SciBERT - have a large number of complete token-words, which means that splitting the original ones into smaller units will be minimal. Given this fact, we need to make sure that after tokenisation by the chosen tokeniser, the sequence that comes to the input of the model is not clipped and does not lose information that is useful for training algorithms. For different models we tried different ways of partitioning.

heading: 4.2 Changing BERT-like encoders
text: The baseline result that was shown with the SciBERT model displayed high score. Currently, there are a large number of pre-trained encoders that are able to show good basic quality solution to the problem. However, further pre-training under the specific domain performs differently for all models. This is the motivation behind the encoder variation approach. Looking back at the experience of (Omelianchuk et al., 2020), who proposed the GECToR architecture, we also examined XLNet (Yang et al., 2019). In addition, we tried the approach with the QLoRa adapter (Dettmers et al., 2023) pre-training for the token classification task with the large language model (LLM) Mistral. This language model, according to benchmark results, is capable of solving an impressive number of tasks at a high level. Domain-specific LLM adaptor training may sometimes circumvent the quality of problem solving with established encoder models, such as RoBERTa (Liu et al., 2019), DeBERTa (He et al., 2020), etc.

heading: 5 Results
text: The results of the experiments can be seen in Table 3. The specificity of the task, scientific domain, allowed us to keep the SciBERT model as the main encoder for our architecture after the experiments.
However, as shown in the table, the best quality is achieved when the texts are divided into intervals of 350 token-words. Given the limited input context of transformed-based models, it is the case that the least amount of information is lost after tokenisation, thus achieving the highest quality. In addition, the dropout value was selected, and after varying it was set to 0.7. Also it was observed that with the threshold value set to 0.55, a quality improvement is obtained to drop human-written sequences during inference. The previously described architecture with two linear layers together with these settings helped our team to achieve the quality of 0.96 average macro F1-score on the development set. As for the test set, the results were similar and we took 5th place in the competition with an average of 0.96.

heading: 6 Conclusion
text: In this paper we present a descriptive overview of the solution approach that was used by our team to solve the DAGPap24 competition for detecting AI-generated fragments in scientific documents. A token classification approach was chosen to map each token to one of four pre-defined classes. In our solution, we used a BERT-based encoder and two linear layers to process the output vectors of the encoder for each token in sequence. One of the layers is responsible for binary classification and the other for the predefined 4 classes. Exploring shared training, the classification quality becomes better for identical model settings, and on the provided development dataset, this method helped to improve the quality by 9% on the macro F1-score metric.
In the future work we would be interested in analysing the distribution of the metric across classes and based on this we would like to add weights to the loss function during pre-training for class balancing. In addition, it would be interesting to observe this approach on a larger dataset, where classes can be defined by more common text generation methods.

heading: Future Work
text: In the future work we would be interested in analysing the distribution of the metric across classes and based on this we would like to add weights to the loss function during pre-training for class balancing. In addition, it would be interesting to observe this approach on a larger dataset, where classes can be defined by more common text generation methods