KR102610431B1 - Apparatus and method for generating summary of program source code based on ai analysis - Google Patents

Apparatus and method for generating summary of program source code based on ai analysis Download PDF

Info

Publication number
KR102610431B1
KR102610431B1 KR1020210150771A KR20210150771A KR102610431B1 KR 102610431 B1 KR102610431 B1 KR 102610431B1 KR 1020210150771 A KR1020210150771 A KR 1020210150771A KR 20210150771 A KR20210150771 A KR 20210150771A KR 102610431 B1 KR102610431 B1 KR 102610431B1
Authority
KR
South Korea
Prior art keywords
source code
generating
program
embedding
attention
Prior art date
Application number
KR1020210150771A
Other languages
Korean (ko)
Other versions
KR20230065017A (en
Inventor
한요섭
손지경
한중혁
서현태
Original Assignee
연세대학교 산학협력단
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 연세대학교 산학협력단 filed Critical 연세대학교 산학협력단
Priority to KR1020210150771A priority Critical patent/KR102610431B1/en
Publication of KR20230065017A publication Critical patent/KR20230065017A/en
Application granted granted Critical
Publication of KR102610431B1 publication Critical patent/KR102610431B1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/34Browsing; Visualisation therefor
    • G06F16/345Summarisation for human users
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/36Creation of semantic tools, e.g. ontology or thesauri
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding

Abstract

본 발명은 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치 및 방법에 관한 것으로, 상기 장치는 특정 프로그램에 관한 소스코드 및 요약문을 입력받는 프로그램 입력부; 상기 소스코드를 분석하여 간선과 노드로 구성된 프로그램 의존 그래프를 생성하는 그래프 생성부; 상기 소스코드 및 상기 요약문을 기초로 적어도 하나의 어휘사전을 생성하는 어휘사전 생성부; 및 동작 과정에서 상기 적어도 하나의 어휘사전이 적용되는 인코더(Encoder)와 디코더(Decoder)를 포함하고, 상기 소스코드에 대응되는 소스코드 임베딩을 기초로 상기 노드의 어텐션을 산출하여 소스코드 요약문을 생성하는 소스코드 요약문 생성부;를 포함한다.The present invention relates to an apparatus and method for generating a summary of program source code based on artificial intelligence analysis, the apparatus comprising: a program input unit that receives source code and a summary for a specific program; a graph generator that analyzes the source code and generates a program dependency graph composed of edges and nodes; a vocabulary dictionary generator that generates at least one vocabulary dictionary based on the source code and the summary sentence; And an encoder and a decoder to which the at least one vocabulary dictionary is applied during the operation process, and generate a source code summary by calculating the attention of the node based on the source code embedding corresponding to the source code. Includes a source code summary generation unit.

Description

인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치 및 방법{APPARATUS AND METHOD FOR GENERATING SUMMARY OF PROGRAM SOURCE CODE BASED ON AI ANALYSIS}Apparatus and method for generating a summary of program source code based on artificial intelligence analysis {APPARATUS AND METHOD FOR GENERATING SUMMARY OF PROGRAM SOURCE CODE BASED ON AI ANALYSIS}

본 발명은 소스코드 요약 기술에 관한 것으로, 보다 상세하게는 기존의 트랜스포머 모델을 기반으로 그래프 처리 모델을 적용하여 프로그램 소스코드에 대한 자연어 요약문을 생성하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치 및 방법에 관한 것이다.The present invention relates to source code summarization technology, and more specifically, an artificial intelligence analysis-based program source code summary generator that generates a natural language summary of the program source code by applying a graph processing model based on the existing transformer model, and It's about method.

소스코드(source code)의 요약은 코드에 관한 간단한 자연어(natural language) 설명을 생성하는 작업에 해당할 수 있다. 소스코드에 대한 간단한 설명은 프로그래머가 코드 자체를 읽을 필요없이 해당 코드의 동작과 전체 프로그램에서 해당 코드의 목적을 쉽게 이해하도록 할 수 있다.Summarizing source code may correspond to the task of creating a simple natural language description of the code. A simple description of the source code can help programmers easily understand the operation of the code and its purpose in the overall program without having to read the code itself.

또한, 프로그래머는 소스코드에 대한 요약문을 통해 해당 코드의 동작에 대한 명확한 그림을 그릴 수 있고, 해당 코드의 구체적인 동작을 이해하는데 소요되는 시간을 절약할 수 있다.Additionally, through a summary of the source code, programmers can draw a clear picture of the operation of the code and save time spent understanding the specific operation of the code.

이에 따라, 자동 코드 요약 기술은 빠르게 연구되어 왔으며, 최근에는 AI, 자연어 처리(NLP) 및 마이닝(mining) 분야에서 신경망을 적용하여 소스코드의 요약문을 생성하고자 하는 시도가 존재한다.Accordingly, automatic code summarization technology has been rapidly researched, and recently, there have been attempts to generate source code summaries by applying neural networks in the fields of AI, natural language processing (NLP), and mining.

한국공개특허 제10-2013-0116908호 (2013.10.24)Korean Patent Publication No. 10-2013-0116908 (2013.10.24)

소스코드와 추상구문트리를 이용하는 기존의 소스코드 요약생성 모델의 경우 구조정보 학습을 위한 별도의 인코더를 둠으로써 모델의 크기가 커져 훈련 효율성이 상대적으로 낮은 문제점이 있다. 또한, 소스코드의 제어흐름을 이용한 기존의 소스코드 요약생성 모델의 경우 제어흐름을 사전 학습하는 과정이 추가되어 이중훈련이 필요하고 요약문을 생성하는데 데이터흐름 정보를 포함하지 않는 문제점이 있다.In the case of the existing source code summary generation model that uses source code and abstract syntax tree, there is a problem in that training efficiency is relatively low because the size of the model increases by having a separate encoder for learning structural information. In addition, in the case of the existing source code summary generation model using the control flow of the source code, a process of pre-learning the control flow is added, requiring double training, and there is a problem in that data flow information is not included in generating the summary.

본 발명에 따른 기존의 트랜스포머 모델을 기반으로 그래프 처리 모델을 적용하여 프로그램 소스코드에 대한 자연어 요약문을 생성하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치 및 방법을 제공하고자 한다.The present invention seeks to provide an artificial intelligence analysis-based program source code summary generation device and method that generates a natural language summary of the program source code by applying a graph processing model based on the existing transformer model according to the present invention.

실시예들 중에서, 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치는 특정 프로그램에 관한 소스코드 및 요약문을 입력받는 프로그램 입력부; 상기 소스코드를 분석하여 간선과 노드로 구성된 프로그램 의존 그래프를 생성하는 그래프 생성부; 상기 소스코드 및 상기 요약문을 기초로 적어도 하나의 어휘사전을 생성하는 어휘사전 생성부; 및 동작 과정에서 상기 적어도 하나의 어휘사전이 적용되는 인코더(Encoder)와 디코더(Decoder)를 포함하고, 상기 소스코드에 대응되는 소스코드 임베딩을 기초로 상기 노드의 어텐션을 산출하여 소스코드 요약문을 생성하는 소스코드 요약문 생성부;를 포함한다.Among embodiments, an apparatus for generating a summary of a program source code based on artificial intelligence analysis includes a program input unit that receives source code and a summary for a specific program; a graph generator that analyzes the source code and generates a program dependency graph composed of edges and nodes; a vocabulary dictionary generator that generates at least one vocabulary dictionary based on the source code and the summary sentence; And an encoder and a decoder to which the at least one vocabulary dictionary is applied during the operation process, and generate a source code summary by calculating the attention of the node based on the source code embedding corresponding to the source code. Includes a source code summary generation unit.

이때, 상기 인코더(Encoder)는 트랜스포머(transformer) 과정의 출력이 그래프 합성곱 과정의 입력에 연결되도록 구현될 수 있다.At this time, the encoder may be implemented so that the output of the transformer process is connected to the input of the graph convolution process.

상기 그래프 생성부는 상기 소스코드의 코드 블록을 상기 노드로 구성하고 데이터 플로우 또는 제어 플로우로 정의되는 상기 노드 간의 연결을 상기 간선으로 구성할 수 있다.The graph generator may configure code blocks of the source code as the nodes, and configure connections between the nodes defined as data flows or control flows as the trunk lines.

상기 어휘사전 생성부는 최대 빈도수를 기준으로 상기 어휘사전에 있는 어휘 개수를 상위 N 개로 제한할 수 있고, 상기 N은 상기 소스코드의 크기에 비례할 수 있다.The vocabulary dictionary generator may limit the number of vocabulary words in the vocabulary dictionary to the top N based on the maximum frequency, and N may be proportional to the size of the source code.

상기 소스코드 요약문 생성부는 상기 소스코드의 입력 토큰들에 대한 워드 임베딩을 통해 각 입력 토큰 별로 각각이 해당 토큰의 의미 정보와 위치 정보를 포함하는 토큰 임베딩 및 위치 임베딩을 생성하고, 상기 토큰 임베딩 및 상기 위치 임베딩 간의 합 연산에 의해 생성된 임베딩 벡터를 상기 인코더의 입력으로 사용할 수 있다.The source code summary generator generates a token embedding and a location embedding each including semantic information and location information of the corresponding token for each input token through word embedding of the input tokens of the source code, and generates the token embedding and the location embedding. An embedding vector generated by a sum operation between position embeddings can be used as an input to the encoder.

상기 소스코드 요약문 생성부는 상기 소스코드 임베딩을 기초로 상기 입력 토큰들의 어텐션을 산출하여 상기 소스코드 내 자기학습을 강화하는 셀프 어텐션(self-attention) 과정과, 상기 셀프 어텐션 과정의 결과로서 획득된 노드 어텐션 벡터를 완전 연결 계층에 입력하여 노드 잠재표현 벡터를 생성하는 피드 포워드(feed forward) 과정을 포함하는 상기 트랜스포머 과정을 수행할 수 있다.The source code summary generator calculates the attention of the input tokens based on the source code embedding and performs a self-attention process to enhance self-learning in the source code, and a node obtained as a result of the self-attention process. The transformer process including a feed forward process of generating a node latent expression vector by inputting the attention vector to a fully connected layer can be performed.

상기 소스코드 요약문 생성부는 상기 그래프 합성곱 과정에서 상기 프로그램 의존 그래프의 간선 정보를 기초로 상기 노드 잠재표현 벡터 간의 합성 곱을 반복적으로 수행하여 상기 노드의 어텐션을 산출할 수 있다.The source code summary generator may calculate the attention of the node by repeatedly performing convolution between the node latent expression vectors based on edge information of the program-dependent graph in the graph convolution process.

상기 소스코드 요약문 생성부는 상기 노드의 어텐션과 상기 요약문을 상기 디코더에 입력하여 요약 어휘 임베딩을 생성할 수 있다.The source code summary generator may input the attention of the node and the summary to the decoder to generate a summary vocabulary embedding.

상기 소스코드 요약문 생성부는 상기 노드의 어텐션을 상기 디코더의 멀티 헤드 어텐션 과정의 입력으로 사용할 수 있다.The source code summary generator may use the attention of the node as an input to the multi-head attention process of the decoder.

상기 소스코드 요약문 생성부는 상기 요약 어휘 임베딩을 활성화 함수에 적용한 결과를 기초로 상기 소스코드 요약문을 생성할 수 있다.The source code summary generator may generate the source code summary based on a result of applying the summary vocabulary embedding to an activation function.

실시예들 중에서, 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법은 특정 프로그램의 소스코드를 분석하여 프로그램 의존 그래프를 생성하는 단계; 상기 소스코드 및 상기 특정 프로그램에 관한 요약문을 기초로 적어도 하나의 어휘사전을 생성하는 단계; 상기 소스코드에 대응되는 소스코드 임베딩을 생성하는 단계; 상기 소스코드 임베딩을 기초로 상기 프로그램 의존 그래프의 노드들에 관한 제1 노드 임베딩을 생성하는 단계; 상기 제1 노드 임베딩 및 상기 프로그램 의존 그래프의 간선 정보를 이용하여 그래프 어텐션(graph attention)을 수행하는 단계; 상기 그래프 어텐션에 따른 노드들의 제2 노드 임베딩 및 상기 요약문을 기초로 요약 어휘들에 관한 요약 어휘 임베딩을 생성하는 단계; 및 상기 요약 어휘 임베딩을 기초로 상기 소스코드에 관한 소스코드 요약문을 생성하는 단계;를 포함한다.Among embodiments, a method for generating a summary of a program source code based on artificial intelligence analysis includes the steps of analyzing the source code of a specific program to generate a program dependency graph; generating at least one vocabulary dictionary based on the source code and a summary of the specific program; generating source code embedding corresponding to the source code; generating first node embeddings for nodes of the program dependency graph based on the source code embeddings; performing graph attention using the first node embedding and edge information of the program dependent graph; generating summary vocabulary embeddings for summary vocabularies based on second node embeddings of nodes according to the graph attention and the summary sentence; and generating a source code summary regarding the source code based on the summary vocabulary embedding.

상기 소스코드 임베딩을 생성하는 단계는 상기 소스코드의 입력 토큰들에 대한 워드 임베딩을 통해 각 입력 토큰 별로 각각이 해당 토큰의 의미 정보와 위치 정보를 포함하는 토큰 임베딩 및 위치 임베딩을 생성하는 단계; 및 상기 토큰 임베딩 및 상기 위치 임베딩 간의 합 연산을 통해 임베딩 벡터를 생성하는 단계를 포함할 수 있다.The step of generating the source code embedding includes generating a token embedding and a location embedding for each input token, each including semantic information and location information of the corresponding token, through word embedding of the input tokens of the source code; And it may include generating an embedding vector through a sum operation between the token embedding and the position embedding.

상기 제1 노드 임베딩을 생성하는 단계는 셀프 어텐션(self-attention) 과정을 통해 상기 소스코드 임베딩을 기초로 상기 입력 토큰들의 어텐션을 산출하여 상기 소스코드 내 자기학습을 강화하는 단계; 및 피드 포워드(feed forward) 과정을 통해 상기 셀프 어텐션 과정의 결과로서 획득된 노드 어텐션 벡터를 완전 연결 계층에 입력하여 노드 잠재표현 벡터를 생성하는 단계를 포함할 수 있다.The step of generating the first node embedding includes calculating attention of the input tokens based on the source code embedding through a self-attention process to strengthen self-learning in the source code; and generating a node latent expression vector by inputting the node attention vector obtained as a result of the self-attention process into a fully connected layer through a feed forward process.

상기 그래프 어텐션을 수행하는 단계는 상기 프로그램 의존 그래프의 간선 정보를 기초로 상기 제1 노드 임베딩 간의 합성 곱을 반복적으로 수행하는 단계를 포함할 수 있다.The step of performing the graph attention may include repeatedly performing a convolution between the first node embeddings based on edge information of the program dependent graph.

상기 소스코드 요약문을 생성하는 단계는 상기 요약 어휘 임베딩을 활성화 함수에 적용한 결과를 기초로 상기 소스코드 요약문을 생성하는 단계를 포함할 수 있다.The step of generating the source code summary may include generating the source code summary based on a result of applying the summary vocabulary embedding to an activation function.

개시된 기술은 다음의 효과를 가질 수 있다. 다만, 특정 실시예가 다음의 효과를 전부 포함하여야 한다거나 다음의 효과만을 포함하여야 한다는 의미는 아니므로, 개시된 기술의 권리범위는 이에 의하여 제한되는 것으로 이해되어서는 아니 될 것이다.The disclosed technology can have the following effects. However, since it does not mean that a specific embodiment must include all of the following effects or only the following effects, the scope of rights of the disclosed technology should not be understood as being limited thereby.

본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치 및 방법은 기존의 트랜스포머 모델을 기반으로 그래프 처리 모델을 적용하여 프로그램 소스코드에 대한 자연어 요약문을 효과적으로 생성할 수 있다.The apparatus and method for generating a summary of program source code based on artificial intelligence analysis according to the present invention can effectively generate a natural language summary of the program source code by applying a graph processing model based on the existing transformer model.

본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치 및 방법은 트랜스포머 기반의 code-to-sequence 모델에 GCN 계층을 추가적으로 사용하여 소스코드의 시퀀스 정보뿐 아니라 그래프의 구조정보가 담긴 요약을 생성할 수 있다.The device and method for generating a summary of program source code based on artificial intelligence analysis according to the present invention additionally uses a GCN layer in a transformer-based code-to-sequence model to generate a summary containing not only sequence information of the source code but also structure information of the graph. can do.

도 1은 본 발명에 따른 요약문 생성 시스템을 설명하는 도면이다.
도 2는 본 발명에 따른 요약문 생성 장치의 시스템 구성을 설명하는 도면이다.
도 3은 본 발명에 따른 요약문 생성 장치의 기능적 구성을 설명하는 도면이다.
도 4는 본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법을 설명하는 순서도이다.
도 5는 본 발명에 따른 요약문 생성 인공지능 프로그램을 설명하는 도면이다.
도 6은 본 발명에 따른 프로그램 의존 그래프를 설명하는 도면이다.
도 7은 본 발명에 따른 소스코드 토큰의 유형을 설명하는 도면이다.
도 8은 소스코드 입력에 따른 그래프 및 요약문 생성 과정의 일 실시예를 설명하는 도면이다.
1 is a diagram illustrating a summary generating system according to the present invention.
Figure 2 is a diagram explaining the system configuration of the summary text generating device according to the present invention.
Figure 3 is a diagram explaining the functional configuration of the summary text generating device according to the present invention.
Figure 4 is a flowchart explaining a method of generating a summary of artificial intelligence analysis-based program source code according to the present invention.
Figure 5 is a diagram illustrating an artificial intelligence program for generating a summary statement according to the present invention.
Figure 6 is a diagram illustrating a program dependency graph according to the present invention.
Figure 7 is a diagram explaining the types of source code tokens according to the present invention.
Figure 8 is a diagram illustrating an embodiment of a graph and summary generation process according to source code input.

본 발명에 관한 설명은 구조적 내지 기능적 설명을 위한 실시예에 불과하므로, 본 발명의 권리범위는 본문에 설명된 실시예에 의하여 제한되는 것으로 해석되어서는 아니 된다. 즉, 실시예는 다양한 변경이 가능하고 여러 가지 형태를 가질 수 있으므로 본 발명의 권리범위는 기술적 사상을 실현할 수 있는 균등물들을 포함하는 것으로 이해되어야 한다. 또한, 본 발명에서 제시된 목적 또는 효과는 특정 실시예가 이를 전부 포함하여야 한다거나 그러한 효과만을 포함하여야 한다는 의미는 아니므로, 본 발명의 권리범위는 이에 의하여 제한되는 것으로 이해되어서는 아니 될 것이다.Since the description of the present invention is only an example for structural or functional explanation, the scope of the present invention should not be construed as limited by the examples described in the text. In other words, since the embodiments can be modified in various ways and can have various forms, the scope of rights of the present invention should be understood to include equivalents that can realize the technical idea. In addition, the purpose or effect presented in the present invention does not mean that a specific embodiment must include all or only such effects, so the scope of the present invention should not be understood as limited thereby.

한편, 본 출원에서 서술되는 용어의 의미는 다음과 같이 이해되어야 할 것이다.Meanwhile, the meaning of the terms described in this application should be understood as follows.

"제1", "제2" 등의 용어는 하나의 구성요소를 다른 구성요소로부터 구별하기 위한 것으로, 이들 용어들에 의해 권리범위가 한정되어서는 아니 된다. 예를 들어, 제1 구성요소는 제2 구성요소로 명명될 수 있고, 유사하게 제2 구성요소도 제1 구성요소로 명명될 수 있다.Terms such as “first” and “second” are used to distinguish one component from another component, and the scope of rights should not be limited by these terms. For example, a first component may be named a second component, and similarly, the second component may also be named a first component.

어떤 구성요소가 다른 구성요소에 "연결되어"있다고 언급된 때에는, 그 다른 구성요소에 직접적으로 연결될 수도 있지만, 중간에 다른 구성요소가 존재할 수도 있다고 이해되어야 할 것이다. 반면에, 어떤 구성요소가 다른 구성요소에 "직접 연결되어"있다고 언급된 때에는 중간에 다른 구성요소가 존재하지 않는 것으로 이해되어야 할 것이다. 한편, 구성요소들 간의 관계를 설명하는 다른 표현들, 즉 "~사이에"와 "바로 ~사이에" 또는 "~에 이웃하는"과 "~에 직접 이웃하는" 등도 마찬가지로 해석되어야 한다.When a component is referred to as being “connected” to another component, it should be understood that it may be directly connected to the other component, but that other components may exist in between. On the other hand, when a component is referred to as being “directly connected” to another component, it should be understood that there are no other components in between. Meanwhile, other expressions that describe the relationship between components, such as "between" and "immediately between" or "neighboring" and "directly neighboring" should be interpreted similarly.

단수의 표현은 문맥상 명백하게 다르게 뜻하지 않는 한 복수의 표현을 포함하는 것으로 이해되어야 하고, "포함하다"또는 "가지다" 등의 용어는 실시된 특징, 숫자, 단계, 동작, 구성요소, 부분품 또는 이들을 조합한 것이 존재함을 지정하려는 것이며, 하나 또는 그 이상의 다른 특징이나 숫자, 단계, 동작, 구성요소, 부분품 또는 이들을 조합한 것들의 존재 또는 부가 가능성을 미리 배제하지 않는 것으로 이해되어야 한다.Singular expressions should be understood to include plural expressions unless the context clearly indicates otherwise, and terms such as “comprise” or “have” refer to implemented features, numbers, steps, operations, components, parts, or them. It is intended to specify the existence of a combination, and should be understood as not excluding in advance the possibility of the presence or addition of one or more other features, numbers, steps, operations, components, parts, or combinations thereof.

각 단계들에 있어 식별부호(예를 들어, a, b, c 등)는 설명의 편의를 위하여 사용되는 것으로 식별부호는 각 단계들의 순서를 설명하는 것이 아니며, 각 단계들은 문맥상 명백하게 특정 순서를 기재하지 않는 이상 명기된 순서와 다르게 일어날 수 있다. 즉, 각 단계들은 명기된 순서와 동일하게 일어날 수도 있고 실질적으로 동시에 수행될 수도 있으며 반대의 순서대로 수행될 수도 있다.For each step, identification codes (e.g., a, b, c, etc.) are used for convenience of explanation. The identification codes do not explain the order of each step, and each step clearly follows a specific order in context. Unless specified, events may occur differently from the specified order. That is, each step may occur in the same order as specified, may be performed substantially simultaneously, or may be performed in the opposite order.

본 발명은 컴퓨터가 읽을 수 있는 기록매체에 컴퓨터가 읽을 수 있는 코드로서 구현될 수 있고, 컴퓨터가 읽을 수 있는 기록 매체는 컴퓨터 시스템에 의하여 읽혀질 수 있는 데이터가 저장되는 모든 종류의 기록 장치를 포함한다. 컴퓨터가 읽을 수 있는 기록 매체의 예로는 ROM, RAM, CD-ROM, 자기 테이프, 플로피 디스크, 광 데이터 저장 장치 등이 있다. 또한, 컴퓨터가 읽을 수 있는 기록 매체는 네트워크로 연결된 컴퓨터 시스템에 분산되어, 분산 방식으로 컴퓨터가 읽을 수 있는 코드가 저장되고 실행될 수 있다.The present invention can be implemented as computer-readable code on a computer-readable recording medium, and the computer-readable recording medium includes all types of recording devices that store data that can be read by a computer system. . Examples of computer-readable recording media include ROM, RAM, CD-ROM, magnetic tape, floppy disk, and optical data storage devices. Additionally, the computer-readable recording medium can be distributed across computer systems connected to a network, so that computer-readable code can be stored and executed in a distributed manner.

여기서 사용되는 모든 용어들은 다르게 정의되지 않는 한, 본 발명이 속하는 분야에서 통상의 지식을 가진 자에 의해 일반적으로 이해되는 것과 동일한 의미를 가진다. 일반적으로 사용되는 사전에 정의되어 있는 용어들은 관련 기술의 문맥상 가지는 의미와 일치하는 것으로 해석되어야 하며, 본 출원에서 명백하게 정의하지 않는 한 이상적이거나 과도하게 형식적인 의미를 지니는 것으로 해석될 수 없다.All terms used herein, unless otherwise defined, have the same meaning as commonly understood by a person of ordinary skill in the field to which the present invention pertains. Terms defined in commonly used dictionaries should be interpreted as consistent with the meaning they have in the context of the related technology, and cannot be interpreted as having an ideal or excessively formal meaning unless clearly defined in the present application.

도 1은 본 발명에 따른 요약문 생성 시스템을 설명하는 도면이다.1 is a diagram illustrating a summary generating system according to the present invention.

도 1을 참조하면, 요약문 생성 시스템(100)은 사용자 단말(110), 요약문 생성 장치(130) 및 데이터베이스(150)를 포함할 수 있다.Referring to FIG. 1 , the summary statement generating system 100 may include a user terminal 110, a summary statement generating device 130, and a database 150.

사용자 단말(110)은 사용자에 의해 운용되는 단말 장치에 해당할 수 있다. 예를 들어, 사용자는 사용자 단말(110)을 통해 특정 프로그램에 관한 소스코드와 요약문을 직접 작성할 수 있으며, 이에 관한 데이터를 입력하고 그 결과를 확인할 수 있다. 본 발명의 실시예에서 사용자는 하나 이상의 사용자로 이해될 수 있으며, 복수의 사용자들은 하나 이상의 사용자 그룹으로 구분될 수 있다.The user terminal 110 may correspond to a terminal device operated by a user. For example, a user can directly write source code and a summary of a specific program through the user terminal 110, input data about it, and check the results. In an embodiment of the present invention, a user may be understood as one or more users, and a plurality of users may be divided into one or more user groups.

또한, 사용자 단말(110)은 요약문 생성 시스템(100)을 구성하는 하나의 장치로서 요약문 생성 장치(130)와 연동하여 동작하는 컴퓨팅 장치에 해당할 수 있다. 예를 들어, 사용자 단말(110)은 요약문 생성 장치(130)와 연결되어 동작 가능한 스마트폰, 노트북 또는 컴퓨터로 구현될 수 있으며, 반드시 이에 한정되지 않고, 태블릿 PC 등 포함하여 다양한 디바이스로도 구현될 수 있다. 또한, 사용자 단말(110)은 요약문 생성 장치(130)와 연동하기 위한 전용 프로그램 또는 어플리케이션(또는 앱, app)을 설치하여 실행할 수 있다.Additionally, the user terminal 110 is a device constituting the summary statement generation system 100 and may correspond to a computing device that operates in conjunction with the summary statement generation device 130. For example, the user terminal 110 may be implemented as a smartphone, laptop, or computer that can be operated by being connected to the summary generating device 130, but is not necessarily limited thereto, and may also be implemented as a variety of devices, including tablet PCs, etc. You can. Additionally, the user terminal 110 may install and execute a dedicated program or application (or app) for interworking with the summary text generating device 130.

요약문 생성 장치(130)는 본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법을 수행하는 컴퓨터 또는 프로그램에 해당하는 서버로 구현될 수 있다. 또한, 요약문 생성 장치(130)는 사용자 단말(110)과 유선 네트워크 또는 블루투스, WiFi, LTE 등과 같은 무선 네트워크로 연결될 수 있고, 네트워크를 통해 사용자 단말(110)과 데이터를 송·수신할 수 있다.The summary generating device 130 may be implemented as a server corresponding to a computer or program that performs the method of generating a summary of an artificial intelligence analysis-based program source code according to the present invention. In addition, the summary text generating device 130 may be connected to the user terminal 110 through a wired network or a wireless network such as Bluetooth, WiFi, or LTE, and may transmit and receive data with the user terminal 110 through the network.

또한, 요약문 생성 장치(130)는 관련 동작을 수행하기 위하여 독립된 외부 시스템(도 1에 미도시함)과 연결되어 동작하도록 구현될 수 있다. 예를 들어, 요약문 생성 장치(130)는 포털 시스템, SNS 시스템, 클라우드 시스템 등과 연동하여 다양한 서비스를 제공하도록 구현될 수 있다.Additionally, the summary statement generating device 130 may be implemented to operate in connection with an independent external system (not shown in FIG. 1) to perform related operations. For example, the summary statement generating device 130 may be implemented to provide various services in conjunction with a portal system, SNS system, cloud system, etc.

데이터베이스(150)는 요약문 생성 장치(130)의 동작 과정에서 필요한 다양한 정보들을 저장하는 저장장치에 해당할 수 있다. 예를 들어, 데이터베이스(150)는 소스코드와 이미지에 관한 정보를 저장할 수 있고, 학습을 위한 트랜스포머 모델이나 그래프 처리 모델에 관한 정보를 저장할 수 있으며, 반드시 이에 한정되지 않고, 요약문 생성 장치(130)가 본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법을 수행하는 과정에서 다양한 형태로 수집 또는 가공된 정보들을 저장할 수 있다.The database 150 may correspond to a storage device that stores various information required during the operation of the summary statement generating device 130. For example, the database 150 may store information about source code and images, and may store information about a transformer model or graph processing model for learning, but is not necessarily limited thereto, and the summary statement generating device 130 In the process of performing the method for generating a summary of the artificial intelligence analysis-based program source code according to the present invention, information collected or processed in various forms can be stored.

한편, 도 1에서, 데이터베이스(150)는 요약문 생성 장치(130)와 독립적인 장치로서 도시되어 있으나, 반드시 이에 한정되지 않고, 논리적인 저장장치로서 요약문 생성 장치(130)에 포함되어 구현될 수 있음은 물론이다.Meanwhile, in FIG. 1, the database 150 is shown as a device independent of the summary statement generating device 130, but is not necessarily limited thereto, and may be implemented as a logical storage device included in the summary statement generating device 130. Of course.

도 2는 본 발명에 따른 요약문 생성 장치의 시스템 구성을 설명하는 도면이다.Figure 2 is a diagram explaining the system configuration of the summary text generating device according to the present invention.

도 2를 참조하면, 요약문 생성 장치(130)는 프로세서(210), 메모리(230), 사용자 입출력부(250) 및 네트워크 입출력부(270)를 포함할 수 있다.Referring to FIG. 2 , the summary text generating device 130 may include a processor 210, a memory 230, a user input/output unit 250, and a network input/output unit 270.

프로세서(210)는 본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 프로시저를 실행할 수 있고, 이러한 과정에서 읽혀지거나 작성되는 메모리(230)를 관리할 수 있으며, 메모리(230)에 있는 휘발성 메모리와 비휘발성 메모리 간의 동기화 시간을 스케줄 할 수 있다. 프로세서(210)는 요약문 생성 장치(130)의 동작 전반을 제어할 수 있고, 메모리(230), 사용자 입출력부(250) 및 네트워크 입출력부(270)와 전기적으로 연결되어 이들 간의 데이터 흐름을 제어할 수 있다. 프로세서(210)는 요약문 생성 장치(130)의 CPU(Central Processing Unit)로 구현될 수 있다.The processor 210 can execute a procedure for generating a summary of the artificial intelligence analysis-based program source code according to the present invention, and can manage the memory 230 that is read or written in this process, and can manage the volatile memory 230 in the memory 230. The synchronization time between memory and non-volatile memory can be scheduled. The processor 210 can control the overall operation of the summary statement generating device 130 and is electrically connected to the memory 230, the user input/output unit 250, and the network input/output unit 270 to control the data flow between them. You can. The processor 210 may be implemented as a central processing unit (CPU) of the summary statement generating device 130.

메모리(230)는 SSD(Solid State Disk) 또는 HDD(Hard Disk Drive)와 같은 비휘발성 메모리로 구현되어 요약문 생성 장치(130)에 필요한 데이터 전반을 저장하는데 사용되는 보조기억장치를 포함할 수 있고, RAM(Random Access Memory)과 같은 휘발성 메모리로 구현된 주기억장치를 포함할 수 있다. 또한, 메모리(230)는 전기적으로 연결된 프로세서(210)에 의해 실행됨으로써 본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법을 실행하는 명령들의 집합을 저장할 수 있다.The memory 230 may be implemented as a non-volatile memory such as a solid state disk (SSD) or a hard disk drive (HDD) and may include an auxiliary memory used to store all data required for the summary statement generating device 130, It may include a main memory implemented as volatile memory such as RAM (Random Access Memory). In addition, the memory 230 is executed by the electrically connected processor 210 and can store a set of instructions for executing the method for generating a summary of the artificial intelligence analysis-based program source code according to the present invention.

사용자 입출력부(250)은 사용자 입력을 수신하기 위한 환경 및 사용자에게 특정 정보를 출력하기 위한 환경을 포함하고, 예를 들어, 터치 패드, 터치 스크린, 화상 키보드 또는 포인팅 장치와 같은 어댑터를 포함하는 입력장치 및 모니터 또는 터치 스크린과 같은 어댑터를 포함하는 출력장치를 포함할 수 있다. 일 실시예에서, 사용자 입출력부(250)은 원격 접속을 통해 접속되는 컴퓨팅 장치에 해당할 수 있고, 그러한 경우, 요약문 생성 장치(130)는 독립적인 서버로서 수행될 수 있다.The user input/output unit 250 includes an environment for receiving user input and an environment for outputting specific information to the user, and includes an input adapter such as, for example, a touch pad, a touch screen, an on-screen keyboard, or a pointing device. It may include an output device including a device and an adapter such as a monitor or touch screen. In one embodiment, the user input/output unit 250 may correspond to a computing device connected through a remote connection, and in such case, the summary generating device 130 may be performed as an independent server.

네트워크 입출력부(270)은 네트워크를 통해 사용자 단말(110)과 연결되기 위한 통신 환경을 제공하고, 예를 들어, LAN(Local Area Network), MAN(Metropolitan Area Network), WAN(Wide Area Network) 및 VAN(Value Added Network) 등의 통신을 위한 어댑터를 포함할 수 있다. 또한, 네트워크 입출력부(270)는 데이터의 무선 전송을 위해 WiFi, 블루투스 등의 근거리 통신 기능이나 4G 이상의 무선 통신 기능을 제공하도록 구현될 수 있다.The network input/output unit 270 provides a communication environment for connection to the user terminal 110 through a network, for example, a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), and It may include an adapter for communication such as VAN (Value Added Network). Additionally, the network input/output unit 270 may be implemented to provide short-range communication functions such as WiFi and Bluetooth or wireless communication functions of 4G or higher for wireless transmission of data.

