Software reconstruction method, device and equipment based on artificial intelligence and storage medium

By analyzing code and user data combined with large language models to generate a software reconstruction strategy that takes into account technical optimization and business needs, the problems of low efficiency, high cost and disconnection between the reconstruction solution and business expectations in the existing technology are solved, and efficient and accurate software reconstruction is achieved to adapt to the changes in demand during the software iteration process.

CN120540697AActive Publication Date: 2025-08-26SHENZHEN FENZHUAN TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510653353.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-21
Publication Date
2025-08-26
Estimated Expiration
2045-05-21

AI Technical Summary

Technical Problem

The existing technology is inefficient and costly in software reconstruction. Manual reconstruction is prone to introduce errors and is difficult to cover all potential optimization points. Automation tools lack dynamic response capabilities to business needs, and the generated code lacks a deep understanding of the original code context and business goals, which leads to the disconnection of the reconstruction scheme from business expectations.

Method used

By analyzing code data and user data, combining large language model generation target reconstruction strategies that take into account both technical optimization and business needs, using code optimization detection models to identify code problems, and extract business expectations based on user interaction data to generate refactored code data to ensure that the refactored code accurately matches the user's actual business scenario while optimizing technical indicators.

Benefits of technology

It improves the accuracy and efficiency of software reconstruction, reduces the cost of secondary modification caused by deviations in demand understanding, adapts to the changes in demand during the software iteration process, and ensures that the reconstruction plan meets the actual business needs of users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120540697A_ABST
    Figure CN120540697A_ABST
Patent Text Reader

Abstract

The invention provides a software reconstruction method based on artificial intelligence. The method comprises the following steps: acquiring current code data of to-be-reconstructed software and user data of the to-be-reconstructed software; determining a target reconstruction strategy of the current code data based on the current code data and the user data; based on the large language model, generating reconstruction code data corresponding to the target reconstruction strategy; and based on the reconstruction code data, performing code reconstruction on the to-be-reconstructed software, and obtaining target software after reconstruction is completed. According to the method, by analyzing the code data and the user data, considering the code problem of the software to be reconstructed and the user service expectation, the target reconstruction strategy giving consideration to technical optimization and service requirements is generated, the problem of technical optimization and service target separation in a traditional method is avoided, it is ensured that the reconstructed code optimizes the technical indexes, and meanwhile the technical optimization efficiency is improved. And the actual business scene of the user is precisely fit, the secondary modification cost caused by the demand understanding deviation is reduced, and the reconstruction accuracy and reconstruction efficiency of the software are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence, and in particular to an artificial intelligence-based software reconstruction method, apparatus, device and storage medium. Background Art

[0002] As software systems continue to grow in complexity and scale, software refactoring has become a crucial tool for improving code quality and adapting to changing business needs. Traditional software refactoring relies primarily on developer experience, manually analyzing code structure and identifying redundant or inefficient code (e.g., "code smells"). However, this approach suffers from low efficiency, high cost, and high subjectivity. Especially in large-scale projects, manual refactoring is prone to introducing errors and struggles to address all potential optimization opportunities.

[0003] In recent years, some automated code refactoring tools (such as static code analyzers) have been proposed. However, their capabilities are limited to detecting specific types of code issues (such as code duplication and excessively long functions) and lack the ability to dynamically respond to business needs. Furthermore, existing tools typically only provide optimization suggestions and cannot generate refactored code that can be directly applied, requiring developers to manually modify the code.

[0004] Meanwhile, large language models (such as GPT and Codex) have shown potential in code generation, but their application to software refactoring remains limited. First, the code generated by the models may lack a deep understanding of the original code's context and business objectives. Second, existing methods fail to consider user needs and code optimization goals, leading to a disconnect between refactoring solutions and business expectations. Therefore, leveraging AI to achieve efficient, accurate, and business-oriented automated software refactoring has become a pressing issue. Summary of the Invention

[0005] An embodiment of the present invention provides an artificial intelligence-based software reconstruction method, aiming to provide an automated software reconstruction solution that utilizes artificial intelligence technology to achieve high efficiency, accuracy, and compliance with business needs. By analyzing code data and user data, the present invention considers the code issues of the software to be reconstructed and the user's business expectations, and generates a target reconstruction strategy that takes into account both technical optimization and business needs. This avoids the problem of separating technical optimization from business goals in traditional methods, ensures that the reconstructed code accurately fits the user's actual business scenarios while optimizing technical indicators, reduces the cost of secondary modifications caused by deviations in the understanding of requirements, and thus improves the accuracy and efficiency of software reconstruction.

[0006] In a first aspect, an embodiment of the present invention provides a software reconstruction method based on artificial intelligence, the method comprising the following steps: Acquire current code data of the software to be reconstructed and user data of the software to be reconstructed, wherein the user data is interaction data of the user during use of the software to be reconstructed; Determining a target reconstruction strategy for the current code data based on the current code data and the user data; Based on the large language model, generating reconstructed code data corresponding to the target reconstructing strategy; Based on the reconstructed code data, the software to be reconstructed is reconstructed, and the target software is obtained after the reconstruction is completed.

[0007] Optionally, determining a target reconstruction strategy for the current code data based on the current code data and the user data includes: Performing code optimization detection on the current code data, and determining a first refactoring strategy that can be optimized in the current code data; Performing business expectation extraction on the user data to extract the user's business expectations for the software to be reconstructed, and determining a second reconstructing strategy in the current code data based on the business expectations; Based on the first reconstruction strategy and the second reconstruction strategy, a target reconstruction strategy for the current code data is determined.

[0008] Optionally, performing code optimization detection on the current code data and determining an optimizable first reconstruction strategy in the current code data includes: Inputting the current code data into a pre-trained code optimization detection model to perform code optimization detection, and outputting the code smell of the current code data; Based on the code smell, a first optimizable refactoring strategy is determined in the current code data.

[0009] Optionally, extracting business expectations from the user data to extract the user's business expectations for the software to be reconstructed includes: Performing semantic extraction on the user data to obtain multiple user semantics; Classify the plurality of user semantics to determine the user semantics related to the software to be reconstructed; The user semantics related to the software to be reconstructed are used to generate the user's business expectations for the software to be reconstructed.

[0010] Optionally, determining a second reconstruction strategy in the current code data based on the business expectation includes: Parsing the service expectation and the current code data into multimodal feature vectors respectively to obtain a first multimodal feature vector and a second multimodal feature vector, wherein the first multimodal feature vector corresponds to the service expectation, and the second multimodal feature vector corresponds to the current code data; Based on the vector similarity between the first multimodal feature vector and the second multimodal feature vector, a second reconstruction strategy is determined in the current code data.

