CN119782590A - Question and answer processing method, device, electronic device and storage medium based on large model - Google Patents

Question and answer processing method, device, electronic device and storage medium based on large model Download PDF

Info

Publication number
CN119782590A
CN119782590A CN202411709204.2A CN202411709204A CN119782590A CN 119782590 A CN119782590 A CN 119782590A CN 202411709204 A CN202411709204 A CN 202411709204A CN 119782590 A CN119782590 A CN 119782590A
Authority
CN
China
Prior art keywords
code snippet
code
snippet
question
database
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411709204.2A
Other languages
Chinese (zh)
Inventor
潘旭
龚建
孙珂
孙冠超
田明
陈一言
孙倩
黄培
吴志全
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202411709204.2A priority Critical patent/CN119782590A/en
Publication of CN119782590A publication Critical patent/CN119782590A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本公开提供了一种基于大模型的问答处理方法、装置、电子设备及存储介质,涉及机器学习、知识图谱与自然语言处理等人工智能技术领域。具体实现方案为:基于用户的问题,从预先创建的代码片段数据库中进行检索,获取目标代码片段;所述代码片段数据库中包括多个代码片段;基于所述目标代码片段,参考预先创建的图数据库,获取至少一个相关代码片段;所述图数据库中包括不同代码片段之间的关系;基于所述目标代码片段和所述至少一个相关代码片段,采用大语言模型,生成所述问题的答案。本公开的技术,能够高效、准确地生成问题的答案。

The present disclosure provides a question-answering processing method, device, electronic device and storage medium based on a large model, which relates to artificial intelligence technology fields such as machine learning, knowledge graph and natural language processing. The specific implementation scheme is: based on the user's question, search from a pre-created code snippet database to obtain a target code snippet; the code snippet database includes multiple 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 the relationship between different code snippets; based on the target code snippet and the at least one related code snippet, a large language model is used to generate the answer to the question. The technology disclosed in the present disclosure can efficiently and accurately generate answers to questions.

Description