도 3은 본 발명에 따른 요약문 생성 장치의 기능적 구성을 설명하는 도면이다.Figure 3 is a diagram explaining the functional configuration of the summary text generating device according to the present invention.

도 3을 참조하면, 요약문 생성 장치(130)는 프로그램 입력부(310), 그래프 생성부(330), 어휘사전 생성부(350), 소스코드 요약문 생성부(370) 및 제어부(390)를 포함할 수 있다.Referring to FIG. 3, the summary generating device 130 may include a program input unit 310, a graph generating unit 330, a vocabulary dictionary generating unit 350, a source code summary generating unit 370, and a control unit 390. You can.

프로그램 입력부(310)는 특정 프로그램에 관한 소스코드 및 요약문을 입력받을 수 있다. 소스코드(source code)는 프로그래밍 언어로 작성된 원시코드에 해당할 수 있으며, 특정 목적 달성을 위해 일련의 동작들을 정의하는 프로그래밍 언어의 시퀀스에 해당할 수 있다. 요약문은 특정 프로그램의 목적 및 동작을 설명하는 텍스트로서 자연어들의 집합에 해당할 수 있다. 프로그램 입력부(310)는 데이터베이스(150)에 저장된 소스코드와 요약문을 독출하여 메모리(230)에 저장할 수 있으며, 이를 기초로 다음 단계의 동작들이 수행될 수 있다. 또한, 프로그램 입력부(310)는 사용자 단말(110)과 연동하여 사용자에 의해 직접 작성되거나 또는 입력되는 소스코드와 요약문을 수신할 수도 있다.The program input unit 310 can receive source code and a summary of a specific program. Source code may correspond to source code written in a programming language, and may correspond to a sequence of a programming language that defines a series of operations to achieve a specific purpose. A summary is a text that explains the purpose and operation of a specific program and may correspond to a set of natural languages. The program input unit 310 can read the source code and summary text stored in the database 150 and store them in the memory 230, and based on this, next-stage operations can be performed. Additionally, the program input unit 310 may receive source code and a summary written or input directly by the user in conjunction with the user terminal 110.

