Question and answer processing method and device based on large model, electronic equipment and storage medium
By retrieving code snippets in the code snippet database and graph database and generating answers using large language models, the problem that is difficult to obtain the answers to R&D questions in the existing technology is solved, and efficient and accurate question-and-answer processing is achieved.
Patent Information
- Application Number
- CN202411709204.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-04-08
AI Technical Summary
The existing technology is difficult to obtain the answers to R&D personnel's questions from the code file library efficiently and accurately, resulting in inefficient R&D.
A big model-based question-and-answer processing method is adopted to retrieve target code snippets and related code snippets from pre-created code snippet databases and graph databases, and to generate answers to questions using large language models.
It realizes efficient and accurate generation of answers to questions, and improves the efficiency of R&D personnel in obtaining knowledge from code snippet databases.
Smart Images

Figure CN119782590A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, specifically to the field of artificial intelligence technology such as machine learning, knowledge graphs and natural language processing, and more particularly to a question-answering processing method, device, electronic device and storage medium based on a large model. Background Art
[0002] As R&D technology matures, various R&D companies have accumulated more and more code files.
[0003] All code files of each company can be collected together to form a code file library. R&D personnel within the company can refer to each code file in the code file library to learn code development knowledge and improve R&D efficiency. Summary of the invention
[0004] The present invention provides a question-answering processing method, device, electronic device and storage medium based on a large model.
[0005] According to one aspect of the present disclosure, a question-answering processing method based on a large model is provided, the method comprising:
[0006] Based on the user's question, a search is performed from a pre-created code snippet database to obtain a target code snippet; the code snippet database includes a plurality of code snippets;
[0007] Based on the target code snippet, refer to a pre-created graph database to obtain at least one related code snippet; the graph database includes relationships between different code snippets;
[0008] Based on the target code snippet and the at least one related code snippet, an answer to the question is generated using a large language model.
[0009] According to another aspect of the present disclosure, a question-answering processing device based on a large model is provided, the device comprising:
[0010] A snippet retrieval module is used to retrieve a target code snippet from a pre-created code snippet database based on a user's question; the code snippet database includes a plurality of code snippets;
[0011] A snippet acquisition module, configured to acquire at least one related code snippet based on the target code snippet and referring to a pre-created graph database; the graph database includes relationships between different code snippets;
[0012] A generation module is used to generate an answer to the question based on the target code snippet and the at least one related code snippet using a large language model.
[0013] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any possible implementation manner and the aspects described above.
[0017] According to yet another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method of the above-mentioned aspect and any possible implementation manner.
[0018] According to yet another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the computer program implements the above-mentioned aspects and any possible implementation method.
[0019] According to the technology of the present disclosure, answers to questions can be generated efficiently and accurately.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0022] Figure 1 is a schematic diagram according to a first embodiment of the present disclosure;
[0023] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure;
[0024] Figure 3 yes Figure 2 Schematic diagram of the process flow diagram shown;
[0025] Figure 4 is a schematic diagram of the relationship mined in the embodiment of the present disclosure;
[0026] Figure 5 is a schematic diagram according to a third embodiment of the present disclosure;
[0027] Figure 6 is a schematic diagram according to a fourth embodiment of the present disclosure;
[0028] Figure 7 The block diagram is a block diagram of an electronic device for implementing the method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0030] Obviously, the described embodiments are only part of the embodiments of the present disclosure, but not all of them. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present disclosure.
[0031] It should be noted that the terminal devices involved in the embodiments of the present disclosure may include but are not limited to mobile phones, personal digital assistants (PDAs), wireless handheld devices, tablet computers and other smart devices; display devices may include but are not limited to personal computers, televisions and other devices with display functions.
[0032] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0033] In actual scenarios, based on a pre-created code file library, developers usually manually search and learn the knowledge of each code file in the code file library.
[0034] Figure 1 is a schematic diagram according to the first embodiment of the present disclosure; Figure 1 As shown, this embodiment provides a question-answering processing method based on a large model, which is used to implement question-answering processing based on a code snippet database, and specifically may include the following steps:
[0035] S101, based on the user's question, searching from a pre-created code snippet database to obtain a target code snippet; the code snippet database includes a plurality of code snippets;
[0036] S102, based on the target code snippet, refer to a pre-created graph database to obtain at least one related code snippet; the graph database includes relationships between different code snippets;
[0037] S103: Generate an answer to the question using a large language model (LLM) based on the target code snippet and at least one related code snippet.
[0038] The execution subject of the question-answering processing method based on a big model in this embodiment can be a question-answering processing device based on a big model, which can be an electronic entity or a software integrated application. The device can answer the user's questions based on the big model and refer to the code snippet database.
[0039] The code snippet database of this embodiment is a database collected at the code snippet granularity. For example, each independent code snippet in the code snippet database of this embodiment can be a function, class name, structure, class member, global variable, static variable, or comment.
[0040] In the graph database of this embodiment, each node is a code snippet, and the graph database includes the relationship between different code snippets. For example, the relationship in this embodiment may include including, being included, belonging to, being belonged to, referencing, being referenced, calling, being called, and parent-child relationship, etc. That is to say, in the graph database, if there is a relationship between two code snippets, there is an edge between the two code snippets; otherwise, there is no connection between the two code snippets.
[0041] In this embodiment, based on the target code snippet and at least one related code snippet, rich knowledge support can be provided for answering the user's question. Based on this, the large language model can generate the answer to the user's question more accurately based on the target code snippet and at least one related code snippet.
[0042] The user of this embodiment may refer to a developer. The application scenario of this embodiment may be that when a developer has questions during the development process, he or she may input the user's question into the question-answering processing device based on the big model. At this time, the user's question may be a question about development, such as how to implement the call of function A, how to define the global variable X, etc. After receiving the user's question, the question-answering processing device based on the big model may use the big language model, refer to the code snippet database and the graph database, and use the above-mentioned technical solution of this embodiment to generate the answer to the user's question and feedback to the user.
[0043] Based on the technical solution of this embodiment, R&D personnel do not need to manually check code files. By adopting the solution of this embodiment, they can provide users with accurate and efficient answers based on a code snippet library and a graph database and using a large language model.
[0044] The big model-based question-answering processing method of this embodiment can obtain the target code snippet and at least one related code snippet corresponding to the user's question based on the code snippet database and the graph database, providing rich knowledge support for answering the user's question, and then using a big language model. According to the target code snippet and at least one related code snippet, it can efficiently and accurately generate answers to questions, providing effective support for R&D personnel to acquire knowledge from the code snippet database.
[0045] Figure 2 is a schematic diagram according to a second embodiment of the present disclosure; Figure 3 yes Figure 2 The question-answering processing method based on the large model of this embodiment, in the above Figure 1 Based on the technical solutions of the embodiments shown in the figure, the technical solutions of the present disclosure are further described in more detail. Figure 2 and Figure 3 As shown, the question-answering processing method based on the large model of this embodiment may specifically include the following steps:
[0046] S201, obtaining a vector expression of the user's question;
[0047] S202, obtaining a vector expression of each code snippet in a code snippet database;
[0048] S203, based on the vector expression of the user's question and the vector expression of each code snippet, obtaining the code snippet with the highest similarity to the user's question from the code snippet database as the target code snippet;
[0049] Specifically, the similarity between the vector expression of the user's question and the vector expression of each code snippet is calculated; then the code snippet with the highest similarity is obtained as the target code snippet.
[0050] In this embodiment, the vector expression of the user's question and the vector expression of each code snippet can be obtained by using a pre-trained vector expression model.
[0051] Steps S201-S203 are as above Figure 1 An implementation of step S101 of the illustrated embodiment is a vectorized search method to obtain the target code fragment. In this method, the target code fragment can be accurately and efficiently obtained.
[0052] Steps 201-S203 correspond to Figure 3 The target code snippet obtained during the vectorized retrieval process is Figure 3 The search results in .
[0053] Optionally, in actual applications, the relevance between the user's question and each code snippet can be directly obtained based on semantics, and then the code snippet with the highest relevance can be obtained as the target code snippet. For example, keywords in the user's question can be obtained, and then based on the keywords in the user's question, the code snippet with the highest relevance can be retrieved from the code snippet database and obtained as the target code snippet.
[0054] S204, based on the target code snippet, retrieving from the graph database an identifier of at least one related code snippet having a relationship with the target code snippet;
[0055] For example, in a specific implementation, considering that the number of target code snippets is limited, in order to enrich the search results, in this embodiment, the target code snippet can be used as the search starting point, and at least one level of search can be performed in the graph database to obtain the identification of at least one related code snippet that has a relationship with the target code snippet. In this way, at least one level of search can be performed in the graph database to accurately obtain the identification of at least one related code snippet that has a relationship with the target code snippet.
[0056] Optionally, in actual operation, subject to the limitation of the tokens that can be received at the time of LLM input, a two-level or three-level search may be performed.
[0057] In other words, taking the target code snippet as the search starting point, at most 2nd degree relationships are retrieved in the graph database. When taking the target code snippet as the search starting point and retrieving the 1st degree relationship, multiple nearest neighbor nodes that have a direct relationship with the target code snippet are obtained, and then taking each nearest neighbor node as the search starting point, the 2nd degree relationship is retrieved, and multiple secondary nearest neighbor nodes that have a direct relationship with the nearest neighbor node are obtained. At this time, the 2nd degree relationship retrieval is completed.
[0058] S205. Acquire at least one related code fragment based on the identifier of at least one related code fragment;
[0059] When step S203 is implemented specifically, two situations may be included:
[0060] Scenario 1: The graph database stores not only the identifiers of each node but also the content of at least one relevant code snippet of each node. In this case, at least one relevant code snippet can be obtained from the graph database based on the identifier of the at least one relevant code snippet.
[0061] Scenario 2: The graph database only stores the identifiers of each node, but does not store the content of at least one relevant code snippet of each node. In this case, at least one relevant code snippet can be obtained from the code snippet database based on the identifier of at least one relevant code snippet.
[0062] In either case, at least one relevant code snippet can be accurately and efficiently obtained.
[0063] Steps S204-S205 are as above Figure 1 A specific implementation of step S102 of the illustrated embodiment. By adopting this method, at least one relevant code snippet can be accurately and efficiently acquired.
[0064] Steps S204-S205 correspond to Figure 3 In the process of relation retrieval in , at least one relevant code snippet is obtained, that is, the corresponding Figure 3 Relationship retrieval results in .
[0065] Optionally, in actual applications, each code snippet may be directly analyzed in the graph database to mine at least one related code snippet related to the target code snippet.
[0066] S206, acquiring, from the graph database, a relationship between the target code snippet and at least one related code snippet;
[0067] Specifically, it may include the relationship between the target code snippet and the related code snippet obtained by the first retrieval in at least one related code snippet, and the relationship between each related code snippet obtained by the first retrieval and the corresponding related code snippet obtained by the second retrieval. This step can be considered as further adding the relationship existing in at least one related code snippet to the relationship retrieval result to improve the accuracy of the answer to the generated question.
[0068] In this embodiment, the type of relationship depends on the specific scenario. For example, in the unit test scenario, a call relationship is required. However, in the function interpretation scenario, a parent-child relationship is required. In actual applications, specific scenarios are handled specifically, and examples are not given here one by one. In short, all relationships existing in the target code snippet and at least one related code snippet can be obtained from the graph database.
[0069] S207 : Generate an answer to the question using LLM based on the target code snippet, the at least one related code snippet, and the relationship between the target code snippet and the at least one related code snippet.
[0070] Optionally, in this embodiment, subject to the constraint of the maximum token that LLM can receive, if the length of the target code fragment, at least one related code fragment, and the length of the relationship between the target code fragment and at least one related code fragment is greater than the maximum token, the related code fragments and corresponding relationships of the second-degree relationship can be preferentially pruned to ensure the normal operation of LLM.
[0071] In this embodiment, not only the target code snippet and at least one related code snippet are input to the LLM, but also the relationship between the target code snippet and at least one related code snippet. Combining the relationship can make the LLM perform better and generate more accurate answers to questions.
[0072] In this embodiment, by providing the LLM model with the relationship between the target code snippet and at least one related code snippet, richer knowledge support can be provided to the LLM, so that the LLM can generate answers to questions more accurately and efficiently.
[0073] Optionally, before step S202 of this embodiment, the following steps may also be included:
[0074] (1) Collect multiple code documents;
[0075] (2) For each code document, split it according to function, class name, structure, class member, global variable, static variable or comment to obtain multiple code snippets;
[0076] (3) Based on multiple code snippets in each code document, a code snippet database is constructed.
[0077] In this embodiment, by segmenting the code document according to function, class name, structure, class member, global variable, static variable or comment, each code snippet can be made smaller in granularity and can be accurately located when being searched. In this way, a code snippet database can be constructed efficiently and accurately.
[0078] Optionally, before step S204 of this embodiment, the following steps may also be included:
[0079] (a) For each code document, mining the relationship between different code snippets in the code document;
[0080] For example, the relationship between the mined code fragments Segment1 and Segment2 can be expressed as: Segment1->Relation->Segment2.
[0081] In this embodiment, a pre-trained relationship mining model may be used to mine the relationships between different code snippets.
[0082] For example, the relationship in this embodiment may include a calling relationship, a parent-child relationship, etc. A calling relationship may include: function A calls function B, and function A uses global variables. A parent-child relationship may include: a class and its member functions, a class and its member variables, and a function and its local variables.
[0083] For example, Figure 4 Schematic diagram of the relationship mined in the embodiment of the present disclosure. Figure 4 As shown, the following relationships can be mined: function A->call->function B, function B->called->function A, function A->parent->class C, class C->child->function A, class member member->called->function A, function A->call->class member member, class member member->parent->class C, and class C->child->class member member, etc.
[0084] (b) Build a graph database based on the relationship between different code snippets in each code document.
[0085] Specifically, in the constructed graph database, each code snippet is used as a node, and the relationship between different code snippets is used as an edge between different code snippets. The graph database created based on the above method can be considered as a knowledge graph about code snippets. Using this method, the graph database can be constructed accurately and efficiently.
[0086] Optionally, in this embodiment, the graph database may store the content of the code snippet of each node, or may only store the identifier of each node without storing the content of the code snippet of each node. Specifically, the content of the code snippet is obtained from the code snippet database.
[0087] For example, the following takes the code file db.py as an example to describe the technical solution of the present disclosure. Specifically, the specific content of the code file db.py is as follows:
[0088]
[0089]
[0090] According to the division method of the code snippets of this embodiment, the following two code snippets can be obtained:
[0091] Code snippet 1:
[0092]
[0093] Code snippet 2:
[0094]
[0095] In a specific application scenario, the user's query may be: "Check whether there is a bug in the database creation function?"
[0096] After entering the search, the first step is to search for the "create_db" function. If only the first-level search is performed, the search results will only search for "create_db". At this time, the user's query and "create_password" are not very relevant, so "create_password" will not be searched. As a result, LLM cannot see the "create_password" function, so it cannot give a correct answer and only tells the user that it needs to check for anomalies.
[0097] Therefore, by adopting the method of this embodiment, at least two searches can be performed to obtain at least one relevant code snippet. At this time, in the above application example, "create_password" can be retrieved based on "create_db", and then the LLM model can generate an answer to the user's query based on "create_db" and "create_password".
[0098] Figure 5 is a schematic diagram according to the third embodiment of the present disclosure; Figure 5 As shown, this embodiment provides a question-answer processing device 500 based on a large model, which is used to implement question-answer processing based on a code snippet database, including:
[0099] A snippet retrieval module 501 is used to retrieve a target code snippet from a pre-created code snippet database based on a user's question; the code snippet database includes a plurality of code snippets;
[0100] A fragment acquisition module 502 is used to obtain at least one related code fragment based on the target code fragment and refer to a pre-created graph database; the graph database includes the relationship between different code fragments;
[0101] The generating module 503 is used to generate an answer to the question based on the target code snippet and the at least one related code snippet by using a large language model.
[0102] The big model-based question and answer processing device 500 of this embodiment implements the implementation principle and technical effect of big model-based question and answer processing by adopting the above-mentioned modules, which is the same as the implementation of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, which will not be repeated here.
[0103] Figure 6 is a schematic diagram according to a fourth embodiment of the present disclosure; Figure 6 As shown, the question-answering processing device 600 based on the large model of this embodiment, in the above Figure 5 Based on the technical solutions of the embodiments shown in the figure, the technical solutions of the present disclosure are further described in more detail. Figure 5As shown, the question-answering processing device 600 based on the large model of this embodiment includes the above Figure 5 The modules with the same name and function are shown as follows: a fragment retrieval module 601 , a fragment acquisition module 602 and a generation module 603 .
[0104] In this embodiment, the fragment acquisition module 602 is used to:
[0105] Based on the target code snippet, retrieving from the graph database an identification of at least one related code snippet having a relationship with the target code snippet;
[0106] Based on the identifier of the at least one related code snippet, at least one related code snippet is obtained.
[0107] Further optionally, in one embodiment of the present disclosure, the fragment acquisition module 502 is used to:
[0108] Based on the identifier of the at least one related code snippet, acquiring the at least one related code snippet from the graph database; or
[0109] Based on the identifier of the at least one related code snippet, the at least one related code snippet is acquired from the code snippet database.
[0110] Further optionally, in one embodiment of the present disclosure, the fragment acquisition module 602 is used to:
[0111] Taking the target code snippet as a search starting point, at least one level of search is performed in the graph database to obtain an identifier of at least one related code snippet that has a relationship with the target code snippet.
[0112] Further optionally, in one embodiment of the present disclosure, the fragment retrieval module 601 is used to:
[0113] Obtaining a vector expression of the user's question;
[0114] Obtaining a vector expression of each code snippet in the code snippet database;
[0115] Based on the vector expression of the user's question and the vector expression of each of the code snippets, the code snippet with the highest similarity to the user's question is obtained from the code snippet database as the target code snippet.
[0116] Further optionally, if Figure 6 As shown, in one embodiment of the present disclosure, the question-answering processing apparatus 600 based on the large model further includes:
[0117] A relationship acquisition module 604 is used to acquire the relationship between the target code snippet and the at least one related code snippet from the graph database;
[0118] The generating module 603 is used for:
[0119] Based on the target code snippet, the at least one related code snippet, and the relationship between the target code snippet and the at least one related code snippet, the large language model is used to generate an answer to the question.
[0120] Further optionally, if Figure 6 As shown, in one embodiment of the present disclosure, the question-answering processing apparatus 600 based on the large model further includes:
[0121] A collection module 605 is used to collect multiple code documents;
[0122] A segmentation module 606 is used to segment each of the code documents according to function, class name, structure, class member, global variable, static variable or comment to obtain multiple code snippets;
[0123] The construction module 607 is used to construct the code snippet database based on the multiple code snippets of each of the code documents.
[0124] Further optionally, if Figure 6 As shown, in one embodiment of the present disclosure, the question-answering processing apparatus 600 based on the large model further includes:
[0125] A mining module 608 is used to mine the relationship between different code snippets in each of the code documents;
[0126] The construction module 607 is also used to construct the graph database based on the relationship between different code snippets in each of the code documents.
[0127] The big model-based question and answer processing device 600 of this embodiment implements the implementation principle and technical effect of big model-based question and answer processing by adopting the above-mentioned modules, which is the same as the implementation of the above-mentioned related method embodiments. For details, please refer to the records of the above-mentioned related method embodiments, which will not be repeated here.
[0128] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0129] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0130] Figure 7A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. 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 can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, 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 present disclosure described and / or required herein.
[0131] like Figure 7 As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0132] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0133] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as the above-mentioned methods of the present disclosure. For example, in some embodiments, the above-mentioned methods of the present disclosure may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via ROM 702 and / or a communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the above-mentioned methods of the present disclosure described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the above-mentioned methods of the present disclosure in any other appropriate manner (e.g., by means of firmware).
[0134] 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 chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0135] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0136] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0137] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the 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 acoustic input, voice input, or tactile input).
[0138] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0139] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0140] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0141] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A question-answering processing method based on a large model, the method comprising: Based on the user's question, search from the pre-created code snippet database to obtain the target code snippet; The code snippet database includes a plurality of code snippets; Based on the target code snippet, refer to a pre-created graph database to obtain at least one related code snippet; the graph database includes relationships between different code snippets; Based on the target code snippet and the at least one related code snippet, an answer to the question is generated using a large language model.
2. The method according to claim 1, wherein: Based on the target code snippet, refer to a pre-created graph database to obtain at least one related code snippet, including: Based on the target code snippet, retrieving from the graph database an identification of at least one related code snippet having a relationship with the target code snippet; Based on the identifier of the at least one related code snippet, at least one related code snippet is obtained.
3. The method according to claim 2, wherein: Based on the identifier of the at least one related code snippet, obtaining at least one related code snippet includes: Based on the identifier of the at least one related code snippet, acquiring the at least one related code snippet from the graph database; or Based on the identifier of the at least one related code snippet, the at least one related code snippet is acquired from the code snippet database.
4. The method according to claim 3, wherein: Based on the target code snippet, retrieving from the graph database an identifier of at least one related code snippet having a relationship with the target code snippet, comprising: Taking the target code snippet as a search starting point, at least one level of search is performed in the graph database to obtain an identifier of at least one related code snippet that has a relationship with the target code snippet.
5. The method according to claim 1, wherein: Based on the user's question, search from the pre-created code snippet database to obtain the target code snippet, including: Obtaining a vector expression of the user's question; Obtaining a vector expression of each code snippet in the code snippet database; Based on the vector expression of the user's question and the vector expression of each of the code snippets, the code snippet with the highest similarity to the user's question is obtained from the code snippet database as the target code snippet.
6. The method according to any one of claims 1 to 5, wherein: After obtaining at least one related code snippet based on the target code snippet and referring to a pre-created graph database, the method further includes: Acquire, from the graph database, a relationship between the target code snippet and the at least one related code snippet; Based on the target code snippet and the at least one related code snippet, using a large language model, generating an answer to the question, including: Based on the target code snippet, the at least one related code snippet, and the relationship between the target code snippet and the at least one related code snippet, the large language model is used to generate an answer to the question.
7. The method according to any one of claims 1 to 5, wherein: Based on the user's question, before searching from a pre-created code snippet database to obtain the target code snippet, the method further includes: Collect multiple code documents; For each of the code documents, segment them according to function, class name, structure, class member, global variable, static variable or comment to obtain multiple code snippets; The code snippet database is constructed based on the multiple code snippets of each of the code documents.
8. The method according to claim 7, wherein: After building the code snippet database based on the multiple code snippets of each of the code documents, and before acquiring at least one related code snippet by referring to a pre-created graph database based on the target code snippet, the method further includes: For each of the code documents, mining the relationship between different code snippets in the code document; The graph database is constructed based on the relationship between different code snippets in each of the code documents.
9. A question-answering processing device based on a large model, the device comprising: A snippet retrieval module is used to retrieve a target code snippet from a pre-created code snippet database based on a user's question; The code snippet database includes a plurality of code snippets; A snippet acquisition module, configured to acquire at least one related code snippet based on the target code snippet and referring to a pre-created graph database; the graph database includes relationships between different code snippets; A generation module is used to generate an answer to the question based on the target code snippet and the at least one related code snippet using a large language model.
10. The device according to claim 9, wherein: The fragment acquisition module is used to: Based on the target code snippet, retrieving from the graph database an identification of at least one related code snippet having a relationship with the target code snippet; Based on the identifier of the at least one related code snippet, at least one related code snippet is obtained.
11. The device according to claim 10, wherein: The fragment acquisition module is used to: Based on the identifier of the at least one related code snippet, acquiring the at least one related code snippet from the graph database; or Based on the identifier of the at least one related code snippet, the at least one related code snippet is acquired from the code snippet database.
12. The device according to claim 11, wherein The fragment acquisition module is used to: Taking the target code snippet as a search starting point, at least one level of search is performed in the graph database to obtain an identifier of at least one related code snippet that has a relationship with the target code snippet.
13. The device according to claim 9, wherein: The fragment retrieval module is used to: Obtaining a vector expression of the user's question; Obtaining a vector expression of each code snippet in the code snippet database; Based on the vector expression of the user's question and the vector expression of each of the code snippets, the code snippet with the highest similarity to the user's question is obtained from the code snippet database as the target code snippet.
14. The device according to any one of claims 9 to 13, wherein: The device also includes: A relationship acquisition module, used to acquire, from the graph database, the relationship between the target code snippet and the at least one related code snippet; The generating module is used for: Based on the target code snippet, the at least one related code snippet, and the relationship between the target code snippet and the at least one related code snippet, the large language model is used to generate an answer to the question.
15. The device according to any one of claims 9 to 13, wherein: The device also includes: A collection module, used to collect multiple code documents; A segmentation module is used to segment each of the code documents according to function, class name, structure, class member, global variable, static variable or comment to obtain multiple code snippets; A construction module is used to construct the code snippet database based on multiple code snippets of each of the code documents.
16. The device according to claim 15, wherein: The device also includes: A mining module, used for mining the relationship between different code snippets in each of the code documents; The construction module is also used to construct the graph database based on the relationship between different code snippets in each of the code documents.
17. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
18. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-8.
19. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Knowledge graph construction and query method and device, equipment, storage medium and product
CN115827487A
Code retrieval processing method and device
CN117933395A
Code retrieval method and device based on large language model
CN118643120A
Cited By
Code generation method and device, storage medium and electronic equipment
CN120447880A