Warehouse level code problem solving system based on large language model

Through a warehouse-level code problem-solving system based on large language models, a warehouse-level code diagram and dynamic evolution knowledge graph are built, and combined with context retrieval and generation modules, the problems of low code repair efficiency and high error rate in the existing technology are solved, and efficient and accurate code repair and optimization are achieved.

CN119576384AInactive Publication Date: 2025-03-07北京开放传神科技有限公司

Patent Information

Application Number
CN202510138365.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-08
Publication Date
2025-03-07
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When facing complex and changing code bases, existing code repair technology has unsatisfactory repair results, low efficiency and high error rate, and lacks flexibility and intelligence, so it cannot be adjusted dynamically.

Method used

The warehouse-level code problem-solving system based on the large language model is adopted. The warehouse-level code graph is built through the warehouse analysis module, the dynamic evolution knowledge graph module combines historical problem-solving data to build a knowledge graph, the context search module dynamically searches and solves the problem-solving strategy, the generation module uses the large language model to generate code patches, and optimizes the problem-solving strategy through the feedback module.

Benefits of technology

It significantly improves the efficiency and quality of code patch generation, completion and review, and can accurately capture complex cross-module and cross-file dependencies in the code, reduce errors, optimize generated fix patches, improve development efficiency and reduce development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576384A_ABST
    Figure CN119576384A_ABST
Patent Text Reader

Abstract

The invention discloses a warehouse level code problem solving system based on a large language model, and relates to the technical field of software engineering, a source code file is extracted from a code warehouse, a static analysis tool is utilized to analyze codes, a warehouse level code graph is constructed, and then code entities and dependency relationships thereof are analyzed; based on the warehouse-level code graph, combining historical problem solving data, and constructing a dynamic evolution knowledge graph through continuous learning; through a context retrieval module, according to the context information of the current problem, dynamically retrieving related solution strategies and generating corresponding code patches, complementing or reviewing suggestions; the validity of the generated patch is verified through static analysis, unit testing and integration testing, and a problem solving strategy is optimized according to feedback of a developer. The problem solving efficiency and accuracy can be improved, the development cost is reduced, the solving process is gradually optimized through an intelligent feedback mechanism, a closed-loop feedback mechanism is formed, and therefore the increasingly complex software development requirements are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software engineering, and in particular to a warehouse-level code problem solving system based on a large language model. Background Art

[0002] In the modern software development process, as the scale of projects continues to expand, the complexity of the code is also increasing significantly. Developers are faced with the problem of how to effectively manage and repair large amounts of code. Existing code repair techniques usually rely on static analysis tools, manual debugging, or developer experience. Although they can find some problems in the code, they often lack flexibility and intelligence and cannot make dynamic adjustments based on the evolution of the code and the context of the actual problem. Therefore, in a complex and ever-changing code base, the repair effect of existing technologies is often unsatisfactory, the repair process is inefficient, and there is a high error rate.

[0003] Currently, many code repair tools perform preliminary error detection through static analysis, such as detecting memory leaks, null pointer references, etc., or generating code patches. However, these tools usually have problems such as low generation efficiency and inability to fully capture complex dependencies in the code. For example, when performing code repair, SpecRover must rely on multiple iterations and regression testing to ensure the accuracy of the repair results, which greatly increases development costs and maintenance burdens. When dealing with large-scale code repositories, tools like CodePlan rely too much on static analysis methods, resulting in a very slow repair generation process and failure to meet the needs of developers in a timely manner.

[0004] In addition, most current tools separate the patch generation and verification processes, which requires developers to repeatedly adjust and optimize patches when repairs fail, increasing development time and debugging costs. For example, DRCodePilot needs to rely on a feedback mechanism to make multiple rounds of adjustments to the generated patches, but due to the long feedback loop, the overall repair efficiency is low. Moreover, existing automated code review tools mostly only analyze code at the file level, lack a global perspective from the repository level, and have difficulty effectively handling cross-module dependencies, resulting in the review suggestions being unable to fully cover the potential impact of code changes.

[0005] Therefore, the present invention proposes a warehouse-level code problem solving system based on a large language model. Summary of the invention

[0006] The purpose of the present invention is to solve the problems in the background technology and to propose a warehouse-level code problem solving system based on a large language model.