그래프 생성부(330)는 소스코드를 분석하여 간선과 노드로 구성된 프로그램 의존 그래프(Program Dependence Graph, PDG)를 생성할 수 있다. 프로그램 의존 그래프는 노드(node)와 간선(edge)으로 구성될 수 있으며, 노드 사이의 데이터 흐름 또는 제어 흐름을 표현하기 위해 방향 간선(directed edge)을 갖는 방향 그래프로 표현될 수 있다.The graph generator 330 may analyze the source code and generate a program dependency graph (PDG) consisting of edges and nodes. A program dependency graph may be composed of nodes and edges, and may be expressed as a directed graph with directed edges to express data flow or control flow between nodes.

여기에서, 프로그램 의존 그래프는 소스코드의 데이터 플로우(data flow)와 제어 플로우(control flow)에 따라 생성되는 그래프에 해당할 수 있다. 이때, 제어 플로우는 제어 의존 관계에 대응될 수 있고, 데이터 플로우는 데이터 의존 관계에 대응될 수 있다. 제어 의존 관계는 프로그램 실행 시의 순차적 진행 과정을 정의하기 위한 것으로, 예를 들어, B코드의 실행 여부가 A코드에 따라 결정되는 경우 B는 A에 의존관계가 있는 것으로 결정될 수 있다. 데이터 의존 관계는 제어 흐름에 영향을 받는 변수들 사이의 관계에 해당할 수 있으며, 프로그램의 실행순서에 따라 각 실행문에서 사용된 데이터의 흐름을 표현할 수 있다.Here, the program dependence graph may correspond to a graph generated according to the data flow and control flow of the source code. At this time, the control flow may correspond to a control dependency relationship, and the data flow may correspond to a data dependency relationship. The control dependency relationship is intended to define the sequential process when executing a program. For example, if whether or not to execute B code is determined depending on A code, B may be determined to have a dependency on A. Data dependency relationships may correspond to relationships between variables affected by control flow, and the flow of data used in each execution statement can be expressed according to the execution order of the program.

