Human perceiving behavior modeling in evaluation of code generation models (2022)

Abstract: Within this study, we evaluated a series of code generation models based on CodeGen and GPTNeo to compare the metric-based performance and human evaluation. For a deeper analysis of human perceiving within the evaluation procedure we’ve implemented a 5-level Likert scale assessment of the model output using a perceiving model based on the Theory of Planned Behavior (TPB). Through such analysis, we showed an extension of model assessment as well as a deeper understanding of the quality and applicability of generated code for practical question answering. The approach was evaluated with several model settings in order to assess diversity in quality and style of answer. With the TPB-based model, we showed a different level of perceiving the model result, namely personal understanding, agreement level, and readiness to use the particular code. With such analysis, we investigate a series of issues in code generation as natural language generation (NLG) problems observed in a practical context of programming question-answering with code.

## introduction recent advances in natural language generation (nlg) support rapid growth in potential areas of application. one of the significant successes of nlg is the possible generation of code in various settings @xcite : the translation of explicit specification into code, fixing errors, suggesting short snippets, etc. the common practice in nlg problems is the usage of known metrics (bertscore, bleu, etc.) to evaluate models. moreover, specific metrics dedicated to 1 https://stackoverflow.com/ code generation evaluation were developed, such as codebleu @xcite , ruby @xcite , and others. still, recent studies @xcite show that the direct application of metrics often leads to issues in code generation evaluation. with this in mind, investigated the applicability of human evaluation widely spread in nlg problems @xcite to assess an alternative approach to code evaluation and a deeper understanding of human perceiving of code generation @xcite . the study poses two research questions. first, how is human perceiving reflected by the text-or code-oriented nlp metrics? second, what is the structure of human perceiving in the human evaluation procedure in the questionanswering scenario? here we consider perceiving as an act of becoming subjectively aware and conscious of the observed information. the structure of the paper is as follows. the next section describes the datasets used in the study. the following section presets the details of code generation models' selection and preparation. section 4 describes human evaluation solutions and procedures. section 5 discusses the study results and evaluation results. finally, sections 6 and 7 provide a discussion and concluding remarks respectively. ## dataset within the study, we focused on question answering (qa) with a generation of short snippets as answers to real-world problems such as questions asked in stack overflow 1 (so). for consistency, we added the following restrictions to the questions and answers considered within the study, taking so as a reference for the analysis. alternatively, we prepared our own dataset from the original data on so questions available on stack exchange foot_1 . to follow our requirements, we selected questions with the tag "python". for reference, we selected answers that earned maximum scores according to the so data. to filter questions on presence or absence of code, we search the text @xmath0. after that, we selected questions with no explicit code paired with answers with a single code snippet. finally, we used regular expressions following @xcite to select "conceptual" and "api usage" classes of questions. furthermore, we performed cleaning of the code (e.g. removing decorations inserted by software (">>>", "in [1]:", etc.), comments, and checked the parsing status using tree-sitter foot_2 . after these steps, we obtained a dataset containing 42292 entries (pairs of questions and answers). out of them, we selected 1000 entries as a test dataset. the test dataset was built using questions from 2021 and beyond to lower possible data leaking as we are using models trained on publicly available data. ## discussion the study focused on code generation problems. for this purpose, we used modern nlg models (codegen, gpt) and performed fine-tuning to obtain a higher quality of the results according to the common pipeline. the results we obtained with the codegen model look promising and produce high-quality results comparable to the industrial solutions (copilot). still, we consider the further improvement of the code generation qa model as one of our future research directions. the main goal of the study is the investigation of the human perceiving structure in the nlg problem. the area of human evaluation is widely studied in different nlg settings including general assessment of natural language generation, as well as distinguishing model-generated from humangenerated answer. the common goal of most studies in the area is model improvement with collected evaluation feedback. still, the question of how we can evaluate human feedback and which level of trust can be given to it is still open. this problem becomes more challenging if the evaluation is performed in a complex domain where a human annotator needs to be a domain expert. in that case, the human feedback collection could be more expensive and can provide more diversity in judgments. with this in mind, we considered a problem of nlg in programming qa and code generation, with programmers as experts evaluating high-level correspondence of the answer to a proposed question. within the study, we focused on the general structure of human perceiving divided into three main parts: whether the human understands the model output; whether he/she considers it as correct; whether he/she is ready to use it in practice. this structure of human perceiving was considered previously in the expert-based evaluation of decision support systems @xcite and showed good results in understanding human intentions in perceiving ai-based prediction in such complex domains as medicine. within the study, we analyzed internal interconnection between human perceiving features in code generation and discovered that although the agreement and intention to use are highly correlated, the understanding (subjective correctness) and agreement show lower interconnections. this could be interpreted as a sign of existing issues in generated code properly recognized by a human, i.e., the answer generated by the model "looks like code" but doesn't resolve the question properly. on the other hand, the high interconnection between agreement and intention to use could be treated as promising results for code generation problems: if the code answers the question, it is good enough to be used. an interesting result obtained in the analysis of external interconnection of perceiving score is a rather weak mi of connections to the common nlp metrics. the only metric showing medium interconnection is ruby, intentionally developed for code evaluation with semantic comparison @xcite . we consider this result as a sign of the rather weak applicability of common nlp metrics to complex nlg problems. one of the questions raised during the evaluation is whether we can compare the syntactic correctness of the code to the subjective correctness (understanding) of the code. during the evaluation, we see several examples of code that was syntactically incorrect but may have been evaluated as useful (e.g. containing the correct line of code followed by an ill-formatted line). we believe that continuous likert-scale-based evaluation may help to improve the model training/finetuning in further studies with human evaluation. still, we consider this issue as one of the directions for the future development of the proposed approach. it is worth mentioning that codegen ft:so shows lower performance compared to codegen ft:c even on the so dataset. we suppose that a possible reason for such behavior is the fact that the conala dataset was manually curated and contains only one-line code answers. at the same time, the so dataset was not filtered in that way and contains answers of diverse length, structure, and quality. a further investigation of this issue is one of the directions for further research. the presented results can be used in two ways. first, to improve models by training with a deeper understanding of human perceiving structure. for example, the mentioned values could be considered as a sequential filter where the next step can be considered only by the answer passed from the previous one. in this way, the perceiving may be considered as a reward for the model in the generation of the answer. second, the understanding of human perceiving may improve human-computer interaction in aibased applications. for instance, the separate prediction of human perceiving features may provide important information depending on the interaction scenario. in particular, the agree score may be more influential in code automatically generated by explicit specification, while the use score may be more important in direct humancentered qa (e.g., in a form of an intelligent ide assistant). ## conclusion and future work the current study shows early results in the research of human perceiving understanding within the context of nlg human evaluation. being aimed at a deeper understanding of the internal structure of human perceiving and interconnection with common metrics, the study shows that perceiving structure may be decomposed into a complex value with implicit interconnection directing from model-generated structure evaluation to subjective intention to use. the proposed structure of human perceiving may be further used for collecting judgments in complex domains where direct application of common nlp metrics gives rather weak results and where a high semantic diversity in the possible answer may be observed. we consider the further development of the proposed study in the following directions. first, we would like to continue collecting human feedback in order to advance the development of the perceiving model. additionally, we would like to extend the research to analyze the personal characteristics of the human (in our case, it may be a personal experience, relevance to the question, etc.). second, we would like to investigate the possible application of the decomposed human perceiving value to model training/finetuning. third, we are interested in the extension of the model with technical characteristics of generated code (e.g. checking for syntactic errors, test-based evaluation). finally, we are planning to investigate the influence of the context on human perceiving including the dependencies from the application scenario.