RPA code generation method based on deep learning model
By generating the RPA code generation method based on deep learning models, using the expansion vocabulary and multi -header attention mechanism to solve the problem of the code in the existing technology that does not meet the RPA grammar and the private SDK protocol, and realize the efficient and automated code generation, which has improved, and improved it. The syntax matching of the code and the unity of format.
Patent Information
- Application Number
- CN202411892542.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-12-20
AI Technical Summary
The existing technology is difficult to generate code that complies with specific RPA syntax and private SDK protocols, resulting in a large amount of manual modifications required, and the generated code format is inconsistent, affecting the efficiency of the automation process.
The RPA code generation method based on the deep learning model is adopted, and through the construction of a deep learning model, using the expansion vocabulary meter, dynamic location coding mechanism and task -related multi -header attention mechanism to generate code that meets the requirements of the RPA private SDK syntax and format.
It improves the syntax matching, unity, accuracy and degree of automation of the RPA private SDK code, reducing the needs of manual modification, and improving the efficiency of the automation process.
Smart Images

Figure CN119376708A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning and natural language processing technology, and specifically to an RPA code generation method based on a deep learning model. Background Art
[0002] In the existing natural language processing (NLP) and robotic process automation (RPA) fields, generating code that meets specific syntax and format requirements has always been a challenge. Existing methods mainly focus on generating code in general programming languages (such as Python, Java, etc.), but the support for specific RPA syntax and private SDK protocols is relatively limited. Specifically, the syntax of the code generated by the existing methods does not comply with the RPA private SDK protocol, resulting in a large amount of manual modification; the format of the code generated by the existing methods is not unified, which is difficult to be parsed and processed by subsequent applications, affecting the efficiency of the automation process. Summary of the invention
[0003] The purpose of the present invention is to provide an RPA code generation method based on a deep learning model. The present invention can improve the syntax matching, format uniformity, accuracy and automation of the generated RPA private SDK code.
[0004] The technical solution of the present invention is a method for generating RPA code based on a deep learning model, comprising the following steps: Step 1: Collect and preprocess data based on large code platforms and natural language description data sources to obtain a data set; at the same time, build and expand the vocabulary based on the existing RPA code base; Step 2: Build a deep learning model, embed the expanded vocabulary into the deep learning model to form a vocabulary expansion module, and then use the mapping data set to train the deep learning model. During the training process, the dynamic position encoding mechanism and task-related multi-head attention mechanism are used to ensure the format consistency of the generated code and meet the format and grammar requirements; Step 3: Use the trained deep learning model to generate RPA code.
[0005] In the aforementioned RPA code generation method based on deep learning models, in step one, data is obtained by crawling large code platforms and natural language description data sources, the collected data is annotated and preprocessed into JSONL format, and a mapping data set for generating RPA code from the user's natural language is constructed.
[0006] In the aforementioned RPA code generation method based on deep learning models, in step one, relevant code snippets and documents are extracted from the existing RPA code base, and the extracted code snippets are preprocessed, which includes removing noise and irrelevant information and retaining key syntax and function calls; then the code snippets are annotated and cleaned through regular expressions and natural language processing methods to form an RPA code base; then the initial vocabulary is constructed with the RPA code base, and finally, terminology and new vocabulary in specific fields are added to obtain an expanded vocabulary.
[0007] In the aforementioned RPA code generation method based on a deep learning model, in step 2, a word vector model is used to map the words in the expanded vocabulary into a high-dimensional vector and embed it into the deep learning model; the formula of the word vector model is as follows: ; in, and represents a word in the extended vocabulary; is the size of the vocabulary; Yes word and words The number of co-occurrences of and The words and words The word vector of and Yes word and words The bias term of is a weighting function, defined as: ; in, and They are hyperparameters respectively.
[0008] In the aforementioned RPA code generation method based on a deep learning model, in step 2, the dynamic position encoding mechanism dynamically adjusts the parameters and function form of the position encoding according to the context information of the input code. The formula is as follows: ; in, is the encoding function name, is a positional parameter, is the index parameter, is a learnable function, For context information.
[0009] In the aforementioned RPA code generation method based on a deep learning model, the task-related multi-head attention mechanism is provided with a syntax attention head, a format attention head and a context attention head; The grammatical attention head is used to capture the grammatical structure in the code and extract the grammatical features in the input code; the output formula of the grammatical attention head is as follows: ; Where: is the query matrix, is the key matrix, is the value matrix; is the transpose operator, which means that Perform transposition; is the dimension of the key; is a normalization function used to convert attention scores into probability distributions; The format attention head is used to capture the format features in the code and extract the format features in the input code; the output formula of the format attention head is as follows: ; The contextual attention head is used to enhance the attention mechanism's ability to capture task-specific information. It encodes the context information of the input code to generate a context matrix , the context information is fused with the input code as the input of the context attention head. The formula is as follows: ; in, is the input code; is a connection function used to connect multiple tensors along the specified dimension; The output formula of the context attention head is as follows: .
[0010] In the aforementioned RPA code generation method based on deep learning model, in the task-related multi-head attention mechanism, the weight of the grammar attention head is determined according to the task requirements. Adjustments are as follows: ; The weights of the attention heads in the format Adjustments are as follows: .
[0011] In the aforementioned RPA code generation method based on the deep learning model, the outputs of the syntax attention head, format attention head, and context attention head are weighted and summed to obtain the output of the task-related multi-head attention mechanism. The formula is as follows: ; in, , and The weight range is [0,1], and , and The sum of the weights is 1.
[0012] Compared with the prior art, the present invention has the following beneficial effects: 1. The present invention introduces a variety of innovative algorithms and methods, such as task-related multi-head attention mechanism, dynamic position encoding mechanism, vocabulary embedding optimization, etc., to improve the overall performance of the model. The present invention ensures that the generated code complies with the RPA private SDK syntax by expanding the initial vocabulary according to task requirements and embedding it into the deep learning model, reducing the need for manual modification, and through the multi-head attention mechanism, ensures that the syntax of the generated code meets the requirements. The present invention adopts a dynamic position encoding mechanism to make it suitable for specific tasks, thereby improving the accuracy and format consistency of the generated code. In addition, the present invention also enhances the ability of the attention mechanism to capture task-specific information through context encoding and fusion mechanisms, thereby improving the accuracy and consistency of the generated code. The present invention combines the latest NLP and deep learning methods to ensure the advancement and foresight of the present invention.
[0013] 2. The present invention uses task-related multi-head attention mechanisms and domain-specific task fine-tuning to enable the model to adapt to different RPA task requirements and generate code that conforms to specific syntax and format. The present invention also uses dynamic position encoding and task-related weight learning to enable the deep learning model to dynamically adjust according to the contextual information of the input code, thereby improving the adaptability of the generated code.
[0014] 3. In the fine-tuning stage, the present invention generates RPA code in a unified format through specific formatting rules and optimization algorithms, which is convenient for subsequent application parsing and processing. The present invention designs an attention head specifically for capturing code format features to ensure the uniformity of the generated code format and improve the efficiency of the automation process.
[0015] 4. The present invention generates codes in a unified format to facilitate the automated parsing and processing of subsequent applications, thereby improving the automation and efficiency of the RPA process. It also reduces the need for manual modification and intervention by ensuring that the syntax and format of the generated code meet the requirements, thereby improving overall work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION
[0017] The present invention is further described below in conjunction with the accompanying drawings and embodiments, but they are not intended to limit the present invention.
[0018] Embodiment: A RPA code generation method based on a deep learning model is applied to RPA process automation. RPA (Robot Process Automation) is an automation technology that uses software robots to simulate manual operations and handle various repetitive and standardized tasks. The purpose of the present invention is to make the generated RPA code meet the requirements of the SDK protocol. The SDK protocol refers to a series of rules and conventions in the software development kit (Software Development Kit). The SDK protocol is to ensure the correct interaction between the various components within the SDK, as well as the compatibility and consistency between the SDK and external systems. It usually includes regulations on data formats, communication protocols, calling conventions, error handling, etc. When using the SDK, developers need to follow these protocols so that they can correctly use the functions provided by the SDK.
[0019] Specifically, Figure 1 As shown, the following steps are included: Step 1: Collect and preprocess data based on large code platforms and natural language description data sources to obtain a data set; at the same time, build and expand the vocabulary based on the existing RPA code base; In this step, we crawled large code platforms and natural language description data sources from GitHub to build a mapping dataset that covers a variety of programming tasks, where the user's natural language generates RPA code. We used semi-automatic tools and domain experts to annotate the collected data to ensure data quality. We preprocessed the data into JSONL format, where each record contains a set of dialogues. Users describe tasks in natural language, and the system generates the corresponding Python code.
[0020] Extract relevant code snippets and documents from the existing RPA code base, pre-process the extracted code snippets, remove noise and irrelevant information, and retain key syntax and function calls; then use regular expressions and natural language processing methods (such as word segmentation and part-of-speech tagging) to annotate and clean the code snippets to form input code and form a new RPA code base; then use the RPA code base to build an initial vocabulary, including commonly used functions, variable names, and operators. Use statistical methods (such as TF-IDF, TF-IDF is a statistical method used to evaluate the importance of a word to a file set or one of the files in a corpus) and deep learning models to expand the initial vocabulary, add terms for specific fields (such as callback functions, recursive functions, and anonymous functions) and newly emerging words (such as workflow, sub-process, and unattended), and obtain an expanded vocabulary.
[0021] Step 2: Build a deep learning model, embed the expanded vocabulary into the deep learning model to form a vocabulary expansion module, and then use the mapping data set to train the deep learning model. During the training process, the dynamic position encoding mechanism and task-related multi-head attention mechanism are used to ensure the format consistency of the generated code and meet the format and grammar requirements; In this step, the word vector model GloVe is used to map the words in the extended vocabulary into a high-dimensional vector and embed it into the deep learning model; the word vector model GloVe formula is as follows: ; in, and Represents a word in the extended vocabulary, is the size of the vocabulary; Yes word and word Number of co-occurrences; and The words and words The word vector of and Yes word and words The bias term of is a weighting function, defined as: ; in, and They are hyperparameters respectively.
[0022] By optimizing the above GloVe objective function, the embedding vector of each word in the expanded vocabulary is obtained.
[0023] Then, the deep learning model is trained using the mapping dataset. During the training process, the dynamic position encoding mechanism and multi-head attention mechanism are adopted. The mapping dataset in JSONL format is used to fine-tune the deep learning model through the conversation context to better adapt it to the specific RPA syntax and task requirements.
[0024] The design of the dynamic position encoding mechanism will focus on standardizing the format of the generated code, thereby ensuring that the generated code strictly follows the defined format. This will not only improve the efficiency of subsequent parsing and processing, but also ensure seamless integration with the low-code platform. The following is the detailed principle of the dynamic position encoding mechanism and its implementation steps, with the focus on ensuring the format consistency of the generated code.
[0025] According to the task requirements, the dynamic position encoding mechanism adjusts the parameters and function form of the position encoding to better capture the position dependency in the input code. The dynamic position encoding mechanism dynamically adjusts the position encoding according to the context information of the input code. The formula is as follows: ; in, is the encoding function name, is a positional parameter, is the index parameter, is a learnable function, For context information.
[0026] The task-related multi-head attention mechanism processes the input code in parallel through multiple attention heads, and generates a query matrix by encoding the input code. , key matrix Sum Matrix ; Each attention head calculates a different attention distribution, the formula is as follows: ; in, is the dimension of the key.
[0027] According to the task requirements, adjust the parameters and calculation method of each attention head to better capture the syntax and format information in the code, and introduce task-specific weight matrices , perform weighted summation on the output of each attention head; ; in, It is The weight of the attention head, is the number of attention heads.
[0028] In this embodiment, preferably, the task-specific multi-head attention mechanism is provided with a syntax attention head, a format attention head, and a context attention head; the syntax attention head is specifically used to capture the syntax structure in the code, such as function definition, variable declaration, loop structure, etc., and extract the syntax features in the code by using specific syntax rules and templates. For example, the function definition can be extracted by identifying the keyword `def`` and the function name, and the variable declaration can be extracted by identifying the assignment operator `=`.
[0029] The formula for calculating the output of the grammatical attention head is as follows: ; Where: is the query matrix, is the key matrix, is the value matrix; is the transpose operator, which means that Perform transposition; is the dimension of the key; It is a normalization function used to convert the attention score into a probability distribution so that the sum of the output elements is 1, which can be used for weight allocation.
[0030] Adjust the weight of the grammatical attention head according to task requirements , the formula is as follows: ; The format attention head is specifically used to capture format features in the code, such as code indentation, comment style, variable naming conventions, etc. It extracts format features in the code by using specific format rules and templates. For example, code indentation can be extracted by identifying spaces or tabs, and comment style can be extracted by identifying the comment symbol `#`.
[0031] The formula for calculating the format attention head output is as follows: ; Adjust the weight of the format attention head according to task requirements , the formula is as follows: .
[0032] Introduce task-related contextual information into the attention mechanism, such as the context of the code, function call relations, etc. Through context encoding, the attention mechanism's ability to capture task-specific information is enhanced.
[0033] The contextual attention head is used to enhance the attention mechanism’s ability to capture task-specific information. Its design can be achieved through the following steps: Encode the contextual information of the code snippet, such as function call relations, variable scopes, etc., to generate a context matrix; The task-related context information is fused with the input code as the input of the context attention head to improve the sensitivity of the context attention head to task-specific information. By encoding the context information of the input code, the context information is fused with the input code as the input of the attention mechanism. The formula is as follows: ; in, is the input code; A concatenation function that concatenates multiple tensors along a specified dimension.
[0034] The formula for calculating the contextual attention head output is as follows: .
[0035] Weights of contextual attention heads Through deep learning model training, the optimization is performed, and finally the context attention head is adjusted according to the weights. Adjustments are as follows: .
[0036] Fine-tune the deep learning model through formatting rules and optimization algorithms. In the fine-tuning stage, define specific formatting rules to ensure that the generated RPA code meets the unified format requirements. These rules can include code indentation, comment style, variable naming specifications, etc. Use optimization algorithms (such as Adam and RMSprop) to fine-tune the deep learning model so that the generated code is more in line with the needs of specific tasks.
[0037] At the beginning of model training, the weights of the attention heads are initialized according to the requirements of specific tasks, making them more inclined to capture specific grammatical and format features.
[0038] During the model training process, the weights of the attention heads are dynamically adjusted through the back-propagation algorithm to better adapt to the needs of specific tasks.
[0039] Design attention heads specifically to capture code grammatical structures, such as function definitions, variable declarations, loop structures, etc.
[0040] The outputs of the grammatical attention head, format attention head, and context attention head are weighted summed to obtain the task-specific attention output, as shown in the following formula: ; in, , and They are the weights of the grammatical attention head, format attention head, and context attention head respectively. , and The weight range of is in [0,1], and the sum of the weight values of , and is 1.
[0041] Step 3: Use the trained deep learning model to generate RPA code.
[0042] Through the above design, the task-specific attention head can effectively capture the grammatical structure and format features in the code snippet, and combine the contextual information to improve the accuracy and consistency of the generated code.
[0043] The present invention introduces a variety of innovative algorithms and methods, such as task-related multi-head attention mechanism, dynamic position encoding mechanism, vocabulary embedding optimization, etc., to improve the overall performance of the model. The present invention expands the initial vocabulary according to the task requirements and embeds it into the deep learning model to ensure that the generated code complies with the RPA private SDK syntax, reducing the need for manual modification, and through the multi-head attention mechanism, ensures that the syntax of the generated code meets the requirements. The present invention adopts a dynamic position encoding mechanism to make it suitable for specific tasks and improve the accuracy and format consistency of the generated code. In addition, the present invention also enhances the ability of the attention mechanism to capture task-specific information through context encoding and fusion mechanisms, and improves the accuracy and consistency of the generated code. The present invention combines the latest NLP and deep learning methods to ensure the advancement and foresight of the present invention. In the fine-tuning stage, the present invention generates RPA code in a unified format through specific formatting rules and optimization algorithms, which is convenient for subsequent application parsing and processing. The present invention uses task-related multi-head attention mechanisms and domain-specific task fine-tuning to enable the model to adapt to different RPA task requirements and generate code that complies with specific syntax and format. The present invention designs an attention head specifically for capturing code format features to ensure the uniform format of the generated code and improve the efficiency of the automation process. The present invention improves the automation and efficiency of the RPA process by generating codes in a unified format, which facilitates the automatic parsing and processing of subsequent applications. It also reduces the need for manual modification and intervention by ensuring that the syntax and format of the generated code meet the requirements, thereby improving overall work efficiency. The present invention also enables the deep learning model to be dynamically adjusted according to the contextual information of the input code through dynamic position encoding and task-related weight learning, thereby improving the adaptability of the generated code.
[0044] In summary, the present invention can improve the syntax matching, format uniformity, accuracy and automation of the generated RPA private SDK code.
Claims
1. A RPA code generation method based on a deep learning model, characterized in that: The following steps are involved: Step 1: Collect and preprocess data based on large code platforms and natural language description data sources to obtain a data set; at the same time, build and expand the vocabulary based on the existing RPA code base; Step 2: Build a deep learning model, embed the expanded vocabulary into the deep learning model to form a vocabulary expansion module, and then use the mapping data set to train the deep learning model. During the training process, the dynamic position encoding mechanism and task-related multi-head attention mechanism are used to ensure the format consistency of the generated code and meet the format and grammar requirements; Step 3: Use the trained deep learning model to generate RPA code.
2. The RPA code generation method based on the deep learning model according to claim 1 is characterized in that: In step 1, data is obtained by crawling large code platforms and natural language description data sources, the collected data is annotated and preprocessed into JSONL format, and a mapping dataset for generating RPA code from the user's natural language is constructed.
3. The RPA code generation method based on the deep learning model according to claim 1 is characterized in that: In step one, relevant code snippets and documents are extracted from the existing RPA code base, and the extracted code snippets are preprocessed, which includes removing noise and irrelevant information and retaining key syntax and function calls. The code snippets are then annotated and cleaned using regular expressions and natural language processing methods to form an RPA code base. The initial vocabulary is then constructed using the RPA code base, and finally, field-specific terms and new vocabulary are added to obtain an expanded vocabulary.
4. The RPA code generation method based on the deep learning model according to claim 3 is characterized in that: In step 2, a word vector model is used to map the words in the extended vocabulary into a high-dimensional vector and embed it into the deep learning model; the word vector model formula is as follows: ; in, and Represents a word in the extended vocabulary, is the size of the vocabulary; Yes word and words The number of co-occurrences of and The words and words The word vector of and Yes word and words The bias term of is a weighting function, defined as: ; in, and They are hyperparameters respectively.
5. The RPA code generation method based on the deep learning model according to claim 1 is characterized in that: In step 2, the dynamic position coding mechanism dynamically adjusts the parameters and function form of the position coding according to the context information of the input code. The formula is as follows: ; in, is the encoding function name, is a positional parameter, is the index parameter, is a learnable function, For context information.
6. The RPA code generation method based on the deep learning model according to claim 1 is characterized in that: The task-related multi-head attention mechanism includes a grammatical attention head, a format attention head and a context attention head; The grammatical attention head is used to capture the grammatical structure in the code and extract the grammatical features in the input code; The output formula of the grammatical attention head is as follows: ; Where: is the query matrix, is the key matrix, is the value matrix; is the transpose operator, which means that Perform transposition; is the dimension of the key; is a normalization function used to convert attention scores into probability distributions; The format attention head is used to capture the format features in the code and extract the format features in the input code; The output formula of the attention head in the format is as follows: ; The contextual attention head is used to enhance the attention mechanism's ability to capture task-specific information. It encodes the context information of the input code to generate a context matrix , the context information is fused with the input code as the input of the context attention head. The formula is as follows: ; in, is the input code; is a connection function used to connect multiple tensors along the specified dimension; The output formula of the context attention head is as follows: 。 7. The RPA code generation method based on the deep learning model according to claim 6 is characterized in that: In the task-related multi-head attention mechanism, according to the task requirements, the grammatical attention head is weighted according to Adjustments are as follows: ; The format attention head is based on the weight Adjustments are as follows: ; The context attention head is weighted according to Adjustments are as follows: 。 8. The RPA code generation method based on the deep learning model according to claim 7 is characterized in that: The outputs of the grammatical attention head, format attention head, and context attention head are weighted summed to obtain the output of the task-related multi-head attention mechanism. The formula is as follows: ; in, , and The weight range is [0,1], and , and The sum of the weights is 1.
Citation Information
Patent Citations
Code generation method and system based on natural semantic understanding
CN115202640A
Lightweight code generation method based on prompt learning
CN116301893A
Python code automatic generation method and system
CN116400901A
RPA component generation method and device, equipment, medium and program product
CN118092871A
RPA process execution code generation method and device based on AI and AI Agent
CN118444894A