일 실시예에서, 그래프 생성부(330)는 소스코드의 코드 블록을 노드로 구성하고 데이터 플로우 또는 제어 플로우로 정의되는 노드 간의 연결을 간선으로 구성할 수 있다. 보다 구체적으로, 그래프 생성부(330)는 소스코드를 코드 블록 단위로 분해할 수 있으며, 코드 블록은 특정 연산을 수행하는 소스코드의 부분코드로서 프로그램을 구성하는 프로시저에 대응될 수 있다. 그래프 생성부(330)는 소스코드 분석을 통해 도출된 코드 블록에 대응하여 노드를 생성할 수 있고, 코드 블록 간의 제어 플로우 또는 데이터 플로우를 기초로 노드 간의 연결을 간선으로 구성할 수 있다.In one embodiment, the graph generator 330 may configure code blocks of source code as nodes and configure connections between nodes defined as data flows or control flows as trunk lines. More specifically, the graph generator 330 can decompose the source code into code blocks, and a code block is a partial code of the source code that performs a specific operation and may correspond to a procedure that constitutes a program. The graph generator 330 can create nodes corresponding to code blocks derived through source code analysis, and can configure connections between nodes as trunk lines based on control flows or data flows between code blocks.

한편, 프로그램 의존 그래프의 노드들과 제어 플로우에 대응되는 간선들은 소스코드에 관한 제어 흐름 그래프(Control Flow Graph, CFG)로 표현될 수 있으며, 프로그램 의존 그래프의 노드들과 데이터 플로우에 대응되는 간선들은 소스코드에 관한 데이터 흐름 그래프(Data Flow Graph, DFG)로 표현될 수 있다.Meanwhile, the nodes of the program dependence graph and the edges corresponding to the control flow can be expressed as a control flow graph (CFG) of the source code, and the nodes of the program dependence graph and the edges corresponding to the data flow are It can be expressed as a data flow graph (DFG) regarding source code.

어휘사전 생성부(350)는 소스코드 및 요약문을 기초로 적어도 하나의 어휘사전을 생성할 수 있다. 소스코드는 변수, 변수 유형, 키워드, 특수문자, 함수, 리터럴(literal) 등 다양한 유형의 토큰들을 포함할 수 있다. 어휘사전 생성부(350)는 입력받은 소스코드와 요약문을 분석하여 소스코드 요약문 생성 과정에 사용되는 어휘사전을 생성할 수 있다. 이때, 어휘사전에는 소스코드 어휘사전과 요약문 어휘사전이 포함될 수 있다. 소스코드 어휘사전은 소스코드에서 추출된 토큰(token)들의 집합으로 정의될 수 있고, 요약문 어휘사전은 요약문에서 추출된 워드(word)들의 집합으로 정의될 수 있다. 어휘사전 생성부(350)에 의해 생성된 어휘사전들은 이후 단계의 동작 과정에서 활용될 수 있다.The vocabulary dictionary creation unit 350 may generate at least one vocabulary dictionary based on the source code and the summary sentence. Source code can contain various types of tokens, such as variables, variable types, keywords, special characters, functions, and literals. The vocabulary dictionary generation unit 350 may analyze the input source code and summary text and generate a vocabulary dictionary used in the source code summary generation process. At this time, the vocabulary dictionary may include a source code vocabulary dictionary and a summary sentence vocabulary dictionary. The source code dictionary can be defined as a set of tokens extracted from the source code, and the summary dictionary can be defined as a set of words extracted from the summary. Vocabulary dictionaries generated by the vocabulary dictionary generation unit 350 can be used in the operation process at a later stage.

일 실시예에서, 어휘사전 생성부(350)는 최대 빈도수를 기준으로 어휘사전에 있는 어휘 개수를 상위 N 개로 제한할 수 있다. 이때, N은 소스코드의 크기에 비례할 수 있다. 소스코드에 포함된 변수는 프로그래머의 지정 어휘에 따라 달라질 수 있다. 즉, 프로그램의 소스코드마다 서로 상이한 변수들이 정의되어 사용될 수 있으며, 이는 프로그램의 분석에 있어 구조적 정보를 고려하는데 방해가 될 수 있다. 따라서, 어휘사전 생성부(350)는 어휘의 전체 개수를 어휘의 최대 빈도수를 기준으로 제한할 수 있다. 이에 따라, 최대 빈도수를 기준으로 상위 N개의 어휘들만 어휘사전에 포함될 수 있다. 이때, N은 소스코드의 크기에 비례하여 가변적으로 설정될 수 있다.In one embodiment, the dictionary generator 350 may limit the number of words in the dictionary to the top N based on the maximum frequency. At this time, N may be proportional to the size of the source code. Variables included in source code may vary depending on the programmer's specified vocabulary. In other words, different variables may be defined and used for each program source code, which may interfere with considering structural information when analyzing a program. Accordingly, the vocabulary dictionary generator 350 may limit the total number of vocabulary words based on the maximum frequency of the vocabulary. Accordingly, only the top N vocabularies based on maximum frequency can be included in the vocabulary dictionary. At this time, N can be set variably in proportion to the size of the source code.

소스코드 요약문 생성부(370)는 동작 과정에서 적어도 하나의 어휘사전이 적용되는 인코더(Encoder)와 디코더(Decoder)를 포함하고, 소스코드에 대응되는 소스코드 임베딩을 기초로 노드의 어텐션을 산출하여 소스코드 요약문을 생성할 수 있다. 여기에서, 소스코드 임베딩은 소스코드에 대응하는 벡터에 해당할 수 있으며, 소스코드의 토큰별 임베딩을 기초로 1차원 벡터로 표현될 수 있다. 또한, 소스코드 요약문 생성부(370)는 트랜스포머 모델을 기반으로 구현되는 인코더와 디코더를 포함할 수 있다. 소스코드 요약문 생성부(370)는 인코더를 통해 소스코드에 대응되는 특징을 벡터로 표현하고 디코더를 통해 벡터 표현에 대응되는 요약문을 생성할 수 있다. 특히, 소스코드 요약문 생성부(370)는 인코더에 그래프 정보를 학습하는 GCN 계층을 추가하여 인코더를 통해 소스코드에 대응하는 잠재표현을 생성하고, 디코더를 통해 노드의 어텐션에 따른 소스코드와의 관계를 분석하여 요약문을 출력할 수 있다.The source code summary generator 370 includes an encoder and a decoder to which at least one vocabulary dictionary is applied during the operation process, and calculates the attention of the node based on the source code embedding corresponding to the source code. You can create a source code summary. Here, the source code embedding may correspond to a vector corresponding to the source code, and may be expressed as a one-dimensional vector based on the embedding for each token of the source code. Additionally, the source code summary generator 370 may include an encoder and a decoder implemented based on a transformer model. The source code summary generator 370 can express features corresponding to the source code as a vector through an encoder and generate a summary corresponding to the vector expression through a decoder. In particular, the source code summary generator 370 adds a GCN layer that learns graph information to the encoder, generates a latent expression corresponding to the source code through the encoder, and determines the relationship with the source code according to the attention of the node through the decoder. You can analyze and output a summary.

일 실시예에서, 소스코드 요약문 생성부(370)는 소스코드의 입력 토큰들에 대한 워드 임베딩을 통해 각 입력 토큰 별로 각각이 해당 토큰의 의미 정보와 위치 정보를 포함하는 토큰 임베딩 및 위치 임베딩을 생성하고, 토큰 임베딩 및 위치 임베딩 간의 합 연산에 의해 생성된 임베딩 벡터를 인코더의 입력으로 사용할 수 있다.In one embodiment, the source code summary generator 370 generates a token embedding and a location embedding for each input token, each including semantic information and location information of the corresponding token, through word embedding of the input tokens of the source code. And, the embedding vector generated by the sum operation between token embedding and position embedding can be used as the input of the encoder.

