Question and answer method and device, equipment, storage medium and program product

By processing and filtering user question information, a high matching target document collection is generated, which solves the problem of low accuracy in specific fields in the prior art question-and-answer system, and realizes more accurate reply information generation.

CN119202181APending Publication Date: 2024-12-27SHANGHAI IFLYTEK HEGUANG TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411308478.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-19
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The existing document question and answer system is low in specific fields such as the agriculture field, mainly due to the lack of professional semantic understanding ability and insufficient correlation matching between the document and the question information, resulting in low accuracy of reply information.

Method used

By processing the question information entered by the user, a second question information with the same semantics but different wording is generated, and a collection of candidate documents is searched in the knowledge base to filter out a high-matching target document collection to generate more accurate reply information .

Benefits of technology

It improves the accuracy of the question-and-answer system in specific fields, ensures that the reply information is more relevant to user questions, and is suitable for applications in professional fields such as agriculture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202181A_ABST
    Figure CN119202181A_ABST
Patent Text Reader

Abstract

The invention discloses a question and answer method and device, equipment, a storage medium and a program product, and relates to the technical field of artificial intelligence, and the method comprises the steps: after obtaining input first question information, rewriting the first question information into second question information with the same semantics as the first question information, searching a candidate document set in a knowledge base at least based on the first question information; the candidate document set at least comprises first-class candidate documents, and the matching degree of each first-class candidate document and the first question information is higher than the matching degree of non-first-class candidate documents and the first question information; screening out a target document set from the candidate document set based on the target information; the matching degree of each target document and the target information is higher than that of the non-target document and the target information; the target information is second question information, or the target information is the first question information and the second question information; and generating reply information according to the target document set and the first question information. The accuracy of the question answering system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering method, apparatus, device, storage medium, and program product. Background Art

[0002] Document question answering is an important aspect of artificial intelligence. Existing document question answering systems retrieve documents related to the user's question from the knowledge base based on the user's question, and then extract the most relevant fragments from the retrieved documents as the answer information. This type of question answering system has low accuracy. Summary of the invention

[0003] In view of the above problems, the present application provides a question-answering method, apparatus, device, storage medium and program product to improve the accuracy of the question-answering system. The specific solution is as follows:

[0004] The first aspect of the present application provides a question-answering method, comprising:

[0005] Obtaining input first question information;

[0006] Processing the first question information to obtain second question information; the second question information has the same semantics as the first question information;

[0007] searching a candidate document set in a knowledge base based at least on the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree between each first-category candidate document and the first question information is higher than the matching degree between non-first-category candidate documents and the first question information;

[0008] A target document set is screened out from the candidate document set based on the target information; the matching degree between each target document and the target information is higher than the matching degree between a non-target document and the target information; the target information is the second question information, or the target information is the first question information and the second question information;

[0009] Reply information is generated according to the target document set and the first question information.

[0010] In a possible implementation, searching for a candidate document set in a knowledge base at least based on the first question information includes:

[0011] Determine the candidate document set based on the similarity between the first question information and each document in the knowledge base; the documents in the candidate document set are first-category candidate documents; the similarity between each first-category candidate document and the first question information is higher than the similarity between non-first-category candidate documents and the first question information;

[0012] Or, based on the similarity between the first question information and each document in the knowledge base, a first-category candidate document set is determined, and the similarity between each first-category candidate document and the first question information is higher than the similarity between non-first-category candidate documents and the first question information; based on the similarity between the second question information and each document in the knowledge base, a second-category candidate document set is determined, and the similarity between each second-category candidate document and the first question information is higher than the similarity between non-second-category candidate documents and the first question information; the first-category candidate document set and the second-category candidate document set constitute the candidate document set.

[0013] In a possible implementation, when a document in the candidate document set is a first-category candidate document, screening out a target document set from the candidate document set based on the second question information includes:

[0014] Based on the similarity between the second question information and each first-category candidate document, screening out a target document set from the candidate document set;

[0015] The similarity between each target document and the second question information is greater than the similarity between non-target documents in the candidate document set and the second question information.

[0016] In a possible implementation, when the target information includes the first question information and the second question information, the step of selecting a target document set from the candidate document set based on the target information includes:

[0017] Obtaining a first similarity between each candidate document and the first question information, and a second similarity between each candidate document and the second question information;

[0018] Sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document;

[0019] According to the sorting result, candidate documents whose sorting meets the conditions are selected to form a target document set; the matching degree between the candidate documents whose sorting meets the conditions and the target information is higher than the matching degree between the candidate documents whose sorting does not meet the conditions and the target information.

[0020] In a possible implementation, the step of sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document includes:

[0021] constructing a first optimization target based on a first similarity between the candidate document and the first question information, and constructing a second optimization target based on a second similarity between the candidate document and the second question information;

