Code generation method and device, equipment and storage medium

By obtaining the content information in the system analysis document and using the large language model to filter and change the code base, the problem of insufficient scalability of code generation methods in large-scale engineering projects is solved, the efficiency and quality of code development are improved, and complexity is achieved Flexible response to demands.

CN119271211APending Publication Date: 2025-01-07ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411486377.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

In large-scale engineering projects, existing code generation methods are difficult to adapt to complex project structures and complex dependencies of large files due to insufficient scalability and poor adaptability, which makes it difficult to improve development efficiency and quality.

Method used

By obtaining the content information in the system analysis document, using multimodal and text large language models to filter and change the code files in the code base, generate target codes that meet the needs, realize warehouse-level context query and flexibly respond to demand changes.

Benefits of technology

The efficiency and quality of code development are improved, and the generated code is more in line with actual needs, and can flexibly respond to changes in demand and adapt to the complexity of large-scale engineering projects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271211A_ABST
    Figure CN119271211A_ABST
Patent Text Reader

Abstract

One or more embodiments of the invention provide a code generation method and device, equipment and a storage medium. The method comprises the following steps: acquiring content information related to code generation in a system analysis document; obtaining a set number of code files with the highest relevancy from a code library platform according to the content information; filtering the set number of code files by utilizing a text large language model to obtain code files to be processed; and changing the to-be-processed code file according to the content information to obtain a target code. According to the method, related code files are globally retrieved on a code library platform firstly, then a text large language model is used for filtering, context query of a warehouse level can be achieved, and the code files highly related to development requirements are obtained; the filtered code file is changed according to the system analysis document, the generated code better meets the actual requirement and can flexibly cope with the change of the requirement, and the code quality is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of computer technology, and in particular, to a code generation method, apparatus, device, and storage medium. Background Art

[0002] With the development of software engineering, code generation technology has become an important means to improve the efficiency and quality of software development. Existing code generation methods mainly rely on users to configure automation tools, including defining rules, templates, parameters and constraints for code generation, and guiding the code generation process by inputting data such as business logic description, database model, API definition, and user interface design.

[0003] However, in large-scale engineering projects, the code base may contain a huge number of files and complex dependencies. Existing automation tools are difficult to adapt to such large-scale and complex project structures due to their insufficient scalability and poor adaptability. Summary of the invention

[0004] In view of this, one or more embodiments of this specification provide a code generation solution to improve the efficiency and quality of complex requirement code development in large projects.