Question-answering processing method and device based on large model, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of computers, in particular to the technical field of artificial intelligence such as machine learning, knowledge graph and natural language processing, and especially relates to a question-answering processing method, device, electronic equipment and storage medium based on a large model.
Background
As research and development technologies mature, various research and development companies accumulate more and more code files.
All code files of each company can be integrated to form a code file library. The research personnel in the company can refer to each code file in the code file library to learn the code development knowledge, so that the research and development efficiency is improved.
Disclosure of Invention
The disclosure provides a question-answering processing method and device based on a large model, electronic equipment and a storage medium.
According to an aspect of the present disclosure, there is provided a big model-based question-answering processing method, the method including:
searching from a pre-created code segment database based on the problem of a user to obtain a target code segment, wherein the code segment database comprises a plurality of code segments;
based on the target code segments, referring to a pre-created graph database, and acquiring at least one relevant code segment, wherein the graph database comprises relations among different code segments;
and generating an answer to the question by adopting a large language model based on the target code segment and the at least one relevant code segment.
According to another aspect of the present disclosure, there is provided a big model-based question-answering processing apparatus, the apparatus including:
The system comprises a segment retrieval module, a target code segment retrieval module and a code segment generation module, wherein the segment retrieval module is used for retrieving from a pre-established code segment database based on the problem of a user to obtain the target code segment;
The segment acquisition module is used for acquiring at least one relevant code segment by referring to a pre-created graph database based on the target code segment, wherein the graph database comprises relations among different code segments;
And the generating module is used for generating an answer to the question by adopting a large language model based on the target code segment and the at least one relevant code segment.
According to still another aspect of the present disclosure, there is provided an electronic apparatus including:
At least one processor, and
A memory communicatively coupled to the at least one processor, wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the aspects and methods of any one of the possible implementations described above.
According to yet another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of the aspects and any possible implementation described above.
According to yet another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method of the aspects and any one of the possible implementations described above.
According to the technology disclosed by the invention, the answers to the questions can be efficiently and accurately generated.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a schematic diagram according to a first embodiment of the present disclosure;
FIG. 2 is a schematic diagram according to a second embodiment of the present disclosure;
FIG. 3 is a schematic diagram of the flow diagram of FIG. 2;
FIG. 4 is a schematic diagram of a relationship mined in an embodiment of the present disclosure;
FIG. 5 is a schematic diagram according to a third embodiment of the present disclosure;
FIG. 6 is a schematic diagram according to a fourth embodiment of the present disclosure;
fig. 7 is a block diagram of an electronic device for implementing the methods of embodiments of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It will be apparent that the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments in this disclosure without inventive faculty, are intended to be within the scope of this disclosure.
It should be noted that, the terminal device according to the embodiments of the present disclosure may include, but is not limited to, a smart device such as a mobile phone, a Personal digital assistant (Personal DIGITAL ASSISTANT, PDA), a wireless handheld device, a Tablet Computer (Tablet Computer), and the like, and the display device may include, but is not limited to, a device with a display function such as a Personal Computer, a television, and the like.
In addition, the term "and/or" is merely an association relation describing the association object, and means that three kinds of relations may exist, for example, a and/or B, and that three kinds of cases where a exists alone, while a and B exist alone, exist alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
In a practical scenario, based on a pre-created code file library, a developer typically manually searches and learns knowledge of each code file in the code file library.
Fig. 1 is a schematic diagram of a first embodiment of the present disclosure, and as shown in fig. 1, the present embodiment provides a big model-based question-answer processing method for implementing question-answer processing based on a code segment database, which may specifically include the following steps:
S101, searching from a pre-established code segment database based on the problem of a user to obtain a target code segment, wherein the code segment database comprises a plurality of code segments;
S102, based on target code segments, referring to a pre-created graph database to acquire at least one relevant code segment, wherein the graph database comprises relations among different code segments;
S103, generating answers to the questions by using a large language model (Large Language Model; LLM) based on the target code segment and at least one related code segment.
The execution subject of the big model-based question-answer processing method of the present embodiment may be a big model-based question-answer processing device, which may be an electronic entity, or may also be a software-integrated application. The device can solve the problem of the user based on a large model and by referring to the code segment database.
The code segment database of the embodiment is a database collected by taking code segments as granularity. For example, each individual code segment in the code segment database in this embodiment may be a function, class name, structure, intra-class member, global variable, static variable, annotation, or the like.
Each node in the graph database of the embodiment is a code segment, and the graph database includes relationships between different code segments. For example, the relationships in this embodiment may include, be included, belong to, be attributed to, reference, be referenced, call, be called, parent-child relationships, and so forth. That is, in the graph database, if there is a relationship between two code segments, there is an edge between the two code segments, otherwise there is no connection between the two code segments.
In this embodiment, based on the target code segment and at least one relevant code segment, a rich knowledge support can be provided for the solution of the user problem. Based on this, the large language model can generate answers to user questions more accurately from the target code segment and at least one relevant code segment.
The user of the present embodiment may be referred to as a developer. The application scenario of this embodiment may be that, in the development process, a developer may have a question that is input to the question-answer processing device based on the large model, where the question of the user may be a question about development, such as how the call of the a function is implemented, how the global variable X is defined, and so on. After receiving the questions of the user, the question-answering processing device based on the large model can adopt the large language model to refer to the code segment database and the graph database, and by adopting the technical scheme of the embodiment, answers of the questions of the user are generated and fed back to the user.
Based on the technical scheme of the embodiment, the research and development personnel do not need to manually check the code file, and by adopting the scheme of the embodiment, a large language model can be adopted to provide accurate and efficient answers for users based on the code segment library and the graph database.
According to the question-answering processing method based on the large model, the target code segment and at least one relevant code segment corresponding to the user question can be obtained based on the code segment database and the graph database, rich knowledge support is provided for solving the user question, and further, a large language model is adopted, answers to the question can be efficiently and accurately generated according to the target code segment and the at least one relevant code segment, and effective support is provided for research personnel to obtain knowledge from the code segment database.
Fig. 2 is a schematic diagram of a second embodiment according to the present disclosure, and fig. 3 is a schematic diagram of the flow diagram shown in fig. 2. The solution of the present disclosure is further described in more detail on the basis of the solution of the embodiment shown in fig. 1. As shown in fig. 2 and 3, the question-answering processing method based on the large model in this embodiment may specifically include the following steps:
s201, acquiring vector expression of a problem of a user;
s202, obtaining vector expression of each code segment in a code segment database;
s203, based on the vector expression of the problem of the user and the vector expression of each code segment, acquiring the code segment with the highest similarity with the problem of the user from a code segment database as a target code segment;
Specifically, the similarity between the vector expressions of the problems of the user and the vector expressions of the code segments is calculated, and then the code segment with the highest similarity is obtained as the target code segment.
In this embodiment, the vector expression of the problem of the user may be obtained by using a pre-trained vector expression model.
Steps S201-S203 are one implementation of step S101 in the embodiment shown in fig. 1. The implementation mode is a vectorization retrieval mode, and the target code segment is acquired. By the method, the target code segment can be accurately and efficiently acquired.
Steps 201 to S203 correspond to the vectorization search process in fig. 3, and the obtained target code segment is the search result in fig. 3.
Optionally, in practical application, the problem of the user and the relevance of each code segment can be directly obtained based on the semantics, so that the code segment with the highest relevance can be obtained as the target code segment. For example, a keyword in a question of a user may also be acquired, and then a code segment having the highest correlation degree may be retrieved and acquired from a code segment database as a target code segment based on the keyword in the question of the user.
S204, based on the target code segment, retrieving the identification of at least one relevant code segment with a relation with the target code segment from the graph database;
For example, in a specific implementation, considering that the number of target code segments is limited, in order to enrich the search result, in this embodiment, at least one level of search may be performed in the graph database with the target code segment as a search start point, so as to obtain an identifier of at least one relevant code segment having a relationship with the target code segment. By means of the method, at least one level of search is conducted in the graph database, and identification of at least one relevant code segment with relation to the target code segment can be accurately obtained.
Alternatively, in practice, two or three levels of search may be performed, subject to the restriction of symbols (token) that can be received when LLM is entered.
It can also be said that the target code segment is used as a search start point, and at most 2-degree relationships are searched in the graph database. When searching for the 1 st degree relation by taking the target code segment as a searching starting point, a plurality of nearest neighbor nodes which are directly related to the target code segment are obtained, then searching for the 2 nd degree relation by taking each nearest neighbor node as a searching starting point, and obtaining a plurality of secondary nearest neighbor nodes which are directly related to the nearest neighbor nodes, wherein the 2 degree relation searching is completed.
S205, acquiring at least one relevant code segment based on the identification of the at least one relevant code segment;
When this step S203 is specifically implemented, two cases may be included:
In the first case, the graph database stores not only the identity of each node but also the content of at least one relevant code segment of each node. At this time, at least one relevant code segment may be obtained from the graph database based on the identification of the at least one relevant code segment.
In the second case, only the node identifiers are stored in the graph database, and the content of at least one relevant code segment of each node is not stored. At this time, at least one relevant code segment may be obtained from the code segment database based on the identification of the at least one relevant code segment.
In either case, at least one relevant code segment can be accurately and efficiently acquired.
Steps S204-S205 are a specific implementation of step S102 in the embodiment shown in fig. 1. By adopting the method, at least one relevant code segment can be accurately and efficiently acquired.
Steps S204-S205 correspond to the process of the relationship retrieval in fig. 3, and the obtained at least one relevant code segment corresponds to the relationship retrieval result in fig. 3.
Alternatively, in practical application, each code segment may be directly analyzed in the graph database, and at least one relevant code segment related to the target code segment is mined.
S206, acquiring the target code segment and the relation existing in at least one relevant code segment from the graph database;
The method specifically can comprise the relation between the target code segment and the relevant code segment obtained by the 1 st degree retrieval in at least one relevant code segment and the relation between each relevant code segment obtained by the 1 st degree retrieval and the relevant code segment obtained by the corresponding 2 nd degree retrieval. This step may be considered as further adding relationships present in at least one relevant code segment to the relationship search results to improve the accuracy of the answer to the generated question.
In this embodiment, the type of the relationship is related to a specific scenario, for example, in a unit test scenario, a call relationship is required. However, in a function interpretation scenario, a parent-child relationship is required. In practical application, specific processing of specific scenes is not described herein in detail. In summary, all relationships that exist in the object code segment and at least one relevant code segment are obtained from the graph database.
S207, generating an answer to the question by using LLM based on the target code segment, the at least one relevant code segment and the relation existing in the target code segment and the at least one relevant code segment.
Optionally, in this embodiment, the maximum token that can be received by the LLM is taken as a constraint, and if the length of the object code segment, at least one relevant code segment, and the relationship existing in the object code segment and at least one relevant code segment is greater than the maximum token, the relevant code segment and the corresponding relationship of the 2 nd degree relationship may be cut preferentially, so as to ensure that the LLM works normally.
In this embodiment, not only the target code segment and at least one relevant code segment are input to the LLM, but also the relationship existing in the target code segment and at least one relevant code segment is input, and the combination relationship can make the LLM better, so that the answer of the generated question is more accurate.
In this embodiment, by providing the LLM model with the relationships between the target code segment and at least one relevant code segment, richer knowledge support can be provided for the LLM, so that the LLM can generate answers to questions more accurately and efficiently.
Optionally, before step S202 of the present embodiment, the following steps may be further included:
(1) Collecting a plurality of code documents;
(2) For each code document, dividing according to functions, class names, structural bodies, members in classes, global variables, static variables or notes to obtain a plurality of code fragments;
(3) A code segment database is constructed based on a plurality of code segments of each code document.
In this embodiment, the code document is segmented according to a function, a class name, a structure, members in a class, a global variable, a static variable or an annotation, so that each code segment has smaller granularity, and can be accurately positioned when being retrieved. In this way, the code segment database can be constructed efficiently and accurately.
Optionally, before step S204 of the present embodiment, the following steps may be further included:
(a) For each code document, mining the relation between different code fragments in the code document;
For example, the relationship between mined code segments Segment1 and Segment2 may be expressed as Segment1- > Relation- > Segment2.
In this embodiment, a pre-trained relation mining model may be used to mine the relation between different code segments.
For example, the relationships of the present embodiment may include call relationships, parent-child relationships, and so forth. The call relationship may include that function a calls function B, which uses global variables. The parent-child relationships may include classes and class member functions, class and class member variables, functions and local variables within functions.
For example, FIG. 4 is a schematic diagram of a relationship mined in an embodiment of the present disclosure. As shown in FIG. 4, the relationships can be mined that function A- > calls- > function B, function B- > is called- > function A, function A- > parent- > class C, class C- > child- > function A, class member- > is called- > function A, function A- > calls- > class member, class member- > parent- > class C, and class C- > child- > class member, and so forth.
(B) Based on the relation between different code segments in each code document, a graph database is constructed.
Specifically, in the constructed graph database, each code segment is used as a node, and the relationship among different code segments is used as an edge among different code segments. The graph database created based on the above manner can be regarded as a knowledge graph about the code segments. By adopting the mode, the graph database can be accurately and efficiently constructed.
Alternatively, in this embodiment, the content of the code segment of each node may be stored in the graph database, or only the identifier of each node may be stored, instead of storing the content of the code segment of each node, specifically, the content of the code segment is obtained from the code segment database.
For example, the technical solution of the present disclosure is described below by taking a code file db.py as an example, and specifically, the specific contents of the code file db.py are as follows:
according to the code segment division manner of the present embodiment, the following two code segments can be obtained by division:
Code segment 1:
Code segment 2:
In one specific application scenario, the user's query may be "check whether a bug exists in the create database function?
The first step after search can search the "create_db" function, if only one-stage search is performed, the obtained search result only searches the "create_db". At this time, the relevance of the query and the "create_password" of the user is low, so the "create_password" cannot be searched. Thus, the LLM cannot see the "create_password" function, so that the LLM cannot answer correctly, and only tells the user to check for anomalies.
Therefore, by adopting the manner of this embodiment, at least two-degree search can be performed to obtain at least one relevant code segment, and in the application example, the "create_password" can be searched based on the "create_db", so that the LLM model can generate the answer of the query of the user based on the "create_db" and the "create_password".
Fig. 5 is a schematic diagram of a third embodiment of the present disclosure, and as shown in fig. 5, the present embodiment provides a big model-based question-answering processing apparatus 500 for implementing question-answering processing based on a code segment database, including:
The segment retrieval module 501 is configured to retrieve from a pre-created code segment database based on a user problem, and obtain a target code segment;
a segment obtaining module 502, configured to obtain at least one relevant code segment by referring to a pre-created graph database based on the target code segment, where the graph database includes relationships between different code segments;
A generating module 503, configured to generate an answer to the question using a large language model based on the target code segment and the at least one relevant code segment.
The big model-based question-answer processing device 500 of the present embodiment implements the implementation principle and the technical effect of the big model-based question-answer processing by adopting the above modules, and is the same as the implementation of the above related method embodiments, and details of the above related method embodiments may be referred to in the description, and will not be repeated herein.
Fig. 6 is a schematic diagram of a fourth embodiment of the present disclosure, and as shown in fig. 6, a big model-based question-answering apparatus 600 of the present embodiment further describes the technical solution of the present disclosure in more detail on the basis of the technical solution of the embodiment shown in fig. 5. As shown in fig. 5, the big model-based question-answering processing apparatus 600 of the present embodiment includes the same-name and same-function modules shown in fig. 5, namely a fragment retrieval module 601, a fragment acquisition module 602, and a generation module 603.
In this embodiment, the segment obtaining module 602 is configured to:
Retrieving, based on the target code segment, from the graph database, an identification of at least one relevant code segment having a relationship with the target code segment;
at least one relevant code segment is obtained based on the identification of the at least one relevant code segment.
Further optionally, in an embodiment of the present disclosure, the segment acquisition module 502 is configured to:
Retrieving said at least one relevant code segment from said graph database based on an identification of said at least one relevant code segment, or
The at least one relevant code segment is obtained from the code segment database based on the identification of the at least one relevant code segment.
Further optionally, in an embodiment of the present disclosure, the segment acquisition module 602 is configured to:
and taking the target code segment as a searching starting point, and performing at least one-stage searching in the graph database to obtain the identification of at least one relevant code segment with a relation with the target code segment.
Further alternatively, in one embodiment of the present disclosure, the segment retrieval module 601 is configured to:
acquiring vector expression of the problem of the user;
Obtaining vector expression of each code segment in the code segment database;
And acquiring a code segment with highest problem similarity with the user from the code segment database based on the vector expression of the problem of the user and the vector expression of each code segment, and taking the code segment as the target code segment.
Further alternatively, as shown in fig. 6, in one embodiment of the present disclosure, the big model based question-answering processing apparatus 600 further includes:
A relationship obtaining module 604, configured to obtain, from the graph database, a relationship existing in the target code segment and the at least one related code segment;
a generating module 603, configured to:
and generating an answer to the question by using the large language model based on the target code segment, the at least one relevant code segment, and the relation existing in the target code segment and the at least one relevant code segment.
Further alternatively, as shown in fig. 6, in one embodiment of the present disclosure, the big model based question-answering processing apparatus 600 further includes:
An acquisition module 605 for acquiring a plurality of code documents;
The segmentation module 606 is configured to segment each code document according to a function, a class name, a structure, a member in a class, a global variable, a static variable or an annotation, to obtain a plurality of code segments;
A construction module 607 is configured to construct the code segment database based on a plurality of code segments of each of the code documents.
Further alternatively, as shown in fig. 6, in one embodiment of the present disclosure, the big model based question-answering processing apparatus 600 further includes:
A mining module 608, configured to mine, for each of the code documents, a relationship between different code segments in the code document;
the construction module 607 is further configured to construct the graph database based on the relationships between different code segments in each of the code documents.
The big model-based question-answer processing device 600 of the present embodiment implements the implementation principle and the technical effect of the big model-based question-answer processing by adopting the above modules, and is the same as the implementation of the above related method embodiments, and details of the above related method embodiments may be referred to in the description, and will not be repeated herein.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the related user personal information all conform to the regulations of related laws and regulations, and the public sequence is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
Fig. 7 illustrates a schematic block diagram of an example electronic device 700 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 7, the apparatus 700 includes a computing unit 701 that 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 RAM703, various programs and data required for the operation of the device 700 may also be stored. The computing unit 701, the ROM 702, and the RAM703 are connected to each other through a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Various components in the device 700 are connected to the I/O interface 705, including an input unit 706, e.g., keyboard, mouse, etc., an output unit 707, e.g., various types of displays, speakers, etc., a storage unit 708, e.g., magnetic disk, optical disk, etc., and a communication unit 709, e.g., network card, modem, wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The computing unit 701 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 701 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as the above-described methods of the present disclosure. For example, in some embodiments, the above-described methods of the present disclosure may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program may be loaded and/or installed onto device 700 via ROM702 and/or communication unit 709. When the computer program is loaded into RAM 703 and executed by computing unit 701, one or more steps of the above-described 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-described methods of the present disclosure by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be a special or general purpose programmable processor, operable to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here 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 a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user, for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback), and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can 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.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (19)