[0007] In order to achieve the above object, the present invention adopts the following technical solutions: A repository-level code problem solving system based on a large language model, including: Warehouse parsing module: extracts source code files from the code warehouse and parses the source code files through static analysis tools, including extracting code entities and determine dependencies between code entities ; The code entities include functions, classes, variables and constants, and the dependencies between the code entities include function calls, inheritance relationships and variable dependencies; based on the code entities and their dependencies, a warehouse-level code graph G=(E,R) is constructed, and the warehouse-level code graph forms a graph structure by modeling each code entity as a node and modeling the dependencies between nodes as edges, and the graph structure is used to represent the code entities and their dependencies; Dynamic evolution knowledge graph module: based on the warehouse-level code graph G, combined with historical problem solving data The dependency R with the current code is used to build a dynamic evolution knowledge graph DEKG=(E',R') through continuous learning of the problem-solving process; the dynamic evolution knowledge graph contains the evolution information of historical problem-solving patterns, problem-solving strategies and problem-solving results; the evolution information is used to update the historical problem-solving patterns and their corresponding solution strategies, thereby optimizing the processing process of subsequent problems to adapt to problems of different complexity and types; Contextual retrieval module: Based on the contextual information of the current problem, combined with the historical problem-solving patterns and problem-solving strategies in the dynamically evolving knowledge graph DEKG, dynamically retrieve strategies related to the current problem; the strategies include repair strategies, completion strategies, optimization strategies, and review strategies. The retrieval adjusts the strategies through the evolutionary information in the graph to adapt to different types of tasks and their complexity; Generation module: Generates a problem-solving strategy based on the context information of the current problem and the historical problem-solving mode, combined with the strategy generated in the context retrieval module; the problem-solving strategy generates a corresponding code patch through a large language model, and the code patch includes a repair patch, code completion or review suggestion; the patch is verified for validity, and the verification method includes static analysis, unit testing and integration testing to ensure the correctness and validity of the patch; Feedback module: obtain feedback information based on the verification results of the generated patches and the feedback from developers, analyze the feedback information and update the dynamic evolution knowledge graph DEKG, adjust the historical problem solving mode and problem solving strategy; the feedback module is used to gradually optimize the problem solving process and form a closed-loop feedback mechanism to improve the efficiency and accuracy of subsequent problem solving.

[0008] Preferably, the repository parsing module includes: extracting source code files from the code repository , where each source code file Represents a source code file; for source code files Perform static analysis to identify the code entities and generate the corresponding code entity set through the syntax tree , where each node Represents a specific code entity; identifies dependencies between code entities and generates dependency sets , where each edge Representation Node and nodes Dependencies between nodes; based on node sets and edge sets , build a repository-level code graph , where each code entity is represented by a node and the dependencies between code entities are represented by edges.

[0009] Preferably, the dynamically evolving knowledge graph module includes: , solving data from historical problems Extract the patterns of each problem-solving process , each mode Including problem type, solution strategy, and execution results; dynamically adjust the historical problem solving mode based on the context information of the current problem, and update the historical mode through the following steps: compare the context of the current problem with the problem type in the historical problem mode, and identify the most matching historical mode ; If the current problem does not completely match the historical pattern, modify the current problem through the existing solution strategy and generate a new solution , update the historical question pattern set to ; Based on historical problem solving model Feedback from developers , adjust the set of problem-solving strategies The adjustment method is: optimize the relevant strategies for the invalid patches or incomplete solutions mentioned in the feedback; fine-tune the strategy parameters to make the strategy more suitable for solving the current problem.

[0010] Preferably, the context retrieval module includes: obtaining the context information of the current problem, including the error prompt, code snippet, and call stack data of the current code, by analyzing the problem description, error report, or log information of the current code; retrieving relevant historical problem solving patterns and strategies from the dynamically evolving knowledge graph based on the context information of the current problem, and the retrieval process includes: searching for the historical problem pattern most relevant to the current problem type through the nodes and edges in the graph; ; Based on the solution strategy in the historical model , dynamically adjust and generate corresponding solutions , and provide it to the subsequent generation module.

[0011] Preferably, the generation module comprises: according to the strategy obtained from the context retrieval module and the context information of the current problem, combined with the historical problem-solving model P, to generate a preliminary solution , the solution The generation process is achieved through the following steps: using a large language model based on contextual information and Generate code patches , Patches include fix patches, code completion, and review suggestions.

[0012] Preferably, the feedback module includes: analyzing developer feedback and patch verification results: based on the developer's feedback on the patch and patch verification results , analyze the effectiveness of the current patch; based on the feedback information and verification results, update the historical problem solving model P and solution strategy S.

[0013] Preferably, the historical problem solving model P includes multiple problem solving paths, and the paths are recorded according to the strategy execution process of each problem solving. Each path includes the type of problem, solution strategy, execution result and developer feedback. The path will continue to evolve and update with the introduction of new problems.

[0014] Preferably, the use of a large language model is based on context information and Generated patches Verification is performed, and the verification steps include: verifying the grammatical correctness of the patch through static analysis tools; verifying the execution effect of the patch through unit testing or integration testing to ensure that it correctly solves the current problem and does not introduce new problems; patch verification results Indicates the execution results of the patch in different test scenarios.

[0015] Preferably, the process of updating the historical problem solving mode P and the solution strategy S includes: if the developer feedbacks that the patch is invalid or needs to be redesigned, modify the historical problem solving mode , so that it can better adapt to the type of current problem; optimize the problem-solving strategy S to make it more general or more targeted at specific types of problems.