[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:

[0006] According to a first aspect of one or more embodiments of this specification, a code generation method is proposed, including:

[0007] Obtain content information related to code generation in system analysis documents;

[0008] Acquire a set number of code files with the highest relevance from the code library platform according to the content information;

[0009] Using a text large language model to filter the set number of code files to obtain code files to be processed;

[0010] The code file to be processed is changed according to the content information to obtain the target code.

[0011] In some embodiments, obtaining content information related to code generation in the system analysis document includes:

[0012] Parsing the image in the system analysis document using a multimodal large language model to obtain a parsing result of the image;

[0013] The text content and the image analysis results contained in the system analysis document are input into the text large language model to obtain content information related to code generation.

[0014] In some embodiments, the using of a multimodal large language model to parse an image in the system analysis document to obtain a parsing result of the image includes:

[0015] Performing optical character recognition on the image in the system analysis document to obtain a text recognition result;

[0016] The image and the text recognition result of the image are input into a multimodal large language model to obtain a parsing result of the image.

[0017] In some embodiments, the filtering of the set number of code files using the text large language model to obtain the code files to be processed includes:

[0018] Obtaining context information according to the content information and the set number of code files;

[0019] The context information is concatenated with the original prompt information, and the concatenated result is input into the text large language model, so that the text large language model outputs a code file to be processed.

[0020] In some embodiments, the step of changing the code to be processed according to the content information to obtain the target code includes:

[0021] Determining a plurality of code files to be changed from the code to be processed according to the content information;

[0022] Generate a single file change plan for each code file to be changed using the text large language model;

[0023] Modifying the code file to be changed according to the single file change plan to obtain a changed code;

[0024] The target code is obtained according to the changed codes of each code file to be changed.

[0025] In some embodiments, determining a plurality of code files to be changed from the processed code according to the content information includes:

[0026] Generate a global change plan for the code to be processed using the text large language model according to the code to be processed and the content information;

[0027] The global change plan is processed using the text large language model to generate a list of code files to be changed, where the list of code files to be changed is used to indicate multiple code files to be changed.

[0028] In some embodiments, the method further includes: uploading the target code to a new branch of the code library platform.

[0029] According to a second aspect of one or more embodiments of this specification, a code generation device is provided, including:

[0030] An acquisition unit, used for acquiring content information related to code generation in a system analysis document;

[0031] A retrieval unit, configured to obtain a set number of code files with the highest relevance from a code library platform according to the content information;

[0032] A filtering unit, used for filtering the set number of code files using a text large language model to obtain code files to be processed;

[0033] A changing unit is used to change the code file to be processed according to the content information to obtain a target code.

[0034] In some embodiments, the acquisition unit is specifically used to:

[0035] Parsing the image in the system analysis document using a multimodal large language model to obtain a parsing result of the image;

[0036] The text content and the image analysis results contained in the system analysis document are input into the text large language model to obtain content information related to code generation.

[0037] In some embodiments, when the acquisition unit is used to parse the image in the system analysis document using a multimodal large language model to obtain the parsing result of the image, it is specifically used to:

[0038] Performing optical character recognition on the image in the system analysis document to obtain a text recognition result;

[0039] The image and the text recognition result of the image are input into a multimodal large language model to obtain a parsing result of the image.

[0040] In some embodiments, the filtering unit is specifically used for:

[0041] Obtaining context information according to the content information and the set number of code files;

[0042] The context information is concatenated with the original prompt information, and the concatenated result is input into the text large language model, so that the text large language model outputs a code file to be processed.

[0043] In some embodiments, the changing unit is specifically used to:

[0044] Determining a plurality of code files to be changed from the processed code according to the content information;

[0045] Generate a single file change plan for each code file to be changed using the text large language model;

[0046] Modifying the code file to be changed according to the single file change plan to obtain a changed code;

[0047] The target code is obtained according to the changed codes of each code file to be changed.

[0048] In some embodiments, when the changing unit is used to determine a plurality of code files to be changed from the processed code according to the content information, it is specifically used to:

[0049] Generate a global change plan for the code to be processed using the text large language model according to the code to be processed and the content information;

[0050] The global change plan is processed using the text large language model to generate a list of code files to be changed, where the list of code files to be changed is used to indicate multiple code files to be changed.

[0051] In some embodiments, the device further includes an uploading unit, configured to upload the target code to a new branch of the code library platform.

[0052] According to a third aspect of one or more embodiments of this specification, an electronic device is provided, including:

[0053] processor;

[0054] a memory for storing processor-executable instructions;

[0055] The processor implements the steps of the method proposed in the above embodiment by running the executable instructions.

[0056] According to a fourth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method provided in the above embodiment are implemented.

[0057] According to a fifth aspect of one or more embodiments of the present specification, a computer program product is proposed, comprising a computer program / instruction, which implements the steps of the method proposed in the above embodiment when executed by a processor.

[0058] The code generation method proposed in the embodiment of this specification can achieve warehouse-level context query and obtain code files that are highly relevant to development needs by first globally searching the relevant code files on the code library platform and then filtering them using a text large language model; the filtered code files are changed according to the system analysis document, and the generated code is more in line with actual requirements, and can flexibly respond to changes in requirements, thereby improving code quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is an application scenario diagram of a code generation method provided by an exemplary embodiment.

[0060] Figure 2 It is a flowchart of a code generation method provided by an exemplary embodiment.

[0061] Figure 3 is a flowchart of a code changing method provided by an exemplary embodiment.

[0062] Figure 4 is a flowchart of another code generation method provided by an exemplary embodiment.

[0063] Figure 5 This is a multi-terminal interaction diagram of a code generation method provided by an exemplary embodiment.

[0064] Figure 6 It is a block diagram of a code generating device provided by an exemplary embodiment.

[0065] Figure 7 It is a structural schematic diagram of a device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0066] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0067] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.

[0068] To help understand this specification, technical terms related to this specification are first introduced.

