On the Evaluation of NLP-based Models for Software Engineering

NLP-based models have been increasingly incorporated to address SE problems. These models are either employed in the SE domain with little to no change, or they are greatly tailored to source code and its unique characteristics. Many of these approaches are considered to be outperforming or complementing existing solutions. However, an important question arises here:"Are these models evaluated fairly and consistently in the SE community?". To answer this question, we reviewed how NLP-based models for SE problems are being evaluated by researchers. The findings indicate that currently there is no consistent and widely-accepted protocol for the evaluation of these models. While different aspects of the same task are being assessed in different studies, metrics are defined based on custom choices, rather than a system, and finally, answers are collected and interpreted case by case. Consequently, there is a dire need to provide a methodological way of evaluating NLP-based models to have a consistent assessment and preserve the possibility of fair and efficient comparison.


INTRODUCTION
Researchers have been using NLP-models to solve a diverse set of SE problems such as code generation, completion, summarization, bug fixing, question answering, test case generation, documentation, and many more. As these models attract more researchers and the number and diversity of studies grows, it is imperative to have good evaluation measures and techniques to assess them properly. These measures should be consistent throughout the literature in order to conduct fair and comparable comparisons. To understand the evaluation of NLP models, we reviewed the field in the past five years and report the results here. To the best of our knowledge, we are the first to conduct a systematic literature Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for third-party components of this work must be honored. For all other uses, contact the owner/author(s review on evaluation of NLP-based models to understand the underlying patterns, identify the challenges, and recommend future research direction.

METHODOLOGY
We conducted our systematic review using the following protocol. Our main research question is "How are NLP-based models evaluated in SE?". Search phrases in the title, abstract or body of a paper are NLP, natural language processing, code, and evaluation. Papers must be peer-reviewed, written in English, and be published after 2017 by one of the following SE prominent conferences and journals: ICSE, ESEC/FSE, ASE, IEEE TSE, ACM TOSEM, and EMSE. We used Google Scholar as the source, and retrieved 157 papers. Two of the authors manually inspected all papers to identify the papers that propose an NLP-based model to solve a SE problem. Finally, 53 papers were excluded because of one or more of the following reasons: the paper's scope was unrelated to NLP and SE, the main proposed model was not based on NLP, or it was a secondary or duplicate study. Next, we present the result of the review on the remaining 104 included papers. More information on the protocol and papers can be found in our GitHub repository. 1

EVALUATION OF NLP-BASED MODELS
There are two approaches to evaluation intrinsic with a focus on intermediary goals (sub-tasks), and extrinsic for assessing the performance of the final goal. NLP-based models in SE are generally evaluated with one or more of the following metrics.
(1) Automatically: Automatic evaluation consists of three groups, namely (i) metrics for assessing the results of classification models such as Accuracy, Precision, Recall, and F measure, (ii) metrics for assessing recommendation lists including @ or ranked versions such as MRR and MAP, and (iii) metrics for analyzing the quality of generated text or source code including BLEU, METEOR, ROUGE, CIDEr, chrF, Perplexity, and Levenshtein similarity metrics.
(2) Manually: Manual assessment is more subjective and heeds the judgment of human participants. Researchers first select the relevant metric(s) to evaluate different aspects of the proposed model's output. Then, they invite a group of experts to assess the results based on the selected metrics. For instance, for a code summarization task, researchers use informativeness as an indicator of the quality of the generated summaries from the developers' perspective.
Automatic evaluation is easier, faster, and completely objective compared to the manual version. Thus most researchers opt to use automatic evaluation for assessing their models. However, humanbased assessments can potentially convey more information for several aspects of a model, hence, they can be used to complement automatic evaluation. Recently, Roy et al. [12] conducted an empirical study on the applicability and interpretation of automatic metrics for evaluation of the. code summarization task. With the help of 226 human annotators, they assessed the degree to which automatic metrics reflect human evaluation. They claim that less than 2 points improvements for an automatic metric such as BLEU do not guarantee systematic improvements in summarization quality. This makes the role of human assessment salient.
Although automatic measures are uniformly defined in the literature, manual metrics are harder to define, interpret and use. These measures must be properly indicative of a model's goal and performance. Furthermore, their definitions and usage must be kept consistent to have comparable results. Hence, in the following we review the most popular existing manual assessment measures in the SE domain and leave the rest of them (such as effectiveness, comprehensibility, time-saving, relatedness, rightness, usability, recency, grammatically correctness, advantageousness, diversity, self-explanatory, theme identification, and more) for a more comprehensive study. Usefulness: Several studies define usefulness as how useful participants find the proposed solution for solving the problem at hand [2,4,7,11,16]. Others define usefulness as the tendency or preference of users to use their proposed model [17]. Jiang et al. [8] assess the usefulness of its results based on both its accuracy and the difficulty of generating outputs. That is, they focus on how often the model works when it is indeed needed. Naturalness, Expressiveness, Readability, and Understandability: Roy et al. [13] define naturalness as how easy it is to read and understand generated outputs. They also use readability to measure to what extent the output is perceived as readable and understandable by the participants. Aghamohammadi et al. [1] define naturalness as how smooth, human-readable, and syntactically-correct are their outputs. Gao et al. [5] measure naturalness as the grammatical correctness and fluency of a generated sentence. Zhou et al. [18] use expressiveness as whether their model's output is clear and understandable. Correctness or Content: Huang et al. [6] define correctness as whether participants can find the correct API using their proposed tool, while Chen et al. [3] define it as a measure to verify the general correctness of the abbreviations and synonyms in their thesaurus. In Roy et al. 's [13] study, content means whether a summary correctly reflects the content of a test case. Completeness and Informativeness: Uddin et al. [14] define completeness as a complete yet presentable summarization of API reviews. Aghamohammadi et al. [1] define informativeness as how much of the important parts of a piece of code are covered by a generated summary. Conciseness: In Roy et al. 's [13] study, concise summaries do not include extraneous or irrelevant information. Zhou et al. [18] quantifies conciseness through answering whether the repair recommendation is free of other constraint-irrelevant information. Relevance or Similarity: Several studies define relevance as to how relevant is the model's output to the reference text or code [2,5,11,16]. Others asked developers to rate the similarity, relatedness, and contextual or semantic similarity between outputs and reference texts [9,10,15].

DISCUSSION, AND FUTURE DIRECTION
We reviewed 104 studies to understand how NLP-based models are usually evaluated in the SE domain and provided the list of most used metrics. Next, we provide the main challenges for the evaluation of NLP-based models. (1) Both automatic and manual approaches can be utilized to provide a more holistic view of the performance of an NLP-based model, however, not all of the eligible studies use both of these approaches. (2) For the manual form of assessment, there exist numerous and sometimes conflicting or ambiguous evaluation metrics. This problem exacerbates in the case of measures with multiple definitions (e.g., informativeness) or in case of multiple metrics which are overlapping (e.g., naturalness, readability, understandability, and expressiveness). Some researchers evaluate different aspects of their model, (e.g., completeness, naturalness, or correctness) while others only address one or two aspects. As there are various aspects to each model, there should be a methodological way to first identify the most important aspects of a given SE task and then properly evaluate those aspects with concretely defined metrics. (3) In addition to the definition and use of the metrics, there is no standard for defining the set of answers. That is, some use yes/no answers, while others use -point Likert scale or even free-format text answers. (4) Finally, identifying novel evaluation metrics or techniques can help SE researchers assess these models more thoroughly and where it matters. For example, for the automatic code completion task, predicting an identifier is more valuable and difficult than predicting a keyword. Hence, evaluating models for predicting any token is not very helpful. Through reviewing the literature, we took the first step toward addressing the challenges of proper evaluation for NLP-based models. We suggest future research focus on providing a systematic and consistent framework for evaluation of these models to (1) clearly define measures, (2) distinguish between different needs of SE tasks, and (3) determine the proper use of a measure in the context. Hopefully, a systematic way of evaluation makes it possible to conduct fair and correct evaluations for the NLP-based models in the SE field.