[0022] Based on the first optimization objective and the second optimization objective, using a non-dominated algorithm to sort each candidate document in the candidate document set, so as to divide the candidate document set into a plurality of non-dominated hierarchies;

[0023] Correspondingly, the candidate documents that meet the ranking conditions are the candidate documents located at the first non-dominated level.

[0024] In a possible implementation, the step of sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document includes:

[0025] For each candidate document, weighted sum of the first similarity and the second similarity corresponding to the candidate document is performed to obtain a comprehensive similarity corresponding to the candidate document;

[0026] Sort the candidate documents in descending order of comprehensive similarity;

[0027] Correspondingly, the candidate documents that meet the ranking conditions are: the top N candidate documents, or the candidate documents whose comprehensive similarity is greater than the target similarity.

[0028] In a possible implementation, the second question information has different wording and / or different structure from the first question information.

[0029] A second aspect of the present application provides a question-answering device, comprising:

[0030] An input module, used for obtaining input first question information;

[0031] a rewriting module, configured to process the first question information to obtain second question information; the second question information has the same semantics as the first question information;

[0032] A first screening module is used to search for a candidate document set in a knowledge base based at least on the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree between each first-category candidate document and the first question information is higher than the matching degree between non-first-category candidate documents and the first question information;

[0033] A second screening module is used to screen out a target document set from the candidate document set based on target information; the matching degree between each target document and the target information is higher than the matching degree between a non-target document and the target information; the target information is the second question information, or the target information is the first question information and the second question information;

[0034] A generating module is used to generate reply information according to the target document set and the first question information.

[0035] A third aspect of the present application provides a computer program product, comprising computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the question-and-answer method of the first aspect or any implementation of the first aspect.

[0036] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:

[0037] The memory is used to store computer programs;

[0038] The processor is used to execute the computer program so that the electronic device can implement the question-answering method of the above-mentioned first aspect or any implementation manner of the first aspect.

[0039] A fifth aspect of the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the question-and-answer method of the first aspect or any implementation of the first aspect.

[0040] By means of the above technical scheme, the question-answering method, device, equipment, storage medium and program product provided by the present application, after obtaining the input first question information, rewrites the first question information into the second question information with the same semantics as the first question information, searches for a candidate document set in the knowledge base at least based on the first question information; the candidate document set contains at least the first category candidate documents, and the matching degree of each first category candidate document with the first question information is higher than the matching degree of non-first category candidate documents with the first question information; screens out a target document set from the candidate document set based on the target information; the matching degree of each target document with the target information is higher than the matching degree of non-target documents with the target information; the target information is the second question information, or the target information is the first question information and the second question information; generates reply information according to the target document set and the first question information. The present application first searches for a candidate document set related to the first question information in the knowledge base at least based on the original first question information, and then further screens the candidate document set based on the second question information, or further screens the candidate document set based on the first question information and the second question information, so that the target document obtained has a higher correlation with the first question information, so that the reply information generated according to the target document set and the first question information is more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0042] Figure 1 A flowchart for implementing the question-and-answer method provided in this application;

[0043] Figure 2 A flowchart for implementing the method of selecting a target document set from a candidate document set based on target information provided by the present application;

[0044] Figure 3 A flowchart for implementing sorting of candidate documents based on the first similarity and the second similarity corresponding to each candidate document provided in the present application;

[0045] Figure 4 Another implementation flow chart of sorting candidate documents based on the first similarity and the second similarity corresponding to each candidate document provided in the present application;

[0046] Figure 5 A schematic diagram of the structure of the question-answering device provided in this application;

[0047] Figure 6 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION

[0048] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0049] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0050] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0051] The application of document question answering systems is becoming more and more widespread and can be used in many fields, such as agriculture, medicine, computing, etc.

[0052] Taking the agricultural sector as an example, farmers need to obtain professional guidance on agricultural technology in agricultural production. At present, there are three main ways for farmers to obtain professional designation: through expert consultation platforms built by the government or enterprises, including agricultural technology promotion stations, agricultural technology promotion platforms and other expert resources to answer farmers' questions; purchase relevant professional books for study; visit agricultural-related professional websites, read relevant articles or Q&A. However, due to the shortage of expert resources, it is impossible to respond to farmers immediately, and agricultural technology-related books and documents are usually highly professional, making it difficult for farmers to learn.

[0053] With the development of big model technology, the application demand of document question answering system in the agricultural field is increasing. There are two technical solutions used in existing document question answering systems:

[0054] One is to focus on open domain question answering: farmers' questions are directly input into a general large model, and the large model outputs the answers. This question-answering method lacks the semantic understanding ability of agricultural professionals, resulting in poor accuracy of answers.