먼저, 소스코드 요약문 생성부(370)는 입력 토큰과 위치 값을 인코더 신경망에 입력으로 제공하기 위해 워드 임베딩을 통해 입력 토큰에 대응되는 벡터를 생성할 수 있다. 토큰 임베딩은 소스코드의 각 입력 토큰에 대응되는 임베딩 벡터에 해당할 수 있으며, 위치 임베딩은 임베딩 벡터에 위치 정보를 추가하기 위한 포지셔널 인코딩(positional encoding)값에 해당할 수 있다. 일 실시예에서, 위치 임베딩은 사인(sin) 또는 코사인(cos) 함수를 통해 생성될 수 있다.First, the source code summary generator 370 may generate a vector corresponding to the input token through word embedding to provide the input token and position value as input to the encoder neural network. Token embedding may correspond to an embedding vector corresponding to each input token of the source code, and positional embedding may correspond to a positional encoding value for adding position information to the embedding vector. In one embodiment, the location embedding may be generated using a sine (sin) or cosine (cos) function.

이후, 소스코드 요약문 생성부(370)는 토큰 임베딩 및 위치 임베딩 간의 합 연산에 의해 생성된 임베딩 벡터를 인코더의 입력으로 사용할 수 있다. 예를 들어, 토큰의 길이가 m인 입력 토큰 x = (x1, x2, …, xm)에 대해 x의 토큰 임베딩이 ex = (ex1, ex2, …, exm)이고, 위치 정보 p = (1, 2, …, m)에 대해 p의 위치 임베딩이 ep=(e1, e2, …, em)인 경우, 소스코드 요약문 생성부(370)는 다음의 수학식 1과 같이 두 벡터를 더해준 다음 최종적으로 인코더 신경망의 입력으로 사용할 수 있다.Thereafter, the source code summary generator 370 may use the embedding vector generated by the sum operation between the token embedding and the position embedding as an input to the encoder. For example, for an input token x = (x 1 , x 2 , …, x m ) of token length m, the token embedding of x is e x = (e x1 , e x2 , …, e xm ), For location information p = (1, 2, ..., m), if the location embedding of p is e p = (e 1 , e 2 , ..., e m ), the source code summary generator 370 uses the following math After adding the two vectors as shown in Equation 1, they can be finally used as input to the encoder neural network.

[수학식 1][Equation 1]

일 실시예에서, 소스코드 요약문 생성부(370)는 소스코드 임베딩을 기초로 입력 토큰들의 어텐션을 산출하여 소스코드 내 자기학습을 강화하는 셀프 어텐션(self-attention) 과정과, 셀프 어텐션 과정의 결과로서 획득된 노드 어텐션 벡터를 완전 연결 계층에 입력하여 노드 잠재표현 벡터를 생성하는 피드 포워드(feed forward) 과정을 포함하는 트랜스포머 과정을 수행할 수 있다. 소스코드 요약문 생성부(370)는 트랜스포머 모델 기반의 인코더와 디코더를 포함할 수 있고, 트랜스포머 과정은 인코더 내부에서 수행될 수 있으며 셀프 어텐션 과정과 피드 포워드 과정을 포함할 수 있다.In one embodiment, the source code summary generator 370 calculates the attention of input tokens based on the source code embedding and performs a self-attention process to enhance self-learning in the source code, and the result of the self-attention process. A transformer process including a feed forward process of generating a node latent expression vector can be performed by inputting the node attention vector obtained as a fully connected layer. The source code summary generator 370 may include an encoder and decoder based on a transformer model, and the transformer process may be performed inside the encoder and may include a self-attention process and a feed-forward process.

보다 구체적으로, 인코더 내의 트랜스포머는 셀프 어텐션(self-attention) 계층과 완전연결(Fully connected) 계층으로 구성될 수 있다. 이때, 셀프 어텐션 계층을 통해 상기의 셀프 어텐션 과정이 수행될 수 있으며, 완전연결 계층을 통해 상기의 피드 포워드 과정이 수행될 수 있다.More specifically, the transformer in the encoder may be composed of a self-attention layer and a fully connected layer. At this time, the above self-attention process can be performed through the self-attention layer, and the above feed-forward process can be performed through the fully connected layer.

셀프 어텐션 계층은 입력된 토큰 간 어텐션(attention)을 계산하여 소스코드 내 자기학습을 강화할 수 있다. 예를 들어, Q, K, V는 가중치가 곱해진 소스코드의 벡터(즉, 소스코드 임베딩)에 해당할 수 있으며, 자기학습이기에 모두 동일한 소스코드를 표현할 수 있다. Q와 K는 내적 후 소프트맥스(softmax)를 통해 활성화 정도가 산출될 수 있다. 그 후, 각 토큰은 자신의 활성화 정보와 연산되어 노트 어텐션 벡터를 출력할 수 있으며, 다음의 수학식 2와 같이 표현될 수 있다.The self-attention layer can enhance self-learning within the source code by calculating attention between input tokens. For example, Q, K, and V may correspond to vectors of source code multiplied by weights (i.e., source code embedding), and because they are self-learning, they can all express the same source code. The activation level of Q and K can be calculated through softmax after dot product. Afterwards, each token can be calculated with its own activation information to output a note attention vector, which can be expressed as Equation 2 below.

[수학식 2][Equation 2]

여기에서, Q, K 및 V는 각각 쿼리(Query), 키(Key), 값(Value)이고, dk는 K벡터의 크기(차원수)이며, 는 K행렬의 전치행렬이다.Here, Q, K, and V are Query, Key, and Value, respectively, and d k is the size (number of dimensions) of the K vector, is the transpose matrix of the K matrix.

또한, 셀프 어텐션 계층에서 출력된 노드 어텐션 벡터 는 완전연결 계층에 입력될 수 있다. 완전연결 계층은 노드 어텐션 벡터 를 학습 가중치 W1과 연산한 후 ReLU를 통해 활성화할 수 있다. 완전연결 계층은 활성화된 정보를 다시 한번 학습 가중치 W2와 연산한 후 입력과 같은 피처(feature)를 갖는 벡터를 출력할 수 있으며, 다음의 수학식 3과 같이 표현될 수 있다.Additionally, the node attention vector output from the self-attention layer can be input to the fully connected layer. Fully connected layer is node attention vector After calculating with the learning weight W 1 , it can be activated through ReLU. The fully connected layer can output a vector with the same features as the input after calculating the activated information with the learning weight W 2 again, and can be expressed as Equation 3 below.

[수학식 3][Equation 3]

여기에서, FFNN은 피드 포워드 신경망이고, 는 노드 어텐션이며, 벡터 b1 및 b2는 바이어스 벡터(bias vector)이다.Here, FFNN is a feed forward neural network, is the node attention, and vectors b 1 and b 2 are bias vectors.

완전연결 계층에 의해 출력된 모든 벡터 T는 신경망 계층을 거쳐 벡터 N으로 집약될 수 있으며, N은 각 코드 블럭의 집약된 정보이자 하나의 노드를 의미할 수 있다. 즉, 다음의 수학식 4와 같이 표현될 수 있으며, N은 노드 잠재표현 벡터에 해당할 수 있다.All vectors T output by the fully connected layer can be aggregated into vector N through the neural network layer, where N is the aggregated information of each code block and can mean one node. That is, it can be expressed as in Equation 4 below, where N may correspond to the node latent expression vector.

[수학식 4][Equation 4]

일 실시예에서, 소스코드 요약문 생성부(370)는 그래프 합성곱 과정에서 프로그램 의존 그래프의 간선 정보를 기초로 노드 잠재표현 벡터 간의 합성 곱을 반복적으로 수행하여 노드의 어텐션을 산출할 수 있다. 즉, 인코더 내의 트랜스포머 과정의 출력은 그래프 합성곱 과정의 입력으로 연결될 수 있다. 이에 따라, 소스코드 요약문 생성부(370)는 프로그램 의존 그래프의 간선 정보를 이용하여 각 노드에 대응되는 노드 잠재표현 벡터들 간의 연산을 수행할 수 있다. In one embodiment, the source code summary generator 370 may calculate the attention of a node by repeatedly performing convolution between node latent expression vectors based on edge information of the program-dependent graph during the graph convolution process. In other words, the output of the transformer process within the encoder can be connected to the input of the graph convolution process. Accordingly, the source code summary generator 370 can perform an operation between node latent expression vectors corresponding to each node using edge information of the program dependency graph.

보다 구체적으로, M은 프로그램 의존 그래프의 간선(edge) 정보를 갖는 행렬(matrix)에 해당할 수 있으며, M∈Rnode num×node num의 형상을 가질 수 있다. 간선 정보가 1인 노드들의 관계는 '이웃(neighbor)'으로 결정될 수 있고, 해당 노드는 자신의 이웃 노드 hneighbor들과 더해질 수 있다. 한편, 합성곱 과정에서 마스크(mask)를 통해 노드 값에 M 정보가 반영될 수 있으며, 데이터의 특징에 따라 합성곱 연산이 반복적으로 수행될 수도 있다. 해당 동작은 다음의 수학식 5와 같이 표현될 수 있다.More specifically, M may correspond to a matrix having edge information of a program dependency graph and may have the shape of M∈R node num×node num . The relationship between nodes with edge information of 1 can be determined as 'neighbor', and the node can be added to its neighbor nodes h neighbors . Meanwhile, during the convolution process, M information may be reflected in the node value through a mask, and the convolution operation may be performed repeatedly depending on the characteristics of the data. The operation can be expressed as Equation 5 below.

[수학식 5][Equation 5]

여기에서, h는 특정 노드의 임베딩이고, hneightbor은 노드 h의 이웃 노드의 임베딩이다.Here, h is the embedding of a specific node, and h neightbor is the embedding of node h's neighbors.

일 실시예에서, 소스코드 요약문 생성부(370)는 노드의 어텐션과 요약문을 디코더에 입력하여 요약 어휘 임베딩을 생성할 수 있다. 여기에서, 노드의 어텐션은 노드에 관한 어텐션 벡터에 해당할 수 있으며, 요약 어휘 임베딩은 소스코드 요약문 생성에 사용될 가능성이 있는 요약 어휘들의 임베딩 벡터에 해당할 수 있다. 소스코드 요약문 생성부(370)는 디코더를 통해 요약 어휘 별로 요약 어휘 임베딩을 생성할 수 있다.In one embodiment, the source code summary generator 370 may generate a summary vocabulary embedding by inputting the attention and summary of the node to the decoder. Here, the attention of the node may correspond to an attention vector about the node, and the summary vocabulary embedding may correspond to an embedding vector of summary vocabularies that may be used to generate source code summaries. The source code summary generator 370 may generate summary vocabulary embeddings for each summary vocabulary through a decoder.

한편, 디코더는 멀티 헤드 셀프 어텐션 계층(multi head self-attention), 멀티 헤드 어텐션(multi head attention) 계층 및 피드 포워드(feed forward) 계층으로 구성될 수 있다. 멀티 헤드 셀프 어텐션 계층은 인코더의 셀프 어텐션 과정과 동일하게 수행될 수 있다. 멀티 헤드 어텐션 계층은 멀티 헤드 어텐션 과정을 수행할 수 있다. 피드 포워드 계층은 인코더의 피드 포워드 과정과 동일하게 수행될 수 있다.Meanwhile, the decoder may be composed of a multi head self-attention layer, a multi head attention layer, and a feed forward layer. The multi-head self-attention layer can be performed in the same way as the encoder's self-attention process. The multi-head attention layer can perform a multi-head attention process. The feed forward layer can be performed in the same way as the encoder feed forward process.