[0016] Preferably, the dynamic adjustment generates a corresponding solution , and provide it to the subsequent generation module; dynamically adjust the retrieved strategy through the following steps: fine-tune the execution details of the solution strategy according to the characteristics of the current problem, including adjusting the specific repair position of the patch if the strategy is a repair strategy; and adjusting the optimization range if it is an optimization strategy.

[0017] The present invention has the following beneficial effects: 1. In the present invention, the efficiency and quality of code patch generation, completion and review are significantly improved through the combination of warehouse-level code graph construction, dynamically evolving knowledge graphs and intelligent problem-solving strategies. Through continuous learning and updating of historical problem-solving patterns, it is possible to accurately capture complex cross-module and cross-file dependencies in the code, reduce errors caused by incomplete context capture, and optimize the generated repair patches. Compared with the prior art, the present invention can more efficiently generate high-quality code repair solutions, reduce developers' manual debugging and multiple iterative operations, thereby greatly improving development efficiency and reducing development costs.

[0018] 2. In the present invention, by introducing a closed-loop feedback mechanism, the problem-solving strategy can be continuously optimized according to the developer's feedback and patch verification results, and an adaptive repair process can be achieved. The patch generation and verification process are no longer separated, but the two are combined to ensure the accuracy and effectiveness of the patch by dynamically adjusting the strategy. This intelligent repair process can significantly reduce the developer's maintenance costs and improve the accuracy and efficiency of problem solving. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is an architecture diagram of the warehouse-level code problem solving system based on a large language model proposed by the present invention; Figure 2 This is a diagram showing the patch verification result changes in the present invention. DETAILED DESCRIPTION

[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0021] like Figure 1-Figure 2 As shown, the warehouse-level code problem solving system based on a large language model proposed by the present invention.

[0022] In one embodiment, the repository parsing module extracts source code files from the code repository and parses these files through a Tree-Sitter or AST parser. The parsed data includes code entities and code dependencies, and a repository-level code graph is constructed based on these data. The code graph can model each code entity as a node in the graph, and the dependencies between code entities are connected by edges, thereby forming a code graph structure that can be used by subsequent modules.

[0023] The repository parsing module receives the following input data: source code file collection: parameters , where each Represents a source code file. Each file in is parsed by a Tree-Sitter or AST parser. Each file may contain multiple code entities, such as functions, classes, variables, etc., which are constructed as nodes in the repository-level code graph.

[0024] Step 1: Parse the source code file using Tree-Sitter or AST parser , parse the code, identify code entities such as variables, functions, and classes, and extract their attributes, such as variable types, function signatures, etc. It is also necessary to identify and extract the dependencies between code entities, such as function call relationships, variable reference relationships, etc.

[0025] Tree-Sitter or AST parser from each source code file Extract code entities from , each entity It could be: function : including function name, input parameters, return value type, etc.; variables : Including variable name, type, scope, etc.; class : Including class name, inheritance relationship, member variables, methods, etc.; Each code entity It will be marked as a node, and the node marking content includes: entity unique identifier; entity type, such as function, variable, class, etc.; entity attributes, such as function signature, variable type, class member method, etc.

[0026] Step 2: Extraction of code dependencies: Code dependencies represent the mutual dependencies between code entities, including: function call dependency: one function calls another function; variable reference dependency: a variable is referenced in another function or class; Class inheritance dependency: a class inherits from another class.

[0027] Use Tree-Sitter or AST parser to extract dependencies between code entities in the file. Each dependency Consists of a pair of entities, for example: =( , ), indicating an entity Depends on entity For example, if functionA calls functionB, (functionA, functionB) will be added to the dependency relationship.

[0028] Step 3: Based on the extracted dependency R, the code entity E and the dependency R are used as nodes and edges in the graph to construct a repository-level code graph G = (E, R), where: , where each Represents a code entity (such as a function, class, variable, etc.). , where each Represents dependencies between entities.

[0029] The operation steps are: As nodes in the graph; dependencies between code entities Connect the corresponding nodes as edges; combine the parsing results of multiple source code files to generate a warehouse-level code graph to ensure that the dependencies between different files can be correctly reflected in the graph.

[0030] Step 4: After generating the repository-level code graph, the system can further optimize the graph. If there is no actual dependency between some code entities, redundant nodes can be deleted. For recurring code patterns, they can be merged to improve the simplicity of the graph and processing efficiency.

[0031] The repository parsing module extracts code entities and their dependencies by performing static analysis on the source code files in the code repository, and builds a repository-level code graph based on this information. Each code entity is modeled as a node, and the dependencies between entities are modeled as edges, forming a complete graph structure.

[0032] In one embodiment, the dynamically evolving knowledge graph module builds a self-updating and continuously evolving knowledge graph based on the warehouse-level code graph and historical problem-solving data generated by the warehouse parsing module.