[0055] Another implementation method is to use a retriever + reader architecture: the retriever matches k (k is a fixed value) relevant documents from a given document based on the farmer's question, and then the reader extracts the fragments matching the farmer's question from the k relevant documents as the reply content for output. In this method, since the k value is a parameter that is sensitive to specific questions and documents, there is a risk that the k value is too high, resulting in too much irrelevant information in the matched document set, while a k value that is too small increases the risk of not matching relevant documents, resulting in low accuracy of the reply information obtained. Moreover, the retriever is usually pre-trained using general expectations and lacks semantics and knowledge in agriculture, which makes the matched documents less relevant to the farmer's question, and also leads to low accuracy of the reply information. In addition, people often have many different ways to enter query keywords, which may result in the documents related to the query keywords not being retrieved, which also leads to low accuracy of the reply information obtained.

[0056] In order to improve the accuracy of the question-answering system, this application scheme is proposed.

[0057] like Figure 1 As shown, a flowchart for implementing the question-answering method provided in an embodiment of the present application may include:

[0058] Step S101: obtaining input first question information.

[0059] The first question information is the question information of a specific field input by the user into the question-answering system. As an example, the specific field can be, but is not limited to, any of the following fields: agricultural field, medical field, computer field, Internet field, etc.

[0060] Step S102: Process the first question information to obtain second question information; the second question information has the same semantics as the first question information.

[0061] The present application rewrites the first question information to obtain the second question information with the same semantics as the first question information. That is, the content of the second question information is different from that of the first question information, but the meanings expressed are the same or similar.

[0062] Step S103: searching for a candidate document set in the knowledge base based at least on the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree between each first-category candidate document and the first question information is higher than the matching degree between non-first-category candidate documents and the first question information.

[0063] The knowledge base here is a knowledge base in a specific field, that is, the knowledge base is the knowledge base of the field in which the question-answering system is applied.

[0064] Optionally, only documents with a high degree of matching with the first question information may be searched in the knowledge base as candidate documents. In this case, the candidate document set only includes the first category of candidate documents.

[0065] Optionally, the knowledge base may be searched for documents with a high degree of matching with the first question information, and the knowledge base may be searched for documents with a high degree of matching with the second question information as candidate documents. In this case, the candidate documents searched in the knowledge base based on the first question information are first-category candidate documents, and the first-category candidate documents are part of the candidate document set, and the candidate document set also includes second-category candidate documents searched in the knowledge base based on the second question information; the second-category candidate documents have a higher degree of matching with the second question information than the non-second-category candidate documents have with the second question information.

[0066] Step S104: Filter out a target document set from the candidate document set based on the target information; the matching degree between each target document and the target information is higher than the matching degree between the non-target document and the target information; the target information is the second question information, or the target information is the first question information and the second question information.

[0067] After obtaining the candidate document set, the present application needs to further screen the candidate documents to eliminate the candidate documents in the candidate document set that have a low degree of match with the target information, and retain the candidate documents in the candidate document set that have a high degree of match with the target information to assist in responding to the first question information.

[0068] Through two screenings, it is ensured that the target document in the target document set has a high relevance to the first question information.

[0069] Step S105: Generate reply information according to the target document set and the first question information.

[0070] Optionally, a large model may be used to process the target document set and the first question information to generate the answer information. As an example, the large model is a generative large model, for example, the large model may be a large language model (LLM) or a multimodal large model.

[0071] Optionally, a prompt (also called a prompt word) may be generated based on the target document set and the first question information, and the prompt instructs the large model to answer the first question information according to each target document in the target document set.

[0072] For example, the first question is: What does compound operation of agricultural machinery mean?

[0073] The target document set obtained by screening the solution of this application includes three documents, namely: p1. Agricultural machinery retest operation is a modern agricultural practice, which refers to the use of multiple mechanical equipment to work together to improve the efficiency and productivity of farmland operations. p2. In the agricultural field, agricultural machinery retest operation refers to farmers or agricultural practitioners using advanced agricultural machinery and equipment, such as tractors, harvesters, etc. to work together at the same time. P3. Agricultural machinery retest operation is a modern agricultural management practice that uses multiple agricultural machinery and equipment at the same time to complete the operation in a collaborative manner.

[0074] The corresponding prompt example can be:

[0075] Prompt = (

[0076] "<Instructions> Based on the known information, answer the question using concise and easy-to-understand language. If you can't get the answer from it, please say 'Based on the known information, this question cannot be answered;'\n"

[0077] "<Known information>{p1. Agricultural machinery retest operation is a modern agricultural practice, which refers to the use of multiple mechanical equipment to work together to improve the efficiency and productivity of farmland operations. p2. In the agricultural field, agricultural machinery retest operation refers to farmers or agricultural practitioners using advanced agricultural machinery and equipment, such as tractors and harvesters, to work together at the same time. P3. Agricultural machinery retest operation is a modern agricultural management practice that uses multiple agricultural machinery and equipment to work together.}\n"

[0078] "<Question>{What does it mean to use multiple operations of agricultural machinery?}" )