일 실시예에서, 소스코드 요약문 생성부(370)는 노드의 어텐션을 디코더의 멀티 헤드 어텐션 과정의 입력으로 사용할 수 있다. 디코더는 자연어 토큰과 인코더 출력을 입력으로 수신할 수 있으며, 자연어 토큰은 요약문에서 추출된 토큰들에 해당할 수 있다. 한편, 자연어 토큰은 띄어쓰기를 기준으로 추출될 수 있다. 디코더 또한 인코더와 동일하게 요약문에 관한 토큰 임베딩 및 위치 임베딩을 기초로 생성된 임베딩 벡터를 입력으로 수신할 수 있으며, 경우에 따라 임베딩 벡터는 행렬로 표현될 수 있다. 멀티 헤드 어텐션 과정은 K 및 Q에 대해 인코더의 출력, 즉 노드의 어텐션을 사용하는 반면, V는 자연어 토큰으로부터 생성된 잠재표현(또는 잠재표현 벡터)을 사용할 수 있다. 또한, 멀티 헤드 어텐션 과정은 헤드(head) 개수만큼 다수의 어텐션들을 동시에 학습하고 그 결과들을 서로 연결하는 과정을 통해 출력을 생성할 수 있다.In one embodiment, the source code summary generator 370 may use the node's attention as an input to the decoder's multi-head attention process. The decoder may receive a natural language token and an encoder output as input, and the natural language token may correspond to tokens extracted from the summary sentence. Meanwhile, natural language tokens can be extracted based on spacing. Like the encoder, the decoder can also receive an embedding vector generated based on the token embedding and position embedding of the summary as input, and in some cases, the embedding vector can be expressed as a matrix. The multi-head attention process uses the output of the encoder, i.e., the node's attention, for K and Q, while V can use latent expressions (or latent expression vectors) generated from natural language tokens. Additionally, the multi-head attention process can generate output through a process of simultaneously learning as many attentions as there are heads and connecting the results.

일 실시예에서, 소스코드 요약문 생성부(370)는 요약 어휘 임베딩을 활성화 함수에 적용한 결과를 기초로 소스코드 요약문을 생성할 수 있다. 소스코드 요약문 생성부(370)는 디코더로부터 출력된 요약 어휘 임베딩을 활성화 함수(예를 들어, softmax 함수)에 입력한 결과를 이용하여 요약 어휘들 중에서 최종 출력될 어휘들을 결정할 수 있다. 결과적으로, 소스코드 요약문 생성부(370)는 최종 출력 어휘들로 구성된 소스코드 요약문을 출력으로 생성할 수 있다.In one embodiment, the source code summary generator 370 may generate a source code summary based on the result of applying the summary vocabulary embedding to the activation function. The source code summary generator 370 may use the result of inputting the summary vocabulary embedding output from the decoder into an activation function (eg, softmax function) to determine the final output vocabulary among the summary vocabularies. As a result, the source code summary generator 370 can generate a source code summary composed of the final output vocabulary as output.

제어부(390)는 요약문 생성 장치(130)의 전체적인 동작을 제어하고, 프로그램 입력부(310), 그래프 생성부(330), 어휘사전 생성부(350) 및 소스코드 요약문 생성부(370) 간의 제어 흐름 또는 데이터 흐름을 관리할 수 있다.The control unit 390 controls the overall operation of the summary generating device 130, and the control flow between the program input unit 310, the graph generating unit 330, the vocabulary generating unit 350, and the source code summary generating unit 370. Or you can manage the data flow.

도 4는 본 발명에 따른 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법을 설명하는 순서도이다.Figure 4 is a flowchart explaining a method of generating a summary of artificial intelligence analysis-based program source code according to the present invention.

도 4를 참조하면, 요약문 생성 장치(130)는 프로그램 입력부(310)를 통해 특정 프로그램에 관한 소스코드 및 요약문을 입력받을 수 있다. 이때, 프로그램 입력부(310)는 사용자 단말(110)과 연결되어 사용자에 의해 직접 작성된 소스코드와 요약문을 수신할 수도 있다.Referring to FIG. 4, the summary statement generating device 130 can receive source code and a summary statement regarding a specific program through the program input unit 310. At this time, the program input unit 310 may be connected to the user terminal 110 and receive source code and a summary written directly by the user.

요약문 생성 장치(130)는 그래프 생성부(330)를 통해 소스코드를 분석하여 간선과 노드로 구성된 프로그램 의존 그래프를 생성할 수 있다(단계 S410). 소스코드에 대응되는 프로그램 의존 그래프는 소스코드의 부분 코드에 해당하는 코드 블록을 노드로 표현하고 코드 블록 간의 데이터 흐름 또는 제어 흐름을 간선으로 표현함으로써 생성될 수 있다.The summary statement generating device 130 may analyze the source code through the graph generating unit 330 and generate a program-dependent graph composed of edges and nodes (step S410). A program dependency graph corresponding to source code can be created by expressing code blocks corresponding to partial codes of the source code as nodes and expressing data flow or control flow between code blocks as edges.

요약문 생성 장치(130)는 어휘사전 생성부(350)를 통해 소스코드 및 요약문을 기초로 적어도 하나의 어휘사전을 생성할 수 있다(단계 S420). 적어도 하나의 어휘사전은 소스코드 어휘사전 및 요약문 어휘사전을 포함할 수 있다. 소스코드 어휘사전은 소스코드의 토큰들로 구성될 수 있으며, 요약문 어휘사전은 요약문의 단어들로 구성될 수 있다. 어휘사전 생성부(350)는 필요에 따라 어휘사전의 크기, 즉 어휘사전에 포함되는 어휘들의 개수를 제한적으로 적용할 수 있다.The summary sentence generating device 130 may generate at least one vocabulary dictionary based on the source code and the summary sentence through the vocabulary dictionary generation unit 350 (step S420). At least one vocabulary dictionary may include a source code vocabulary dictionary and a summary sentence vocabulary dictionary. The source code dictionary may be composed of tokens of source code, and the summary statement dictionary may be composed of words from the summary statement. The vocabulary dictionary creation unit 350 may limit the size of the vocabulary dictionary, that is, the number of words included in the vocabulary dictionary, as necessary.

요약문 생성 장치(130)는 소스코드 요약문 생성부(370)를 통해 소스코드에 대응되는 소스코드 임베딩을 생성하여 인코더에 입력할 수 있다(단계 S430). 즉, 소스코드 요약문 생성부(370)는 트랜스포머 모델 기반으로 구현된 인코더와 디코더를 포함할 수 있으며, 인코더와 디코더는 동작 과정에서 적어도 하나의 어휘사전을 적용할 수 있다. 이때, 소스코드 임베딩은 1차원 벡터로 변화되어 인코더에 입력될 수 있다.The summary generating device 130 may generate a source code embedding corresponding to the source code through the source code summary generating unit 370 and input it to the encoder (step S430). That is, the source code summary generator 370 may include an encoder and a decoder implemented based on a transformer model, and the encoder and decoder may apply at least one vocabulary dictionary during the operation process. At this time, the source code embedding can be converted into a one-dimensional vector and input to the encoder.

요약문 생성 장치(130)는 소스코드 요약문 생성부(370)의 인코더를 통해 소스코드 임베딩을 기초로 프로그램 의존 그래프의 노드들에 관한 제1 노드 임베딩을 생성할 수 있다(단계 S440). 이때, 해당 과정은 인코더의 트랜스포머 과정에 해당할 수 있으며, 제1 노드 임베딩은 노드 잠재표현 벡터에 해당할 수 있으며, 소스코드 내에 존재하는 노드들의 임베딩에 해당할 수 있다.The summary generating device 130 may generate a first node embedding for the nodes of the program dependency graph based on the source code embedding through the encoder of the source code summary generating unit 370 (step S440). At this time, the process may correspond to the transformer process of the encoder, the first node embedding may correspond to the node latent expression vector, and the embedding of nodes existing in the source code.

요약문 생성 장치(130)는 소스코드 요약문 생성부(370)의 인코더를 통해 제1 노드 임베딩 및 프로그램 의존 그래프의 간선 정보를 이용하여 그래프 어텐션(graph attention)을 수행할 수 있다(단계 S450). 이때, 해당 과정은 인코더의 그래프 합성곱 과정에 해당할 수 있다. 즉, 소스코드 내 존재하는 노드들의 임베딩을 기초로 그래프 합성곱 과정이 수행된 결과 그래프 어텐션에 관한 노드들의 임베딩이 갱신될 수 있다.The summary generating device 130 may perform graph attention using the first node embedding and edge information of the program dependency graph through the encoder of the source code summary generating unit 370 (step S450). At this time, the process may correspond to the encoder's graph convolution process. That is, as a result of performing a graph convolution process based on the embeddings of nodes existing in the source code, the embeddings of nodes related to graph attention can be updated.

요약문 생성 장치(130)는 소스코드 요약문 생성부(370)의 디코더를 통해 그래프 어텐션에 따른 노드들의 제2 노드 임베딩 및 요약문을 기초로 요약 어휘들에 관한 요약 어휘 임베딩을 생성할 수 있다(단계 S460). 이때, 제2 노드 임베딩은 인코더의 출력으로서 노드의 어텐션에 해당할 수 있으며, 디코더는 인코더의 출력과 요약문을 입력으로 수신하여 요약 어휘 임베딩을 출력을 위한 신경망 학습을 수행할 수 있다.The summary generating device 130 may generate summary vocabulary embeddings for summary vocabularies based on the second node embedding and summary of nodes according to graph attention through the decoder of the source code summary generating unit 370 (step S460 ). At this time, the second node embedding is the output of the encoder and may correspond to the attention of the node, and the decoder may receive the output of the encoder and the summary as input and perform neural network learning to output the summary vocabulary embedding.

이후, 요약문 생성 장치(130)는 소스코드 요약문 생성부(370)를 통해 요약 어휘 임베딩을 활성화 함수에 적용할 수 있고, 그 결과를 이용하여 소스코드에 관한 소스코드 요약문을 생성할 수 있다(단계 S470).Thereafter, the summary generating device 130 can apply the summary vocabulary embedding to the activation function through the source code summary generating unit 370, and use the result to generate a source code summary regarding the source code (step S470).

도 5는 본 발명에 따른 요약문 생성 인공지능 프로그램을 설명하는 도면이다.Figure 5 is a diagram illustrating an artificial intelligence program for generating a summary statement according to the present invention.

도 5를 참조하면, 본 발명에 따른 요약문 생성 인공지능 방법은 프로그램을 통해 구현될 수 있다. 요약문 생성을 위한 인공지능 프로그램은 소스코드를 입력받아 자연어 요약문(510)을 출력하는 모델로 트랜스포머, 그래프 처리 모델인 GCN(graph convolutional network) 기반의 code2seq모델에 해당할 수 있다. 기존의 트랜스포머 모델은 두 개의 순환신경망이 각각 인코더-디코더의 역할을 수행한 반면, 본 발명에 따른 모델은 인코더(Encoder)에 그래프 정보를 학습하는 GCN 계층(도 5의 PDG GCN)이 추가된 형태로 구현될 수 있다. 즉, 입력된 소스코드는 1차원의 벡터로 변환되어 인코더(Encoder)에 입력될 수 있으며, 인코더(Encoder)는 학습된 잠재표현을 출력할 수 있다. 디코더(Decoder)는 인코더(Encoder)의 출력을 입력받아 소스코드와의 관계를 학습한 후 소스코드에 대응되는 요약문(510)을 출력할 수 있다.Referring to Figure 5, the artificial intelligence method for generating a summary according to the present invention can be implemented through a program. The artificial intelligence program for generating a summary is a model that receives source code as input and outputs a natural language summary (510) and may correspond to the code2seq model based on GCN (graph convolutional network), a transformer and graph processing model. While the existing transformer model has two recurrent neural networks each playing the role of an encoder and decoder, the model according to the present invention adds a GCN layer (PDG GCN in Figure 5) that learns graph information to the encoder. It can be implemented as: That is, the input source code can be converted into a one-dimensional vector and input to the encoder, and the encoder can output the learned latent expression. The decoder can receive the output of the encoder, learn the relationship with the source code, and then output a summary 510 corresponding to the source code.