1.一种基于大模型的问答处理方法,所述方法包括:1. A question-answering processing method based on a large model, the method comprising: 基于用户的问题,从预先创建的代码片段数据库中进行检索,获取目标代码片段;所述代码片段数据库中包括多个代码片段;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; 基于所述目标代码片段,参考预先创建的图数据库,获取至少一个相关代码片段;所述图数据库中包括不同代码片段之间的关系;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.根据权利要求1所述的方法,其中,基于所述目标代码片段,参考预先创建的图数据库,获取至少一个相关代码片段,包括:2. The method according to claim 1, wherein, based on the target code snippet, referring to a pre-created graph database, obtaining at least one related code snippet comprises: 基于所述目标代码片段,从所述图数据库中,检索与所述目标代码片段具有关系的至少一个相关代码片段的标识;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.根据权利要求2所述的方法,其中,基于所述至少一个相关代码片段的标识,获取至少一个相关代码片段,包括:3. The method according to claim 2, wherein obtaining at least one related code snippet based on the identification of the at least one related code snippet comprises: 基于所述至少一个相关代码片段的标识,从所述图数据库中获取所述至少一个相关代码片段;或者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.根据权利要求3所述的方法,其中,基于所述目标代码片段,从所述图数据库中,检索与所述目标代码片段具有关系的至少一个相关代码片段的标识,包括:4. The method according to claim 3, wherein, based on the target code snippet, retrieving an identifier of at least one related code snippet having a relationship with the target code snippet from the graph database comprises: 以所述目标代码片段为搜索起点,在所述图数据库中进行至少一级搜索,得到与所述目标代码片段具有关系的至少一个相关代码片段的标识。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.根据权利要求1所述的方法,其中,基于用户的问题,从预先创建的代码片段数据库中进行检索,获取目标代码片段,包括:5. The method according to claim 1, wherein, based on the user's question, searching from a pre-created code snippet database to obtain the target code snippet comprises: 获取所述用户的问题的向量表达;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.根据权利要求1-5任一所述的方法,其中,基于所述目标代码片段,参考预先创建的图数据库,获取至少一个相关代码片段之后,所述方法还包括: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 comprises: 从所述图数据库中,获取所述目标代码片段以及所述至少一个相关代码片段中存在的关系;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.根据权利要求1-5任一所述的方法,其中,基于用户的问题,从预先创建的代码片段数据库中进行检索,获取目标代码片段之前,所述方法还包括:7. The method according to any one of claims 1 to 5, wherein before searching from a pre-created code snippet database based on the user's question to obtain the target code snippet, the method further comprises: 采集多个代码文档;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.根据权利要求7所述的方法,其中,基于各所述代码文档的多个代码片段,构建所述代码片段数据库之后,基于所述目标代码片段,参考预先创建的图数据库,获取至少一个相关代码片段之前,所述方法还包括:8. The method according to claim 7, wherein after constructing 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 comprises: 对于各所述代码文档,挖掘所述代码文档中不同代码片段之间的关系;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.一种基于大模型的问答处理装置,所述装置包括: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.根据权利要求9所述的装置,其中,所述片段获取模块,用于: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.根据权利要求10所述的装置,其中,所述片段获取模块,用于: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.根据权利要求11所述的装置,其中,所述片段获取模块,用于: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.根据权利要求9所述的装置,其中,所述片段检索模块,用于: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.根据权利要求9-13任一所述的装置,其中,所述装置还包括:14. The device according to any one of claims 9 to 13, wherein the device further comprises: 关系获取模块,用于从所述图数据库中,获取所述目标代码片段以及所述至少一个相关代码片段中存在的关系;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.根据权利要求9-13任一所述的装置,其中,所述装置还包括:15. The device according to any one of claims 9 to 13, wherein the device further comprises: 采集模块,用于采集多个代码文档;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.根据权利要求15所述的装置,其中,所述装置还包括:16. The apparatus according to claim 15, wherein the apparatus further comprises: 挖掘模块,用于对于各所述代码文档,挖掘所述代码文档中不同代码片段之间的关系;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.一种电子设备,包括:17. An electronic device comprising: 至少一个处理器;以及at least one processor; and 与所述至少一个处理器通信连接的存储器;其中,a memory communicatively connected to the at least one processor; wherein, 所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-8中任一项所述的方法。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.一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行根据权利要求1-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 to 8. 19.一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现根据权利要求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.
CN202411709204.2A 2024-11-26 2024-11-26 Question and answer processing method, device, electronic device and storage medium based on large model Pending CN119782590A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411709204.2A CN119782590A (en) 2024-11-26 2024-11-26 Question and answer processing method, device, electronic device and storage medium based on large model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411709204.2A CN119782590A (en) 2024-11-26 2024-11-26 Question and answer processing method, device, electronic device and storage medium based on large model