[0011] Optionally, determining a target reconstruction strategy for the current code data based on the first reconstruction strategy and the second reconstruction strategy includes: Determining a common portion between the first reconstruction strategy and the second reconstruction strategy, determining a first difference portion between the first reconstruction strategy and the second reconstruction strategy, and determining a second difference portion between the second reconstruction strategy and the first reconstruction strategy; Performing a global verification on the first difference portion and the second difference portion to obtain a target difference portion that succeeds the global verification; The target difference portion and the common portion are determined as a target reconstruction strategy for the current code data.

[0012] Optionally, generating the reconstructed code data corresponding to the target reconstructing strategy based on the large language model includes: Get the AST abstract syntax tree corresponding to the current code data; Constructing an input file of the large language model based on the target reconstruction strategy and the AST abstract syntax tree corresponding to the current code data; The input file is input into the large language model to generate reconstructed code data corresponding to the target reconstructing strategy.

[0013] In a second aspect, an embodiment of the present invention further provides an artificial intelligence-based software reconstruction device, the artificial intelligence-based software reconstruction device comprising: An acquisition module, configured to acquire current code data of the software to be reconstructed and user data of the software to be reconstructed, wherein the user data is interaction data of the user during use of the software to be reconstructed; a processing module, configured to determine a target reconstruction strategy for the current code data based on the current code data and the user data; A generation module, configured to generate reconstructed code data corresponding to the target reconstructing strategy based on the large language model; The reconstructing module is used to reconstruct the code of the software to be reconstructed based on the reconstructed code data, and obtain the target software after the reconstruction is completed.

[0014] In a third aspect, an embodiment of the present invention provides an electronic device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the artificial intelligence-based software reconstruction method provided in an embodiment of the present invention are implemented.

[0015] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program implements the steps in the artificial intelligence-based software reconstruction method provided in an embodiment of the invention.

[0016] In an embodiment of the present invention, the current code data of the software to be reconstructed and the user data of the software to be reconstructed are obtained; based on the current code data and the user data, a target reconstruction strategy for the current code data is determined; based on the large language model, reconstruction code data corresponding to the target reconstruction strategy is generated; based on the reconstructed code data, the software to be reconstructed is reconstructed, and the target software is obtained after the reconstruction is completed. The present invention analyzes the code data and user data, considers the code problems of the software to be reconstructed itself and the user's business expectations, and generates a target reconstruction strategy that takes into account both technical optimization and business needs, avoiding the problem of separating technical optimization from business goals in traditional methods, ensuring that the reconstructed code accurately fits the user's actual business scenario while optimizing technical indicators, reducing the cost of secondary modifications caused by deviations in understanding requirements, and thereby improving the accuracy and efficiency of software reconstruction. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 This is a flowchart of a software reconstruction method based on artificial intelligence provided by an embodiment of the present invention; Figure 2 This is a schematic structural diagram of an artificial intelligence-based software reconstruction device provided by an embodiment of the present invention; Figure 3 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0019] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0020] like Figure 1 As shown, Figure 1 1 is a flowchart of an artificial intelligence-based software reconstruction method provided by an embodiment of the present invention, the artificial intelligence-based software reconstruction method comprising the steps of: 101. Obtain current code data of the software to be reconstructed and user data of the software to be reconstructed.

[0021] In an embodiment of the present invention, the above-mentioned artificial intelligence-based software reconstruction method can be applied to a software reconstruction platform. The above-mentioned software reconstruction platform is composed of a server or a distributed server. The above-mentioned software reconstruction platform is deployed with an artificial intelligence-based software reconstruction application, as well as a large language model (LLM) or a large language model interface. The above-mentioned large language model can be GPT, Wenxin Yiyan, Tongyi Qianwen, etc. The above-mentioned large language model can verify and optimize the code data based on the user's prompt words, and can also output the corresponding code data based on the user's prompt words. The software reconstruction platform can also be provided with a code warehouse or a code warehouse interface, and the code data of the software to be reconstructed can be obtained through the code warehouse or the code warehouse interface. Read the source code files of the software to be refactored through the code repository interface (such as Git, SVN) or the local file system, including but not limited to programming language files such as .java, .py, and .js, and extract their code structure, function definition, class relationship, and annotation information to obtain the current code data of the software to be refactored.

[0022] The aforementioned user data refers to user interaction data during the use of the software to be refactored, and may specifically include user operation logs, user comment data, and user feedback data. User operation logs may include data such as clicks, navigation paths, frequency of function usage, and operation timing on the software interface. User comment data may include comments, messages, and ratings left by users in the review section while using the software. The aforementioned user feedback data may include text descriptions or questionnaires submitted by users using the software's built-in feedback module. This interaction data is collected in real time or offline using tracking tools (such as Sentry and ELK), log collection systems, or user behavior analysis platforms (such as Mixpanel).

[0023] 102. Based on the current code data and user data, determine a target reconstruction strategy for the current code data.

[0024] In an embodiment of the present invention, the current code data can be input into a pre-trained code optimization detection model (such as a deep learning-based code analysis tool) to identify defects or optimizable code in the current code data. The detection results include redundant code, inefficient structure, design defects, etc. Among them: Redundant code refers to duplicate functions and unused variables; inefficient structure refers to overly long functions and overly nested conditional statements; design defects refer to unclear class responsibilities and excessive coupling.

[0025] A first reconstruction strategy can be generated based on the detection results, such as "split function A into two independent modules" and "remove unused dependent library B".

[0026] User data can be analyzed to extract the user's business expectations for the software and reconstruct it, and then the corresponding second reconstruction strategy can be matched according to the business expectations. Specifically, cluster analysis can be performed on user operation logs to identify frequently used functional modules (such as "users frequently trigger data export operations"); API call records can be counted to locate high-latency interfaces (such as "the average response time of the order submission interface exceeds 2 seconds"); natural language processing (NLP) can be performed on feedback text to extract keywords and intent, such as "slow speed", "missing functions", and "cannot take long screenshots". The above business expectation generation can generate user business expectations for the software based on the above analysis results, such as: "Optimize the execution efficiency of the data export function"; "Add an API interface for batch deletion of orders"; "Reduce timeout errors in the order submission interface"; "Optimize the interface UI".

[0027] After obtaining the business expectations, we can perform strategy matching based on them, thereby logically linking the business expectations with the code. Specifically, we can parse the business expectation (e.g., "optimize data export efficiency") into a first multimodal feature vector (semantic embedding vector); parse the current code data (e.g., the code of the data export module) into a second multimodal feature vector (code structure graph embedding); calculate the similarity between the two, determine the code scope that needs to be refactored, and generate a second refactoring strategy (e.g., "change loop queries in data export to batch queries").