[0080] In the above prompt example, the known information is the target document set, and the question is the first question information input by the user.

[0081] The prompt is input into the big model, and the big model answers the question based on the prompt's instructions and the target document set. The answers given are expressed in concise and easy-to-understand language to facilitate user understanding.

[0082] Different from the existing question-answering scheme (the existing question-answering scheme directly uses the question information to search for a candidate document set in the knowledge base after obtaining the input question information, and then replies to the question information based on the candidate document set), the present application rewrites the first question information into the second question information with the same semantics as the first question information after obtaining the input first question information, and searches for a candidate document set in the knowledge base at least based on the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree of each first-category candidate document with the first question information is higher than the matching degree of non-first-category candidate documents with the first question information; a target document set is screened out from the candidate document set based on the target information; the matching degree of each target document with the target information is higher than the matching degree of non-target documents with the target information; the target information is the second question information, or the target information is the first question information and the second question information; the target document obtained through the above two screenings has a higher correlation with the first question information, so that the reply information generated based on the target document set and the first question information is more accurate.

[0083] In an optional embodiment, one implementation of searching the candidate document set in the knowledge base based on the first question information may be:

[0084] Based on the similarity between the first question information and each document in the knowledge base, a candidate document set is determined. The candidate documents in the candidate document set are first-category candidate documents, and the similarity between each first-category candidate document and the first question information is higher than the similarity between non-first-category candidate documents and the first question information.

[0085] Optionally, the similarity between the first question information and each document in the knowledge base may be calculated based on the vector representation of the first question information and the vector representation of each document in the knowledge base.

[0086] The semantic vector model can be used to vectorize the question information and the document to obtain a vector representation of the question information and a vector representation of the document. Taking the first question information as an example, the first question information can be input into the semantic vector model, and the semantic vector model can vectorize the first question information to obtain a vector representation of the first question information.

[0087] As an example, the semantic vector model can be a BGE (BAAI General Embedding) model. Since the training corpus of the BGE model covers a wide range of fields, including but not limited to science and technology, news, agriculture, literature, academia and other fields, it has the ability to semantically understand the proprietary vocabulary of some specific fields. If the training corpus of the BGE model does not contain the corpus of the application field of the question-answering system, the training corpus of the application field of the question-answering system can be used to fine-tune the BGE model so that the BGE model has the ability to semantically understand the proprietary vocabulary of the application field of the question-answering system.

[0088] As an example, the semantic vector model may be an m3e (Moka Massive Mixed Embedding) model. Conventional pre-trained m3e models are usually trained using general domain corpora, and have insufficient semantic representation capabilities for specialized vocabulary in vertical domains (for example, taking the agricultural vertical domain as an example, conventional pre-trained m3e models have insufficient representation capabilities for vocabulary such as "compound operations, rated speed" in the use of agricultural machinery, "diseases and pests" in planting techniques, and "chemical control methods"). In order to enable the m3e model to have more professional semantic understanding capabilities in vertical domains, the corpus in the vertical domain may be used to fine-tune the conventional pre-trained m3e model, so that the m3e model has more professional semantic understanding capabilities in vertical domains. For example, the corpus in the agricultural vertical domain may be used to fine-tune the conventional pre-trained m3e model, so that the m3e model has semantic understanding capabilities for specialized vocabulary in the agricultural vertical domain.

[0089] For documents in the knowledge base, the vector representation of each document can be obtained in advance and saved in the vector database. In this way, when it is necessary to calculate the similarity between the question information and the document, it is only necessary to vectorize the question information to obtain the vector representation of the question information. The vector representation of the document can be directly read from the vector database, and there is no need to vectorize the document every time, thereby improving the question and answer response speed.

[0090] Optionally, for any document in the knowledge base, the similarity between the first question information and the any document can be calculated based on the vector representation of the first question information and the vector representation of the any document. As an example, the distance between the vector representation of the first question information and the vector representation of the any document can be calculated, and the similarity between the first question information and the any document can be represented by the distance. Alternatively, the reciprocal of the distance can be used to represent the similarity between the first question information and the any document.

[0091] As an example, the distance here may be Euclidean distance, or other distances, such as Manhattan distance.

[0092] Taking the reciprocal of the distance between the question information and the document as an example to represent the similarity between the question information and the document, the similarity between the question information and the document can be calculated in the following way:

[0093] Similanrity = 1 / (d+1) (1)