도 6은 본 발명에 따른 프로그램 의존 그래프를 설명하는 도면이다.Figure 6 is a diagram illustrating a program dependency graph according to the present invention.

도 6을 참조하면, 요약문 생성 장치(130)는 그래프 생성부(330)를 통해 소스코드를 분석하여 간선(630)과 노드(610)로 구성된 프로그램 의존 그래프를 생성할 수 있다. 프로그램 의존 그래프는 도 6과 같이 소스코드의 데이터 흐름(data flow)과 제어 흐름(control flow)에 따라 그래프를 생성할 수 있다. 그래프는 노드(610)들과 노드(610) 간의 간선(630)으로 구성될 수 있으며, 노드(610)는 부분 소스코드를 의미하고 간선(630)은 프로그램의 작동에 따라 부분 소스코드 간의 연결을 의미할 수 있다. Referring to FIG. 6 , the summary sentence generating device 130 may analyze the source code through the graph generating unit 330 to generate a program-dependent graph composed of an edge 630 and a node 610. The program dependency graph can be created according to the data flow and control flow of the source code, as shown in Figure 6. The graph may be composed of nodes 610 and an edge 630 between the nodes 610, where the node 610 represents a partial source code and the edge 630 represents a connection between partial source codes according to the operation of the program. It can mean.

또한, 간선(630)은 데이터 흐름과 제어 흐름을 나타내는 간선으로 분류될 수 있다. 데이터 흐름은 이전에 사용된 데이터의 노드를 기준으로 데이터가 다른 노드에서 사용되는 것을 의미할 수 있다. 제어 흐름은 소스코드가 실행되기 위해 거쳐야 하는 코드 흐름을 의미할 수 있다. 그래프 생성부(330)는 생성된 노드(610)를 기준으로 소스코드를 분리할 수 있고, 분리된 소스코드 간 간선(630) 정보를 데이터로 생성할 수 있다. 이후, 간선 데이터는 GCN 계층의 합성곱(convolution) 레이어에서 연결 노드 간 정보의 연산을 수행하기 위해 사용될 수 있다.Additionally, the trunk line 630 can be classified into trunk lines representing data flow and control flow. Data flow can mean that data is used in other nodes based on the node from which the data was previously used. Control flow can refer to the code flow that source code must go through to be executed. The graph generator 330 can separate the source code based on the generated node 610 and generate information about the trunk 630 between the separated source codes as data. Afterwards, the edge data can be used to perform operations on information between connected nodes in the convolution layer of the GCN layer.

도 7은 본 발명에 따른 소스코드 토큰의 유형을 설명하는 도면이다.Figure 7 is a diagram explaining the types of source code tokens according to the present invention.

도 7을 참조하면, 특정 프로그램에 관한 소스코드(710)는 변수, 변수 유형, 키워드, 특수문자, 함수 및 리터럴과 같은 다양한 종류의 토큰으로 구성될 수 있다. 이 중에서 변수 유형, 특수문자 등은 서로 다른 소스코드에서 공용으로 사용되는 어휘에 해당할 수 있다. 하지만, 변수는 프로그래머의 지정 어휘에 따라 달라질 수 있다. 즉, 소스코드(710)에 따라 무분별한 변수가 정의될 수 있고, 이는 프로그램의 분석에서 구조적 정보를 고려하는데 방해가 될 수 있다. 따라서, 어휘의 전체 수는 어휘의 최대 빈도수를 기준으로 제한될 수 있다.Referring to FIG. 7, source code 710 for a specific program may be composed of various types of tokens such as variables, variable types, keywords, special characters, functions, and literals. Among these, variable types, special characters, etc. may correspond to vocabulary commonly used in different source codes. However, variables may vary depending on the programmer's specified vocabulary. In other words, indiscriminate variables may be defined depending on the source code 710, which may interfere with considering structural information in program analysis. Therefore, the total number of vocabulary may be limited based on the maximum frequency of the vocabulary.

도 8은 소스코드 입력에 따른 그래프 및 요약문 생성 과정의 일 실시예를 설명하는 도면이다.Figure 8 is a diagram illustrating an embodiment of a graph and summary generation process according to source code input.

도 8을 참조하면, 요약문 생성 장치(130)는 특정 프로그램에 관한 소스코드(810)를 입력으로 수신할 수 있으며, 소스코드(810)를 분석하여 소스코드 요약문(850)을 생성할 수 있다.Referring to FIG. 8 , the summary generating device 130 may receive a source code 810 related to a specific program as an input, and may analyze the source code 810 to generate a source code summary 850.

도 8에서, 소스코드(810)는 Main 함수를 정의하는 코드에 해당할 수 있고, 2번째 라인의 'System.out.println(“Hello World”);'은 java 표준 입출력 크래스인 System이라는 클래스의 out이라는 객체를 이용해서 println()메소드를 호출하고, 해당 메소드를 통해 괄호 안에 있는 입력값인 “Hello World”라는 텍스트를 화면에 출력하는 동작을 정의하는 부분 소스코드에 해당할 수 있다.In Figure 8, the source code 810 may correspond to the code defining the Main function, and 'System.out.println(“Hello World”);' in the second line is of a class called System, a Java standard input/output class. This may correspond to partial source code that defines the operation of calling the println() method using an object called out and printing the text “Hello World”, which is the input value in parentheses, on the screen through the method.

또한, 3번째 라인의 'Boolean pasCall = true'는 Boolean 형 변수 passCall을 선언하고 true 값을 할당하는 동작을 정의하고, 4번째 라인의 'if(pasCall == true){'은 변수 pasCall의 값이 true 값인지를 비교하는 동작을 정의하며, 5번째 라인의 'pasCall = false'은 변수 pasCall에 false 값을 할당하는 동작을 정의할 수 있다.In addition, 'Boolean pasCall = true' in the 3rd line defines the action of declaring the Boolean type variable passCall and assigning a true value, and 'if(pasCall == true){' in the 4th line defines the action of declaring the Boolean type variable passCall and assigning a true value. It defines the operation of comparing whether it is a true value, and 'pasCall = false' in line 5 can define the operation of assigning a false value to the variable pasCall.

이에 따라, 요약문 생성 장치(130)는 소스코드(810)에 관한 소스코드 요약문(850)으로서 “change Boolean value if Boolean value is true”라는 텍스트를 출력할 수 있다.Accordingly, the summary statement generating device 130 may output the text “change Boolean value if Boolean value is true” as the source code summary statement 850 regarding the source code 810.

또한, 요약문 생성 장치(130)는 소스코드 요약문(850) 생성을 위하여 소스코드(810)에 대응되는 프로그램 의존 그래프(830)를 생성할 수 있다. 도 8에서, 요약문 생성 장치(130)는 소스코드(810)에서 3 ~ 5 번째 라인들의 코드 블록에 대응되는 노드들(831, 832 및 833)을 생성하고 노드들 사이를 데이터 흐름에 따른 간선(834)과 제어 흐름에 따른 간선(835)으로 연결하는 과정을 통해 프로그램 의존 그래프(830)를 생성할 수 있다.Additionally, the summary generating device 130 may generate a program dependency graph 830 corresponding to the source code 810 to generate the source code summary 850. In FIG. 8, the summary statement generating device 130 generates nodes 831, 832, and 833 corresponding to code blocks of lines 3 to 5 in the source code 810 and creates a trunk line (831, 832, and 833) between the nodes according to the data flow. A program dependency graph 830 can be created through the process of connecting 834) to an edge 835 according to the control flow.

상기에서는 본 발명의 바람직한 실시예를 참조하여 설명하였지만, 해당 기술 분야의 숙련된 당업자는 하기의 특허 청구의 범위에 기재된 본 발명의 사상 및 영역으로부터 벗어나지 않는 범위 내에서 본 발명을 다양하게 수정 및 변경시킬 수 있음을 이해할 수 있을 것이다.Although the present invention has been described above with reference to preferred embodiments, those skilled in the art may make various modifications and changes to the present invention without departing from the spirit and scope of the present invention as set forth in the claims below. You will understand that you can do it.

100: 요약문 생성 시스템
110: 사용자 단말 130: 요약문 생성 장치
150: 데이터베이스
210: 프로세서 230: 메모리
250: 사용자 입출력부 270: 네트워크 입출력부
310: 프로그램 입력부 330: 그래프 생성부
350: 어휘사전 생성부 370: 소스코드 요약문 생성부
390: 제어부
100: Summary statement generation system
110: User terminal 130: Summary generating device
150: database
210: Processor 230: Memory
250: user input/output unit 270: network input/output unit
310: Program input unit 330: Graph generation unit
350: Vocabulary dictionary generation unit 370: Source code summary generation unit
390: Control unit

Claims (14)

