Question and answer method and device
By obtaining semantic vectors in large language models and analyzing user input problems, and using the target network to disassemble the problem, the problem of low dialogue accuracy in specific industry scenarios is solved, and more accurate and flexible answers are achieved. Reduced training costs.
Patent Information
- Application Number
- CN202411220112.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-09-02
AI Technical Summary
When facing specific industries or knowledge-intensive vertical scenarios, large language models have low accuracy in generating dialogues, and traditional training methods are costly and flexible, which cannot effectively stimulate professional knowledge.
By obtaining the target semantic vector, analyzing the query problems entered by the user, and filtering out the target problems and task disassembly nodes related to the input problems from the target network, disassembly the problem, obtaining multiple sub-questions, and obtaining answers in the order of disassembly. Use the query software corresponding to the target sub-question to obtain the final answer.
Improve the accuracy and pertinence of the conversation, reduce training costs and time, achieve flexible professional knowledge stimulation, and enhance the generalization and robustness of large language models when generating replies.
Smart Images

Figure CN118733746B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of artificial intelligence, and in particular, to a question-answering method and device. Background Art
[0002] With the continuous development of large language model technology, new chatbots based on these technologies are rapidly gaining popularity in various fields. Although large language models have made significant breakthroughs in general fields and can cope with diversified task requirements, their application still faces many challenges when facing some specific industries or knowledge-intensive vertical scenarios. Specifically, conversational robots need to have a deep professional knowledge base, which means that robots must not only understand general language, but also be able to master the terminology and concepts of specific industries.
[0003] However, the requirements for the specificity and professionalism of the responses of the large language model in different scenarios vary. Some scenarios require rich past case experience, while some scenarios require in-depth understanding of complex professional theoretical knowledge. If the traditional large language model training method is used, a lot of training cost and time are required during training. Not only is the training cost low, but the flexibility is also low. At the same time, it cannot effectively stimulate the professional knowledge of the large language model.
[0004] There is currently no effective solution to the above problems. Summary of the invention
[0005] The embodiments of the present invention provide a question-answering method and device to at least solve the problem of low accuracy in generating dialogues in the related art.
[0006] According to one embodiment of the present invention, a question-answering method is provided, comprising: obtaining a target semantic vector, wherein the target semantic vector is a vector obtained by semantically encoding a query question input by a target account; determining a target question node in the target network according to a similarity between the target semantic vector and semantic vectors of each question node in the target network; determining a target task decomposition node in the target network according to a connection relationship between a connection node of the target question node in the target network and the target question node, wherein the target network comprises: a question node, a task decomposition node, and a connection relationship between each node; decomposing the target question through the target task decomposition node to obtain a plurality of target sub-questions, and obtaining an answer to each of the target sub-questions in sequence according to the order of the plurality of target sub-questions obtained by the decomposition to obtain a target answer to the query question.
[0007] In an exemplary embodiment, a target task disassembly node is determined in the target network based on a connection relationship between a node connected to the target problem node in the target network and the target problem node, including: obtaining N first nodes connected to the target problem node in the target network, wherein N is an integer greater than or equal to 1, and the first node is the problem node or the task disassembly node; and determining the target task disassembly node in the target network based on a connection weight between the target problem node and the N first nodes, wherein the connection relationship includes the connection weight.
[0008] In an exemplary embodiment, the target task decomposition node is determined in the target network according to the connection weight between the target problem node and the N first nodes, including: determining the transition probability of each of the first nodes according to the connection weight between the target problem node and the N first nodes to obtain N first transition probabilities, wherein the transition probability is used to represent the correlation between the first node and the target problem node, and the correlation is positively correlated with the transition probability; determining the node with the largest transition probability among the N first nodes as the first target node, wherein the first target node is the problem node or the task decomposition node; and determining the target task decomposition node in the target network according to the node type of the first target node.
[0009] In an exemplary embodiment, the target task disassembly node is determined in the target network according to the node type of the first target node, including: when the node type of the first target node is the task disassembly node, the first target node is determined as the target task disassembly node; when the node type of the first target node is the problem node, the transition probability of each second node is determined according to the connection weight between the first target node and M second nodes to obtain M second transition probabilities, wherein the M second nodes are nodes other than the target problem node among the nodes connected to the first target node; according to N+M-1 transition probabilities, the target task disassembly node is determined among N+M-1 nodes, wherein the N+M-1 transition probabilities are other transition probabilities among the N first transition probabilities and the M second transition probabilities except the transition probability between the target problem node and the first target node, and the N+M-1 nodes are other nodes among the N first nodes and the M second nodes except the first target node.
[0010] In an exemplary embodiment, the target task disassembly node is determined among N+M-1 nodes based on N+M-1 transition probabilities, including: determining the node with the largest transition probability among the N+M-1 nodes as the second target node, wherein the second target node is the problem node or the task disassembly node; and determining the target task disassembly node in the target network based on the node type of the second target node.
[0011] In an exemplary embodiment, the transition probability of each of the N first nodes is determined according to the connection weight between the target problem node and the N first nodes to obtain N first transition probabilities, including: determining the selection weight between the target problem node and each of the first nodes according to the connection weight between the target problem node and each of the first nodes, and the node type of the target problem node and each of the first nodes; determining the transition probability of each of the first nodes by the selection weight between the target problem node and each of the first nodes.
[0012] In an exemplary embodiment, the transition probability of each first node is determined by the selection weight between the target problem node and each first node, including: determining the selection weight between the target problem node and the first node as the first selection weight; determining the sum of the selection weights between the target problem node and N first nodes as the target sum; and determining the ratio of the first selection weight to the target sum as the transition probability of the first node.
[0013] In an exemplary embodiment, the answer to each of the target sub-problems is obtained in sequence in the order of decomposing the multiple target sub-problems to obtain the target answer to the query question, including: calling the query software of each of the target sub-problems in sequence in the order of the multiple target sub-problems to obtain the target answer, wherein the input of the query software of the latter of two sequentially adjacent target sub-problems includes the output of the query software of the previous target sub-problem.
[0014] According to another embodiment of the present invention, there is provided a question-answering device, comprising: a first acquisition module, for acquiring a target semantic vector, wherein the target semantic vector is a vector obtained by semantically encoding a query question input by a target account; a first determination module, for determining a target question node in a target network according to a similarity between the target semantic vector and semantic vectors of each question node in the target network; a second determination module, for determining a target task decomposition node in the target network according to a connection relationship between a connection node of the target question node in the target network and the target question node, wherein the target network comprises: a question node, a task decomposition node, and a connection relationship between each node; a second acquisition module, for decomposing a target question through the target task decomposition node to obtain a plurality of target sub-questions, and obtaining an answer to each of the target sub-questions in sequence according to the order of the plurality of target sub-questions obtained by the decomposition to obtain a target answer to the query question.
[0015] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0016] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0017] According to yet another embodiment of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0018] Through the present invention, by analyzing the query questions input by the user, and screening out the target questions and target task decomposition nodes related to the input query questions from the target network, and decomposing the target questions through the target task decomposition nodes to obtain multiple target sub-questions, the query software corresponding to the target sub-questions is called to obtain answers, and the final results of the query questions are obtained, so that the system can not only understand the user's questions, but also use the provided examples to provide more accurate and targeted answers. Therefore, the problem of low accuracy in generating dialogues in related technologies can be solved, and the accuracy of generating dialogues can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is a hardware structure block diagram of a mobile terminal according to a question-answering method according to an embodiment of the present invention;
[0020] Figure 2is a flow chart of a question-answering method according to an embodiment of the present invention;
[0021] Figure 3 is a schematic diagram of a structure of a problem-task disassembly heterogeneous network according to an embodiment of the present invention;
[0022] Figure 4 is a schematic diagram of an interactive interface of a task disassembly system according to an embodiment of the present invention;
[0023] Figure 5 is a schematic diagram of a system structure according to an embodiment of the present invention;
[0024] Figure 6 is a schematic diagram of the structure of a corpus task decomposition module according to an embodiment of the present invention;
[0025] Figure 7 is a schematic diagram of the structure of a question retrieval module according to an embodiment of the present invention;
[0026] Figure 8 4 is a structural block diagram of a question-answering device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0029] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a question-answering method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0030] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the question-answering method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0031] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0032] In this embodiment, a question-answering method running on the above mobile terminal is provided. Figure 2 is a flow chart of a question-answering method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0033] Step S202, obtaining a target semantic vector, wherein the target semantic vector is a vector obtained by semantically encoding the query question input by the target account;
[0034] The encoding method of the above semantic encoding can be BERT encoder technology. After the user enters the query question through the target account, the query question is encoded into a target semantic vector using BERT encoder technology.
[0035] Step S204, determining a target problem node in the target network according to the similarity between the target semantic vector and the semantic vectors of each problem node in the target network;
[0036] The above similarity can be obtained by calculating the cosine similarity between the target semantic vector and the semantic vector of the problem node; the above target network can be a problem-task decomposition heterogeneous network, which contains a variety of corpora of corresponding application scenarios, such as police scenarios, medical scenarios, etc., and is stored in the form of nodes, such as problem nodes, etc.; according to the similarity between the semantic vectors, the target semantic vector is matched and retrieved with the semantic vector of the problem corresponding to each problem node in the target network using a walking algorithm, so as to determine the target problem node corresponding to the problem closest to the query problem in the target network. Through the walking algorithm, relevant samples and their paths in the network are extensively retrieved, ensuring the diversity and comprehensiveness of the retrieval results.
[0037] As an optional implementation, Figure 3 is a schematic diagram of a problem-task decomposition structure of a heterogeneous network according to an embodiment of the present invention, such as Figure 3 As shown, the heterogeneous network includes problem nodes A1, A2, A3, and task decomposition nodes A11, A12, A21, A31, and A32. When the query question input by the target account is "query Zhang San's family members", the target semantic vector corresponding to the query question is obtained. According to the similarity between the semantic vectors, the question with the highest similarity to the query question can be found in the heterogeneous network. For example, through similarity comparison, the semantic vector of the question "query Zhang San's wife" corresponding to the problem node A1 is most similar to the semantic vector of the query question, and the problem node A1 is determined as the target problem node.
[0038] Step S206, determining a target task decomposition node in the target network according to a connection relationship between a connection node of the target problem node in the target network and the target problem node, wherein the target network includes: a problem node, a task decomposition node, and a connection relationship between each node;
[0039] The above-mentioned connection relationship can be a connection weight, which can include the rationality score, similarity, etc. of the task decomposition. For example, for the edge between the problem node and the problem node, its connection weight s is defined as the similarity between the problems; the edge between the problem node and the task decomposition node, its connection weight r represents the rationality score of the task decomposition; the edge between the task decomposition node and the task decomposition node, its connection weight s reflects the similarity between them. Optionally, in this embodiment, the problem and the task decomposition can be converted into corresponding semantic vectors by BERT encoder technology, and the weight s of the edge between the problem node and the problem node can be determined by calculating the cosine similarity between the problem semantic vectors. At the same time, the cosine similarity between the task decomposition semantic vectors can also be used to determine the weight s of the edge between the task decomposition node and the task decomposition node. By incorporating similarity and task decomposition rationality into the connection weight at the same time, not only the similarity of the problem and task decomposition content can be captured, but also the rationality of task decomposition can be considered, thereby providing a richer and more accurate connection structure for the network.
[0040] Specifically, N first nodes connected to the target problem node in the target network are obtained, wherein N is an integer greater than or equal to 1, and the first node is the problem node or the task decomposition node; based on the connection weight between the target problem node and the N first nodes, the target task decomposition node is determined in the target network, wherein the connection relationship includes the connection weight.
[0041] For example Figure 3 As shown, the target problem node A1 is connected to the problem nodes A2, A3 and the task decomposition nodes A11, A12 respectively, then the first nodes are A2, A3, A11, A12, wherein the connection weight s between A1 and A2 is 0.7, the connection weight s between A1 and A3 is 0.52, the connection weight r between A1 and A11 is 0.8, and the connection weight r between A1 and A12 is 0.65; a target problem node A1 is the initial node, which wanders in the target network, and determines the target task decomposition node among the four first nodes according to the connection weights between the four first nodes and the target problem node A1.
[0042] Optionally, the target task decomposition node is determined in the target network according to the connection weight between the target problem node and the N first nodes, including: determining the transition probability of each of the first nodes according to the connection weight between the target problem node and the N first nodes to obtain N first transition probabilities, wherein the transition probability is used to represent the correlation between the first node and the target problem node, and the correlation is positively correlated with the transition probability; determining the node with the largest transition probability among the N first nodes as the first target node, wherein the first target node is the problem node or the task decomposition node; and determining the target task decomposition node in the target network according to the node type of the first target node.
[0043] Through the question-task decomposition heterogeneous network architecture, the question and the corresponding decomposition information are integrated into the same network. When a user asks a question, semantically similar questions and their decomposition methods can be retrieved in the network. Through the network walking strategy, diverse and comprehensive related questions and task decomposition paths can be obtained, thus avoiding the problem of insufficient recall rate of similar conversations and further improving the generalization and robustness of the large language model when generating responses.
[0044] Step S208, decomposing the target problem through the target task decomposition node to obtain multiple target sub-problems, and obtaining the answer to each of the target sub-problems in sequence according to the order of the multiple target sub-problems obtained by decomposition to obtain the target answer to the query problem.
[0045] By matching the query questions input by the user with high-quality task decomposition samples in the pre-built target network, the system can automatically fill in the prompt words and generate a sub-tool call path that is highly relevant to the current question and logically reasonable, thereby significantly improving the accuracy and rationality of the question response.
[0046] Specifically, the query software of each target sub-problem is called in sequence according to the order of the multiple target sub-problems to obtain the target answer, wherein the input of the query software of the latter target sub-problem of two adjacent target sub-problems includes the output of the query software of the previous target sub-problem.
[0047] The corresponding query software is called according to the generated multiple sub-tool calling paths, and the answer to the previous question is used as the input of the next question, ensuring the logical coherence and integrity between the question and the answer.
[0048] As an optional implementation, Figure 4 is a schematic diagram of an interactive interface of a task decomposition system according to an embodiment of the present invention. Figure 4As shown in the figure, the query question input by the target account is "Query Zhang San's relatives". According to the matching retrieval, the target question node similar to the query question in the target network is determined to be A1 "Query Zhang San's wife". Further, through the wandering strategy, the target task decomposition node corresponding to the target question node is A11. At this time, the target question "Query Zhang San's wife" is decomposed through the target task decomposition node to obtain two target sub-problems "Query ID card" and "Query wife". After that, the query software corresponding to the target sub-problems is called in turn for query, and the first answer to the first sub-problem "Query ID card" is "Zhang San's ID card is xxxx", and the first answer is input into the query software corresponding to the second sub-problem "Query wife" for query, and the second answer to the second sub-problem is "Zhang San's ID card is xxxx, and his wife is Wang Wu", thereby obtaining the target answer to the query question "Zhang San's wife is Wang Wu".
[0049] Optionally, the executor of the above steps may be a background processor, or other devices with similar processing capabilities, or a machine that integrates at least an image acquisition device and a data processing device, wherein the image acquisition device may include a graphics acquisition module such as a camera, and the data processing device may include terminals such as computers and mobile phones, but is not limited to these.
[0050] Through the above steps, by analyzing the query questions input by the user, and screening out the questions and task decomposition paths related to the input query questions from the high-quality task decomposition cases (in the target network) as prompt word examples, the query software corresponding to the decomposition path is called to get the answer and the final result of the query question is obtained, so that the system can not only understand the user's questions, but also use the provided examples to provide more accurate and targeted answers. The problem of low accuracy and relevance of generated dialogues in related technologies is solved, and the accuracy and rationality of generated dialogues are improved.
[0051] In addition, compared with traditional model training, the method described in this embodiment is low-cost and highly flexible, does not require a lot of training cost and time, and only requires cleverly embedding guiding prompt words in the target network to effectively stimulate and utilize the expertise of the large language model.
[0052] As an optional implementation, the target task decomposition node is determined in the target network according to the node type of the first target node, including: when the node type of the first target node is the task decomposition node, the first target node is determined as the target task decomposition node; when the node type of the first target node is the problem node, the transition probability of each second node is determined according to the connection weight between the first target node and M second nodes to obtain M second transition probabilities, wherein the M second nodes are nodes other than the target problem node among the nodes connected to the first target node; according to N+M-1 transition probabilities, the target task decomposition node is determined among N+M-1 nodes, wherein the N+M-1 transition probabilities are other transition probabilities among the N first transition probabilities and the M second transition probabilities except the transition probability between the target problem node and the first target node, and the N+M-1 nodes are other nodes among the N first nodes and the M second nodes except the first target node.
[0053] For example Figure 3 As shown in the figure, when the target problem node is A1, the target task decomposition node is determined among the nodes connected to A1 through the walking strategy. Since the node connected to A1 may be a problem node or a task decomposition node: if among the nodes connected to A1, the node with the highest transfer probability to A1 is a task decomposition node (such as A11), then A11 is directly determined as the target task decomposition node; if among the nodes connected to A1, the node with the highest transfer probability to A1 is a problem node (such as A2), then the connection weights between each node connected to A2 (such as A21, A3, etc.) and A2 are determined, and each transfer probability is determined according to the connection weight, and the target task decomposition node is jointly determined according to each transfer probability between A1 and the node connected to it and each transfer probability between A2 and the node connected to it. It should be noted that when determining the connection weights between each node connected to A2 and A2, node A1 does not need to be considered; when determining the target task decomposition nodes based on the various transition probabilities between A1 and the nodes connected to it and the various transition probabilities between A2 and the nodes connected to it, the transfer weight between A1 and A2 does not need to be considered.
[0054] Specifically, the node with the largest transfer probability among the N+M-1 nodes is determined as the second target node, wherein the second target node is the problem node or the task disassembly node; and the target task disassembly node is determined in the target network according to the node type of the second target node.
[0055] As an optional implementation, when the node type of the second target node is the task decomposition node, the first target node is determined as the target task decomposition node; when the node type of the second target node is the problem node, the transition probability of each of the third nodes is determined according to the connection weight between the second target node and L third nodes, L third transition probabilities are obtained, and the first transition probability, the second transition probability, and the third transition probability are given to jointly determine the target task decomposition node. The specific implementation method refers to the implementation method of the above embodiment.
[0056] As an optional implementation, the transition probability of each of the N first nodes is determined according to the connection weight between the target problem node and the N first nodes to obtain N first transition probabilities, including: determining the selection weight between the target problem node and each of the first nodes according to the connection weight between the target problem node and each of the first nodes, and the node type of the target problem node and each of the first nodes; determining the transition probability of each of the first nodes by the selection weight between the target problem node and each of the first nodes.
[0057] The above-mentioned connection weight can be the similarity s between problem nodes and problem nodes, can be the rationality score r of task decomposition between problem nodes and task decomposition nodes, or can be the similarity s between task decomposition nodes and task decomposition nodes; according to the connection weight between the node type of the first node and the first node in the target problem node domain, the selection weight between the target problem node and the first node is determined, and the transfer probability of each first node is determined according to the selection weight.
[0058] Optionally, the transition probability of each first node is determined by the selection weight between the target problem node and each first node, including: determining the selection weight between the target problem node and the first node as the first selection weight; determining the sum of the selection weights between the target problem node and N first nodes as the target sum; and determining the ratio of the first selection weight to the target sum as the transition probability of the first node.
[0059] Specifically, the transition probability between the target problem node and the first node is obtained by the following formula:
[0060]
[0061] in, is the target problem node, is the first node, is the jth first node among the N first nodes connected to the target problem node, where j is an integer greater than or equal to 1 and less than or equal to N, is the transition probability between the target problem node and the first node, is the selection weight between the target problem node and the first node, is the selection weight between the target problem node and the j-th first node.
[0062] Optionally, determining the selection weight between the target problem node and the first node includes: determining the first node type between the target problem node and the first node, and obtaining the value of the type parameter according to the first node type; determining the connection weight between the target problem node and the first node, and determining the selection weight between the target problem node and the first node according to the value of the type parameter, the connection weight and a preset value.
[0063] Specifically, the selection weight between the target problem node and the first node is obtained by the following formula:
[0064]
[0065] in, is the target problem node, is the first node, is the selection weight between the target problem node and the first node, is the default value. is the type parameter value between the target problem node and the first node. When the target problem node and the first node are of the same type The value of is the first value. When the target problem node is of a different type from the first node, The value of is a second value, the first value is smaller than the second value, is the connection weight between the target problem node and each of the first nodes. As an optional implementation, Figure 5 is a schematic diagram of a system structure according to an embodiment of the present invention. Figure 5 As shown, the specific structure includes:
[0066] Corpus task decomposition module S1: It is used to collect and organize question-answer corpora in relevant scenarios, and decompose complex business into several independent sub-tool modules. For example, for a query question, this module will generate a variety of different sub-tool call paths (i.e., question nodes and task decomposition nodes), and then construct high-quality task decomposition small samples (i.e., target sub-questions), which will be used for question retrieval in the S2 module.
[0067] The specific submodules can be Figure 6 As shown, it is subdivided into:
[0068] Business refinement S11: Collect a wide range of question and answer corpora of relevant application scenarios. These corpora not only come from actual work, but also have been carefully sorted and classified to ensure the quality and availability of the data. Through in-depth analysis of business processes, complex business logic can be intelligently split into multiple sub-tool modules (nodes) that are easy to manage and operate. For example, in response to the common need to query ID cards based on names, a special ID query tool (question node) can be created, which is specially optimized to handle such queries and provide fast and accurate feedback. Similarly, for the complex task of querying kinship, there is also a special relationship query tool to handle it. At the same time, according to the newly added question and answer corpus, the functions of each sub-tool module are continuously adjusted and improved to adapt to the changing work needs.
[0069] Corpus task decomposition S12: Based on S11, each question-answer pair in the question-answer corpus is deeply decomposed. This decomposition process is based on the sub-tool module (question node) abstracted by S11, with the aim of generating high-quality, fine-grained task decomposition samples for related fields. For example, in order to improve the flexibility and diversity of task decomposition, the sub-tool module in the existing corresponding business system can be introduced as input, and combined with specific task decomposition examples, a task decomposition large language model can be jointly constructed. This model can explore a variety of different task decomposition paths (task decomposition nodes) for specific problems, and for each decomposition path, the model will provide a task decomposition rationality score r. This score is used in the S2 module to construct a heterogeneous network of question-task decomposition. Through the task decomposition large language model, the number of high-quality task decomposition small samples can be effectively increased, thereby enriching the data processing capability of the police question-answering system.
[0070] Question retrieval module S2: It is used to use the question-task decomposition data generated by S1 to build a heterogeneous network (target network), which closely associates question nodes with their corresponding task decomposition nodes. When a user asks a new query question, it can quickly locate semantically similar questions (target question nodes) in the heterogeneous network and extract the corresponding task decomposition strategy (target task decomposition node). Through the network walking algorithm, it can widely search and provide a series of related sample questions and their decomposition paths, ensuring the diversity and comprehensiveness of the retrieval results.
[0071] The specific submodules can be Figure 7 As shown, it is subdivided into:
[0072] S21: Problems and task decompositions are considered as two types of nodes. For the edge between problem nodes, the connection weight s is defined as the similarity between problems; for the edge between problem nodes and task decomposition nodes, the connection weight r represents the rationality score of task decomposition; for the edge between task decomposition nodes, the connection weight s reflects the similarity between them.
[0073] In this embodiment, in order to construct a problem-task decomposition heterogeneous network (target network), this module adopts BERT encoder technology, which can convert problems and task decompositions into corresponding semantic vectors. The connection weight s of the edge between problem nodes and problem nodes is determined by calculating the cosine similarity between the problem semantic vectors, and the cosine similarity between the task decomposition semantic vectors is also used to determine the connection weight s of the edge between task decomposition nodes and task decomposition nodes. In addition, in the S12 submodule, the task decomposition rationality score r corresponding to each problem is also included as one of the weights of the relevant edges in the heterogeneous network. In this way, the target network not only captures the similarity between the content of the problem and task decomposition, but also considers the rationality of the task decomposition, thereby providing a richer and more accurate connection structure for the network. The specific problem-task decomposition heterogeneous network is as follows: Figure 3 shown.
[0074] S22: Encode the query question entered by the user into a semantic vector using BERT encoder technology, and then calculate the cosine similarity with all the question nodes in the question-task decomposition heterogeneous network (target network) to obtain the target question node with the highest similarity. Subsequently, use this node as the initial node and perform a random walk in the question-task decomposition heterogeneous network to obtain a series of question-answer pairs (target question node-task decomposition node / question node) associated with the query question entered by the user. During the walk, the transition probability from one node to another is determined by the following formula:
[0075]
[0076] in, is the target problem node, is the first node (the node connected to the target problem node), is the jth first node among the N first nodes connected to the target problem node, is an integer greater than or equal to 1 and less than or equal to N, is the transition probability between the target problem node and the first node, is the selection weight between the target problem node and the first node, is the selection weight between the target problem node and the j-th first node.
[0077] During the walk, a domain sampling strategy is used to select the reachable edges (selection weights) for the walk. This strategy takes into account the node type and edge weights, which can be achieved through the following formula:
[0078]
[0079] in, is the target problem node, is the first node, is the selection weight between the target problem node and the first node, is the default value. is the type parameter value between the target problem node and the first node. When the target problem node and the first node are of the same type The value of is the first value. When the target problem node is of a different type from the first node, The value of is a second value, the first value is smaller than the second value, is the connection weight between the target problem node and each of the first nodes.
[0080] In this way, it can be ensured that the random walk process not only considers the similarity between nodes, but also the rationality and domain relevance of task decomposition, thereby improving the quality and diversity of retrieval results.
[0081] Response information generation module S3: The query text, the relevant target questions retrieved by the S2 unit, and the task decomposition path (target subtask) are integrated into the response generation prompt of the large language model as reference examples. Subsequently, the corresponding query software is called to generate professional and reasonable response information; at the same time, based on the system interaction interface, users can enter questions and obtain relevant target questions and decomposition paths (target subquestions).
[0082] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0083] In this embodiment, a question-and-answer device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0084] Figure 8 is a structural block diagram of a question-answering device according to an embodiment of the present invention. Figure 8 As shown, the device includes: a first acquisition module 802, used to obtain a target semantic vector, wherein the target semantic vector is a vector obtained by semantically encoding a query question input by a target account; a first determination module 804, used to determine a target question node in the target network according to a similarity between the target semantic vector and the semantic vectors of each question node in the target network; a second determination module 806, used to determine a target task decomposition node in the target network according to a connection relationship between a connection node of the target question node in the target network and the target question node, wherein the target network includes: a question node, a task decomposition node, and a connection relationship between each node; a second acquisition module 808, used to decompose the target question through the target task decomposition node to obtain a plurality of target sub-questions, and sequentially obtain an answer to each of the target sub-questions in the order of the plurality of target sub-questions obtained by the decomposition to obtain a target answer to the query question.
[0085] In an exemplary embodiment, the device is also used to obtain N first nodes connected to the target problem node in the target network, wherein N is an integer greater than or equal to 1, and the first node is the problem node or the task decomposition node; based on the connection weight between the target problem node and the N first nodes, the target task decomposition node is determined in the target network, wherein the connection relationship includes the connection weight.
[0086] In an exemplary embodiment, the device is also used to determine the transition probability of each of the target problem node and the N first nodes based on the connection weight between the target problem node and the N first nodes, to obtain N first transition probabilities, wherein the transition probability is used to represent the correlation between the first node and the target problem node, and the correlation is positively correlated with the transition probability; determine the node with the largest transition probability among the N first nodes as the first target node, wherein the first target node is the problem node or the task disassembly node; determine the target task disassembly node in the target network according to the node type of the first target node.
[0087] In an exemplary embodiment, the device is also used to determine the first target node as the target task decomposition node when the node type of the first target node is the task decomposition node; when the node type of the first target node is the problem node, determine the transition probability of each second node according to the connection weight between the first target node and M second nodes to obtain M second transition probabilities, wherein the M second nodes are nodes other than the target problem node among the nodes connected to the first target node; determine the target task decomposition node among N+M-1 nodes according to N+M-1 transition probabilities, wherein the N+M-1 transition probabilities are other transition probabilities among the N first transition probabilities and the M second transition probabilities except the transition probability between the target problem node and the first target node, and the N+M-1 nodes are other nodes among the N first nodes and the M second nodes except the first target node.
[0088] In an exemplary embodiment, the device is also used to determine the node with the largest transfer probability among the N+M-1 nodes as the second target node, wherein the second target node is the problem node or the task disassembly node; and determine the target task disassembly node in the target network according to the node type of the second target node.
[0089] In an exemplary embodiment, the device is also used to determine the selection weight between the target problem node and each of the first nodes based on the connection weight between the target problem node and each of the first nodes, and the node type of the target problem node and each of the first nodes; and determine the transition probability of each of the first nodes through the selection weight between the target problem node and each of the first nodes.
[0090] In an exemplary embodiment, the device is also used to determine the selection weight between the target problem node and the first node as the first selection weight; determine the sum of the selection weights between the target problem node and N first nodes as the target sum; and determine the ratio of the first selection weight to the target sum as the transition probability of the first node.
[0091] In an exemplary embodiment, the device is also used to call the query software of each target sub-problem in sequence according to the order of the multiple target sub-problems to obtain the target answer, wherein the input of the query software of the latter target sub-problem of two sequentially adjacent target sub-problems includes the output of the query software of the previous target sub-problem.
[0092] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0093] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0094] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0095] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0096] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0097] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the steps of the method described in each embodiment of the present application when executed by a processor.
[0098] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0099] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0100] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A question-answering method, characterized in that: include: Obtaining a target semantic vector, wherein the target semantic vector is a vector obtained by semantically encoding a query question input by the target account; Determining a target problem node in the target network according to the similarity between the target semantic vector and the semantic vectors of each problem node in the target network; Determining a target task decomposition node in the target network according to a connection relationship between a connection node of the target problem node in the target network and the target problem node, wherein the target network includes: a problem node, a task decomposition node, and a connection relationship between each node; Decomposing the target problem through the target task decomposition node to obtain multiple target sub-problems, and obtaining the answer to each of the target sub-problems in order according to the order of the multiple target sub-problems obtained by decomposition, so as to obtain the target answer to the query problem; Wherein, determining a target task decomposition node in the target network according to a connection relationship between a connection node of the target problem node in the target network and the target problem node includes: Acquire N first nodes connected to the target problem node in the target network, where N is an integer greater than or equal to 1, and the first node is the problem node or the task decomposition node; The target task decomposition node is determined in the target network according to the connection weight between the target problem node and the N first nodes, wherein the connection relationship includes the connection weight.
2. The method according to claim 1, characterized in that Determining the target task decomposition node in the target network according to the connection weight between the target problem node and the N first nodes includes: Determine the transition probability of each first node according to the connection weight between the target problem node and the N first nodes, and obtain N first transition probabilities, wherein the transition probability is used to represent the correlation between the first node and the target problem node, and the correlation is positively correlated with the transition probability; Determine the node with the largest transfer probability among the N first nodes as the first target node, wherein the first target node is the problem node or the task decomposition node; The target task disassembly node is determined in the target network according to the node type of the first target node.
3. The method according to claim 2, characterized in that Determining the target task disassembly node in the target network according to the node type of the first target node includes: In a case where the node type of the first target node is the task disassembly node, determining the first target node as the target task disassembly node; In the case where the node type of the first target node is the problem node, determining the transition probability of each of the second nodes according to the connection weight between the first target node and M second nodes, to obtain M second transition probabilities, wherein the M second nodes are nodes other than the target problem node among the nodes connected to the first target node; According to N+M-1 transition probabilities, the target task disassembly node is determined among N+M-1 nodes, wherein the N+M-1 transition probabilities are other transition probabilities among the N first transition probabilities and the M second transition probabilities except the transition probability between the target problem node and the first target node, and the N+M-1 nodes are other nodes among the N first nodes and the M second nodes except the first target node.
4. The method according to claim 3, characterized in that According to the N+M-1 transition probabilities, determining the target task decomposition node among the N+M-1 nodes includes: Determine the node with the largest transfer probability among the N+M-1 nodes as the second target node, wherein the second target node is the problem node or the task decomposition node; The target task disassembly node is determined in the target network according to the node type of the second target node.
5. The method according to claim 2, characterized in that: Determining the transition probability of each of the first nodes according to the connection weight between the target problem node and the N first nodes to obtain N first transition probabilities includes: Determine a selection weight between the target problem node and each of the first nodes according to a connection weight between the target problem node and each of the first nodes, and a node type of the target problem node and each of the first nodes; The transition probability of each of the first nodes is determined by the selection weight between the target problem node and each of the first nodes.
6. The method according to claim 5, characterized in that Determining the transition probability of each of the first nodes by the selection weight between the target problem node and each of the first nodes includes: Determine a selection weight between the target problem node and the first node as a first selection weight; Determine the sum of the selection weights between the target problem node and the N first nodes as a target sum; A ratio of the first selection weight to the target sum is determined as a transition probability of the first node.
7. The method according to claim 1, characterized in that Obtaining the answer to each of the target sub-problems in sequence according to the order in which the multiple target sub-problems are obtained, so as to obtain the target answer to the query question, including: The query software of each target sub-problem is called in sequence in the order of the multiple target sub-problems to obtain the target answer, wherein the input of the query software of the latter target sub-problem of two adjacent target sub-problems includes the output of the query software of the previous target sub-problem.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 7.