[0028] Merge the first refactoring strategy (technical optimization) and the second refactoring strategy (business adaptation). If there is a conflict (for example, optimizing performance results in decreased code readability), priority arbitration is performed through preset rules or reinforcement learning models to ultimately generate the target refactoring strategy.

[0029] 103. Based on the large language model, generate refactored code data corresponding to the target refactoring strategy.

[0030] In an embodiment of the present invention, the current code data can be parsed into an AST (abstract syntax tree) and combined with the target refactoring strategy to construct a structured input file. For example, the nodes to be modified in the AST (such as functions and loop blocks) are marked, and a policy description corresponding to the target refactoring strategy is attached (such as "change the loop of function F1 to parallel computation"). The input file is input into a large language model (such as Code Llama or GPT-4). The model generates refactored code snippets based on the code context and policy instructions, and obtains refactored code data corresponding to the target refactoring strategy. For example, the serial loop for (i in list){...} in the original code is replaced with the parallel computation list.parallelStream().forEach(...).

[0031] In a possible embodiment, the syntax correctness of the generated code may be verified by a compiler or a static analysis tool to ensure that there are no compilation errors, and the generated code without compilation errors may be determined as .

[0032] 104. Based on the reconstructed code data, the code of the software to be reconstructed is reconstructed, and the target software is obtained after the reconstruction is completed.

[0033] In an embodiment of the present invention, after obtaining the reconstructed code data, the generated reconstructed code data can be compared with the original code (a Diff tool can be used for the difference comparison), and the target code segment can be automatically replaced to retain the integrity of the unmodified part.

[0034] In one possible embodiment, automated test cases (such as unit tests and integration tests) may be run to verify the functional correctness and performance improvement of the refactored software.

[0035] Deploy the refactored code as the target software through the continuous integration / continuous deployment (CI / CD) pipeline, and generate a refactoring report (such as optimization point statistics and performance comparison data).

[0036] In a possible embodiment, the software to be restructured is an order processing module of an e-commerce system. Users frequently encounter the problem of "slow order export speed" during use. The interactive data shows: User operation log: Order export operations are triggered 500 times per day on average, with an average waiting time of 8 seconds; API call records: The standard deviation of the order export interface response time is large (1 second to 15 seconds); Feedback text: The user submitted the feedback multiple times: "Exporting orders takes too long, affecting work efficiency"; Review Text: Multiple users mentioned that "wait times to view orders were too long."

[0037] Based on the above interaction data: During code optimization, it was discovered that the order export function had a database query one by one (code smell). Business expectations are extracted to generate a goal: "Reduce order export time to less than 3 seconds"; Strategy matching locates the need to optimize database query logic; The target reconstruction strategy is to "change query by query to batch query and add paging processing"; Generate JPA batch query-based code logic through a large language model; After the reconstruction, the test showed that the average time for order export was reduced to 2.1 seconds, and the problem resolution rate of user feedback increased by 90%.

[0038] In an embodiment of the present invention, the current code data of the software to be reconstructed and the user data of the software to be reconstructed are obtained; based on the current code data and the user data, a target reconstruction strategy for the current code data is determined; based on the large language model, reconstruction code data corresponding to the target reconstruction strategy is generated; based on the reconstructed code data, the software to be reconstructed is reconstructed, and the target software is obtained after the reconstruction is completed. The present invention analyzes the code data and user data, considers the code problems of the software to be reconstructed itself and the business expectations of the users, and generates a target reconstruction strategy that takes into account both technical optimization and business needs, avoids the problem of separation of technical optimization and business goals in traditional methods, ensures that the reconstructed code accurately fits the user's actual business scenario while optimizing technical indicators, reduces the cost of secondary modifications caused by deviations in understanding requirements, and thus improves the accuracy and efficiency of software reconstruction. At the same time, the present invention can dynamically adjust the reconstruction strategy based on the continuously collected interaction data, adapt to changes in requirements during the software iteration process, and directly obtain the expectations corresponding to the business from the user data, without the need to submit business requirements through the product manager.

[0039] It is understandable that in the specific implementation of this application, code data, user data and other related data are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data, as well as the training, deployment and calling of algorithm models, must comply with the relevant laws, regulations and standards of relevant countries and regions.

[0040] Optionally, based on the current code data and the user data, a target reconstruction strategy for the current code data is determined, including: performing code optimization detection on the current code data, and determining a first optimizable reconstruction strategy in the current code data; performing business expectation extraction on the user data, extracting the user's business expectations for the software to be reconstructed, and determining a second reconstruction strategy in the current code data based on the business expectations; and determining a target reconstruction strategy for the current code data based on the first reconstruction strategy and the second reconstruction strategy.

[0041] In an embodiment of the present invention, a dual-driven refactoring scenario combining static code optimization and dynamic business demand analysis is considered, and a target refactoring strategy is determined based on current code data and user data.

[0042] Specifically, a pre-trained code optimization detection model (such as a Transformer-based neural network) is used. The training data of the code optimization detection model includes labeled samples in the open source code library (code snippets marked as "bad smell" or "normal") to learn the relationship between code structure, grammatical patterns and optimization requirements.

[0043] The current code data can be split into multiple code units according to modules or functions; features (such as code complexity, dependencies, and repetition rate) can be extracted for each code unit; after inputting into the model, the probability value is output to determine whether there is a "bad smell" and its specific type.

[0044] For example, it is detected that the function processOrder() contains 200 lines of code (exceeding the threshold of 150 lines) and is judged as an "overly long function"; it is detected that there is a circular dependency between the classes UserService and OrderService and is judged as a "tightly coupled design".

[0045] Preliminary refactoring suggestions are generated based on the code smell type, matching it to a predefined optimization rule library. For example, for an "overly long function," it's recommended to split it into sub-functions such as validateOrder() and calculatePrice(); for a "tightly coupled design," it's recommended to introduce an intermediary class, OrderProcessor, to decouple dependencies.

[0046] Format the preliminary refactoring strategy. Specifically, the suggestions can be converted into structured instructions (such as JSON format), including the code location to be modified, the optimization type, and the reference template.

[0047] When analyzing interaction data, we can extract high-frequency operation paths (such as "users trigger data export operations 300 times a day") to identify functional hotspots; sort API response times (such as "the average delay of the payment interface is 1.8 seconds") to locate performance bottlenecks; and classify user feedback text (such as "hope to support PDF export format") to extract functional expansion requirements.

[0048] The analysis results can be mapped to executable refactoring targets. For example: Operation log analysis → "Improve the efficiency of data export functionality"; API latency statistics → "Optimize the database query logic of the payment interface"; Feedback text analysis → "Add a PDF export module"; and so on.