[0033] Warehouse-level code diagram: Input data G=(E,R), each node in G Both represent an entity in the code. It represents the dependencies between entities, helping to identify and analyze the propagation paths of problems between different code modules.

[0034] Historical problem solving data: Input data H={h1,h2,...,hn}, where: =(p,s,r), represents a historical problem solving record, including: p: Problem description node, indicating the type of the problem (such as memory leak, null pointer exception, etc.).

[0035] s: Solution strategy node, which indicates the solution to the problem (such as code fix, function addition, performance optimization, etc.).

[0036] r: Execution result node, indicating the execution effect of the strategy (such as "success", "failure", "partial success", etc.).

[0037] Usage: Each record in H reflects the description of a certain type of problem in the past, the solution adopted, and its actual implementation effect. This historical data provides a basis for the construction and optimization of the knowledge graph.

[0038] Graph construction: The dynamic evolution knowledge graph module extracts information from the input code graph G and historical problem solving data H to construct a problem solving graph DEKG=(E',R'), where: E′={ , ,..., , , ,..., }: Indicates code entity nodes and historical problem nodes.

[0039] R′={ , ,..., ,( , ),( , )}: Indicates the dependency relationship between code entity nodes, problem nodes, solution strategy nodes, and execution result nodes.

[0040] Node generation: Code entity node e: provided by the warehouse parsing module. Problem node p: generated based on historical problem description. Solution strategy node s: generated based on the solution strategy used in historical data. Execution result node r: generated based on the execution effect of the strategy.

[0041] Edge generation and update: Code dependencies: such as function calls, class inheritance, etc., from the repository-level code graph G.

[0042] Association between problems and code entities: Problem nodes p are connected to related code entity nodes e, indicating in which code modules the problem occurs.

[0043] Association between problem and solution strategy: The problem node p is connected to the solution strategy node s, indicating that the strategy is used to solve the problem.

[0044] Association between strategy and execution result: strategy node s is connected to execution result node r, indicating the execution effect of the strategy.

[0045] According to the dependencies extracted from the repository-level code graph G, the dependency edges R between code entities are constructed. According to the data H of historical problems and solutions, connections are added between problem nodes and related strategy nodes to form the problem-strategy relationship in the graph.

[0046] Based on the emergence of new problems and the effectiveness of historical solution strategies, the dynamic evolution knowledge graph module will update the graph. The specific update process includes: When new problem types appear, add new problem nodes and associate appropriate code entities and resolution strategies with them.

[0047] Adjustment of policy execution results: According to the policy execution result r, the priorities between policy nodes are adjusted, the weight of successful policy nodes is increased, and the weight of failed policy nodes is reduced.

[0048] Removing invalid strategies: When certain strategies consistently fail after multiple executions, the system removes these strategy nodes from the graph to prevent them from being recommended again.

[0049] When a new problem arises, the module learns the most appropriate solution strategy from historical data: Extract the characteristics of the current problem, such as error type, impact scope, etc., find the most similar historical problems based on historical problem solving data, and analyze their solution strategies.

[0050] By comparing the feature vectors of the current problem with those of historical problems, the best solution strategy is dynamically selected.

[0051] The dynamically evolving knowledge graph module continuously optimizes its structure based on new data and feedback. The specific evolution includes: For successful strategies, increase their weight and priority in the graph so that they can be prioritized in future problems.

[0052] For strategies that frequently fail, reduce their weight in the graph or remove them from the graph.

[0053] Multiple similar strategies are merged to reduce the redundancy of the graph.

[0054] The strategy nodes are weighted according to the execution results, enhancing successful strategies and optimizing failed strategies.

[0055] The output of the dynamic evolution knowledge graph module is the updated knowledge graph DEKG=(E',R').

[0056] The dynamically evolving knowledge graph module builds and continuously optimizes the knowledge graph by integrating the code graph and historical problem solving data of the warehouse parsing module. The graph not only helps the system identify the root cause of the problem, but also recommends the most appropriate solution strategy to ensure that solutions can be provided quickly and effectively when faced with new problems. Through dynamic evolution and learning, the knowledge graph can adaptively improve strategies and improve the efficiency and accuracy of problem solving.

[0057] During the evolution process, the dynamic knowledge graph will dynamically adjust the historical problem-solving strategy according to the type and complexity of the current problem. This strategy has a good effect on solving certain performance bottlenecks, but due to the different current code environments, this strategy may need to be adjusted (such as adjusting parameters, optimizing algorithms, etc.).

[0058] Steps: When a solution strategy is applied to the current problem, the system adjusts the parameters in the strategy based on the strategy s in the historical pattern and the current code dependencies G.

