Method and apparatus for determining call relationship of generated code, and storage medium
By parsing and compressing code files to generate call relationship graphs and using neural network models to analyze requirement information, the problem of accurately determining call relationships in large-scale projects is solved, achieving high-quality and efficient code generation.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- CHINA TELECOM ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
- Filing Date
- 2025-10-29
- Publication Date
- 2026-07-09
AI Technical Summary
In large-scale projects, the inability to accurately determine the call relationships of generated code leads to a decline in code quality and maintainability.
The initial code file is parsed to obtain the call relationship graph, which is then compressed to generate the target code file. This target code file, along with the target account's requirement information, is input into the target call relationship model for analysis. The target call relationship model, constructed using a neural network model, determines the call relationship of the generated code.
It accurately determines the calling relationships of the generated code, improves code quality and maintainability, reduces duplicate code and performance bottlenecks, and enhances development efficiency.
Smart Images

Figure CN2025130980_09072026_PF_FP_ABST
Abstract
Description
The call relationships for generating code determine the methods, devices, and storage media.
[0001] Related applications
[0002] This application claims priority to Chinese patent application No. 2024119962079, filed on December 31, 2024, entitled "Method, Apparatus and Storage Medium for Determining Call Relationships of Generated Code", the entire contents of which are incorporated herein by reference. Technical Field
[0003] This application relates to the field of computers, and in particular to a method, apparatus, and storage medium for determining call relationships in code generation. Background Technology
[0004] When using large models to generate project code, the clarity and completeness of call relationships are crucial for improving the quality and maintainability of the generated code. However, in large-scale projects containing tens of thousands of callable functions, the call relationships in the project code become extremely complex, making it impossible to accurately determine the call relationships in the generated code. Summary of the Invention
[0005] This application provides a method, apparatus, and storage medium for determining the call relationship of generated code, so as to at least solve the technical problem of being unable to accurately determine the call relationship of generated code.
[0006] According to one aspect of the embodiments of this application, a method for determining the call relationship of generated code is provided. The method may include: in response to an acquisition instruction, acquiring an initial code file of a target project and requirement information of a target account, wherein the initial code file is used to characterize the execution logic of the target project; parsing the initial code file using a parser to obtain a call relationship graph of target function files in the initial code file, wherein the call relationship graph characterizes the call relationship between the target function files and other function files in the initial code file besides the target function files; compressing the initial code file based on the call relationship graph to obtain a target code file of the target project, wherein the storage space of the target code file is smaller than the storage space of the initial code file; and invoking a call relationship analysis model of the target project, using the target code file and the requirement information of the target account as input to a target call relationship model of the target project to obtain the call relationship of the generated code, wherein the requirement information characterizes the requirement of the target account to generate code, and the target call relationship model is constructed using a neural network model.
[0007] In some embodiments, the initial code file is compressed based on a call relationship graph to obtain the target code file of the target project. This includes: determining multiple first function files and multiple second function files of the target function file based on the call relationship graph, wherein the first function files are function files that have called the target function file, and the second function files are function files that have been called by the target function file; compressing the first function files to obtain compressed first function files, and compressing the second function files to obtain compressed second function files; and generating the target code file based on the compressed first function files and the compressed second function files.
[0008] In some embodiments, the target code file and the target account's requirement information are input into the target call relationship model of the target project for analysis to obtain the call relationship of the generated code. This includes: inputting the target code file and the target account's requirement information into the target call relationship model for analysis to obtain the target requirement function file, multiple initial requirement function files, and the correlation results corresponding to the multiple initial requirement function files respectively, wherein the correlation results are used to characterize the degree of association between the initial requirement function files and the target requirement function file; and determining the call relationship of the generated code based on the multiple initial requirement function files and the multiple correlation results.
[0009] In some embodiments, determining the calling relationship of the generated code based on multiple initial requirement function files and multiple correlation results includes: sorting the multiple initial requirement function files according to the multiple correlation results to obtain multiple sorted initial requirement function files; selecting a target number of initial requirement function files from the multiple sorted initial requirement function files; and determining the calling relationship of the generated code based on the target number of initial requirement function files.
[0010] In some embodiments, determining the call relationships of the generated code based on a target number of initial requirement function files includes: updating the call relationship graph based on the target number of initial requirement function files to obtain an updated call relationship graph; and determining the call relationships of the generated code based on the target number of initial requirement function files and the updated call relationship graph.
[0011] In some embodiments, the method further includes: obtaining an initial call relationship model of the target project, wherein the initial call relationship model is constructed by a neural network model; and training the initial call relationship model using an initial code file and target constraints to obtain a target call relationship model, wherein the target constraints are used to constrain the call relationships of function files in the initial code file.
[0012] According to another aspect of the embodiments of this application, a device for determining the call relationship of generated code is also provided, comprising:
[0013] The first acquisition unit is used to acquire the initial code file of the target project and the requirement information of the target account. The initial code file is used to represent the execution logic of the target project.
[0014] The parsing unit is used to parse the initial code file to obtain the call relationship graph of the target function file in the initial code file. The call relationship graph is used to represent the call relationship between the target function file and other function files in the initial code file.
[0015] The compression unit is used to compress the initial code file based on the call relationship graph to obtain the target code file of the target project, wherein the storage space of the target code file is smaller than that of the initial code file;
[0016] The analysis unit is used to input the target code file and the target account's requirement information into the target project's target call relationship model for analysis, and obtain the call relationship of the generated code. The requirement information is used to characterize the target account's requirement for generating code, and the target call relationship model is used to construct it through a neural network model.
[0017] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided, comprising: the storage medium including a stored program, wherein, during program execution, the device where the storage medium is located is controlled to execute any method for determining the call relationship of generated code.
[0018] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement any method for determining the call relationship of generated code.
[0019] In this embodiment, the initial code file of the target project and the requirement information of the target account are obtained. The initial code file is used to represent the execution logic of the target project. The initial code file is parsed to obtain a call relationship graph of the target function files in the initial code file. The call relationship graph is used to represent the call relationship between the target function files and other function files in the initial code file. Based on the call relationship graph, the initial code file is compressed to obtain the target code file of the target project. The storage space of the target code file is smaller than that of the initial code file. The target code file and the requirement information of the target account are input into the target call relationship model of the target project for analysis to obtain the call relationship of the generated code. The requirement information is used to represent the requirement of the target account to generate code. The target call relationship model is constructed by a neural network model. In other words, the initial code file of the target project and the requirement information of the target account can be obtained first. Then, the initial code file can be parsed to obtain a call relationship diagram of the target function files within it. Based on this call relationship diagram, the initial code file can be compressed to obtain the target code file of the target project. Finally, the target code file and the requirement information are input into the target call relationship model of the target project for analysis, achieving the goal of obtaining the call relationship of the generated code. Considering that after obtaining the call relationship diagram of the target function files in the initial code file, the initial code file is compressed based on the call relationship diagram to obtain a target code file with smaller storage space, and then the target code file and the requirement information of the target account are input into the target call relationship model for analysis, the call relationship of the generated code can be obtained. This solves the technical problem of not being able to accurately determine the call relationship of the generated code, achieving the technical effect of accurately determining the call relationship of the generated code.
[0020] Details of one or more embodiments of this application are set forth in the following drawings and description. Other features, objects, and advantages of this application will become apparent from the specification, drawings, and claims. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the conventional technology, the drawings used in the description of the embodiments or the conventional technology will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the disclosed drawings without creative effort.
[0022] Figure 1 is a flowchart of a method for determining the call relationship of generated code according to some embodiments of this application;
[0023] Figure 2 is a flowchart of a method for obtaining a compressed code file according to some embodiments of this application;
[0024] Figure 3 is a flowchart of a file compression method according to some embodiments of this application;
[0025] Figure 4 is a schematic diagram of a code generation and call relationship determination device according to some embodiments of this application;
[0026] Figure 5 is a schematic diagram of an example electronic device for implementing embodiments of the present application, according to some embodiments of the present application. Detailed Implementation
[0027] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] According to an embodiment of this application, a method for determining the call relationship of generated code is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system, such as one capable of executing a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0030] For example, the call relationship of the generated code can be applied to an electronic device that is configured with a call relationship analysis model corresponding to the target project.
[0031] Figure 1 is a flowchart of a method for determining the calling relationship of generated code according to some embodiments of this application. As shown in Figure 1, the method includes the following steps S102-S108.
[0032] Step S102: In response to the acquisition instruction, acquire the initial code file of the target project and the requirement information of the target account.
[0033] In the technical solution provided in step S102 of this application, after receiving a user-input acquisition instruction, the system can, in response to the acquisition instruction, acquire the initial code file of the target project and the requirement information of the target account. The initial code file, which represents the execution logic of the target project, can be simply referred to as a file and includes multiple initial function files.
[0034] In some embodiments, the target account is a preset account, such as a mobile phone number or email address. One target account corresponds to one user. It should be noted that this is only an example of the target account type and does not specifically limit the target account type.
[0035] Step S104: The initial code file is parsed by the parser to obtain the call relationship graph of the target function file in the initial code file.
[0036] In the technical solution provided in step S104 of this application, after obtaining the initial code file, the initial code file is imported into the project system and parsed to obtain the call relationship diagram of the target function file in the initial code file.
[0037] In some embodiments, a call graph is used to represent the call relationships between the target function file and other function files in the initial code file besides the target function file; it can also be called a dependency directed graph.
[0038] In some embodiments, a directed graph can be a graphical structure in which the edges are directed and consist of a set of vertices (or nodes) and a set of directed edges (pointing from one vertex to another). In a directed graph, the direction of the edges is used to represent the relationships between nodes, typically representing some kind of dependency or flow.
[0039] In some embodiments, after the initial code file is imported into the project system, the system invokes a dependency analyzer to analyze the dependencies in the initial code file in order to generate a call graph. The analyzer can also be other types of analyzers, as long as they can analyze the dependencies in the initial code file and generate a call graph.
[0040] For example, after a project is imported, the system will call Dependency Analyzer to analyze the dependencies of functions in the project and create a directed dependency graph, which will then be stored in the database.
[0041] It should be noted that this is only one implementation method for obtaining the call relationship graph of the target function file in the initial code file. It does not specifically limit the acquisition of the call relationship graph of the target function file in the initial code file. As long as the initial code file is parsed and processed to obtain the call relationship graph of the target function file in the initial code file, the process and method are within the protection scope of this application, and will not be listed here.
[0042] Step S106: Based on the call relationship graph, compress the initial code file to obtain the target code file of the target project.
[0043] In the technical solution provided in step S106 of this application, the initial code file is compressed according to the call relationship diagram to obtain the target code file of the target project. The storage space of the target code file is smaller than that of the initial code file, and the target code file includes multiple target function files. The target function files can be called comment files. The comment files include package name, class name and function name.
[0044] It is understood that this is only one implementation method for obtaining the target code file of the target project, and the process and method of obtaining the target code file of the target project are not specifically limited. As long as the process and method of obtaining the target code file of the target project are based on the call relationship diagram and the initial code file is compressed, they are all within the protection scope of this application and will not be listed here.
[0045] Step S108: Invoke the call relationship analysis model of the target project, and take the target code file and the target account's requirement information as input to the target call relationship model of the target project to obtain the call relationship of the generated code.
[0046] In the technical solution provided in step S108 of this application, after obtaining the target code file and the target account requirement information, the target code file and the target account requirement information can be input into the target call relationship model of the target project for analysis, so as to obtain the call relationship of the generated code.
[0047] In some embodiments, the demand information is used to characterize the demand for code generation for the target account. The target call relationship model is constructed using a neural network model, which is used to automatically extract and characterize data features, such as large models, after performing a learning and training process.
[0048] In some embodiments, call relationships refer to the relationships between different functions, methods, or modules in a program. Call relationships show which functions call other functions, as well as the hierarchy and order of these calls. This relationship helps developers understand the program's structure, flow, and potential dependencies. Understanding call relationships is crucial in code analysis and optimization because it helps developers identify performance bottlenecks, reduce code duplication, and improve code maintainability.
[0049] It should be noted that this is only one implementation method for obtaining the call relationship of the generated code. The process and method of obtaining the call relationship of the generated code are not specifically limited. As long as the target code file and the target account's requirement information are input into the target call relationship model of the target project for analysis, the process and method of obtaining the call relationship of the generated code are within the protection scope of this application, and will not be elaborated here.
[0050] In this embodiment, the initial code file of the target project and the requirement information of the target account can be obtained first. Then, the obtained initial code file is parsed to obtain a call relationship diagram of the target function files within the initial code file. Based on this call relationship diagram, the initial code file can be compressed to obtain the target code file of the target project. Finally, the target code file and the requirement information are input into the target call relationship model of the target project for analysis, achieving the goal of obtaining the call relationship of the generated code. Considering that after obtaining the call relationship diagram of the target function files in the initial code file, the initial code file is compressed based on the call relationship diagram to obtain a target code file with smaller storage space, and then the target code file and the requirement information of the target account are input into the target call relationship model for analysis, the call relationship of the generated code can be obtained. This solves the technical problem of not being able to accurately determine the call relationship of the generated code, achieving the technical effect of accurately determining the call relationship of the generated code.
[0051] In some embodiments of this application, the initial code file is compressed based on a call relationship graph to obtain the target code file of the target project. This includes: determining multiple first function files and multiple second function files of the target function file based on the call relationship graph, wherein the first function files are function files that have called the target function file, and the second function files are function files that have been called by the target function file; compressing the first function files to obtain compressed first function files, and compressing the second function files to obtain compressed second function files; and generating the target code file based on the compressed first function files and the compressed second function files.
[0052] In this embodiment, after obtaining the call relationship graph, multiple first function files that have called the target function file and multiple second function files that have been called by the target function file can be identified. Then, the first function files can be compressed to obtain compressed first function files, and the second function files can be compressed to obtain compressed second function files. Based on the compressed first function files and compressed second function files obtained above, the purpose of generating the target code file is achieved.
[0053] In some embodiments, a target code file can be generated based on a compressed first function file, a compressed second function file, and a call relationship graph, using a target call relationship model. The target call relationship model can be simply referred to as the model. A first code file can be composed of multiple first function files. A second code file can be composed of multiple second function files.
[0054] For example, by using a call relationship graph, the code files that have called the target function file, and the code files that the target function file has called, are found. This call relationship graph, the code files that have called the target function file, and the code files that the target function file has called are then provided to the model. The model generates the target code file, which includes class and method comments. This method makes the code comments more accurate. After parsing the commented file using a syntax tree, only the package name, class comments, class signature, function signature, and function comments are retained. After compressing files with call relationships, the compressed files can be processed in parallel to accelerate the process without affecting each other.
[0055] In some embodiments of this application, the target code file and the target account's requirement information are input into the target project's target call relationship model for analysis to obtain the call relationship of the generated code. This includes: inputting the target code file and the target account's requirement information into the target call relationship model for analysis to obtain the target requirement function file, multiple initial requirement function files, and the correlation results corresponding to the multiple initial requirement function files, wherein the correlation results are used to characterize the degree of association between the initial requirement function files and the target requirement function file; and determining the call relationship of the generated code based on the multiple initial requirement function files and the multiple correlation results.
[0056] In this embodiment, the target code file and the target account's requirement information can be input into the target call relationship model for analysis. This allows for the acquisition of the target requirement function file, multiple initial requirement function files, and the correlation results corresponding to each of the initial requirement function files. Based on the obtained initial requirement function files and correlation results, the call relationship of the generated code is determined. The correlation results can be represented by correlation scores.
[0057] In some embodiments, the target account's requirements information can be the user's code generation requirements. The relevance score can be represented numerically, such as 7, 8, etc. A higher relevance score indicates a greater correlation between the initial requirement function file and the target requirement function file; conversely, a lower relevance score indicates a weaker correlation. It should be noted that this is merely an example of how to represent the relevance score and does not specifically limit its representation.
[0058] For example, the user's code generation requirements are obtained. Based on these requirements, 30-50 code files are concatenated using a model. The model then determines which code files will be used in the user's requirements. The model selects the files that may be used from these code files and performs parallel acceleration processing on these files.
[0059] In some embodiments of this application, determining the calling relationship of the generated code based on multiple initial requirement function files and multiple correlation results includes: sorting multiple initial requirement function files according to multiple correlation results to obtain multiple sorted initial requirement function files; selecting a target number of initial requirement function files from the sorted multiple initial requirement function files; and determining the calling relationship of the generated code based on the target number of initial requirement function files.
[0060] In this embodiment, multiple initial requirement function files can be sorted according to multiple relevance scores to obtain sorted initial requirement function files. Then, a target number of initial requirement function files can be selected from these sorted files, and the calling relationship of the generated code can be determined based on these target number of initial requirement function files. The target number can be a preset value, such as 30.
[0061] In some embodiments, multiple initial requirement function files are sorted according to their relevance scores from largest to smallest to obtain sorted initial requirement function files. The first 30 initial requirement function files can then be selected to determine the calling relationship of the generated code.
[0062] For example, after the model selects the files that may be used from these code files and performs parallel acceleration on the above files, it re-sorts all the files that may be used and selects the top 30 files that may be called for the next step of processing.
[0063] In some embodiments of this application, determining the call relationship of the generated code based on a target number of initial requirement function files includes: updating the call relationship graph based on the target number of initial requirement function files to obtain an updated call relationship graph; and determining the call relationship of the generated code based on the target number of initial requirement function files and the updated call relationship graph.
[0064] In this embodiment, the call relationship graph can be updated based on the target number of initial requirement function files to obtain an updated call relationship graph. Then, based on the target number of initial requirement function files and the updated call relationship graph, the call relationship of the generated code can be determined.
[0065] In some embodiments, the call relationship graph is updated based on the target number of initial requirement function files to obtain an updated call relationship graph, including:
[0066] Obtain the call relationship graph and the initial requirement function file;
[0067] The initial requirement function file is restored to the call relationship graph, and the associated files corresponding to the initial requirement function file are determined through the call relationship graph;
[0068] Select an associated file whose association with the initial requirement function file meets the preset conditions as a supplement to expand the call relationship graph, and use the expanded call relationship graph as the updated call relationship graph.
[0069] For example, a call graph can be used to expand the narrowed call relationships, restore the possible calling files to the call graph, and find a secondary call, that is, find the nodes that can associate the calling files, and select the top 10 nodes with the most interconnections as supplements, thereby updating the call graph to determine the call relationships of the generated code.
[0070] In some optional embodiments of this application, the method further includes: obtaining an initial call relationship model of the target project, wherein the initial call relationship model is constructed through a neural network model; and training the initial call relationship model using an initial code file and target constraints to obtain a target call relationship model, wherein the target constraints are used to characterize the call relationship of function files in the initial code file.
[0071] In this embodiment, the initial call relationship model of the target project can be obtained, and the initial call relationship model can be trained according to the initial code file and the target constraints to obtain the target call relationship model.
[0072] In some embodiments, the target constraint can be established using a first loss function and a second loss function, which can be called the target loss function. The first loss function characterizes the difference between the accuracy of the predicted call relationship and the accuracy of the actual call relationship, and can be called the merged loss. The second loss function characterizes the difference between the legality of the predicted call relationship and the legality of the actual call relationship, and can be called the logic detection loss. Both the first and second loss functions can be expressed by the same formula, namely:
[0073] Where J can be used to characterize either the first loss function or the second loss function, p(x i ) is used to characterize the prediction results of the model, q(x) i ) is used to characterize the actual result, μ is used to represent the penalty coefficient, and 0.15 is used as the penalty rate in this case, and φ is used to represent the number of files that did not select the required call relationship.
[0074] Furthermore, the cross-entropy loss function is used to calculate the difference between the predicted call relationships and the actual call relationships. The merge loss and the logic detection loss can be weighted and merged to simultaneously optimize the accuracy of the merged results and the correctness of the logic during training.
[0075] For example, a neural network model (Mistral7B model) is chosen as the base model, and then secondary training is performed to narrow down the call relationships, thereby improving the model's ability to select call relationships. At the same time, in order to improve the identification of call chains when generating multiple files, the model is used for code compression.
[0076] Furthermore, the training process of the above model includes:
[0077] Select training samples, for example, 20 items, all of which have complete labeled data and can be used as pre-training data, fine-tuning data, etc., and obtain, for example, 5000 items from known websites;
[0078] The dependency graph is invoked, in which the Dependency Analyzer is used to analyze the dependencies of functions in the project and create a directed dependency graph;
[0079] Class file compression involves compressing all code files in a project, retaining only the package name (the package name to which the class belongs), class signature, and function signature; simultaneously, it calls the model to generate class and function comments, and uses these comments to replace the code for further compression; by using a call relationship graph, it obtains the code to be called and provides the call relationship graph and the code to be called to the model, thereby compressing the call files.
[0080] Model fine-tuning involves using the target loss function obtained above and the labeled data to help the model learn better call relationships.
[0081] Model testing, where the remaining data can be used to test the model.
[0082] In this embodiment, the initial code file of the target project and the requirement information of the target account can be obtained first. Then, the obtained initial code file is parsed to obtain a call relationship diagram of the target function files within the initial code file. Based on this call relationship diagram, the initial code file can be compressed to obtain the target code file of the target project. Finally, the target code file and the requirement information are input into the target call relationship model of the target project for analysis, achieving the goal of obtaining the call relationship of the generated code. Considering that after obtaining the call relationship diagram of the target function files in the initial code file, the initial code file is compressed based on the call relationship diagram to obtain a target code file with smaller storage space, and then the target code file and the requirement information of the target account are input into the target call relationship model for analysis, the call relationship of the generated code can be obtained. This solves the technical problem of not being able to accurately determine the call relationship of the generated code, achieving the technical effect of accurately determining the call relationship of the generated code.
[0083] The technical solutions of the embodiments of this application will be illustrated below with reference to preferred embodiments.
[0084] When using large models to generate project code, the explicitness and completeness of call relationships are crucial for improving the quality and maintainability of the generated code. Call relationships help the large model understand the dependencies between different modules and functions, thereby generating code that better conforms to the project structure. By understanding which functions call which other functions, the model can maintain consistency in the generated code and ensure that the types of call parameters and return values match. Understanding call relationships helps avoid common programming errors, such as incorrect function calls or unhandled boundary conditions, and also ensures that the generated code is logically coherent, reducing runtime errors. By analyzing call relationships, the model can identify which functionalities can be reused, thereby generating more concise and modular code. This reuse improves code maintainability and reduces the generation of duplicate code.
[0085] In one implementation, models are constrained by context, and providing them with excessively long content reduces their focus. When processing large amounts of information, models may struggle to focus on the core elements of the current task, leading to inaccurate generated code or results that do not match expectations. Excessive contextual information can increase noise, affecting the model's decision-making ability and generating unnecessary or redundant code. When call relationships are too complex or deeply hierarchical, models may struggle to correctly understand the context, impacting code readability and maintainability. Furthermore, handling too many call relationships increases the computational burden of the generation process, prolonging response time and impacting development efficiency. Simultaneously, model accuracy decreases, leading to technical problems such as the inability to accurately determine the call relationships in the generated code.
[0086] To address the aforementioned issues, this application proposes a method for determining the call relationships of generated code. This method first obtains the initial code file of the target project and the requirement information of the target account. Then, it parses the obtained initial code file to obtain a call relationship diagram of the target function files within the initial code file. Based on this call relationship diagram, the initial code file is compressed to obtain the target code file of the target project. Finally, the target code file and the requirement information are input into the target call relationship model of the target project for analysis, thereby achieving the goal of obtaining the call relationships of the generated code. Considering that after obtaining the call relationship diagram of the target function files in the initial code file, the initial code file is compressed based on the call relationship diagram to obtain a target code file with smaller storage space, and then the target code file and the requirement information of the target account are input into the target call relationship model for analysis, the call relationships of the generated code can be obtained. This solves the technical problem of being unable to accurately determine the call relationships of the generated code, achieving the technical effect of accurately determining the call relationships of the generated code.
[0087] To facilitate a better understanding of the technical solutions of this application by those skilled in the art, a specific embodiment will now be described.
[0088] In this embodiment, the Mistral7B model is selected as the base model, and then secondary training is performed to narrow down the call relationships, thereby improving the model's ability to select call relationships. Simultaneously, to improve the identification of call chains when generating multiple files, the model is used for code compression.
[0089] In this embodiment, the Mistral7B model needs to be trained. The training process is as follows: Select training samples, for example, 20 projects. These projects all have complete labeled data and can be used as pre-training data, fine-tuning data, etc., and obtain, for example, 5000 projects from known websites; invoke the dependency graph, using Dependency Analyzer to analyze the dependencies of functions in the projects and create a directed dependency graph; compress class files, compressing all code files in a project, retaining only the package name (the package name to which the class belongs), class signature, and function signature. Simultaneously, the model is invoked to generate class and function comments, which are then used to replace the code for further compression. By invoking the dependency graph, the invoked code is obtained, and the dependency graph and the invoked code are provided to the model to achieve file compression.
[0090] Furthermore, after compressing the called file, the loss function can be determined and expressed by the following formula:
[0091] Where J is used to characterize the first loss function or the second loss function, p(x) i ) is used to characterize the prediction results of the model, q(x) i The symbol ) represents the actual result, and μ represents the penalty coefficient, with 0.15 used as the penalty rate in this case. This represents the number of files for which the desired call relationship was not selected. It's important to note that the cross-entropy loss function is used to calculate the difference between the predicted call relationship and the actual call relationship. The merging loss and the logistic detection loss can be weighted and merged to simultaneously optimize the accuracy of the merged result and the correctness of the logic during training; model fine-tuning utilizes the target loss function obtained above, using labeled data to allow the model to learn better call relationships; model testing uses the remaining data to test the model.
[0092] In addition, the above model training configuration includes the following: the Mistral7B model is used as the base model, with a total of 7 billion parameters. Ten graphics cards are used for training. 7 billion parameters require sufficient video memory (86GB). In the training method, the video memory is compressed and can be placed onto a single graphics card. Each graphics card is trained independently, and the data is mixed and trained in multiple batches. Then, the parallel-trained models are weighted to obtain the final weights.
[0093] Figure 2 is a flowchart of a method for obtaining a compressed code file according to some embodiments of this application. As shown in Figure 2, the method may include the following steps.
[0094] Step S201: Import the project.
[0095] In this embodiment, the file is imported into the system.
[0096] Step S202: parse the function dependencies in the project.
[0097] Step S203: Generate a call relationship diagram.
[0098] In this embodiment, after the project is imported, the system calls Dependency Analyzer to analyze the dependencies of functions in the project, and creates a directed dependency graph, which is then stored in the database.
[0099] In some embodiments, using a Dependency Analyzer to parse the dependency graph can make the call relationships between functions clearer. Dependency graph information can be effectively utilized when generating annotations, and natural language processing techniques are used to improve accuracy. Utilizing the contextual information provided by the dependency graph, more accurate and relevant annotations can be generated, aiding in understanding the functionality and logic of the code. By removing implementation code and import statements, call relationships are simplified, making dependencies clearer and easier to analyze.
[0100] Step S204: Save the call relationship diagram.
[0101] Step S205: Obtain the commented-out code file.
[0102] Step S206: Use the call relationship diagram to obtain the relevant code files and parse the relevant code files.
[0103] Step S207: Compress the code file.
[0104] In this embodiment, after the relationship graph is generated, the system calls the model to generate comments for each code file.
[0105] In some embodiments, a call relationship graph is used to locate the code files that have called the target function file, as well as the code files that the target function file has called. This call relationship graph, the code files that have called the target function file, and the code files that the target function file has called are then provided to the model, allowing the model to generate the target code file. This target code file includes class and method comments, which makes the comments more accurate. After parsing the commented file using a syntax tree, only the package name, class comments, class signature, function signature, and function comments are retained. After compressing files with call relationships, the compressed files can be processed in parallel to accelerate the process without affecting each other.
[0106] Step S208: Save the compressed code file.
[0107] Step S209: Determine whether the entire file has been parsed.
[0108] In this embodiment, it is necessary to determine whether the file has been completely parsed. If so, the process ends directly; otherwise, step S205 is executed. It should be noted that the execution of steps S205 to S209 can be accelerated in parallel.
[0109] Figure 3 is a flowchart of a file compression method according to some embodiments of this application. As shown in Figure 3, the method includes the following steps.
[0110] Step S301: Obtain the user's requirements for generating code.
[0111] Step S302: Obtain the concatenation code file.
[0112] Step S303: Obtain a small number of code files.
[0113] Step S304: Obtain the relevance score of the code file.
[0114] Step S305: Determine whether all code files have obtained relevance scores.
[0115] In this embodiment, it is necessary to determine whether all code files have obtained relevance scores. If so, step S306 is executed; otherwise, step S303 is executed. The execution content of steps S303 to S305 can be processed in parallel to accelerate the process.
[0116] Step S306: Obtain the code file for the target value and the correlation that meet the preset conditions.
[0117] In this embodiment, code files with high relevance to the target value can be obtained. For example, the user's code generation requirements can be obtained. Based on the requirements, a model can be used to concatenate, for example, 30-50 code files. The model can then determine which code files will be used in the user's requirements. The model will select potentially used files from these code files and perform parallel acceleration processing on them. All potentially used files will be reordered, and, for example, the top 30 files that are likely to be called will be selected for the next step of processing.
[0118] Step S307: Expand the code file using a relationship diagram.
[0119] In this embodiment, a relationship graph can be used to expand the code file. For example, a call relationship graph can be used to expand the narrowed call relationship, restore the possible call files to the call relationship graph, and find a secondary call, that is, find the nodes that can associate the call files, and select the top 10 nodes with the most interconnections as supplements, thereby achieving the purpose of expanding the code file.
[0120] Step S308: Select code files whose relevance meets preset conditions. That is, select code files with high relevance.
[0121] Step S309: Obtain the calling relationship of the generated code.
[0122] In this embodiment, the call relationship of the generated code is obtained, and the call relationship used in the end is recorded.
[0123] In some embodiments, all data during the merging process can be collected, including developer feedback, conflict resolution, test results, etc.; the collected data can be used periodically to retrain and fine-tune the model to improve its merging and conflict resolution capabilities.
[0124] In some embodiments, querying the model with a small number of calls each time not only returns results quickly but also prevents the model from exceeding the context length. Selecting the most probable, for example, the top 50 files for use when generating the project ensures that large models do not exceed the token limit when generating code, and supports more rounds of dialogue, resulting in better code generation.
[0125] In some embodiments, selecting the top 50 files with the highest call probability can, to some extent, focus on the most relevant dependencies and improve the accuracy of the generated code. Batch request processing: Design an efficient request mechanism to ensure that requests to large models do not exceed their token limits, while retaining as much context information as possible. Effective batch processing: By querying large models in batches, efficiency can be improved, reducing the overhead of each request, making it suitable for processing a large number of code files.
[0126] In some embodiments, using 20 high-quality labeled items in the training data can improve training performance. Items are found on known websites as foundational data. During the training of large models, a loss function is utilized, multiple GPUs are used to achieve parallel data processing, and data from different groups are mixed and trained in multiple batches to achieve weighted processing. A specially trained model can better handle the filtering of comments and call relationships in code files.
[0127] In this embodiment, the initial code file of the target project and the requirement information of the target account can be obtained first. Then, the obtained initial code file is parsed to obtain a call relationship diagram of the target function files within the initial code file. Based on this call relationship diagram, the initial code file can be compressed to obtain the target code file of the target project. Finally, the target code file and the requirement information are input into the target call relationship model of the target project for analysis, achieving the goal of obtaining the call relationship of the generated code. Considering that after obtaining the call relationship diagram of the target function files in the initial code file, the initial code file is compressed based on the call relationship diagram to obtain a target code file with smaller storage space, and then the target code file and the requirement information of the target account are input into the target call relationship model for analysis, the call relationship of the generated code can be obtained. This solves the technical problem of not being able to accurately determine the call relationship of the generated code, achieving the technical effect of accurately determining the call relationship of the generated code.
[0128] Figure 4 is a schematic diagram of a code generation and call relationship determination device according to an embodiment of the present application. As shown in Figure 4, the code generation and call relationship determination device 400 includes: a first acquisition unit 401, a parsing unit 402, a compression unit 403, and an analysis unit 404.
[0129] The first acquisition unit 401 is used to acquire the initial code file of the target project and the requirement information of the target account, wherein the initial code file is used to represent the execution logic of the target project.
[0130] The parsing unit 402 is used to parse the initial code file to obtain the call relationship graph of the target function file in the initial code file. The call relationship graph is used to represent the call relationship between the target function file and other function files in the initial code file.
[0131] Compression unit 403 is used to compress the initial code file based on the call relationship graph to obtain the target code file of the target project, wherein the storage space of the target code file is smaller than the storage space of the initial code file.
[0132] Analysis unit 404 is used to input the target code file and the target account's requirement information into the target project's target call relationship model for analysis, and obtain the call relationship of the generated code. The requirement information is used to characterize the target account's requirement for generating code, and the target call relationship model is used to construct it through a neural network model.
[0133] In some embodiments, the compression unit 403 may include:
[0134] The first determination module is used to determine multiple first function files and multiple second function files of the target function file based on the call relationship graph, wherein the first function files are function files that have called the target function file, and the second function files are function files that have been called by the target function file;
[0135] The acquisition module is used to compress the first function file to obtain the compressed first function file, and to compress the second function file to obtain the compressed second function file.
[0136] The generation module is used to generate target code files based on the compressed first function file and the compressed second function file.
[0137] In some embodiments, the analysis unit 404 may include:
[0138] The analysis module is used to input the target code file and the target account's requirement information into the target call relationship model for analysis, and to obtain the target requirement function file, multiple initial requirement function files, and the correlation results corresponding to the multiple initial requirement function files respectively. The correlation results are used to characterize the degree of association between the initial requirement function file and the target requirement function file.
[0139] The second determination module is used to determine the calling relationships of the generated code based on multiple initial requirement function files and multiple related results.
[0140] In some embodiments, the second determining module may include:
[0141] The sorting submodule is used to sort multiple initial requirement function files according to multiple correlation results, resulting in sorted initial requirement function files;
[0142] The selection submodule is used to select the target number of initial requirement function files from a sorted list of initial requirement function files;
[0143] Identify submodules used to determine the calling relationships of the generated code based on the target number of initial requirement function files.
[0144] In some embodiments, the determining submodule is further configured to update the call relationship graph based on the target number of initial requirement function files to obtain an updated call relationship graph; and to determine the call relationship of the generated code based on the target number of initial requirement function files and the updated call relationship graph.
[0145] In some embodiments, the device further includes:
[0146] The second acquisition unit is used to acquire the initial call relationship model of the target project, wherein the initial call relationship model is constructed through a neural network model;
[0147] The training unit is used to train the initial call relationship model using the initial code file and target constraints to obtain the target call relationship model. The target constraints are used to constrain the call relationships of function files in the initial code file.
[0148] In this device, the initial code file of the target project and the requirement information of the target account are acquired by the first acquisition unit 401. The initial code file is used to represent the execution logic of the target project. The parsing unit 402 parses the initial code file to obtain the call relationship diagram of the target function files in the initial code file. The call relationship diagram is used to represent the call relationship between the target function files and other function files in the initial code file. The compression unit 403 compresses the initial code file based on the call relationship diagram to obtain the target code file of the target project. The storage space of the target code file is smaller than that of the initial code file. The analysis unit 404 inputs the target code file and the requirement information of the target account into the target call relationship model of the target project for analysis to obtain the call relationship of the generated code. The requirement information is used to represent the requirement of the target account to generate code. The target call relationship model is constructed by a neural network model to solve the technical problem of not being able to accurately determine the call relationship of the generated code and to achieve the technical effect of accurately determining the call relationship of the generated code.
[0149] According to another aspect of the embodiments of this application, a non-volatile storage medium is also provided. The non-volatile storage medium includes a stored program, wherein, during program execution, the device where the non-volatile storage medium is located is controlled to execute any method for determining the call relationship of generated code.
[0150] The aforementioned storage medium is used to store program instructions for the following functions, which, when invoked by at least one processor, implement the following functions:
[0151] Obtain the initial code file of the target project and the requirement information of the target account. The initial code file is used to represent the execution logic of the target project.
[0152] The initial code file is parsed to obtain the call relationship graph of the target function file in the initial code file. The call relationship graph is used to represent the call relationship between the target function file and the function files other than the target function file in the initial code file.
[0153] Based on the call relationship graph, the initial code file is compressed to obtain the target code file of the target project. The storage space of the target code file is smaller than that of the initial code file.
[0154] The target code file and the target account's requirement information are input into the target project's target call relationship model for analysis to obtain the call relationship of the generated code. The requirement information is used to characterize the target account's requirement for generating code, and the target call relationship model is constructed using a neural network model.
[0155] In some embodiments, the storage medium described above may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. More specific examples of the storage medium described above include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0156] In an exemplary embodiment of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the method for determining the call relationship of any of the above-described code generation methods.
[0157] Optionally, when executed by a processor, the computer program may perform the following steps:
[0158] Obtain the initial code file of the target project and the requirement information of the target account. The initial code file is used to represent the execution logic of the target project.
[0159] The initial code file is parsed to obtain the call relationship graph of the target function file in the initial code file. The call relationship graph is used to represent the call relationship between the target function file and the function files other than the target function file in the initial code file.
[0160] Based on the call relationship graph, the initial code file is compressed to obtain the target code file of the target project. The storage space of the target code file is smaller than that of the initial code file.
[0161] The target code file and the target account's requirement information are input into the target project's target call relationship model for analysis to obtain the call relationship of the generated code. The requirement information is used to characterize the target account's requirement for generating code. The target call relationship model is constructed through a neural network model.
[0162] An electronic device is provided according to an embodiment of this application. The electronic device includes: at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to execute any of the above-described methods for determining the call relationship of the generated code.
[0163] In some embodiments, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0164] Figure 5 is a schematic diagram of an example electronic device for implementing embodiments of this application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the application described and / or claimed herein.
[0165] As shown in Figure 5, device 500 includes a computing unit 501, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 502 or a computer program loaded from storage unit 508 into random access memory (RAM) 503. RAM 503 can also store various programs and data required for the operation of device 500. The computing unit 501, ROM 502, and RAM 503 are interconnected via bus 504. Input / output (I / O) interface 505 is also connected to bus 504.
[0166] Multiple components in device 500 are connected to I / O interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of monitors, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0167] The computing unit 501 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as the method for processing chained data. For example, in some embodiments, the method for processing chained data may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by the computing unit 501, one or more steps of the method for processing chained data described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform a method for processing call chain data by any other suitable means (e.g., by means of firmware).
[0168] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0169] The program code used to implement the methods of this application may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0170] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0171] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0172] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0173] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0174] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0175] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0176] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0177] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0178] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0179] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0180] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for determining call relationships in generated code, comprising: In response to the acquisition command, the initial code file of the target project and the requirement information of the target account are acquired, wherein the initial code file is used to characterize the execution logic of the target project; The initial code file is parsed by a parser to obtain a call relationship graph of the target function file in the initial code file. The call relationship graph is used to represent the call relationship between the target function file and other function files in the initial code file. Based on the call relationship graph, the initial code file is compressed to obtain the target code file of the target project, wherein the storage space of the target code file is smaller than the storage space of the initial code file; The call relationship analysis model of the target project is invoked, and the requirement information of the target code file and the target account is used as the input of the target call relationship model of the target project to obtain the call relationship of the generated code. The requirement information is used to characterize the requirement of the target account to generate code. The target call relationship model is constructed through a neural network model.
2. The method according to claim 1, wherein, Based on the call relationship graph, the initial code file is compressed to obtain the target code file of the target project, including: Based on the call relationship graph, multiple first function files and multiple second function files of the target function file are determined, wherein the first function files are function files that have called the target function file, and the second function files are function files that have been called by the target function file; The first function file is compressed to obtain a compressed first function file, and the second function file is compressed to obtain a compressed second function file; The target code file is generated based on the compressed first function file and the compressed second function file.
3. The method according to claim 1, wherein, The target code file and target account requirements are input into the target project's target call relationship model for analysis to obtain the call relationship of the generated code, including: The target code file and the target account's requirement information are input into the target call relationship model for analysis, resulting in a target requirement function file, multiple initial requirement function files, and correlation results corresponding to the multiple initial requirement function files. The correlation results are used to characterize the degree of association between the initial requirement function file and the target requirement function file. Based on multiple initial requirement function files and multiple correlation results, the calling relationships of the generated code are determined.
4. The method according to claim 3, wherein, Based on multiple initial requirement function files and multiple correlation results, the calling relationships of the generated code are determined, including: Based on the multiple correlation results, the multiple initial requirement function files are sorted to obtain the sorted multiple initial requirement function files; Select a target number of the initial requirement function files from the sorted plurality of initial requirement function files; Based on the target number of initial requirement function files, the calling relationships of the generated code are determined.
5. The method according to claim 4, wherein, Based on the target number of initial requirement function files, the calling relationships of the generated code are determined, including: Based on the target number of initial requirement function files, the call relationship graph is updated to obtain the updated call relationship graph; Based on the target number of initial requirement function files and the updated call relationship graph, the call relationship of the generated code is determined.
6. The method according to claim 5, wherein, Based on the target number of initial requirement function files, the call relationship graph is updated to obtain the updated call relationship graph, including: Obtain the call relationship graph and the initial requirement function file; The initial requirement function file is restored to the call relationship graph, and the associated files corresponding to the initial requirement function file are determined through the call relationship graph; Select an associated file whose association with the initial requirement function file meets the preset conditions as a supplement to expand the call relationship graph, and use the expanded call relationship graph as the updated call relationship graph.
7. The method according to any one of claims 1 to 6, wherein, The method further includes: Obtain the initial call relationship model of the target project, wherein the initial call relationship model is constructed through the neural network model; Using the initial code file and target constraints, the initial call relationship model is trained to obtain the target call relationship model, wherein the target constraints are used to constrain the call relationship of function files in the initial code file.
8. The method according to claim 7, wherein, The constraints are obtained through a first loss function and a second loss function, wherein the first loss function is used to characterize the difference between the accuracy of the predicted call relationship and the accuracy of the actual call relationship, and the second loss function is used to characterize the difference between the legality of the predicted call relationship and the legality of the actual call relationship.
9. The method according to claim 8, wherein, The first loss function and the second loss function are expressed by the following formulas: Where J is used to characterize the first loss function or the second loss function, p(x) i ) is used to characterize the prediction result of the model, q(x) i ) is used to characterize the actual result, μ is used to represent the penalty coefficient, and φ is used to represent the number of files that did not select the required call relationship.
10. A device for determining the call relationship of generated code, comprising: The first acquisition unit is configured to, in response to an acquisition instruction, acquire the initial code file of the target project and the requirement information of the target account, wherein the initial code file is used to characterize the execution logic of the target project; The parsing unit is used to parse the initial code file through a parser to obtain a call relationship graph of the target function file in the initial code file, wherein the call relationship graph is used to represent the call relationship between the target function file and other function files in the initial code file besides the target function file; A compression unit is used to compress the initial code file based on the call relationship graph to obtain the target code file of the target project, wherein the storage space of the target code file is smaller than the storage space of the initial code file; The analysis unit is used to input the target code file and the target account's requirement information into the target project's target call relationship model for analysis, and obtain the call relationship of the generated code. The requirement information is used to characterize the target account's requirement for generating code, and the target call relationship model is used to construct it through a neural network model.
11. A computer-readable storage medium comprising a stored executable program, wherein, When the executable program is executed, it controls the device containing the storage medium to perform the method described in any one of claims 1 to 9.
12. An electronic device, comprising: processor; A memory storing instructions executable by the processor; The electronic device is also equipped with a target call relationship model corresponding to the target project; The processor is configured to execute the instructions to implement the method as described in any one of claims 1 to 9.
13. A computer program product comprising computer instructions that, when executed by a processor, implement the method of any one of claims 1 to 9.