[0094] Among them, Similanrity is the similarity between the question information and the document, and d is the distance between the vector representation of the question information and the vector representation of the document. The reciprocal of d is not directly used as the similarity between the question information and the document here to avoid the situation where the reciprocal cannot be calculated due to the d value being zero.

[0095] After obtaining the similarity between the first question information and each document in the knowledge base, each document may be sorted in descending order of similarity, and the top N documents in the sorting may be determined as first-category candidate documents.

[0096] Alternatively, a document whose similarity to the first question information is greater than a similarity threshold may be determined as a first-category candidate document.

[0097] In an optional embodiment, one implementation of searching the candidate document set in the knowledge base at least based on the first question information may be:

[0098] Based on the similarity between the first question information and each document in the knowledge base, a first category candidate document set is determined, wherein the similarity between each first category candidate document and the first question information is higher than the similarity between non-first category candidate documents and the first question information.

[0099] Based on the similarity between the second question information and each document in the knowledge base, a set of second category candidate documents is determined, wherein the similarity between each second category candidate document and the first question information is higher than the similarity between non-second category candidate documents and the first question information.

[0100] The first category candidate document set and the second category candidate document set constitute a candidate document set.

[0101] That is to say, in addition to searching for documents related to the first question information as candidate documents in the knowledge base based on the first question information, the present application also searches for documents related to the second question information as candidate documents in the knowledge base based on the second question information. This ensures the comprehensiveness of information coverage of documents used to assist in answering questions.

[0102] The method for calculating the similarity between the second question information and the document, and the method for determining the second category candidate document set can refer to the aforementioned method for calculating the similarity between the first question information and the document, and the method for determining the first category candidate document set, which will not be repeated here.

[0103] The first category candidate document set and the second category candidate document set may contain the same candidate documents.

[0104] In an optional embodiment, when the documents in the candidate document set are first-category candidate documents (that is, the candidate document set only includes first-category candidate documents), the target information may only include the second question information; an implementation method of screening out the target document set from the candidate document set based on the second question information may be:

[0105] Based on the similarity between the second question information and each of the first-category candidate documents, a target document set is screened out from the candidate document set.

[0106] The similarity between each target document and the second question information is greater than the similarity between non-target documents in the candidate document set and the second question information.

[0107] That is, the present application can perform a rough screening in the knowledge base based on the first question information to obtain a candidate document set (ie, a first-category candidate document set), and then perform a fine screening in the candidate document set based on the second question information to obtain a target document set.

[0108] The method for calculating the similarity between the second question information and each first-category candidate document, and the method for determining the target document set can refer to the aforementioned method for calculating the similarity between the first question information and the document, and the method for determining the first-category candidate document set, which will not be repeated here.

[0109] In an optional embodiment, when the target information includes the first question information and the second question information, the documents in the candidate document set may only be the first category candidate documents, or the documents in the candidate document set include the first category candidate documents and the second category candidate documents. Based on this, the present application provides a flowchart for implementing the method of selecting the target document set from the candidate document set based on the target information. Figure 2 As shown, this may include:

[0110] Step S201: obtaining a first similarity between each candidate document and the first question information, and a second similarity between each candidate document and the second question information.

[0111] In the case where the candidate document set only includes first-category candidate documents, because the first-category candidate documents are screened based on the similarity between the candidate documents and the first question information (i.e., the first similarity), the first similarity can be directly read. In this case, it is necessary to calculate the similarity between each first-category candidate document and the second question information (i.e., the second similarity). The specific calculation method can be found in the aforementioned embodiment and will not be repeated here.

[0112] When the candidate document set includes first-category candidate documents and second-category candidate documents, the first similarity between the first-category candidate documents and the first question information and the second similarity between the second-category candidate documents and the second question information can be directly read. In addition, the similarity between each second-category candidate document and the first question information (i.e., the first similarity) and the similarity between each first-category candidate document and the second question information (i.e., the second similarity) need to be calculated.

[0113] Step S202: Sort the candidate documents based on the first similarity and the second similarity corresponding to each candidate document.

[0114] In the present application, the arrangement order of any candidate document is related to the similarity between the candidate document and the first question information and the similarity between the candidate document and the second question information. In other words, the arrangement order of any candidate document comprehensively considers the similarity between the candidate document and the two question information.

[0115] Step S203: According to the sorting result, candidate documents whose sorting meets the conditions are selected to form a target document set; the matching degree between the candidate documents whose sorting meets the conditions and the target information is higher than the matching degree between the candidate documents whose sorting does not meet the conditions and the target information.

[0116] In an optional embodiment, a flowchart for implementing the above-mentioned sorting of each candidate document based on the first similarity and the second similarity corresponding to each candidate document is as follows: Figure 3 As shown, this may include:

[0117] Step S301: constructing a first optimization target based on a first similarity between a candidate document and first question information, and constructing a second optimization target based on a second similarity between the candidate document and second question information.

[0118] As an example, the present application can construct a multi-objective model, and regard each candidate document in the candidate document set as a set of solutions to be optimized. The first similarity between any candidate document and the first question information is recorded as s1, and the second similarity between any candidate document and the second question information is recorded as s2. Two optimization objectives can be constructed in the following manner (these two optimization objectives constitute a multi-objective model):

[0119] The first optimization goal: f1=1- s1;

[0120] The second optimization goal: f2=1- s2;

[0121] The calculation method of s1 and s2 can refer to formula (1). Based on this, the document screening task is established as a multi-objective minimization problem. The ultimate goal is to screen out candidate documents from the candidate document set that can achieve the best performance on both f1 and f2 (i.e., minimizing objectives f1 and f2).

[0122] Step S302: Based on the first optimization objective and the second optimization objective, the candidate documents in the candidate document set are sorted using a non-dominated algorithm to divide the candidate document set into a plurality of non-dominated levels.

[0123] The process of sorting each candidate document in the candidate document set using the non-dominated algorithm can refer to the existing solution, which will not be described in detail here. After non-dominated sorting, the candidate documents in the candidate document set are divided into multiple non-dominated levels. Correspondingly, the candidate documents that meet the sorting conditions are the candidate documents located in the first non-dominated level.

[0124] The smaller the non-dominated level of the candidate document, the better the joint performance of the candidate document on the two objectives.

[0125] In an optional embodiment, another implementation flowchart of sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document is as follows: Figure 4 As shown, this may include:

[0126] Step S401: For each candidate document, weighted sum of the first similarity and the second similarity corresponding to the candidate document is performed to obtain a comprehensive similarity corresponding to the candidate document.

[0127] Optionally, the weight of the first similarity is greater than or equal to the weight of the second similarity.

[0128] Step S402: Sort the candidate documents in descending order of comprehensive similarity.

[0129] Correspondingly, the candidate documents that meet the ranking conditions are: the top N candidate documents, or the candidate documents whose comprehensive similarity is greater than the target similarity.

[0130] Target similarity is a hyperparameter, which is pre-set.

[0131] By sorting each candidate document based on the first similarity and the second similarity corresponding to each candidate document, the relevance of the target document to the first question information can be maximized according to the similarity between the original question sentence (i.e., the first question information) and the rewritten question (i.e., the second question information) and the document.

[0132] In an optional embodiment, one implementation method of processing the first question information to obtain the second question information may be:

[0133] The first question information is rewritten using the large model. Specifically, an instruction can be generated based on the first question information, and the instruction instructs the large model to rewrite the question. The semantics of the rewritten question is the same as the semantics of the original question, and different wording and structure are used. As shown below, an example of the instruction prompt for rewriting the first question information provided in an embodiment of the present application is as follows:

[0134] Prompt = (

[0135] "You are a natural language rewriting assistant.\n"

[0136] "Please rewrite the following question, keeping the same semantics but using different wording and structure.\n"

[0137] “Original question: [What does it mean to use double operation of agricultural machinery?]” )

[0139] The above prompt for question rewriting is input into the large model, and the rewritten second question information is as follows:

[0140] Could you explain what the term "complex operation" means in the context of agricultural machinery?

[0141] Or, what are compound operations of agricultural machinery?

[0142] Of course, the two examples of the second question information are only for illustrative purposes and do not constitute a limitation on the solution of the present application. Due to the characteristics of the generative language model, the information generated by the generative language model each time is not fixed, but the semantics of the generated question and the original question must be the same or similar, and the wording and structure are different.

[0143] In an optional embodiment, the second question information has different wording or structure from the first question information; or the second question information has different wording and structure from the first question information.

[0144] Depending on the requirements, the prompts used to rewrite the question may vary, such as:

[0145] If you only need the second question message to have different wording than the first question message, an example of prompt is:

[0146] Prompt = (

[0147] "You are a natural language rewriting assistant.\n"

[0148] "Please rewrite the following question, keeping the same semantics but using different wording.\n"

[0149] “Original question: [What does it mean to use double operation of agricultural machinery?]” )

[0151] If you only need the second question information to have a different structure from the first question information, the prompt example is:

[0152] Prompt = (

[0153] "You are a natural language rewriting assistant.\n"

[0154] "Please rewrite the following question to maintain the same semantics but use a different structure.\n"

[0155] “Original question: [What does it mean to use double operation of agricultural machinery?]” )

[0157] Corresponding to the method embodiment, the present application also provides a question-answering device, such as Figure 5 As shown, a schematic diagram of a structure of a question-answering device provided in an embodiment of the present application may include:

[0158] Input module 501, rewriting module 502, first screening module 503, second screening module 504 and generation module 505; wherein,

[0159] The input module 501 is used to obtain input first question information;

[0160] The rewriting module 502 is used to process the first question information to obtain second question information; the second question information has the same semantics as the first question information;

[0161] The first screening module 503 is used to search for a candidate document set in the knowledge base based on at least the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree between each first-category candidate document and the first question information is higher than the matching degree between non-first-category candidate documents and the first question information;

[0162] The second screening module 504 is used to screen out a target document set from the candidate document set based on the target information; the matching degree between each target document and the target information is higher than the matching degree between a non-target document and the target information; the target information is the second question information, or the target information is the first question information and the second question information;

[0163] The generating module 505 is used to generate answer information according to the target document set and the first question information.

[0164] The question-answering device provided in the embodiment of the present application, after obtaining the input first question information, rewrites the first question information into second question information with the same semantics as the first question information, and searches for a candidate document set in the knowledge base at least based on the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree of each first-category candidate document with the first question information is higher than the matching degree of non-first-category candidate documents with the first question information; a target document set is screened out from the candidate document set based on the target information; the matching degree of each target document with the target information is higher than the matching degree of non-target documents with the target information; the target information is the second question information, or the target information is the first question information and the second question information; the target document obtained through the above two screenings has a higher correlation with the first question information, so that the answer information generated according to the target document set and the first question information is more accurate.

[0165] In an optional embodiment, when searching for a candidate document set in a knowledge base based at least on the first question information, the first screening module 503 is configured to:

[0166] Determine the candidate document set based on the similarity between the first question information and each document in the knowledge base; the documents in the candidate document set are first-category candidate documents; the similarity between each first-category candidate document and the first question information is higher than the similarity between non-first-category candidate documents and the first question information;

[0167] Or, based on the similarity between the first question information and each document in the knowledge base, a first-category candidate document set is determined, and the similarity between each first-category candidate document and the first question information is higher than the similarity between non-first-category candidate documents and the first question information; based on the similarity between the second question information and each document in the knowledge base, a second-category candidate document set is determined, and the similarity between each second-category candidate document and the first question information is higher than the similarity between non-second-category candidate documents and the first question information; the first-category candidate document set and the second-category candidate document set constitute the candidate document set.

[0168] In an optional embodiment, when the documents in the candidate document set are first-category candidate documents, the second screening module 504, when screening out the target document set from the candidate document set based on the second question information, is used to:

[0169] Based on the similarity between the second question information and each first-category candidate document, screening out a target document set from the candidate document set;

[0170] The similarity between each target document and the second question information is greater than the similarity between non-target documents in the candidate document set and the second question information.

[0171] In an optional embodiment, when the target information includes the first question information and the second question information, the second screening module 504 is used to:

[0172] Obtaining a first similarity between each candidate document and the first question information, and a second similarity between each candidate document and the second question information;

[0173] Sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document;

[0174] According to the sorting result, candidate documents whose sorting meets the conditions are selected to form a target document set; the matching degree between the candidate documents whose sorting meets the conditions and the target information is higher than the matching degree between the candidate documents whose sorting does not meet the conditions and the target information.

[0175] In an optional embodiment, when the second screening module 504 sorts the candidate documents based on the first similarity and the second similarity corresponding to each candidate document, it is used to:

[0176] constructing a first optimization target based on a first similarity between the candidate document and the first question information, and constructing a second optimization target based on a second similarity between the candidate document and the second question information;

[0177] Based on the first optimization objective and the second optimization objective, using a non-dominated algorithm to sort each candidate document in the candidate document set, so as to divide the candidate document set into a plurality of non-dominated hierarchies;

[0178] Correspondingly, the candidate documents that meet the ranking conditions are the candidate documents located at the first non-dominated level.

[0179] In an optional embodiment, when the second screening module 504 sorts the candidate documents based on the first similarity and the second similarity corresponding to each candidate document, it is used to:

[0180] For each candidate document, weighted sum of the first similarity and the second similarity corresponding to the candidate document is performed to obtain a comprehensive similarity corresponding to the candidate document;

[0181] Sort the candidate documents in descending order of comprehensive similarity;

[0182] Correspondingly, the candidate documents that meet the ranking conditions are: the top N candidate documents, or the candidate documents whose comprehensive similarity is greater than the target similarity.

[0183] In an optional embodiment, the second question information has different wording and / or different structure from the first question information.

[0184] The present application also provides an electronic device in an embodiment. Figure 6 As shown, it shows a structural schematic diagram of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application is a mobile terminal device, such as a mobile phone, a tablet computer, a laptop computer, etc.; it can also be a desktop computer device, such as a desktop computer, an all-in-one computer, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0185] like Figure 6 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0186] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0187] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the question-and-answer methods provided in the embodiments of the present application.

[0188] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any question-and-answer method provided in the embodiment of the present application.

[0189] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0190] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0191] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product. Professionals and technicians may use different methods to implement the described functions for each specific solution, but such implementation should not be considered beyond the scope of this application.

[0192] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

[0193] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0194] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A question-answering method, characterized in that: include: Obtaining input first question information; Processing the first question information to obtain second question information; The second question information has the same semantics as the first question information; Searching for a candidate document set in a knowledge base based at least on the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree between each first-category candidate document and the first question information is higher than the matching degree between non-first-category candidate documents and the first question information; Filtering a target document set from the candidate document set based on the target information; The matching degree between each target document and the target information is higher than the matching degree between the non-target document and the target information; The target information is the second question information, or the target information is the first question information and the second question information; Reply information is generated according to the target document set and the first question information.

2. The method according to claim 1, characterized in that The step of searching the knowledge base for a candidate document set based at least on the first question information includes: Determine the candidate document set based on the similarity between the first question information and each document in the knowledge base; the documents in the candidate document set are first-category candidate documents; the similarity between each first-category candidate document and the first question information is higher than the similarity between non-first-category candidate documents and the first question information; Or, based on the similarity between the first question information and each document in the knowledge base, a first-category candidate document set is determined, and the similarity between each first-category candidate document and the first question information is higher than the similarity between non-first-category candidate documents and the first question information; based on the similarity between the second question information and each document in the knowledge base, a second-category candidate document set is determined, and the similarity between each second-category candidate document and the first question information is higher than the similarity between non-second-category candidate documents and the first question information; the first-category candidate document set and the second-category candidate document set constitute the candidate document set.

3. The method according to claim 2, characterized in that When the documents in the candidate document set are first-category candidate documents, selecting a target document set from the candidate document set based on the second question information includes: Based on the similarity between the second question information and each first-category candidate document, screening out a target document set from the candidate document set; The similarity between each target document and the second question information is greater than the similarity between non-target documents in the candidate document set and the second question information.

4. The method according to claim 2, characterized in that: In a case where the target information includes the first question information and the second question information, the step of selecting a target document set from the candidate document set based on the target information includes: Obtaining a first similarity between each candidate document and the first question information, and a second similarity between each candidate document and the second question information; Sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document; According to the sorting result, candidate documents whose sorting meets the conditions are selected to form a target document set; the matching degree between the candidate documents whose sorting meets the conditions and the target information is higher than the matching degree between the candidate documents whose sorting does not meet the conditions and the target information.

5. The method according to claim 4, characterized in that The step of sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document comprises: constructing a first optimization target based on a first similarity between the candidate document and the first question information, and constructing a second optimization target based on a second similarity between the candidate document and the second question information; Based on the first optimization objective and the second optimization objective, using a non-dominated algorithm to sort each candidate document in the candidate document set, so as to divide the candidate document set into a plurality of non-dominated hierarchies; Correspondingly, the candidate documents that meet the ranking conditions are the candidate documents located at the first non-dominated level.

6. The method according to claim 4, characterized in that The step of sorting the candidate documents based on the first similarity and the second similarity corresponding to each candidate document comprises: For each candidate document, weighted sum of the first similarity and the second similarity corresponding to the candidate document is performed to obtain a comprehensive similarity corresponding to the candidate document; Sort the candidate documents in descending order of comprehensive similarity; Correspondingly, the candidate documents that meet the ranking conditions are: the top N candidate documents, or the candidate documents whose comprehensive similarity is greater than the target similarity.

7. The method according to claim 1, characterized in that The second question information has different wording and / or different structure from the first question information.

8. A question-answering device, characterized in that: include: An input module, used for obtaining input first question information; A rewriting module, used for processing the first question information to obtain second question information; The second question information has the same semantics as the first question information; A first screening module is used to search for a candidate document set in a knowledge base based at least on the first question information; the candidate document set includes at least first-category candidate documents, and the matching degree between each first-category candidate document and the first question information is higher than the matching degree between non-first-category candidate documents and the first question information; A second screening module, configured to screen out a target document set from the candidate document set based on the target information; The matching degree between each target document and the target information is higher than the matching degree between the non-target document and the target information; The target information is the second question information, or the target information is the first question information and the second question information; A generating module is used to generate reply information according to the target document set and the first question information.

9. A computer program product, characterized in that It comprises computer-readable instructions, and when the computer-readable instructions are executed on an electronic device, the electronic device implements the question-answering method as claimed in any one of claims 1 to 7.

10. An electronic device, characterized in that: The electronic device comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the question-answering method as described in any one of claims 1 to 7.

11. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the question-and-answer method as described in any one of claims 1 to 7.