[0059] If the existing historical pattern is not sufficient to solve the current problem, the dynamically evolving knowledge graph will adaptively generate a new problem-solving strategy s' and add it to the knowledge base: S'=Adapt(s,G), where Adapt(s,G) means combining the historical strategy s with the current code dependency G to adjust and optimize the new strategy S'.

[0060] The dynamically evolving knowledge graph records the results of each problem solving and saves the process information of each evolution. Each model update includes the execution results, changes in the execution environment, information on strategy adjustments, etc. The graph update process is as follows: =(H,A,T), where A is the execution result (success or failure), T is the execution timestamp, and H is the updated historical problem solving mode.

[0061] After each update, the evolutionary information and historical patterns of the graph will affect the strategic selection and optimization path for future problem solving.

[0062] In one embodiment, the context retrieval module generates a solution strategy suitable for the current problem by analyzing the context information of the current code problem and combining the historical problem solving patterns and strategies in the dynamically evolving knowledge graph. The module identifies the context features of the current problem, finds patterns similar to historical problems, and adjusts and optimizes the solution strategy based on these patterns to ensure that the generated solution can accurately and effectively solve the current problem.

[0063] The context retrieval module receives the following input data: Context information of the current problem: parameter C=(f,m,e,d), where: f: The code file involved in the problem.

[0064] m: The module or function involved in the problem.

[0065] e: Error type (such as syntax error, runtime exception, performance problem, etc.).

[0066] d: context dependency information (such as call chain, global variable dependency, parameter passing relationship, etc.).

[0067] This data is used to help the module locate the root cause of the problem and accurately analyze the context of the problem.

[0068] Dynamically evolving knowledge graph: Parameter DEKG=(E',R'), which is the knowledge graph generated from historical data and warehouse analysis, contains information such as code entities, historical problem nodes, solution strategies, and execution results.

[0069] Extract key information of the problem from the input context information C, including: Problem type: Such as the error type (e.g. memory leak, logic error, etc.).

[0070] Problem scope: Use f and m to determine the specific code segment and locate the module where the problem lies.

[0071] Dependencies of the problem: Determine the relationship between the problem and other modules or code segments, and accurately identify the upstream and downstream impacts of the problem.

[0072] Convert context information C into feature vector , used to match nodes in the knowledge graph.

[0073] It includes features such as the type of problem, code structure information, and dependencies. For example, if e is a null pointer exception and d indicates that an uninitialized object was called, the feature vector will include dimensions such as error type (null pointer) and call relationship (uninitialized object).

[0074] By calculating the current context feature vector Similarity with node E' in the knowledge graph, find the historical problem-solving mode H={ , ,..., }.

[0075] The matching degree can be calculated using cosine similarity, Euclidean distance, etc.

[0076] If the current problem is a memory overflow, similar historical solutions in the graph will be matched, and the most appropriate repair strategy will be derived based on the relationships in the graph.

[0077] Candidate Node Set : Filter out the historical pattern set related to the current problem type e and problem scope f,m from the graph.

[0078] Matching calculation: calculation The matching degree with each candidate pattern is sorted.

[0079] Select the best matching mode: Select the historical mode with the highest matching degree , as the best matching model for the current problem.

[0080] Dynamically adjust the matched historical solution strategy based on context information.

[0081] If the historical policy is for an older version of the code, and the current code dependencies have changed, you need to adjust the policy based on the new dependencies.

[0082] If the optimization strategy is applicable to the current problem, but the parameters (such as performance optimization target and threshold) need to be adjusted, the optimization parameters are recalculated based on the context information.

[0083] Adjust strategies based on code dependencies: For example, changes in the call chain may require changes in the repair steps.

[0084] Dynamically select strategy priorities based on problem complexity: For example, in performance optimization tasks, prioritize the optimization strategies with the most critical impact.

[0085] The outputs of the context retrieval module include: Related historical problem solving patterns: Indicates the historical patterns that match the current problem in the graph.

[0086] Generated solution strategies: including repair strategies, completion strategies, optimization strategies, or review strategies, which are adjusted according to the context of the current problem.

[0087] Strategy Suitability Score: Provides developers with a suitability score for each solution strategy to help them evaluate the rationality of their choice.

[0088] The context retrieval module analyzes the context information of the current problem, combines the historical patterns and strategies in the dynamically evolving knowledge graph, generates a solution strategy that adapts to the current problem, and dynamically adjusts it according to context changes. This process not only ensures efficient problem solving, but also improves the system's adaptability and solution quality when facing new problems.

[0089] In one embodiment, the specific implementation of the generation module is further described as follows: The input data of the generation module mainly includes the following three parts: Contextual information about the current problem: Input parameters ,in: Indicates the code file involved in the problem; Indicates the module or function involved in the problem; Indicates the error type, such as syntax error, runtime exception, or performance problem; Represents context dependency information, such as call chains, global variable dependencies, parameter passing relationships, etc.

[0090] This information provides context for generating patches, helping the generation module understand the specific context and background of the problem.