[0069] Large Language Model (LLM): A large-scale neural network model in the field of natural language processing (NLP). It usually consists of hundreds of millions to billions of parameters. It learns complex patterns and structures by pre-training on large amounts of text data and can understand and generate complex language data.

[0070] Multimodal Large Language Models: Neural network models that combine multiple types of input data and are able to process and analyze information from different modalities (e.g., text, images, sound, video, etc.). These models can more fully understand and generate information by learning the associations and interactions between different modalities.

[0071] Text Large Language Models: Large-scale neural network models that focus on processing and generating text play an important role in the field of Natural Language Processing (NLP) because they can understand and generate natural language text and thus perform well in various NLP tasks.

[0072] Context: The context in a large language model refers to the input information and its related background that the large language model relies on when processing and generating text, in order to understand and generate more accurate and coherent responses.

[0073] Change plan: A detailed plan for modifying or extending existing code, design, or architecture to ensure that the change process is orderly, controllable, and does not introduce new problems.

[0074] Prompt: refers to the input text provided to the model to guide and generate corresponding output content.

[0075] A code generation method provided in an embodiment of the present application is described below.

[0076] like Figure 1 The figure shows an application scenario diagram of a code generation method in an embodiment of the present application. Figure 1The code base platform 10 includes: a code base platform 10, a document library 20, and a service terminal 30. The code base platform 10 is a service platform for storing, managing, sharing, and collaboratively developing code. The code base platform 10 hosts its services through a server environment, which can be physical servers, virtual servers, or instances of cloud service providers. The server is used to store data of all code bases.

[0077] The document library 20 is a system for storing, managing and sharing system analysis documents of a project. The document library 20 can be established on a server within the company or on a cloud storage service.

[0078] The service terminal 30 is a device with network connection, data processing and user interaction capabilities, which can be a server device or a client device. The service terminal 30 can interact with the code library platform 10 and the document library 20, including obtaining data in the code library from the code library platform 10, uploading the generated code to the code library platform 20, and obtaining system analysis documents from the document library 20, and uploading new or modified system analysis documents to the document library 20. Among them, the service terminal 30 can interact with the code library platform 10 through the client tools of the installed code library platform 10. For example, when the code library platform 10 is GitHub, the code can be copied or pulled from the GitHub server through the Git tool on the client terminal. The service terminal 30 can interact with the document library 20 through the API interface.

[0079] The description in this application only details a single code base platform 10, document library 20, and service terminal 30, but those skilled in the art should understand that the illustrated code base platform 10, document library 20, and service terminal 30 are intended to represent the operations of the code base platform 10, document library 20, and service terminal 30 involved in the technical solution of this application, and do not imply that the number, type, or location of the code base platform 10, document library 20, and service terminal 30 are limited. It should be noted that if additional modules are added to the illustrated environment or individual modules are removed therefrom, the underlying concepts of the example embodiments of this application will not be changed.

[0080] It should be noted that the code generation method proposed in this application is not only applicable to Figure 1 The application scenario shown is also applicable to any device that requires code generation.

[0081] Figure 2 A flowchart of a code generation method provided by an embodiment of the present application is shown. Figure 1 The service terminal in the Figure 2 As shown, the method includes:

[0082] Step 201, obtaining content information related to code generation in a system analysis document.

[0083] A system analysis document is a document that describes the system requirements, functions, architecture, and design in detail. It is used to guide system development and ensure that all parties in the project agree on the system goals and implementation methods. The system analysis document is a comprehensive document that contains content directly related to code development as well as supporting information related to project management and decision making.

[0084] In the system analysis document, the parts directly related to code development usually include functional requirements, data models, interface definitions, business processes, system architecture, design constraints, performance indicators and security measures, etc. These contents provide clear guidance and specifications for code development; those not related to code development may include demand background, stability analysis, schedule, etc., which provide background information, risk assessment, time management and other support for the project, which helps project management and decision making.

[0085] In this step, for the system analysis file of the acquired project development, the content information related to code generation is obtained to carry out the processing in the subsequent steps.

[0086] Step 202: Acquire a set number of code files with the highest relevance from a code library platform according to the content information.

[0087] On the code base platform, a search engine, such as Elasticsearch (ES), can be used to search for code files in the source code and comments in the code base that match the content information related to code generation in the system development documents, such as obtaining the top K related code files (K is the above-set number). These files include both code snippets and complete code files.