특정 프로그램에 관한 소스코드 및 요약문을 입력받는 프로그램 입력부;
상기 소스코드를 분석하여 간선과 노드로 구성된 프로그램 의존 그래프를 생성하는 그래프 생성부;
상기 소스코드 및 상기 요약문을 기초로 적어도 하나의 어휘사전을 생성하는 어휘사전 생성부; 및
동작 과정에서 상기 적어도 하나의 어휘사전이 적용되는 인코더(Encoder)와 디코더(Decoder)를 포함하고, 상기 소스코드에 대응되는 소스코드 임베딩을 기초로 상기 노드의 어텐션을 산출하여 소스코드 요약문을 생성하는 소스코드 요약문 생성부;를 포함하고,
상기 인코더(Encoder)는 트랜스포머(transformer) 과정의 출력이 그래프 합성곱 과정의 입력에 연결되도록 구현되는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
A program input unit that receives source code and summary text for a specific program;
a graph generator that analyzes the source code and generates a program dependency graph composed of edges and nodes;
a vocabulary dictionary generator that generates at least one vocabulary dictionary based on the source code and the summary sentence; and
In the operation process, it includes an encoder and a decoder to which the at least one vocabulary dictionary is applied, and generates a source code summary by calculating the attention of the node based on the source code embedding corresponding to the source code. Includes a source code summary generation unit,
The encoder is a device for generating a summary of program source code based on artificial intelligence analysis, which is implemented so that the output of the transformer process is connected to the input of the graph convolution process.
제1항에 있어서, 상기 그래프 생성부는
상기 소스코드의 코드 블록을 상기 노드로 구성하고 데이터 플로우 또는 제어 플로우로 정의되는 상기 노드 간의 연결을 상기 간선으로 구성하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 1, wherein the graph generator
A device for generating a summary of program source code based on artificial intelligence analysis, characterized in that code blocks of the source code are composed of the nodes, and connections between the nodes defined as data flows or control flows are composed of the trunk lines.
제1항에 있어서, 상기 어휘사전 생성부는
최대 빈도수를 기준으로 상기 어휘사전에 있는 어휘 개수를 상위 N 개로 제한하고, 상기 N은 상기 소스코드의 크기에 비례하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 1, wherein the vocabulary dictionary generator
A device for generating a summary of program source code based on artificial intelligence analysis, wherein the number of vocabulary words in the vocabulary dictionary is limited to the top N based on the maximum frequency, and N is proportional to the size of the source code.
제1항에 있어서, 상기 소스코드 요약문 생성부는
상기 소스코드의 입력 토큰들에 대한 워드 임베딩을 통해 각 입력 토큰 별로 각각이 해당 토큰의 의미 정보와 위치 정보를 포함하는 토큰 임베딩 및 위치 임베딩을 생성하고, 상기 토큰 임베딩 및 상기 위치 임베딩 간의 합 연산에 의해 생성된 임베딩 벡터를 상기 인코더의 입력으로 사용하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 1, wherein the source code summary generator
Through word embedding of the input tokens of the source code, a token embedding and a position embedding are generated for each input token, each containing semantic information and position information of the corresponding token, and a sum operation is performed between the token embedding and the position embedding. A device for generating a summary of program source code based on artificial intelligence analysis, characterized in that the embedding vector generated by the encoder is used as an input to the encoder.
제4항에 있어서, 상기 소스코드 요약문 생성부는
상기 소스코드 임베딩을 기초로 상기 입력 토큰들의 어텐션을 산출하여 상기 소스코드 내 자기학습을 강화하는 셀프 어텐션(self-attention) 과정과, 상기 셀프 어텐션 과정의 결과로서 획득된 노드 어텐션 벡터를 완전 연결 계층에 입력하여 노드 잠재표현 벡터를 생성하는 피드 포워드(feed forward) 과정을 포함하는 상기 트랜스포머 과정을 수행하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 4, wherein the source code summary generator
A self-attention process that strengthens self-learning in the source code by calculating the attention of the input tokens based on the source code embedding, and the node attention vector obtained as a result of the self-attention process is converted into a fully connected layer. A device for generating a summary of an artificial intelligence analysis-based program source code, characterized in that it performs the transformer process including a feed forward process of generating a node latent expression vector by inputting into .
제5항에 있어서, 상기 소스코드 요약문 생성부는
상기 그래프 합성곱 과정에서 상기 프로그램 의존 그래프의 간선 정보를 기초로 상기 노드 잠재표현 벡터 간의 합성 곱을 반복적으로 수행하여 상기 노드의 어텐션을 산출하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 5, wherein the source code summary generator
An apparatus for generating a summary of program source code based on artificial intelligence analysis, characterized in that in the graph convolution process, the attention of the node is calculated by repeatedly performing convolution between the node latent expression vectors based on edge information of the program dependent graph. .
제6항에 있어서, 상기 소스코드 요약문 생성부는
상기 노드의 어텐션과 상기 요약문을 상기 디코더에 입력하여 요약 어휘 임베딩을 생성하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 6, wherein the source code summary generator
A device for generating a summary of an artificial intelligence analysis-based program source code, characterized in that it generates a summary vocabulary embedding by inputting the attention of the node and the summary to the decoder.
제7항에 있어서, 상기 소스코드 요약문 생성부는
상기 노드의 어텐션을 상기 디코더의 멀티 헤드 어텐션 과정의 입력으로 사용하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 7, wherein the source code summary generator
A device for generating a summary of program source code based on artificial intelligence analysis, characterized in that it uses the attention of the node as an input to the multi-head attention process of the decoder.
제7항에 있어서, 상기 소스코드 요약문 생성부는
상기 요약 어휘 임베딩을 활성화 함수에 적용한 결과를 기초로 상기 소스코드 요약문을 생성하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 장치.
The method of claim 7, wherein the source code summary generator
An artificial intelligence analysis-based program source code summary generator, characterized in that it generates the source code summary based on a result of applying the summary vocabulary embedding to an activation function.
특정 프로그램의 소스코드를 분석하여 프로그램 의존 그래프를 생성하는 단계;
상기 소스코드 및 상기 특정 프로그램에 관한 요약문을 기초로 적어도 하나의 어휘사전을 생성하는 단계;
상기 소스코드에 대응되는 소스코드 임베딩을 생성하는 단계;
상기 소스코드 임베딩을 기초로 상기 프로그램 의존 그래프의 노드들에 관한 제1 노드 임베딩을 생성하는 단계;
상기 제1 노드 임베딩 및 상기 프로그램 의존 그래프의 간선 정보를 이용하여 그래프 어텐션(graph attention)을 수행하는 단계;
상기 그래프 어텐션에 따른 노드들의 제2 노드 임베딩 및 상기 요약문을 기초로 요약 어휘들에 관한 요약 어휘 임베딩을 생성하는 단계; 및
상기 요약 어휘 임베딩을 기초로 상기 소스코드에 관한 소스코드 요약문을 생성하는 단계;를 포함하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법.
Generating a program dependency graph by analyzing the source code of a specific program;
generating at least one vocabulary dictionary based on the source code and a summary of the specific program;
generating source code embedding corresponding to the source code;
generating first node embeddings for nodes of the program dependency graph based on the source code embeddings;
performing graph attention using the first node embedding and edge information of the program dependent graph;
generating summary vocabulary embeddings for summary vocabularies based on second node embeddings of nodes according to the graph attention and the summary sentence; and
Generating a source code summary for the source code based on the summary vocabulary embedding; A method for generating a summary of program source code based on artificial intelligence analysis, including.
제10항에 있어서, 상기 소스코드 임베딩을 생성하는 단계는
상기 소스코드의 입력 토큰들에 대한 워드 임베딩을 통해 각 입력 토큰 별로 각각이 해당 토큰의 의미 정보와 위치 정보를 포함하는 토큰 임베딩 및 위치 임베딩을 생성하는 단계; 및
상기 토큰 임베딩 및 상기 위치 임베딩 간의 합 연산을 통해 임베딩 벡터를 생성하는 단계를 포함하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법.
The method of claim 10, wherein the step of generating the source code embedding is
Generating token embeddings and location embeddings for each input token, each including semantic information and location information of the corresponding token, through word embedding of the input tokens of the source code; and
A method of generating a summary of program source code based on artificial intelligence analysis, comprising the step of generating an embedding vector through a sum operation between the token embedding and the position embedding.
제11항에 있어서, 상기 제1 노드 임베딩을 생성하는 단계는
셀프 어텐션(self-attention) 과정을 통해 상기 소스코드 임베딩을 기초로 상기 입력 토큰들의 어텐션을 산출하여 상기 소스코드 내 자기학습을 강화하는 단계; 및
피드 포워드(feed forward) 과정을 통해 상기 셀프 어텐션 과정의 결과로서 획득된 노드 어텐션 벡터를 완전 연결 계층에 입력하여 노드 잠재표현 벡터를 생성하는 단계를 포함하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법.
The method of claim 11, wherein generating the first node embedding comprises
Strengthening self-learning within the source code by calculating attention of the input tokens based on the source code embedding through a self-attention process; and
Artificial intelligence analysis-based program source code comprising the step of generating a node latent expression vector by inputting the node attention vector obtained as a result of the self-attention process through a feed forward process into a fully connected layer. How to create a summary statement.
제10항에 있어서, 상기 그래프 어텐션을 수행하는 단계는
상기 프로그램 의존 그래프의 간선 정보를 기초로 상기 제1 노드 임베딩 간의 합성 곱을 반복적으로 수행하는 단계를 포함하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법.
The method of claim 10, wherein performing the graph attention
A method of generating a summary of a program source code based on artificial intelligence analysis, comprising the step of repeatedly performing a convolution between the first node embeddings based on edge information of the program dependence graph.
제10항에 있어서, 상기 소스코드 요약문을 생성하는 단계는
상기 요약 어휘 임베딩을 활성화 함수에 적용한 결과를 기초로 상기 소스코드 요약문을 생성하는 단계를 포함하는 것을 특징으로 하는 인공지능 분석 기반 프로그램 소스코드의 요약문 생성 방법.
The method of claim 10, wherein the step of generating the source code summary is
A method of generating a summary of a program source code based on artificial intelligence analysis, comprising the step of generating the source code summary based on a result of applying the summary vocabulary embedding to an activation function.
KR1020210150771A 2021-11-04 2021-11-04 Apparatus and method for generating summary of program source code based on ai analysis KR102610431B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020210150771A KR102610431B1 (en) 2021-11-04 2021-11-04 Apparatus and method for generating summary of program source code based on ai analysis

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020210150771A KR102610431B1 (en) 2021-11-04 2021-11-04 Apparatus and method for generating summary of program source code based on ai analysis

Publications (2)

Publication Number Publication Date
KR20230065017A KR20230065017A (en) 2023-05-11
KR102610431B1 true KR102610431B1 (en) 2023-12-06

Family

ID=86379136

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210150771A KR102610431B1 (en) 2021-11-04 2021-11-04 Apparatus and method for generating summary of program source code based on ai analysis

Country Status (1)

Country Link
KR (1) KR102610431B1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117407051B (en) * 2023-12-12 2024-03-08 武汉大学 Code automatic abstracting method based on structure position sensing

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020087127A (en) 2018-11-28 2020-06-04 国立研究開発法人産業技術総合研究所 Program related to encoding data containing graph structure, information processing method, and information processing system
JP2021121952A (en) 2017-05-23 2021-08-26 グーグル エルエルシーGoogle LLC Attention-based sequence transduction neural network

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120197630A1 (en) 2011-01-28 2012-08-02 Lyons Kenton M Methods and systems to summarize a source text as a function of contextual information
KR102327026B1 (en) * 2019-02-07 2021-11-16 고려대학교 산학협력단 Device and method for learning assembly code and detecting software weakness based on graph convolution network
KR20210058059A (en) * 2019-11-13 2021-05-24 주식회사 셀바스에이아이 Unsupervised text summarization method based on sentence embedding and unsupervised text summarization device using the same

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2021121952A (en) 2017-05-23 2021-08-26 グーグル エルエルシーGoogle LLC Attention-based sequence transduction neural network
JP2020087127A (en) 2018-11-28 2020-06-04 国立研究開発法人産業技術総合研究所 Program related to encoding data containing graph structure, information processing method, and information processing system

Also Published As

Publication number Publication date
KR20230065017A (en) 2023-05-11

Similar Documents

Publication Publication Date Title
Uc-Cetina et al. Survey on reinforcement learning for language processing
Umer et al. CNN-based automatic prioritization of bug reports
Shi et al. Incsql: Training incremental text-to-sql parsers with non-deterministic oracles
US11487577B2 (en) Robotic task planning for complex task instructions in natural language
US10580176B2 (en) Visualization of user intent in virtual agent interaction
JP2022018095A (en) Multi-modal pre-training model acquisition method, apparatus, electronic device and storage medium
KR102521765B1 (en) Method and apparatus for determining causality, electronic device and storage medium
Burns et al. A dataset for interactive vision-language navigation with unknown command feasibility
US11093195B2 (en) Method, device and computer program product for updating user interface
US8315874B2 (en) Voice user interface authoring tool
US20220021578A1 (en) Method for configuring modeling parameters, electronic device and computer storage medium thereof
CN113614688A (en) Large automation code
CN112764738A (en) Code automatic generation method and system based on multi-view program characteristics
CN111930912A (en) Dialogue management method, system, device and storage medium
US20230145452A1 (en) Method and apparatus for training a model
US9436912B1 (en) Symmetric schema instantiation method for use in a case-based reasoning system
JP7342971B2 (en) Dialogue processing device, learning device, dialogue processing method, learning method and program
CN115952966A (en) Automatic data transfer between source and target using semantic artificial intelligence for robotic process automation
KR102610431B1 (en) Apparatus and method for generating summary of program source code based on ai analysis
KR20230124104A (en) Natural solution language
WO2023103914A1 (en) Text sentiment analysis method and device, and computer-readable storage medium
Mo et al. Learning text editing tasks from examples: a procedural approach
CN116974554A (en) Code data processing method, apparatus, computer device and storage medium
Li et al. Effective representation for easy-first dependency parsing
JP2020052935A (en) Method of creating learned model, method of classifying data, computer and program

Legal Events

Date Code Title Description
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right