[0049] Input the business expectation text (e.g., "Optimize payment interface speed") into a text encoder (e.g., BERT) to generate a first multimodal feature vector (semantic vector); Parse the current code data (such as payment interface-related code) into an abstract syntax tree (AST), extract structural features through a graph neural network, and generate a second multimodal feature vector (code structure vector); Calculate the cosine similarity of the two vectors to determine the code module with the highest correlation with business expectations (such as the executePayment() function in the payment interface).

[0050] If the business expectation is performance optimization, the generation strategy can be "change the serial query in executePayment() to a batch query." If the business expectation is functionality expansion, the generation strategy can be "add a generatePDF() method to the ExportService class." This results in the second reconstruction strategy.

[0051] After obtaining the first reconstruction strategy and the second reconstruction strategy, the first reconstruction strategy and the second reconstruction strategy are compared to identify overlapping optimization objectives.

[0052] For example: The first strategy suggests "splitting the executePayment() function", and the second strategy suggests "optimizing the executePayment() query logic"; the common part is "refactoring executePayment()".

[0053] Identify code conflicts between the first and second refactoring strategies. For example, the first strategy suggests reducing the number of database connections to reduce coupling, while the second strategy suggests increasing concurrent connections to improve performance.

[0054] When there is a code conflict between the first and second refactoring strategies, arbitration is performed through predefined rules or reinforcement learning models. This can be done by prioritizing business expectations (such as when users explicitly require "performance first") or by using weight distribution (such as a 40% weight for technical optimization and a 60% weight for business requirements). The strategy selection model is trained based on historical refactoring effect data, outputting the optimal solution for the conflicting part and obtaining the target difference part.

[0055] Combine the common parts with the verified target differences to generate the final refactoring strategy, which serves as the target refactoring strategy. For example: Common part: "Split executePayment() into validate() and process()"; Verified differences: "Use batch queries and add a connection pool in process()"; Target refactoring strategy: "Refactor executePayment(), split the function, and optimize the query logic."

[0056] Taking e-commerce system software as an example, if there are performance issues with the inventory management module of the e-commerce system and users report "high inventory deduction delays",

[0057] Code optimization detection: It was detected that the deductStock() function contained complex transaction logic (code smell: "excessive transaction nesting").

[0058] The first reconstruction strategy generated is: "Split the transaction into lockStock() and updateInventory()".

[0059] Business expectation extraction: Analysis of API logs revealed an average inventory deduction interface latency of 2.5 seconds. This generated a business expectation: "Reduce inventory deduction latency to less than 1 second." Multimodal matching located database row lock contention in the deductStock() function.

[0060] Generate the second reconstruction strategy: "Change row locks to optimistic locks and add a cache layer."

[0061] Strategy fusion: Common parts: both need to modify the deductStock() function; Differences: The first strategy focuses on code structure, while the second strategy focuses on concurrency mechanism; Global verification: Business requirements take priority, so the concurrency optimization solution of the second strategy is adopted, while the splitting suggestions of the first strategy are partially adopted. Target strategy: "Split deductStock() into lockStock() and updateInventory(), and introduce Redis cache and optimistic locking mechanism in lockStock()."

[0062] This invention ensures that the reconstruction plan meets both code quality and user value through the dual input of code static analysis (technology-driven) and user behavior data mining (business-driven); adopts a verification method that combines rules and machine learning to avoid reconstruction failures caused by policy conflicts; and through multimodal feature alignment, accurately associates business expectations described in natural language with specific code units, improving the targeted nature of reconstruction.

[0063] Optionally, performing code optimization detection on the current code data and determining a first optimizable reconstruction strategy in the current code data includes: inputting the current code data into a pre-trained code optimization detection model to perform code optimization detection, and outputting the code smell of the current code data; and determining a first optimizable reconstruction strategy in the current code data based on the code smell.

[0064] In an embodiment of the present invention, considering the scenario of automatically identifying code smells and generating refactoring strategies, code optimization detection and first refactoring strategy generation are performed. Specifically, the code optimization detection model training can be performed first, as follows: First, prepare training data. The source of training data can be collected from open source code repositories (such as GitHub) and enterprise code repositories. The annotation types include but are not limited to: Code smell types: overly long functions, duplicate code, redundant conditional judgments, tightly coupled classes, etc.; Severity level: divided into high, medium, and low levels according to the degree of impact on code quality (for example, "duplicate code" is marked as "high" if it exists across modules).

[0065] Secondly, after obtaining the preliminary training data, the preliminary training data can be preprocessed. Data preprocessing can be to standardize the code (such as unified indentation, deleting comments); parse the code into an abstract syntax tree (AST) and extract structural features (such as function call chains, class inheritance relationships); convert it into a model input format (such as token sequence, graph structure or vectorized representation).

[0066] In an embodiment of the present invention, the code optimization detection model may adopt a Transformer-based neural network or a graph neural network (GNN) to adapt to the serialization and structured characteristics of the code.

[0067] Finally, the code optimization detection model is trained by inputting code snippets and their ASTs from the training data. This allows the model to learn the mapping between code patterns and bad smell labels. A cross-entropy loss is used as the loss function, and the optimization goal is to minimize the bad smell classification error. Generalization is enhanced through transfer learning, for example, by fine-tuning the pre-trained CodeBERT. The model's performance (such as precision and recall) is evaluated using the test set. The training data distribution is adjusted to target bad smell types with high false positive rates (such as "over-annotation"), resulting in a trained code optimization detection model.

[0068] Split the current code data of the software to be refactored into independent units by module or function. For example, for Java projects, split by class (.java file); for Python scripts, split by function or class method. Generate an AST for each code unit, extracting node type (such as function definition, loop statement), code complexity (such as cyclomatic complexity, number of dependencies), and context information (such as call relationships). Input the code unit into the trained code optimization detection model, and output the bad smell type and confidence level. For example: The cyclomatic complexity of the generateReport() function was detected to be 15 (threshold ≤ 10), and it was judged as an "excessively long function" with a confidence level of 92%. The DataParser and DataValidator classes referenced each other, and were judged as a "circular dependency" with a confidence level of 85%.

[0069] Post-processing results can be performed by filtering by confidence, retaining only detection results with a confidence level above a set threshold (e.g., 70%) to prevent misjudgments from interfering with policy generation. Contextual analysis aggregates cross-module smells (e.g., duplicated code in multiple locations) to generate global optimization recommendations.