[0088] In one example, based on the BM25 algorithm, by calculating the correlation score between the query term and the code document, factors such as term frequency, document length, and inverse document frequency are comprehensively considered to adjust and optimize the retrieval effect, thereby obtaining a set number of code documents with the highest matching degree.

[0089] Step 203: Filter the set number of code files using the text large language model to obtain code files to be processed.

[0090] Since the number of code files retrieved in step 202 is fixed, it is possible that not all of the returned code files are related to the content information of code development, or the relevance is not high. Assuming that the set number is 10, the number of code files obtained in step 202 is 10. If the number of actually related code files is less than 10, 10 code files will still be returned as the search results.

[0091] For the set number of code files retrieved in step 202, the text large language model can be used to filter to obtain code files with relevance that meets the requirements, and filter out irrelevant or insufficiently relevant code files. After filtering, the number of code files obtained is no longer limited. If there is no code file with relevance that meets the requirements in the code library file, the final filtering result is empty. In the embodiment of the present disclosure, the code file can be converted into a format that can be processed by the text large language model before processing the code file.

[0092] For projects in specific fields or specific businesses, you can also use some labeled code data to fine-tune the text language model so that the language model can learn knowledge in specific fields and better adapt to specific types of code files.

[0093] Step 204: modify the code file to be processed according to the content information to obtain a target code.

[0094] Based on the content information, the functions and performance requirements that the code needs to implement can be determined, so that changes can be made to the code file obtained in step 203, including adding new code segments to implement new functions, modifying the existing code logic to optimize existing functions or fix bugs, and deleting no longer needed code, etc. The obtained target code is a code that meets the requirements of the system analysis document and can implement the functions required for project development.

[0095] In the disclosed embodiment, by first globally searching for relevant code files on the code library platform and then filtering them using a text large language model, a warehouse-level context query can be performed, and code files that are highly relevant to development requirements can be obtained; the filtered code files are changed according to the system analysis document, and the generated code is more in line with actual requirements, and can flexibly respond to changes in requirements, thereby improving code quality.

[0096] In some embodiments, the document library is an online document library. A user can input the URL of the system analysis document to be obtained so that the service terminal can obtain the system analysis document according to the URL. The document library can also be a local document library, such as an internal company document library located on a company server, or a personal document library on a local computer or mobile device. In this case, the required system analysis document can be found in the document browser of the local document library according to the directory structure, or the required system analysis document can be found using the search function.

[0097] The system analysis document can be in Word, HTML, PDF and other formats. The system analysis document can include various types of information, including text content, tables, images, code examples, etc.

[0098] In some embodiments, content information related to code generation in the system analysis document may be obtained in the following manner.

[0099] For images included in the system analysis document, a multimodal large language model may be used to parse the images in the system analysis document to obtain a parsing result of the image. The parsing result may include a text description summarizing the main content or scene of the image and key information in the image.

[0100] For the contents other than images in the system analysis document, the text contents contained in the system analysis document can be obtained by converting into a plain text format.

[0101] Next, the text content and the parsing results of the images contained in the system analysis document are input into the text large language model to obtain content information related to code generation, which may include code descriptions, functional requirements, design suggestions, etc.

[0102] In the disclosed embodiment, the content of the image in the document is first analyzed by a multimodal large language model parsing system, and then the content information related to code generation in the text content and the image content is extracted by a text large language model. This allows the content information related to code generation to be understood and generated quickly and comprehensively, and the generated content has high quality and relevance.

[0103] In some embodiments, the analysis result of the image may be obtained in the following manner.

[0104] First, optical character recognition (OCR) is performed on the image in the system analysis document to extract character information in the image and convert it into text format to obtain a text recognition result. After that, the image and the text recognition result of the image are input into the multimodal large language model to obtain the image analysis result.

[0105] Directly inputting the image into the multimodal large language model for parsing uses the image-to-text function of the large model. Although the model can understand the behavior of the image, it is not accurate in character recognition. The disclosed embodiment first performs OCR on the image to obtain the text content therein, and then inputs the text content and the image into the multimodal large language model together, using the image-to-text function of the large model. In this case, the large model not only receives the visual information of the image, but also receives the text content contained in the image, which helps the large model to understand the meaning of the image more comprehensively and obtain more accurate parsing results.