[0091] Historical Problem Solving Mode: Input Parameters , represents a set of patterns related to historical issues, where: Models representing historical issues; Represents the corresponding repair steps; Represents the result of the repair.

[0092] These historical patterns provide reference for current problems and can help generate effective solution strategies.

[0093] Problem Solving Strategy: Input Parameters , representing different types of solution strategies, including: : Repair strategy, generating repair patches for current problems; : Code completion strategy, generating missing code parts; : Optimization strategy, optimizing code performance or structure; : Code review suggestions, providing review opinions on code quality.

[0094] In the process of generating strategies, if there are multiple historical problem-solving models that need to be integrated, multiple elements in PP Will be combined into a composite strategy , a process that generates a new strategy solution that adapts to the current problem by adjusting and optimizing historical patterns.

[0095] The combined formula is: That is, the repair strategies, solution steps and repair results in multiple historical problem solving models are weighted to form a composite strategy. , so that it can be adapted to the current problem.

[0096] After determining the context of the current problem and the resulting solution strategy Finally, the large language model L is used to generate code patches. The generated code patches It is expressed by the following formula: in: is the generated code patch; It is the context information of the current problem, including the file, module, error type, etc. It is a strategy generated by adapting historical problem-solving patterns.

[0097] Based on the generation strategy The generation module needs to select the appropriate patch type , and its selection rules are as follows: if , a repair patch is generated. ; if , then generate code completion patches, ; if , then an optimized patch is generated, ; if , then generate review suggestions, .

[0098] The patch type selection formula is: in Based on the generation strategy The type of patch type is used to select the function of the patch type.

[0099] Generated code patches The validation process needs to be verified, including static analysis, unit testing, and integration testing, to ensure the correctness and compatibility of the patch. ,in: V is the verification process, which returns whether the patch passes all tests.

[0100] The specific verification steps include: static check (static_check): static code analysis of the generated patch to check syntax errors and potential logic problems; unit test (unit_test): unit test the patch to verify the correctness of its functions; integration test (integration_test): integration test the patch to ensure its compatibility with other modules.

[0101] These validation steps ensure that the generated patch is syntactically, functionally, and performantly valid, and does not introduce new bugs or vulnerabilities.

[0102] The generation module automatically generates code patches by receiving the context information of the current problem, historical problem solving patterns, and problem solving strategies, combined with the large language model. The generated patches will be verified for effectiveness to ensure that they solve the current problem and are compatible with other modules. The entire process provides developers with an efficient and intelligent automated repair and optimization tool by dynamically adjusting strategies and patch types.

[0103] In one embodiment, the feedback module is implemented as follows: The feedback module receives the following input data: the verification result of the generated patch :in Represents the verification result of the generated patch. Each verification result Indicates whether the patch is effective, successfully resolves the problem, or introduces new problems. For example, Might include a tag like "patch works" or "patch doesn't work", or further supplementary information like whether the fix is ​​complete or needs more optimization.

[0104] Developer Feedback : Developer feedback includes feedback on generated patches and solution strategies, including the following: whether the patch is effective; whether the patch meets the developer's expectations; whether the patch needs further adjustment or optimization.

[0105] Developer feedback helps the feedback module evaluate the quality of patches and further adjust historical problem solving patterns and strategies based on feedback.

[0106] Historical problem solving model : A collection of historical problem-solving patterns, each of which Including problem types, solution strategies and execution results. These historical patterns record the solutions to previous problems and provide references for new problem solutions.

[0107] Historical problem solving strategies : A set of problem-solving strategies, where each strategy It may be a repair strategy, optimization strategy, completion strategy or review strategy, etc. The feedback module optimizes the existing solution strategy based on the developer's feedback and verification results to adapt to similar problems in the future.

[0108] The feedback module evaluates the patch effect through the following process: Based on the verification results ,The feedback module evaluates the effect of each generated patch.

[0109] If the patch If the problem is solved successfully and no new problems are introduced, the patch is considered effective; If the patch does not successfully solve the problem or introduces new problems, the feedback module will mark the patch as invalid and need to be modified or regenerated.

[0110] The patch effect evaluation formula is: in, Indicates that for patches The verification function, It is a patch The verification results are used to determine the effectiveness of the patch.

[0111] Based on feedback from developers The feedback module analyzes the effectiveness of patches and solutions. Developer feedback may include the following types: The patch works, but it would be nice to have it optimized; The patch is not effective and needs to be redesigned.

[0112] Based on the feedback from developers, the feedback module will adjust the current strategy to form an optimized solution strategy.

[0113] The developer feedback processing formula is: in, Indicates the strategy adjusted based on developer feedback.

[0114] Based on the patch verification results V and developer feedback F, the feedback module will optimize the historical problem solving mode P and historical problem solving strategy S, including: Update the historical problem-solving model P and adjust the solution strategies used in the historical model to make it suitable for handling similar problems in the future; Optimize the historical problem-solving strategy S and refine the strategy's parameters or application scope to improve the efficiency and accuracy of solving subsequent problems.

[0115] The historical model update formula is: in, It is an updated historical problem-solving model. It is a function of updating the historical model, which comprehensively considers the verification results V and developer feedback F to optimize the historical problem solving model.

[0116] The strategy optimization formula is: in, is the optimized problem-solving strategy, It is a function for strategy optimization, which adjusts the strategy based on developer feedback and verification results.

[0117] The output data of the feedback module includes: Optimized historical problem solving model : An updated collection of historical problem-solving patterns to guide the resolution of subsequent problems.

[0118] Optimized problem-solving strategy : A set of optimized problem-solving strategies, including repair strategies, optimization strategies, completion strategies, etc.

[0119] Feedback Adjustment Log : Record the adjustment process of developer feedback and patch verification results as traceable data of the feedback process.

[0120] The feedback module continuously optimizes historical problem solving patterns and strategies by combining the patch verification results generated by the generation module with the feedback from developers. Each feedback adjustment improves the efficiency and accuracy of the system in handling problems. Through this continuous feedback mechanism, the system can gradually optimize historical patterns and strategies to provide more efficient and accurate solutions for similar problems in the future, thus forming a closed-loop feedback optimization process to ensure that code problems can be quickly resolved while also ensuring the quality of subsequent problem handling.

[0121] Finally, the generated content is displayed through the interactive module and developer feedback is collected. Developers can operate through the following interface: Display generated content: Displays code patches, repair suggestions, code completion or review suggestions generated by the generation module. Developers can view detailed patch information, including its impact range, number of code lines and modified content.

[0122] Collect developer feedback: Developers can evaluate the displayed patches and provide feedback. Feedback includes but is not limited to the following types: Verification feedback: The developer's verification results on the effectiveness of the patch, such as whether it passed the unit test, integration test, or solved the actual problem; Modification suggestions: Developers make modification suggestions for patches to further optimize the quality of the patches; Bug Reports: Developers point out errors or inaccuracies in generated patches.

[0123] Feedback submission: Developers can submit feedback information through the interface. The feedback will be further analyzed by the feedback module and the dynamically evolving knowledge graph will be updated to optimize historical problem solving patterns and problem solving strategies.

[0124] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A warehouse-level code problem solving system based on a large language model, characterized by: include: Warehouse parsing module: extracts source code files from the code warehouse and parses the source code files through static analysis tools, including extracting code entities and determine dependencies between code entities ; The code entities include functions, classes, variables and constants, and the dependencies between the code entities include function calls, inheritance relationships and variable dependencies; based on the code entities and their dependencies, a warehouse-level code graph G=(E,R) is constructed, and the warehouse-level code graph forms a graph structure by modeling each code entity as a node and modeling the dependencies between nodes as edges, and the graph structure is used to represent the code entities and their dependencies; Dynamic evolution knowledge graph module: based on the warehouse-level code graph G, combined with historical problem solving data The dependency R with the current code is used to build a dynamic evolution knowledge graph DEKG=(E',R') through continuous learning of the problem-solving process; the dynamic evolution knowledge graph contains the evolution information of historical problem-solving patterns, problem-solving strategies and problem-solving results; the evolution information is used to update the historical problem-solving patterns and their corresponding solution strategies, thereby optimizing the processing process of subsequent problems to adapt to problems of different complexity and types; Contextual retrieval module: Based on the contextual information of the current problem, combined with the historical problem-solving patterns and problem-solving strategies in the dynamically evolving knowledge graph DEKG, dynamically retrieve strategies related to the current problem; the strategies include repair strategies, completion strategies, optimization strategies, and review strategies. The retrieval adjusts the strategies through the evolutionary information in the graph to adapt to different types of tasks and their complexity; Generation module: Generates a problem-solving strategy based on the context information of the current problem and the historical problem-solving mode, combined with the strategy generated in the context retrieval module; the problem-solving strategy generates a corresponding code patch through a large language model, and the code patch includes a repair patch, code completion or review suggestion; the patch is verified for validity, and the verification method includes static analysis, unit testing and integration testing to ensure the correctness and validity of the patch; Feedback module: obtain feedback information based on the verification results of the generated patches and the feedback from developers, analyze the feedback information and update the dynamic evolution knowledge graph DEKG, adjust the historical problem solving mode and problem solving strategy; the feedback module is used to gradually optimize the problem solving process and form a closed-loop feedback mechanism to improve the efficiency and accuracy of subsequent problem solving.

2. The warehouse-level code problem solving system based on a large language model according to claim 1 is characterized in that: The repository parsing module includes: extracting source code files from the code repository , where each source code file Represents a source code file; for source code files Perform static analysis to identify the code entities and generate the corresponding code entity set through the syntax tree , where each node Represents a specific code entity; identifies dependencies between code entities and generates dependency sets , where each edge Representation Node and nodes Dependencies between nodes; based on node sets and edge sets , build a repository-level code graph , where each code entity is represented by a node and the dependencies between code entities are represented by edges.

3. The warehouse-level code problem solving system based on a large language model as described in claim 1 is characterized in that: The dynamically evolving knowledge graph module includes: , solving data from historical problems Extract the patterns of each problem-solving process , each mode Including problem type, solution strategy, and execution results; dynamically adjust the historical problem solving mode based on the context information of the current problem, and update the historical mode through the following steps: compare the context of the current problem with the problem type in the historical problem mode, and identify the most matching historical mode ; If the current problem does not completely match the historical pattern, modify the current problem through the existing solution strategy and generate a new solution , update the historical question pattern set to ; Based on historical problem solving model Feedback from developers , adjust the set of problem-solving strategies The adjustment method is: optimize the relevant strategies for the invalid patches or incomplete solutions mentioned in the feedback; fine-tune the strategy parameters to make the strategy more suitable for solving the current problem.

4. The warehouse-level code problem solving system based on a large language model as described in claim 1 is characterized in that: The context retrieval module includes: obtaining the context information of the current problem, including the error prompt, code snippet, and call stack data of the current code, by analyzing the problem description, error report, or log information of the current code; retrieving relevant historical problem-solving patterns and strategies from the dynamically evolving knowledge graph based on the context information of the current problem. The retrieval process includes: searching for the historical problem pattern most relevant to the current problem type through the nodes and edges in the graph ; Based on the solution strategy in the historical model , dynamically adjust and generate corresponding solutions , and provide it to the subsequent generation module.

5. The warehouse-level code problem solving system based on a large language model as described in claim 1 is characterized in that: The generation module includes: according to the strategy obtained from the context retrieval module and the context information of the current problem, combined with the historical problem-solving model P, to generate a preliminary solution , the solution The generation process is achieved through the following steps: using a large language model based on contextual information and Generate code patches , Patches include fix patches, code completion, and review suggestions.

6. The warehouse-level code problem solving system based on a large language model as described in claim 1 is characterized in that: The feedback module includes: analyzing developer feedback and patch verification results: based on the developer's feedback on the patch and patch verification results , analyze the effectiveness of the current patch; based on the feedback information and verification results, update the historical problem solving model P and solution strategy S.

7. The warehouse-level code problem solving system based on a large language model according to claim 1 is characterized in that: The historical problem solving model P includes multiple problem solving paths, which are recorded according to the strategy execution process of each problem solving. Each path includes the type of problem, solution strategy, execution result and developer feedback. The path will continue to evolve and update with the introduction of new problems.

8. The warehouse-level code problem solving system based on a large language model as described in claim 5 is characterized in that: The use of a large language model based on contextual information and Generated patches Verification is performed, and the verification steps include: verifying the grammatical correctness of the patch through static analysis tools; verifying the execution effect of the patch through unit testing or integration testing to ensure that it correctly solves the current problem and does not introduce new problems; patch verification results Indicates the execution results of the patch in different test scenarios.

9. The warehouse-level code problem solving system based on a large language model as described in claim 6 is characterized in that: The process of updating the historical problem solving mode P and the solution strategy S includes: if the developer feedback patch is invalid or needs to be redesigned, modify the historical problem solving mode , so that it can better adapt to the type of current problem; optimize the problem-solving strategy S to make it more general or more targeted at specific types of problems.

10. The warehouse-level code problem solving system based on a large language model as described in claim 4 is characterized in that: The dynamic adjustment generates the corresponding solution , and provide it to the subsequent generation module; The retrieved strategy is dynamically adjusted through the following steps: According to the characteristics of the current problem, the execution details of the solution strategy are fine-tuned, including adjusting the specific repair location of the patch if the strategy is a repair strategy; and adjusting the optimization scope if it is an optimization strategy.

Citation Information

Patent Citations

  • Vulnerability code graph construction and code vulnerability detection method based on knowledge graph

    CN114692155A

  • Software knowledge graph incremental updating method based on code submission

    CN115543402A

  • Bidirectional intelligent question and answer code supplementing method and system based on large language model

    CN118426825A

  • Code processing method and code repair testing method

    CN118760612A

  • Program defect automatic repair method, system and equipment based on retrieval enhancement and readable storage medium

    CN119127154A

Cited By

  • Software knowledge graph searching method and system for system-level code generation

    CN119886291A

  • Version controllable data set automatic evolution method based on large language model

    CN120335855A

  • Software defect information fusion method and system based on multi-source data

    CN120632770A

  • Buried pipeline distribution recommendation method based on artificial intelligence

    CN120893154A

  • AI-driven software useless energy technology debt automatic identification and cleaning system

    CN121188362A