Publications (1)

Publication Number Publication Date
CN119782590A true CN119782590A (en) 2025-04-08

Family

ID=95239988

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411709204.2A Pending CN119782590A (en) 2024-11-26 2024-11-26 Question and answer processing method, device, electronic device and storage medium based on large model

Country Status (1)

Country Link
CN (1) CN119782590A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120447880A (en) * 2025-07-14 2025-08-08 济南浪潮数据技术有限公司 Code generation method and device, storage medium and electronic device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115827487A (en) * 2022-12-22 2023-03-21 百度(中国)有限公司 Knowledge graph construction and query method, device, equipment, storage medium and product
CN117933395A (en) * 2024-01-31 2024-04-26 支付宝(杭州)信息技术有限公司 Code retrieval processing method and device
CN118643120A (en) * 2024-06-20 2024-09-13 北京百度网讯科技有限公司 Code retrieval method and device based on large language model

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115827487A (en) * 2022-12-22 2023-03-21 百度(中国)有限公司 Knowledge graph construction and query method, device, equipment, storage medium and product
CN117933395A (en) * 2024-01-31 2024-04-26 支付宝(杭州)信息技术有限公司 Code retrieval processing method and device
CN118643120A (en) * 2024-06-20 2024-09-13 北京百度网讯科技有限公司 Code retrieval method and device based on large language model

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120447880A (en) * 2025-07-14 2025-08-08 济南浪潮数据技术有限公司 Code generation method and device, storage medium and electronic device