[0106] In some embodiments, the set number of code files obtained in step 202 may be filtered using the following method.

[0107] First, context information is obtained according to the content information and the set number of code files; then, the context information is spliced ​​with the original prompt information, and the spliced ​​result is input into the text large language model to guide the text large language model to perform secondary filtering on the set number of code files according to the content information, and output the filtering result as the code file to be processed.

[0108] The original prompt information may be a requirement for the large model, which is used to guide the model to perform specific tasks, such as information retrieval, data screening, content generation, etc. For example, the original prompt information may be: identifying a code file that is consistent with the requirements and functions indicated by the content information of the system analysis document.

[0109] In the disclosed embodiment, by splicing the relevant code files retrieved before requesting the large model into the prompt, the large model can perform warehouse-level contextual queries and obtain code files that are highly relevant to development requirements, thereby enabling code development with complex requirements in large and complex engineering projects.

[0110] In some embodiments, the Figure 3 Change the code according to the flowchart shown in the figure. Figure 3 As shown, the method includes:

[0111] Step 301: Determine a plurality of code files to be changed from the processed code according to the content information.

[0112] For the code to be processed obtained in step 203 and having a relevance to the content information that meets the requirement, a code file to be changed is determined, that is, a plurality of code files to be changed are determined.

[0113] In one example, the global change plan of the code to be processed can be first generated using the text large language model based on the code to be processed and the content information (which may include new requirements, function descriptions, bug fix instructions, etc.). The global change plan is a high-level guidance document that summarizes all changes that need to be made, including but not limited to the addition of new functions, code refactoring, performance optimization, bug fixes, etc. Afterwards, the global change plan is processed using the text large language model, that is, all code files that need to be modified are identified, and a list of code files to be changed is generated. The list of code files to be changed is used to indicate multiple code files to be changed, which can be used as a basis for subsequent change operations.

[0114] Step 302: Generate a single file change plan for each code file to be changed using the text large language model.

[0115] A detailed single-file change plan is generated for each code file to be changed determined in step 301. These plans specify what specific code changes need to be made in each code file, such as adding new functional codes, modifying existing codes, deleting useless parts, etc.

[0116] Step 303: Change the code file to be changed according to the single file change plan to obtain a changed code.

[0117] Specifically, actual modifications are made to each code file according to the single file change plan, such as adding, modifying or deleting code.

[0118] In one example, each code file in the list of code files to be changed may be changed one by one.

[0119] In another example, you can also unit test the changed code to ensure that the changes did not introduce new errors.

[0120] Step 304: Obtain target code according to the changed codes of each code file to be changed.

[0121] Integrate all the changed code to build a new code version, the target code.

[0122] In one example, the changed code can be peer reviewed to ensure code quality and compliance with coding standards. And, after all code files are changed, integration testing can be performed to verify the functionality and performance of the entire system.

[0123] In the disclosed embodiment, the code files that need to be changed are first determined from the pending codes whose relevance to the content information meets the requirements, and a single-file change plan is generated for each code file to be changed using a text large language model. Compared with changing all code files according to a global change plan, the problem of a single output being too long and being staged is avoided, and the code quality is also improved.

[0124] After confirming that all codes have been changed and passed the necessary tests (such as unit tests, integration tests, etc.), the target code can be submitted to the code library platform. Specifically, a new branch can be created on the code library platform to store the changed target code. This method can avoid making changes directly on the main branch and maintain the stability of the main branch.

[0125] Figure 4 FIG. 1 is a flowchart of a code generation method provided by an exemplary embodiment. Figure 4 As shown, the method includes:

[0126] Step 401: Obtain system analysis documents.

[0127] If the document library is an online document library, the URL of the system analysis document to be obtained can be entered so that the service terminal can obtain the system analysis document according to the URL; if the document library is a local document library, the required system analysis document can be found in the document browser of the local document library according to the directory structure, or the required system analysis document can be found using the search function.

[0128] Step 402: Perform OCR on the image in the system analysis document to obtain a text recognition result.

[0129] Step 403: Input the image and the text recognition result of the image into the multimodal LLM to obtain the analysis result of the image.

[0130] Step 404: Input the text content and image parsing results in the system analysis document into the text LLM to obtain content information related to code generation.

[0131] The above steps 401 to 404 can be summarized as the processing of the system analysis document. Through the above processing method, the multimodal LLM receives the visual information of the image and the text information contained therein at the same time, which can more comprehensively understand the meaning of the image and obtain more accurate analysis results. Based on such image analysis results and text content, the text LLM can obtain content information related to code generation in the system analysis document more comprehensively and accurately.

[0132] Step 405: retrieve a set number of related code files from the code library platform.

[0133] Step 406: Filter the code files using the text large language model to obtain code files to be processed.

[0134] The above steps 405 to 406 can be summarized as the extraction of code files. By first globally searching for relevant code files in the code library platform and then filtering them using text LLM, a warehouse-level context query can be performed, and code files with high relevance to development requirements can be obtained.

[0135] Step 407: Generate a global change plan using the text LLM.

[0136] Step 408: Generate a list of code files to be changed using the text LLM.

[0137] Step 409: Generate a single-file change plan using the text LLM.

[0138] The above steps 407 to 409 can be summarized as the generation of a change plan. Using the text large language model to generate a single file change plan for each code file avoids the problem of truncation of a single output due to excessive length, and also improves the code quality, compared to changing all code files according to the global change plan.

[0139] Step 410: Obtain the code file and change plan currently to be processed.

[0140] Step 411, determine whether all code files have been processed. If not, proceed to step 402 to change the code. If the processing is completed, obtain the target code by integrating all the changed codes.

[0141] Figure 5 A multi-terminal interaction diagram of a code generation method provided by an exemplary embodiment is shown. Figure 5 The service terminal in the code generation method is the execution subject. The multimodal LLM, text LLM, and OCR tools can be installed in the service terminal or in the server.

[0142] like Figure 5 As shown, the service terminal first sends a request for obtaining a system analysis document to the document library, and receives the system analysis document returned by the document library.

[0143] After receiving the system analysis document, the service terminal enters the system analysis language file processing process. First, use the OCR tool to perform OCR on the image in the system analysis document to obtain the text recognition result; next, send the image and the text recognition result of the image to the multimodal LLM, so that the multimodal LLM outputs the image analysis result; then, send the text content in the system analysis document and the image analysis result to the text LLM, so that the text LLM outputs the content information related to code generation.

[0144] Next, the service terminal uses a search tool, such as ES, to retrieve a set number of related code files on the code library platform, that is, to query the topK related code files (K is the set number); and sends the queried code files and the content information related to code development in the parsed system analysis documents to the text LLM, so as to use the text LLM to perform secondary filtering on the code files, and use the filtered results as the code files to be processed.

[0145] After that, the service terminal sends a request to generate a global change plan to the text LLM, and receives the returned global change plan; sends a request to generate a list of code files to be changed to the text LLM, and receives the list of files to be changed; sends a request to generate a single file change plan to the text LLM, and receives the single file change plan. For each single file change plan, the changes are performed one by one according to the list of files to be changed, that is, the text LLM is requested to generate text code according to the single text change plan, and the loop is executed until all the code files in the change file list are changed, and the target code is obtained.

[0146] Finally, the service terminal uploads the target code to the new branch of the code library platform, completing the code generation task.

[0147] Figure 6 FIG. 1 is a block diagram of a code generating device provided by an exemplary embodiment. Figure 6 As shown, the device includes: a code generating device, including:

[0148] An acquisition unit 601 is used to acquire content information related to code generation in a system analysis document;

[0149] A retrieval unit 602 is used to obtain a set number of code files with the highest relevance from a code library platform according to the content information;

[0150] A filtering unit 603 is used to filter the set number of code files using a text large language model to obtain code files to be processed;

[0151] The changing unit 604 is used to change the code file to be processed according to the content information to obtain the target code.

[0152] In some embodiments, the acquisition unit is specifically used to:

[0153] Parsing the image in the system analysis document using a multimodal large language model to obtain a parsing result of the image;

[0154] The text content and the image analysis results contained in the system analysis document are input into the text large language model to obtain content information related to code generation.

[0155] In some embodiments, when the acquisition unit is used to parse the image in the system analysis document using a multimodal large language model to obtain the parsing result of the image, it is specifically used to:

[0156] Performing optical character recognition on the image in the system analysis document to obtain a text recognition result;

[0157] The image and the text recognition result of the image are input into a multimodal large language model to obtain a parsing result of the image.

[0158] In some embodiments, the filtering unit is specifically used for:

[0159] Obtaining context information according to the content information and the set number of code files;

[0160] The context information is concatenated with the original prompt information, and the concatenated result is input into the text large language model, so that the text large language model outputs a code file to be processed.

[0161] In some embodiments, the changing unit is specifically used to:

[0162] Determining a plurality of code files to be changed from the processed code according to the content information;

[0163] Generate a single file change plan for each code file to be changed using the text large language model;

[0164] Modifying the code file to be changed according to the single file change plan to obtain a changed code;

[0165] The target code is obtained according to the changed codes of each code file to be changed.

[0166] In some embodiments, when the changing unit is used to determine a plurality of code files to be changed from the processed code according to the content information, it is specifically used to:

[0167] Generate a global change plan for the code to be processed using the text large language model according to the code to be processed and the content information;

[0168] The global change plan is processed using the text large language model to generate a list of code files to be changed, where the list of code files to be changed is used to indicate multiple code files to be changed.

[0169] In some embodiments, the device further includes an uploading unit, configured to upload the target code to a new branch of the code library platform.

[0170] Figure 7 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 7 At the hardware level, the device includes a processor 702, an internal bus 704, a network interface 706, a memory 708, and a non-volatile memory 710, and may also include hardware required for other services. One or more embodiments of this specification may be implemented based on software, such as the processor 702 reading the corresponding computer program from the non-volatile memory 710 into the memory 708 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0171] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.

[0172] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0173] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0174] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0175] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0176] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0177] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0178] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0179] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A code generation method, comprising: Obtain content information related to code generation in system analysis documents; Acquire a set number of code files with the highest relevance from the code library platform according to the content information; Using a text large language model to filter the set number of code files to obtain code files to be processed; The code file to be processed is changed according to the content information to obtain the target code.

2. According to the method of claim 1, the step of obtaining content information related to code generation in the system analysis document comprises: Parsing the image in the system analysis document using a multimodal large language model to obtain a parsing result of the image; The text content and the image analysis results contained in the system analysis document are input into the text large language model to obtain content information related to code generation.

3. According to the method of claim 2, the step of parsing the image in the system analysis document using a multimodal large language model to obtain a parsing result of the image comprises: Performing optical character recognition on the image in the system analysis document to obtain a text recognition result; The image and the text recognition result of the image are input into a multimodal large language model to obtain a parsing result of the image.

4. According to the method of claim 1, the step of filtering the set number of code files using a text large language model to obtain code files to be processed comprises: Obtaining context information according to the content information and the set number of code files; The context information is concatenated with the original prompt information, and the concatenated result is input into the text large language model, so that the text large language model outputs a code file to be processed.

5. The method according to claim 1, wherein the code to be processed is changed according to the content information to obtain the target code, comprising: Determining a plurality of code files to be changed from the code to be processed according to the content information; Generate a single file change plan for each code file to be changed using the text large language model; Modifying the code file to be changed according to the single file change plan to obtain a changed code; The target code is obtained according to the changed codes of each code file to be changed.

6. The method according to claim 5, wherein determining a plurality of code files to be changed from the processed code according to the content information comprises: Generate a global change plan for the code to be processed using the text large language model according to the code to be processed and the content information; The global change plan is processed using the text large language model to generate a list of code files to be changed, where the list of code files to be changed is used to indicate multiple code files to be changed.

7. The method according to claim 1, further comprising: The target code is uploaded to a new branch of the code library platform.

8. A code generating device, comprising: An acquisition unit, used for acquiring content information related to code generation in a system analysis document; A retrieval unit, configured to obtain a set number of code files with the highest relevance from a code library platform according to the content information; A filtering unit, used for filtering the set number of code files using a text large language model to obtain code files to be processed; A changing unit is used to change the code file to be processed according to the content information to obtain a target code.

9. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 7 by running the executable instructions.

10. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Code generation method, device and system

    CN120085871A

  • A method, apparatus and system for code generation

    CN120085871B