[0070] The generation of the first reconstruction strategy can be based on a strategy rule library, which can predefine the mapping relationship between bad smell types and reconstruction operations, for example: Bad smell type refactoring strategy Split long functions into multiple sub-functions to extract common logic Abstract duplicate code into public functions or utility classes Tightly coupled classes introduce interfaces or decouple through intermediary classes Redundant conditional judgment merges conditional branches and reconstructs using strategy mode Based on the above mapping relationship, the corresponding refactoring operation can be selected from the rule library according to the type of bad smell detected. Furthermore, the policy description can be refined in combination with the code context. For example: if "duplicate code" is detected in module A and module B, a policy is generated: "Merge validateUser() in module A and checkUser() in module B into a common method of the tool class UserUtils." When multiple bad smells are detected, priority sorting can also be performed, such as sorting strategies according to the severity level of the bad smell (such as high, medium, and low) to ensure that key issues are dealt with first.

[0071] This invention combines pre-trained models with AST parsing to achieve fine-grained identification of code structural defects, avoiding the coverage gaps of traditional rule engines. Furthermore, based on a rule base and context-aware automatic adjustment mechanism, it generates actionable refactoring instructions rather than general optimization suggestions. Furthermore, confidence filtering and severity grading ensure the reliability and rationality of the strategy.

[0072] Optionally, the business expectation extraction of the user data to extract the user's business expectations for the software to be reconstructed includes: performing semantic extraction on the user data to obtain multiple user semantics; classifying the multiple user semantics to determine the user semantics related to the software to be reconstructed; and generating the user's business expectations for the software to be reconstructed from the user semantics related to the software to be reconstructed.

[0073] In an embodiment of the present invention, a scenario is considered in which refactoring requirements are mined from the dynamic behavior of users using software and mapped to code optimization goals, and business expectations are extracted and a second refactoring strategy is generated.

[0074] User data refers to user interaction data while using the software to be refactored. It can include unstructured text data, semi-structured log data, and structured performance data. Unstructured text data includes user feedback (e.g., "Export is too slow"), work order descriptions, and chat logs. Semi-structured log data includes operation logs (e.g., {timestamp: 2023-10-01, action: "export_data", duration: 8s}) and API call records. Structured performance data includes CPU / memory usage and transaction processing time (e.g., {"api": " / submit_order", "avg_latency": "2.3s"}).

[0075] Pre-trained natural language processing models (such as BERT and RoBERTa) can be used to perform semantic embedding on unstructured text, extracting key entities and intents. For example, input: "Exporting orders takes too long, affecting work efficiency" → extract the entity "export order" and the intent "reduce time consumption." Named entity recognition (NER) models can be used to label business objects (such as "order" and "payment") and operation types (such as "export" and "optimize").

[0076] It can perform regular expression matching and pattern recognition on semi-structured logs to extract key fields (such as operation type export_data and duration of 8 seconds).

[0077] Build a timing analysis model (such as sliding window statistics) for structured performance data to identify anomalies (such as a sudden 50% increase in latency in the / submit_order interface).

[0078] Specifically, the classification model can be trained to label the sample library of user semantic types. The sample library is shown in the following table:

[0079] The classification model can adopt an intent classification model (such as one based on FastText or Transformer) and train the intent classification model based on the above sample library so that the intent classification model can learn the semantic mapping from text to requirements.

[0080] Text semantics can be directly input into the classification model; log and performance data can be converted into descriptive text (such as "export_data operation takes an average of 8 seconds") and then input into the model classification.

[0081] The classification model outputs a category and confidence level for each user semantic message (e.g., "Performance requirement - response speed," with a confidence level of 88%). "Irrelevant semantics" are filtered out (discarded if the confidence level exceeds 90%). Conversational analysis is performed on multiple semantic messages from the same user (e.g., after user feedback about "exporting slowly," add "especially for large files") and merge them into a complete requirement: "Optimize the performance of large file export."

[0082] The mapping of requirements to goals mentioned above primarily involves performance requirements mapping, functional requirements mapping, and stability requirements mapping. For example, a performance requirements mapping might look like this: Input: "Exporting orders takes too long" + log data: "The export_order interface takes an average of 8 seconds" → Generate a quantitative goal: "Reduce order export time to less than 3 seconds." For example, a functional requirements mapping might look like this: Input: "We want to support PDF export" → Generate a functional goal: "Add a generatePDF() method to ExportService." For example, a stability requirements mapping might look like this: Input: "Order submissions frequently time out" + API log: "Timeout rate 15%" → Generate a goal: "Optimize the timeout error rate of the order submission interface to below 2%."

[0083] The business expects that the structured representation can be in a machine-understandable format, such as JSON.

[0084] Furthermore, the business expectation text (e.g., "reduce order export time") is encoded into a first multimodal feature vector (semantic vector); the relevant code (e.g., ExportService.java) is parsed into an AST and a second multimodal feature vector (code structure vector) is generated. Calculate vector similarity to determine code locations that need to be refactored (such as the loop query logic in the exportOrders() function).

[0085] The second reconstruction strategy generation example is as follows: Extract the business expectation: "Optimize the performance of exportOrders()" → Second refactoring strategy: "Change row-by-row queries to batch queries and add a caching mechanism."

[0086] This invention extracts requirements from actual user behavior (operation logs, performance indicators), avoiding the lag of traditional demand research and the subjectivity of business managers; combines multi-dimensional analysis of text, logs, and code structure to improve the accuracy and operability of business expectation extraction; uses vectorized alignment technology to accurately associate requirements described in natural language with specific code units, ensuring the targeted nature of reconstruction strategies; and can continuously monitor user interaction data and dynamically update business expectations to adapt to changes in terminal requirements during software iterations.

[0087] Optionally, determining a second reconstruction strategy in the current code data based on the business expectation includes: parsing the business expectation and the current code data into multimodal feature vectors respectively to obtain a first multimodal feature vector and a second multimodal feature vector, the first multimodal feature vector corresponding to the business expectation, and the second multimodal feature vector corresponding to the current code data; determining a second reconstruction strategy in the current code data based on the vector similarity between the first multimodal feature vector and the second multimodal feature vector.

[0088] In an embodiment of the present invention, a scenario is considered in which the user business expectations described in natural language are accurately associated with the code module to be refactored and a targeted refactoring strategy is generated, so as to determine a second refactoring strategy in the current code data based on the business expectations.

[0089] Specifically, business expectations can be vectorized. First, the target description can be extracted from the generated business expectations, such as "optimizing order export speed," and supplemented with contextual information, such as associated code modules and performance indicators. Second, pre-trained natural language encoding models (such as BERT and Sentence-BERT) can be used to convert text into semantic vectors: input text → output 768-dimensional semantic vector (first multimodal feature vector). If the business expectation includes quantitative indicators (such as "takes 8 seconds → 3 seconds"), the numerical features can be spliced ​​into the semantic vector to form a mixed feature representation. The numerical features are spliced ​​in the order of the semantic types corresponding to the numerical values. The semantic type order is a preset order, for example, it can be sorted by the priority of the semantic type.

[0090] Then, the current code data (such as OrderExportService.java) is parsed into an AST (abstract syntax tree) to extract the code structure features: function call relationship, loop / conditional branch structure, and class dependency graph.

[0091] Graph embedding generation can be used, specifically using a graph neural network (GNN) to encode the AST and generate a code structure vector. Specifically, AST nodes (such as function definitions and variable declarations) can be mapped to initial embedding vectors. Neighboring node information is aggregated through the GNN's message passing mechanism to generate a context-aware embedding for each node. All graph nodes are pooled (e.g., mean pooling) to output the global structure vector of the code module (i.e., the second multimodal feature vector).

[0092] After obtaining the first multimodal feature vector and the second multimodal feature vector, the cosine similarity between the first multimodal feature vector (business expectation) and the second multimodal feature vector (code module) is calculated, and a similarity threshold (such as 0.7) is set to screen out code modules with high matching degrees.

[0093] In one possible embodiment, if the business expectation contains specific keywords (such as "performance" and "concurrency"), performance-related nodes in the code feature vector (such as loops and database calls) are given higher weights to improve matching accuracy.

[0094] Identify the hot spots in code that require refactoring based on similarity sorting. For example, if the business expectation "optimize order export speed" has a similarity of 0.85 with the OrderExportService.export() function, this function is considered to require refactoring first.

[0095] Match the predefined refactoring operation library according to the expected business type. The predefined refactoring operation library is shown in the following table:

[0096] This invention breaks through the semantic gap between natural language requirements and code logic, and realizes the precise mapping of business goals to code modules; adaptively adjusts feature matching weights according to business expectation types to improve the scenario adaptability of strategy generation; ensures the feasibility of the implementation of the generated strategy through static analysis and dependency checking, and reduces the cost of manual correction; integrates multimodal information of text semantics, quantitative indicators and code structure to enhance the expression ability of complex requirements.

[0097] Optionally, the target reconstruction strategy of the current code data is determined based on the first reconstruction strategy and the second reconstruction strategy, including: determining the common part between the first reconstruction strategy and the second reconstruction strategy, and determining a first difference part that is different from the second reconstruction strategy in the first reconstruction strategy, and determining a second difference part that is different from the first reconstruction strategy in the second reconstruction strategy; performing a global check on the first difference part and the second difference part to obtain a target difference part that succeeds in the global check; and determining the target difference part and the common part as the target reconstruction strategy for the current code data.

[0098] In an embodiment of the present invention, the potential contradiction between technical optimization goals and business needs is considered, and a scenario of a high-availability reconstruction solution is generated. Based on the first reconstruction strategy and the second reconstruction strategy, a target reconstruction strategy for the current code data is determined.

[0099] Specifically, the first refactoring strategy is the result of code smell detection, such as "split function A" and "remove redundant dependency B"; the second refactoring strategy is the result of multimodal matching of user data, such as "optimize the query logic of function A" and "add a caching mechanism to function C".

[0100] Convert the policy text for the first and second refactoring strategies into structured operational instructions. For example: the first strategy: "Split function A into A1 and A2"; the second strategy: "Add batch query to function A." Identify strategies with overlapping operational objects, for example, if both strategies involve "function A" → the common part is "Refactor function A." The first difference (proposed only by the first strategy): "Remove redundant dependency B"; the second difference (proposed only by the second strategy): "Add a caching mechanism to function C."

[0101] Detect technical feasibility conflicts. For example, if the second refactoring strategy requires "introducing caching," but the code module has no caching framework dependencies, the code dependency tree will be checked to verify support for the target technology stack. Detect goal priority conflicts. For example, if the first refactoring strategy optimizes readability vs. the second refactoring strategy optimizes performance, arbitration will be conducted based on business priority (such as a user-specified "performance first"). Detect logical contradictions and conflicts. For example, if the first refactoring strategy splits a function vs. the second refactoring strategy requires maintaining function integrity, the code context will be analyzed to determine whether the split is allowed.

[0102] The above-mentioned verification can include static verification and dynamic verification. Among them, static verification uses code dependency analysis tools (such as Dependabot) to check the technical feasibility of the difference parts. For example: if the policy is "introducing Redis cache" but the Redis client library is not included in the project, it will be marked as "needing to add new dependencies"; if the new dependency conflicts with the existing version, a warning will be generated and a manual review will be triggered. Dynamic verification can build a sandbox environment to simulate the execution of the difference parts. For example: for the policy "changing the serial loop of function A to parallel", run unit tests to verify thread safety; if the test coverage is insufficient (such as <80%), it will be marked as "needing to add test cases."

[0103] In one possible embodiment, a classification model can be trained based on historical refactoring data. Inputs include conflict type, code context, and user priority, and the model outputs a recommended strategy. For example, given the input "performance optimization vs. readability optimization," the model recommends "performance optimization" with a 75% probability. Based on the model's recommendations, the strategy with the highest probability is selected and included in the final refactoring strategy.

[0104] After verification is complete, if the verification passes, it is marked as a target difference and allowed to be included in the final strategy. If the verification fails, an alternative solution is generated or manual intervention is triggered. For example, the original strategy is: "Introduce Redis cache" → the alternative solution is: "Use in-memory cache Guava Cache".

[0105] After obtaining the target differences and common parts, the common parts can be directly merged (deduplicated): Deduplication of overlapping operations and optimization of the logical order. For example: Common part: "Restructure function A" → Merged instructions: "First split function A into A1 / A2, then optimize A1's query logic." The differences can be preferentially integrated, and the target differences can be merged after sorting by priority. For example: First difference part (passed): "Remove redundant dependency B"; Second difference part (passed): "Add a caching mechanism for function C"; Merged strategies are arranged in execution order: "Remove B first, then add caching."

[0106] After the target refactoring strategy of the current code data is determined, a machine-executable refactoring plan can be generated according to the target refactoring strategy, such as code files in JSON, YAML and other formats.

[0107] This invention verifies policy conflicts from multiple perspectives, such as code feasibility, target priority, and logical consistency, to avoid the limitations of a single rule; predicts policy risks through simulated execution, reducing runtime errors introduced by refactoring; combines rule engines with machine learning to balance automation efficiency and decision-making accuracy; and generates structured refactoring plans, clarifies the execution order and constraints, and improves implementation transparency.

[0108] Optionally, generating the reconstructed code data corresponding to the target reconstructing strategy based on the large language model includes: obtaining the AST abstract syntax tree corresponding to the current code data; constructing the input file of the large language model based on the target reconstructing strategy and the AST abstract syntax tree corresponding to the current code data; inputting the input file into the large language model to generate the reconstructed code data corresponding to the target reconstructing strategy.

[0109] In this embodiment of the present invention, code parsing tools (such as the AST module) can be used to input current code data into a parser to generate a complete AST structure. The generated AST nodes include class declarations, method declarations, method invocations, and more. After obtaining the AST abstract syntax tree, nodes in the AST that require refactoring (such as functions, loops, conditional branches, etc.) are marked based on the target refactoring strategy.

[0110] The AST abstract syntax tree is serialized, such as in XML or JSON format, and graph embedding technology is used to convert the AST into a feature vector for numerical input of large language models.

[0111] In one possible embodiment, the policy scope can be explicitly marked in the input file. For example, add an indication label in the AST node, such as <refactortarget strategy="split_method" / >Label, indicating that the label is used to instruct the large language model to apply a strategy for this node.

[0112] The above-mentioned large language model can be a general large language model (such as GPT-4), which can be fine-tuned for instructions. It can also be a code-specific large language model (such as Codex, Code Llama, StarCoder, etc.), or a general model (such as GPT-4) for instruction fine-tuning.

[0113] The above input file can be constructed according to the prompt template, which is as follows: "You are a code refactoring assistant. Please generate code based on the following AST structure and refactoring strategy: - AST structure: {ast_xml} - Refactoring strategy: {strategy} - Constraints: {constraints} The generated code must conform to the {language} syntax specification and retain the external interface of the original code. " The large language model parses the AST, policies, and constraints in the input file and selects a generation mode based on the AST node type (e.g., loop statement, function definition). For example, for a node marked "Split Function," it generates multiple sub-functions and adjusts the calling logic. Based on the AST, policies, and constraints in the input file, the large language model generates the corresponding refactored code data.

[0114] After obtaining the refactored code data, you can use a compiler or static analysis tool (such as Checkstyle or ESLint) to check its validity. You can also use a diff tool (such as Git Diff) to compare the old and new code to ensure that only the target nodes have been modified, avoiding accidental changes. You can also automatically generate refactoring annotations based on the target refactoring strategy and update API documentation (such as Swagger descriptions) to make the final code clearer.

[0115] This invention uses AST to accurately convey code structure information, avoiding logical errors caused by lost context in traditional code generation and improving code generation accuracy. Explicitly encoding the target refactoring strategy in the input file constrains the generation direction of the large language model and prevents irrelevant code modifications. Combining the structured AST with natural language strategy descriptions enhances the model's understanding of complex refactoring tasks, further improving code generation accuracy.

[0116] like Figure 2 As shown, an embodiment of the present invention provides a software reconstruction device based on artificial intelligence, and the software reconstruction device based on artificial intelligence includes: An acquisition module 201 is configured to acquire current code data of the software to be reconstructed and user data of the software to be reconstructed, wherein the user data is interaction data of the user during use of the software to be reconstructed; A processing module 202 is configured to determine a target reconstruction strategy for the current code data based on the current code data and the user data; A generating module 203 is used to generate reconstructed code data corresponding to the target reconstructing strategy based on the large language model; The reconstructing module 204 is configured to reconstruct the code of the software to be reconstructed based on the reconstructed code data, and obtain the target software after the reconstruction is completed.

[0117] Optionally, the processing module 202 is further configured to: Performing code optimization detection on the current code data, and determining a first refactoring strategy that can be optimized in the current code data; Performing business expectation extraction on the user data to extract the user's business expectations for the software to be reconstructed, and determining a second reconstructing strategy in the current code data based on the business expectations; Based on the first reconstruction strategy and the second reconstruction strategy, a target reconstruction strategy for the current code data is determined.

[0118] Optionally, the processing module 202 is further configured to: Inputting the current code data into a pre-trained code optimization detection model to perform code optimization detection, and outputting the code smell of the current code data; Based on the code smell, a first optimizable refactoring strategy is determined in the current code data.

[0119] Optionally, the processing module 202 is further configured to: Performing semantic extraction on the user data to obtain multiple user semantics; Classify the plurality of user semantics to determine the user semantics related to the software to be reconstructed; The user semantics related to the software to be reconstructed are used to generate the user's business expectations for the software to be reconstructed.

[0120] Optionally, the processing module 202 is further configured to: Parsing the service expectation and the current code data into multimodal feature vectors respectively to obtain a first multimodal feature vector and a second multimodal feature vector, wherein the first multimodal feature vector corresponds to the service expectation, and the second multimodal feature vector corresponds to the current code data; Based on the vector similarity between the first multimodal feature vector and the second multimodal feature vector, a second reconstruction strategy is determined in the current code data.

[0121] Optionally, the processing module 202 is further configured to: Determining a common portion between the first reconstruction strategy and the second reconstruction strategy, determining a first difference portion between the first reconstruction strategy and the second reconstruction strategy, and determining a second difference portion between the second reconstruction strategy and the first reconstruction strategy; Performing a global verification on the first difference portion and the second difference portion to obtain a target difference portion that succeeds the global verification; The target difference portion and the common portion are determined as a target reconstruction strategy for the current code data.

[0122] Optionally, the generating module 203 is further configured to: Get the AST abstract syntax tree corresponding to the current code data; Constructing an input file of the large language model based on the target reconstruction strategy and the AST abstract syntax tree corresponding to the current code data; The input file is input into the large language model to generate reconstructed code data corresponding to the target reconstructing strategy.

[0123] like Figure 3 As shown, an embodiment of the present invention further provides an electronic device, including a processor, which can execute any of the above-mentioned artificial intelligence-based software reconstruction methods.

[0124] Specifically, the system includes a processor 301, a memory 302, and a computer program for executing an artificial intelligence-based software reconstruction method stored in the memory 302 and capable of running on the processor 301, wherein: The processor 301 runs the computer program of the artificial intelligence-based software reconstruction method stored in the memory 302 and performs the following steps: Acquire current code data of the software to be reconstructed and user data of the software to be reconstructed, wherein the user data is interaction data of the user during use of the software to be reconstructed; Determining a target reconstruction strategy for the current code data based on the current code data and the user data; Based on the large language model, generating reconstructed code data corresponding to the target reconstructing strategy; Based on the reconstructed code data, the software to be reconstructed is reconstructed, and the target software is obtained after the reconstruction is completed.

[0125] Optionally, the determining, by the processor 301, of a target reconstruction strategy for the current code data based on the current code data and the user data includes: Performing code optimization detection on the current code data, and determining a first refactoring strategy that can be optimized in the current code data; Performing business expectation extraction on the user data to extract the user's business expectations for the software to be reconstructed, and determining a second reconstructing strategy in the current code data based on the business expectations; Based on the first reconstruction strategy and the second reconstruction strategy, a target reconstruction strategy for the current code data is determined.

[0126] Optionally, the processor 301 performs code optimization detection on the current code data to determine an optimizable first reconstruction strategy in the current code data, including: Inputting the current code data into a pre-trained code optimization detection model to perform code optimization detection, and outputting the code smell of the current code data; Based on the code smell, a first optimizable refactoring strategy is determined in the current code data.

[0127] Optionally, the processor 301 extracts business expectation from the user data to extract the user's business expectation for the software to be reconstructed, including: Performing semantic extraction on the user data to obtain multiple user semantics; Classify the plurality of user semantics to determine the user semantics related to the software to be reconstructed; The user semantics related to the software to be reconstructed are used to generate the user's business expectations for the software to be reconstructed.

[0128] Optionally, the determining of a second reconstruction strategy in the current code data based on the business expectation performed by the processor 301 includes: Parsing the service expectation and the current code data into multimodal feature vectors respectively to obtain a first multimodal feature vector and a second multimodal feature vector, wherein the first multimodal feature vector corresponds to the service expectation, and the second multimodal feature vector corresponds to the current code data; Based on the vector similarity between the first multimodal feature vector and the second multimodal feature vector, a second reconstruction strategy is determined in the current code data.

[0129] Optionally, the determining of the target reconstruction strategy for the current code data based on the first reconstruction strategy and the second reconstruction strategy performed by the processor 301 includes: Determining a common portion between the first reconstruction strategy and the second reconstruction strategy, determining a first difference portion between the first reconstruction strategy and the second reconstruction strategy, and determining a second difference portion between the second reconstruction strategy and the first reconstruction strategy; Performing a global verification on the first difference portion and the second difference portion to obtain a target difference portion that succeeds the global verification; The target difference portion and the common portion are determined as a target reconstruction strategy for the current code data.

[0130] Optionally, the processor 301 generates the reconstructed code data corresponding to the target reconstructing strategy based on the large language model, including: Get the AST abstract syntax tree corresponding to the current code data; Constructing an input file of the large language model based on the target reconstruction strategy and the AST abstract syntax tree corresponding to the current code data; The input file is input into the large language model to generate reconstructed code data corresponding to the target reconstructing strategy.

[0131] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the computer program implements the various processes of the artificial intelligence-based software reconstruction method provided in the embodiment of the present invention and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0132] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0133] The above disclosure is merely a preferred embodiment of the present invention and certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A software reconstruction method based on artificial intelligence, characterized in that: The method comprises the following steps: Acquire current code data of the software to be reconstructed and user data of the software to be reconstructed, wherein the user data is interaction data of the user during use of the software to be reconstructed; Determining a target reconstruction strategy for the current code data based on the current code data and the user data; Based on the large language model, generating reconstructed code data corresponding to the target reconstructing strategy; Based on the reconstructed code data, the software to be reconstructed is reconstructed, and the target software is obtained after the reconstruction is completed.

2. The software reconstruction method based on artificial intelligence according to claim 1, characterized in that: The determining, based on the current code data and the user data, a target reconstruction strategy for the current code data includes: Performing code optimization detection on the current code data, and determining a first refactoring strategy that can be optimized in the current code data; Performing business expectation extraction on the user data to extract the user's business expectations for the software to be reconstructed, and determining a second reconstructing strategy in the current code data based on the business expectations; Based on the first reconstruction strategy and the second reconstruction strategy, a target reconstruction strategy for the current code data is determined.

3. The software reconstruction method based on artificial intelligence according to claim 2, characterized in that: The performing code optimization detection on the current code data and determining an optimizable first reconstruction strategy in the current code data includes: Inputting the current code data into a pre-trained code optimization detection model to perform code optimization detection, and outputting the code smell of the current code data; Based on the code smell, a first optimizable refactoring strategy is determined in the current code data.

4. The software reconstruction method based on artificial intelligence according to claim 2, characterized in that: The extracting of business expectations from the user data to extract the user's business expectations for the software to be reconstructed includes: Performing semantic extraction on the user data to obtain multiple user semantics; Classify the plurality of user semantics to determine the user semantics related to the software to be reconstructed; The user semantics related to the software to be reconstructed are used to generate the user's business expectations for the software to be reconstructed.

5. The software reconstruction method based on artificial intelligence according to claim 4, characterized in that: Determining a second reconstruction strategy in the current code data based on the business expectation includes: Parsing the service expectation and the current code data into multimodal feature vectors respectively to obtain a first multimodal feature vector and a second multimodal feature vector, wherein the first multimodal feature vector corresponds to the service expectation, and the second multimodal feature vector corresponds to the current code data; Based on the vector similarity between the first multimodal feature vector and the second multimodal feature vector, a second reconstruction strategy is determined in the current code data.

6. The artificial intelligence-based software reconstruction method according to any one of claims 2 to 5, characterized in that: The determining of a target reconstruction strategy for the current code data based on the first reconstruction strategy and the second reconstruction strategy includes: Determining a common portion between the first reconstruction strategy and the second reconstruction strategy, determining a first difference portion between the first reconstruction strategy and the second reconstruction strategy, and determining a second difference portion between the second reconstruction strategy and the first reconstruction strategy; Performing a global verification on the first difference portion and the second difference portion to obtain a target difference portion that succeeds the global verification; The target difference portion and the common portion are determined as a target reconstruction strategy for the current code data.

7. The artificial intelligence-based software reconstruction method according to any one of claims 1 to 5, characterized in that: The generating, based on the large language model, reconstructed code data corresponding to the target reconstructing strategy includes: Get the AST abstract syntax tree corresponding to the current code data; Constructing an input file of the large language model based on the target reconstruction strategy and the AST abstract syntax tree corresponding to the current code data; The input file is input into the large language model to generate reconstructed code data corresponding to the target reconstructing strategy.

8. A software reconstruction device based on artificial intelligence, characterized in that: The software reconstruction device based on artificial intelligence includes: An acquisition module, configured to acquire current code data of the software to be reconstructed and user data of the software to be reconstructed, wherein the user data is interaction data of the user during use of the software to be reconstructed; a processing module, configured to determine a target reconstruction strategy for the current code data based on the current code data and the user data; A generation module, configured to generate reconstructed code data corresponding to the target reconstructing strategy based on the large language model; The reconstructing module is used to reconstruct the code of the software to be reconstructed based on the reconstructed code data, and obtain the target software after the reconstruction is completed.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the software reconstruction method based on artificial intelligence as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the artificial intelligence-based software reconstruction method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Deep learning code-free application layout optimization method and system based on user feedback

    CN117193772A

  • Code review method and device, electronic equipment and medium

    CN117648931A

  • Intelligent code optimization and reconstruction system based on large model

    CN119201214A

  • Code modification strategy determination method and device, equipment, medium and program product

    CN119513709A

  • Interactive And Dynamic Search Based Approach To Software Refactoring Recommendations

    US20190317760A1