Similar Documents

Publication Publication Date Title
US10963794B2 (en) Concept analysis operations utilizing accelerators
CN106919655B (en) Answer providing method and device
US9318027B2 (en) Caching natural language questions and results in a question and answer system
CN111797214A (en) Question screening method, device, computer equipment and medium based on FAQ database
KR102593171B1 (en) Information processing method and device, electronic equipment and storage medium
WO2020237856A1 (en) Smart question and answer method and apparatus based on knowledge graph, and computer storage medium
WO2019091026A1 (en) Knowledge base document rapid search method, application server, and computer readable storage medium
CN111930962A (en) Document data value evaluation method and device, electronic equipment and storage medium
CN113204621B (en) Document storage, document retrieval method, device, equipment and storage medium
CN111737997A (en) A text similarity determination method, device and storage medium
CN114595686B (en) Knowledge extraction method, training method and device for knowledge extraction model
CN112926297B (en) Method, apparatus, device and storage medium for processing information
US20220198358A1 (en) Method for generating user interest profile, electronic device and storage medium
CN112559717B (en) Search matching method, device, electronic equipment and storage medium
CN119782590A (en) Question and answer processing method, device, electronic device and storage medium based on large model
CN111159213A (en) Data query method, device, system and storage medium
CN114610955A (en) An intelligent retrieval method, device, electronic device and storage medium
CN114048315A (en) Method, apparatus, electronic device and storage medium for determining a document label
CN119202152A (en) Problem-solving method, device, computer equipment and medium based on artificial intelligence
CN118626717A (en) Fine-tuning method for large language model, resource recommendation method, device and equipment
CN115577078B (en) Engineering cost audit information retrieval method, system, equipment and storage medium
CN112988778A (en) Method and device for processing database query script
CN114385819B (en) Ontology construction method, device and related equipment in the field of environmental justice
CN116842011A (en) Blood relationship analysis method, device, computer equipment and storage medium
CN115563239A (en) Question answering method, device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination