A method and device for constructing a question-answering model database
By constructing a question and answer model database, we use knowledge materials and network corpus to evaluate the confidence of questions, put high-confidence questions into the basic library, and put low-confidence questions into the extended library, which solves the problem of low efficiency in checking extended questions and bloated databases problem, achieving efficient retrieval and improving accuracy.
Patent Information
- Application Number
- CN202410308914.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-19
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-03-19
AI Technical Summary
The inspection efficiency of extended questions in the existing question and answer model database is low, resulting in a bloated database, low retrieval efficiency, and the extended questions are not effectively used and occupy space.
By acquiring knowledge materials and network corpus of the target industry, we build a basic knowledge base and confidence evaluation model, expand the confidence evaluation of questions, and put questions with high confidence into the basic knowledge base and questions with low confidence into the basic knowledge base. Enter the extended knowledge base for supplementary retrieval.
It improves the accuracy and retrieval speed of the question and answer model, reduces database redundancy, makes automated verification more efficient, and reduces costs.
Smart Images

Figure CN118193486B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for constructing a question-answer model database. Background Art
[0002] With the continuous development of deep learning technology, natural language processing technology based on deep neural networks has been widely used. The development of these technologies has made it possible to use large models in the field of intelligent question answering.
[0003] Currently, the answers are usually preset and question-answering models. Preset answers are usually manually annotated, and there are no answers if there are no presets. The question-answering model has a low accuracy rate and answers repeated and redundant questions. It can identify the points of user concern, but usually cannot provide clear answers, especially when it comes to professional questions. There is also the problem of unclear answer logic because it was not trained during training. The language model answers logically that does not conform to the facts according to the language logic.
[0004] Since a large number of question texts need to be preset for preset answers to increase the coverage of questions, the existing technology will expand the question sentences. However, due to the lack of a verification method for extended questions, the verification of extended questions relies heavily on manual work, which is inefficient and costly. At the same time, some extended questions will not be used for a long time, but will occupy a large amount of database space, causing the database to be bloated and the retrieval efficiency to be low. Summary of the invention
[0005] In view of this, the purpose of the present invention is to provide a method and device for constructing a question-answering model database to solve the problems in the prior art of low efficiency in testing extended questions and easy database bloat.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions:
[0007] A method for constructing a question-answer model database of the present invention comprises:
[0008] Acquire knowledge materials and network corpus of the target industry, wherein the knowledge materials include text materials, picture materials, audio materials and video materials, and the network corpus is crawled regularly from the Internet;
[0009] Building a basic knowledge base based on the knowledge material, wherein the basic knowledge base includes a plurality of question and answer templates, associated audios of the plurality of question and answer templates, and associated videos of the plurality of question and answer templates;
[0010] Expanding the basic question in the question-answer template to obtain an extended question;
[0011] Constructing a confidence evaluation model based on the network corpus, and determining the confidence of the extended question based on the confidence evaluation model, wherein the confidence evaluation model includes confidences when multiple groups of entities and relations are used together;
[0012] Extended questions with a confidence greater than or equal to a preset threshold are placed in the basic knowledge base, and extended questions with a confidence less than a preset threshold are placed in the extended knowledge base, and a question-answering model database is constructed based on the basic knowledge base and the extended knowledge base, wherein the extended database is used to perform supplementary retrieval on questions that are not retrieved in the basic knowledge base, and there is a mapping relationship between the extended questions in the extended database and the corresponding question-answering templates in the basic knowledge base.
[0013] In an embodiment of the present application, when the knowledge material is a text material, constructing a basic knowledge base based on the knowledge material includes:
[0014] Segmenting the text material to obtain multiple text segments;
[0015] Performing triple extraction on the multiple text segments to obtain multiple triples, wherein the structure of the triples is head entity-relation-tail entity;
[0016] The triple entities are taken as nodes, and the nodes are connected based on the relationship between the triples to obtain the triple knowledge graph;
[0017] Calling a language model, generating multiple questions based on multiple text fragments, and building a basic knowledge base based on the multiple questions and corresponding text fragments, or building multiple questions according to the triple knowledge graph, and building a basic knowledge base based on the multiple questions and corresponding text fragments.
[0018] In an embodiment of the present application, when the knowledge material is a picture material, an audio material or a video material, constructing a basic knowledge base based on the knowledge material includes:
[0019] Extracting features of the industry materials to obtain material features;
[0020] Convert the industry materials into text to obtain a description text; and extract keywords from the description text to obtain keywords;
[0021] The material feature is converted into a first feature vector A through a pre-established coding table, and the keyword is converted into a second feature vector B through a pre-established coding table;
[0022] Constructing a composite vector C[A, B] based on the first feature vector A and the second feature vector B, and mixing the composite vector C[A, B] into an object with pre-labeled labels to obtain a mixed data set, wherein the labels include question labels and answer labels;
[0023] Clustering the mixed data set to obtain multiple data clusters, and using labels of objects in the same cluster as the synthetic vector C[A, B] as labels of the synthetic vector C[A, B];
[0024] A basic knowledge base is constructed based on the composite vector C[A, B] and the label of the composite vector C[A, B].
[0025] In one embodiment of the present application, it also includes:
[0026] When the composite vector C[A, B] includes the target word, the composite vector C[A, B] is directly assigned to the corresponding cluster, and the label in the corresponding cluster is used as the label of C[A, B].
[0027] In one embodiment of the present application, a confidence evaluation model is constructed based on the network corpus, including:
[0028] Dividing the network corpus to obtain multiple single sentences;
[0029] Extract related phrases for each single sentence, where the related phrases at least include the head entity W h , relation R and tail entity W t Two of them;
[0030] An associated word library is constructed based on a plurality of associated word groups, and a confidence evaluation model is constructed by counting associated words of each word in the associated word library.
[0031] In one embodiment of the present application, a confidence evaluation model is constructed by counting the associated words of each word in the associated word library, including:
[0032] Selecting a current word W0 from the associated word library;
[0033] Count the occurrence frequency F(W0) of the current word W0 and each associated word W of the current word W0 i The frequency of occurrence F(W i );
[0034] Based on the appearance frequency F(W0) of the current word W0 and the appearance frequency F(W i ) Calculate the confidence C(W) of each associated word of the current word W0 i ), confidence C(W i) is:
[0035]
[0036] In the formula, α i is the weight of the i-th associated word of the current word W0;
[0037] Select the next word from the associated word library as the current word W0, and calculate all the associated words W of the current word W0 i The confidence C(W i ) until the confidence calculation of the associated words of all words in the associated word library is completed, and the confidence evaluation model is obtained.
[0038] In one embodiment of the present application, determining the confidence of the extended question based on the confidence evaluation model includes:
[0039] Extract the keywords in the extended question, where the keywords are the head entities W h , relation R and tail entity W t Two of them;
[0040] The confidence of the keyword is determined by querying the confidence evaluation model, and the confidence of the keyword is used as the confidence of the extended question.
[0041] In one embodiment of the present application, it also includes:
[0042] When performing a question-answering task, matching the question sentence input by the user with the question-answering template in the basic knowledge base, and when there is no matching question-answering template in the basic knowledge base, matching the question sentence input by the user with the question-answering template in the extended knowledge base;
[0043] When a question in any question-answer template matches a question input by a user, a record is made, and the number of successful matches of each question in the basic knowledge base and the extended knowledge base is counted;
[0044] In each use cycle, the questions in the extended knowledge base with a number of successful matches greater than or equal to a number threshold are moved to the basic knowledge base.
[0045] In one embodiment of the present application, it also includes:
[0046] Questions that are successfully matched in multiple use cycles are deleted from the extended knowledge base.
[0047] The present application also includes a device for constructing a question-answer model database, including:
[0048] An acquisition module is used to acquire knowledge materials and network corpus of the target industry, wherein the knowledge materials include text materials, picture materials, audio materials and video materials, and the network corpus is crawled from the Internet at a regular interval;
[0049] A first construction module is used to construct a basic knowledge base based on the knowledge material, wherein the basic knowledge base includes a plurality of question and answer templates, associated audios of the plurality of question and answer templates, and associated videos of the plurality of question and answer templates;
[0050] An extension module, used to expand the basic question sentence in the question-answer template to obtain an extended question sentence;
[0051] A second construction module is used to construct a confidence evaluation model based on the network corpus, and determine the confidence of the extended question based on the confidence evaluation model, wherein the confidence evaluation model includes confidences when multiple groups of entities and relations are used together;
[0052] The third construction module is used to place the extended questions with confidence greater than or equal to the preset threshold in the basic knowledge base, and place the extended questions with confidence less than the preset threshold in the extended knowledge base, and construct a question-answering model database based on the basic knowledge base and the extended knowledge base, wherein the extended database is used to perform supplementary retrieval on questions that are not retrieved in the basic knowledge base, and there is a mapping relationship between the extended questions in the extended database and the corresponding question-answering templates in the basic knowledge base.
[0053] The beneficial effects of the present invention are as follows: a method and device for constructing a question-answering model database of the present invention obtains knowledge materials of the same industry, and then establishes a basic knowledge base based on the knowledge materials, thereby constructing some question-answering templates with high accuracy and frequency of use. In order to cover more scenarios, the present application also uses a language model to expand the questions in the question-answering template, and obtains network corpus, and constructs a confidence evaluation model through the network corpus, so as to evaluate the confidence of the extended questions, and place the extended questions with lower confidence in the extended knowledge base, and place the extended questions with higher confidence in the basic knowledge base. When performing question-answering, question matching is now performed in the basic knowledge base, and when the basic knowledge base cannot be matched, matching is performed in the extended knowledge base. The retrieval speed and the conciseness of the basic knowledge base in most question-answering processes are guaranteed, and the extended questions are automatically verified at the same time, with high verification efficiency and low cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0055] Figure 1 A flowchart of a method for constructing a question-answer model database in one embodiment of the present invention;
[0056] Figure 2 A schematic diagram of a triple knowledge graph in an embodiment of the present application;
[0057] Figure 3 This is a schematic diagram of a process in which a video enters a basic knowledge base in an embodiment of the present application;
[0058] Figure 4 This is a schematic diagram of the process of a picture entering a basic knowledge base in an embodiment of the present application;
[0059] Figure 5 This is a schematic diagram of the process of audio entering the basic knowledge base in an embodiment of the present application;
[0060] Figure 6 This is a structural diagram of a device for constructing a question-answer model database in one embodiment of the present invention. DETAILED DESCRIPTION
[0061] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0062] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show the layers related to the present invention rather than being drawn according to the number, shape and size of the layers in actual implementation. In actual implementation, the type, quantity and proportion of each layer may be changed arbitrarily, and the layer layout may also be more complicated.
[0063] In the following description, numerous details are discussed to provide a more thorough explanation of embodiments of the present invention; however, it is apparent to one skilled in the art that embodiments of the present invention may be practiced without these specific details.
[0064] Figure 1 is a flowchart of a method for constructing a question-answer model database shown in an embodiment of the present application, such as Figure 1 As shown: including the steps:
[0065] S100, acquiring knowledge materials and network corpus of the target industry, wherein the knowledge materials include text materials, picture materials, audio materials and video materials, and the network corpus is crawled from the Internet at a regular interval;
[0066] The target industry’s knowledge materials can be electronic files in PDF or docx format, or books. Since the accuracy of the basic knowledge base needs to be guaranteed, knowledge materials should be obtained from official channels or authoritatively certified materials as much as possible. At the same time, knowledge materials can also be pictures, audio and video materials to ensure the richness of the knowledge base.
[0067] The main function of online corpus is to verify whether the extended question is reasonable, whether it conforms to people's word usage habits and rationality of terms when asking questions, etc. Therefore, it can be crawled from various professional forums and knowledge sharing websites.
[0068] S200, constructing a basic knowledge base based on the knowledge material, wherein the basic knowledge base includes a plurality of question and answer templates, associated audios of the plurality of question and answer templates, and associated videos of the plurality of question and answer templates;
[0069] Since there are many types of knowledge materials, the methods for building a basic knowledge base for different knowledge materials are also different. In this embodiment, the basic knowledge base is built in the following way:
[0070] When the knowledge material is a text material, a basic knowledge base is constructed based on the knowledge material, including:
[0071] S211, segmenting the text material to obtain multiple text segments;
[0072] Specifically, the following steps are used for segmentation processing:
[0073] Divide the article into sections and title levels within the article, with the smallest unit being paragraphs.
[0074] Divide the paragraph into m sentences according to the period
[0075] Determine the total length of the first i sentences that have not been assigned to any paragraph; when assigning for the first time, determine the total length of 1-i sentences.
[0076] When the total length of the first i sentences is less than or equal to N, the first i sentences are classified into the current paragraph;
[0077] When the total length of the first i sentences is greater than N, and the total length of the first i-1 sentences is less than N, the i-1th sentence, the i-th sentence, and the i+1th sentence are vectorized based on the pre-built encoder to obtain the first sentence vector, the second sentence vector, and the third sentence vector; the specific vectorization process is consistent with the vectorization process of the question text in the previous article, and will not be repeated here.
[0078] Calculate the first similarity between the first sentence vector and the second sentence vector, and calculate the second similarity between the second sentence vector and the third sentence vector; when the first similarity is greater than the second similarity, classify the i-th sentence into the current paragraph; when the first similarity is less than or equal to the second similarity, treat the i-th sentence as the first sentence not classified, and return to determine the total length of the first i sentences not classified into any paragraph, until all sentences are classified and multiple paragraphs are obtained.
[0079] In this embodiment, the above classification method is used to ensure that the length of each paragraph is as close to N as possible, thereby ensuring the consistency of the length and the coherence of the content of the paragraph, thereby providing a material basis for the establishment of a text library.
[0080] S212, performing triple extraction on the multiple text segments to obtain multiple triples, wherein the structure of the triples is head entity-relationship-tail entity;
[0081] S213, taking the entities of the triples as nodes and connecting the nodes based on the relationships of the triples to obtain a triple knowledge graph;
[0082] In this embodiment, triples are extracted from the segmented data and stored in a knowledge graph. The obtained knowledge graph can be used as a basis for question generation.
[0083] S214, calling a language model, generating multiple questions based on multiple text fragments, and building a basic knowledge base based on the multiple questions and corresponding text fragments, or, building multiple questions according to the triple knowledge graph, and building a basic knowledge base based on the multiple questions and corresponding text fragments.
[0084] In this embodiment, questions can be generated in two ways: the first is to use a large language model to generate, and the second is to generate based on a triple knowledge graph.
[0085] The process of generating a large language model is as follows:
[0086] Call the LLM model and input: "Please generate m questions based on the following paragraph: [paragraph content], and separate them with ";"." You can get multiple question texts.
[0087] For example:
[0088] Q: What are the indications for enteric-coated aspirin tablets?
[0089] A: Inhibition of platelet aggregation, prevention of recurrence of myocardial infarction, ....
[0090] Q: What is the drug for preventing recurrence of myocardial infarction?
[0091] A: Enteric-coated aspirin tablets,...
[0092] Q: Which documents contain relevant information about enteric-coated aspirin tablets?
[0093] A: "Chinese Practical Medicine", "Modern Drugs and Clinical Practice",...
[0094] Q: What are the contraindications for the use of enteric-coated aspirin tablets?
[0095] A: Kidney failure, liver failure, ...
[0096] Q: Which drugs should not be used by pregnant women?
[0097] A: Enteric-coated aspirin tablets,...
[0098] After obtaining the question text, the computer needs to recognize and match the text later. Therefore, the text needs to be converted into a computer-recognizable encoding form. Specifically, it includes:
[0099] Q (question) and A (answer) are segmented and keywords are extracted using the industry segmentation table.
[0100] Use the encoding table to convert the keywords separated from Q (question) and A (answer) into word vectors and merge them into vector Cv[Qv, Av]
[0101] Get data {"question":"question","answer":"answer","source paragraph":"paragraph content","query vector":"vector Cv[Qv,Av]"}
[0102] Using the entity extraction algorithm and industry vocabulary, we extract entities from the above content and get the following content:
[0103] {"question":"What is the role of aspirin?","answer":"It can inhibit the aggregation of platelets.","Source paragraph":"Enteric-coated aspirin tablets are a commonly used drug that can mainly inhibit the aggregation of platelets. Currently, enteric-coated aspirin tablets are mainly used to prevent the recurrence of myocardial infarction or secondary prevention of stroke, and can reduce the risk of myocardial infarction in patients with some cardiovascular risk factors.","Source":"Modern Drugs and Clinic","China Practical Medicine","Involved people, places, things":"Enteric-coated aspirin tablets, inhibition of platelet aggregation, recurrence of myocardial infarction, secondary prevention of stroke"}
[0104] Finally, the constructed data is stored in the industry text library: {"question":"question","answer":"answer","source paragraph":"paragraph content","source":"[book name],[material name]","involved people, places, things":"entity 1, entity 2, entity 3","query vector":"vector Cv[Qv, Av]"}
[0105] Figure 2 is a schematic diagram of a triple knowledge graph in an embodiment of the present application. The triple knowledge graph constructed in the present application is as follows Figure 2 shown.
[0106] An example of a question generated using a triple knowledge graph is as follows:
[0107] Q: What are the indications for enteric-coated aspirin tablets?
[0108] A: Inhibition of platelet aggregation, prevention of recurrence of myocardial infarction, ....
[0109] Q: What is the drug for preventing recurrence of myocardial infarction?
[0110] A: Enteric-coated aspirin tablets,...
[0111] Q: Which documents contain relevant information about enteric-coated aspirin tablets?
[0112] A: "Chinese Practical Medicine", "Modern Drugs and Clinical Practice",...
[0113] Q: What are the contraindications for the use of enteric-coated aspirin tablets?
[0114] A: Kidney failure, liver failure, ...
[0115] Q: Which drugs should not be used by pregnant women?
[0116] A: Enteric-coated aspirin tablets,...
[0117] Finally, the questions are manually checked and verified, and associated with the segmentation source, inappropriate content is eliminated, and finally a QA question set is generated, thereby building a basic knowledge base.
[0118] In one embodiment of the present application, for pictures, audio and video, the following method is used to construct a basic knowledge base in this embodiment.
[0119] When the knowledge material is a picture material, an audio material or a video material, building a basic knowledge base based on the knowledge material includes:
[0120] S221, extracting features of the industry materials to obtain material features;
[0121] S222, converting the industry material into text to obtain a description text; and extracting keywords from the description text to obtain keywords;
[0122] S223, converting the material feature into a first feature vector A through a pre-established coding table, and converting the keyword into a second feature vector B through a pre-established coding table;
[0123] S224, constructing a composite vector C[A, B] based on the first feature vector A and the second feature vector B, and mixing the composite vector C[A, B] into an object with pre-labeled labels to obtain a mixed data set, wherein the labels include question labels and answer labels;
[0124] S225, clustering the mixed data set to obtain multiple data clusters, and using the labels of objects in the same cluster as the composite vector C[A, B] as the labels of the composite vector C[A, B];
[0125] S226, constructing a basic knowledge base based on the composite vector C[A, B] and the label of the composite vector C[A, B].
[0126] For images, audio, and video, the above process is slightly different.
[0127] Figure 3 FIG. 1 is a schematic diagram of a process of a video entering a basic knowledge base in an embodiment of the present application. Figure 3 As shown, including:
[0128] Extract the audio track of the video to be associated to generate an audio file;
[0129] The audio is extracted by bidirectional LSTM and converted into feature vector A through the encoding table;
[0130] The audio is converted into text through the ASR (Automatic Speech Recognition) model. The obtained text is used to extract keywords through a bidirectional LSTM and converted into a feature vector B through a coding table.
[0131] Combine the audio feature vector A and the text feature vector B into a vector C[A, B];
[0132] Stored in the industry database;
[0133] According to the clustering of the synthetic vector C, the predicted Q, A labels are obtained; specifically, the vector C is mixed into a bunch of pre-labeled objects, each of which is labeled with a QA label, and then clustered to obtain the target cluster corresponding to the vector C. The QA labels of other objects in the target cluster can be directly transferred to the vector C, thereby automatically labeling the vector C;
[0134] Q and A label verification by business professionals;
[0135] Use the encoding table to convert Q (question label) and A (answer label) into word vectors and merge them into vector Cv[Qv, Av];
[0136] {"question":"question","answer":"audio link","source paragraph":"paragraph content","query vector":"vector Cv[Qv,Av]"};
[0137] Use the encoding table to convert Q (question label) and A (answer label) into word vectors and merge them into vector Cv[Qv, Av];
[0138] Store the constructed data into the industry video library {"question":"question","answer":"video link","text content":"text content","query vector":"vector Cv[Qv,Av]"};
[0139] Figure 4 FIG. 1 is a schematic diagram of a process of entering a basic knowledge base into a picture in an embodiment of the present application. Figure 4 As shown, including:
[0140] The image is converted into a one-dimensional feature vector A through CNN convolution;
[0141] The image is converted into text through OCR, and the obtained text is used to extract keywords through bidirectional LSTM and converted into feature vector B through the encoding table;
[0142] Combine the image feature vector A and the text feature vector B into a vector C[A, B];
[0143] Stored in the industry database;
[0144] According to the clustering of the synthetic vector C, the predicted Q and A labels are obtained. The specific clustering process is consistent with that in the video and will not be repeated here.
[0145] Q and A label verification by business professionals;
[0146] Use the encoding table to convert Q (question label) and A (answer label) into word vectors and merge them into vector Cv[Qv, Av];
[0147] {"question":"question","answer":"audio link","source paragraph":"paragraph content","query vector":"vector Cv[Qv,Av]"};
[0148] Use the encoding table to convert Q (question label) and A (answer label) into word vectors and merge them into vector Cv[Qv, Av];
[0149] Store the constructed data into the industry image library {"question":"question","answer":"image link","text content":"text content","query vector":"vector Cv[Qv,Av]"}.
[0150] Figure 5 FIG. 1 is a schematic diagram of a process in which audio enters a basic knowledge base in an embodiment of the present application. Figure 5 As shown, including:
[0151] The audio is extracted by bidirectional LSTM and converted into feature vector A through the encoding table;
[0152] The audio is converted into text through the ASR (Automatic Speech Recognition) model. The obtained text is used to extract keywords through a bidirectional LSTM and converted into a feature vector B through a coding table.
[0153] Combine the audio feature vector A and the text feature vector B into a vector C[A, B];
[0154] Stored in the industry database;
[0155] According to the clustering of the synthetic vector C, the predicted Q and A labels are obtained;
[0156] Q and A label verification by business professionals;
[0157] Use the encoding table to convert Q (question label) and A (answer label) into word vectors and merge them into vector Cv[Qv, Av];
[0158] {"question":"question","answer":"audio link","source paragraph":"paragraph content","query vector":"vector Cv[Qv,Av]"};
[0159] Use the encoding table to convert Q (question label) and A (answer label) into word vectors and merge them into vector Cv[Qv, Av];
[0160] Store the constructed data into the industry audio library {"question":"question","answer":"audio link","text content":"text content","query vector":"vector Cv[Qv,Av]"}.
[0161] In addition, when the composite vector C[A, B] includes the target word, the composite vector C[A, B] is directly assigned to the corresponding cluster, and the label in the corresponding cluster is used as the label of C[A, B].
[0162] In this application, if a specific object appears in the synthetic vector C[A, B], it can be directly determined that the synthetic vector C[A, B] is a specific category. For example, if the words "anti-inflammatory drugs" appear, it can be directly determined that the synthetic vector C[A, B] can be converted to the QA label of "penicillin". The above rules, as a supplement to clustering, can make the label of the synthetic vector C[A, B] more accurate.
[0163] S300, expanding the basic question sentence in the question-answer template to obtain an extended question sentence;
[0164] This application expands the basic question sentence by calling the LLM language model. After calling the model, input "Please generate m questions with the same meaning based on the following question: [question content], and separate them with ";"", and you can get multiple extended questions. Other existing technical means can also be used to expand the question sentence, which will not be described in detail here.
[0165] However, such extended questions are based on a large language model. They may not conform to the industry's linguistic habits, and may even contain errors. For example, this application needs to be applied to the pharmaceutical industry. The question "What are the contraindications of drug A" may be expanded to "What are the taboos of drug A" and "What are the reverse scales of drug A" through synonym replacement or large model replacement. However, in the pharmaceutical industry, the synonyms of "taboo", "taboo" and "reverse scale" are generally not used together with drugs. Therefore, such extended questions are meaningless and have low confidence.
[0166] Therefore, considering the problems that may arise in the above process, in this embodiment, the following method is used to perform automatic verification.
[0167] S400, constructing a confidence evaluation model based on the network corpus, and determining the confidence of the extended question based on the confidence evaluation model, wherein the confidence evaluation model includes confidences when multiple groups of entities and relations are used together;
[0168] The present application constructs a confidence evaluation model through regularly updated network corpus. The network corpus is updated cumulatively. It can be understood that the confidence evaluation model in the present application is also regularly updated.
[0169] In one embodiment of the present application, a confidence evaluation model is constructed based on the network corpus, including:
[0170] S411, dividing the network corpus to obtain multiple single sentences;
[0171] Specifically, direct division can be performed by punctuation marks.
[0172] S412, extracting related phrases from each single sentence, wherein the related phrases at least include the head entity W h , relation R and tail entity W t Two of them;
[0173] If there is a related phrase in a single sentence, it is extracted, if not, it is ignored. This application can extract related phrases through a trained language model to extract keywords required by different industries.
[0174] S413, constructing an associated word library based on the multiple associated word groups, and constructing a confidence evaluation model by counting the associated words of each word in the associated word library.
[0175] Specifically, a confidence evaluation model is constructed by counting the associated words of each word in the associated word library, including:
[0176] S4131, selecting a current word W0 from the associated word library;
[0177] S4132, counting the occurrence frequency F(W0) of the current word W0 and each associated word W of the current word W0 i The frequency of occurrence F(W i );
[0178] S4133, based on the occurrence frequency F(W0) of the current word W0 and the occurrence frequency F(W i ) Calculate the confidence C(W) of each associated word of the current word W0 i ), confidence C(W i ) is:
[0179]
[0180] In the formula, α i is the weight of the i-th associated word of the current word W0;
[0181] S4134, select the next word from the associated word library as the current word W0, and calculate all the associated words W of the current word W0 i The confidence C(W i ) until the confidence calculation of the associated words of all words in the associated word library is completed, and the confidence evaluation model is obtained.
[0182] Step S4131-Step S4134: The confidence of each associated word is calculated by counting the co-occurrence frequency of the current word and the associated words, and the higher the frequency, the higher the confidence.
[0183] S500, placing the extended questions whose confidence is greater than or equal to the preset threshold in the basic knowledge base, and placing the extended questions whose confidence is less than the preset threshold in the extended knowledge base, and constructing a question-answering model database based on the basic knowledge base and the extended knowledge base, wherein the extended database is used to perform supplementary retrieval on questions that are not retrieved in the basic knowledge base, and there is a mapping relationship between the extended questions in the extended database and the corresponding question-answering templates in the basic knowledge base.
[0184] Specifically, determining the confidence of the extended question based on the confidence evaluation model includes:
[0185] S510, extracting keywords from the extended question, where the keywords are head entities W h , relation R and tail entity W t Since the extended question is generally extended through a triple structure, the extended question generally includes two of the triples, namely the head entity W h , relation R and tail entity W t Two of them.
[0186] S520: Determine the confidence of the keyword by querying the confidence evaluation model, and use the confidence of the keyword as the confidence of the extended question.
[0187] By querying the confidence evaluation model to determine the confidence of the two keywords, we can get the confidence of whether the terms and words used in the extended question are appropriate. The higher the confidence, the more common and appropriate the terms are in the industry. Otherwise, there is a risk of not being applicable to the corresponding industry.
[0188] Therefore, in this embodiment, extended questions are screened by setting a preset threshold. Extended questions with higher confidence are assigned to the corresponding question and answer templates of the basic knowledge base. Extended questions with lower confidence are placed in the extended knowledge base. When conducting question and answer, first search in the basic knowledge base. Since the basic knowledge base stores extended questions with high confidence and question and answer templates from industry materials, the accuracy and coverage are relatively high. Most questions can be matched in the basic knowledge base, and then the corresponding answer text is output. If it cannot be matched in the basic knowledge base, then search in the extended knowledge base to further expand the coverage of the question.
[0189] In this embodiment, since the data in the basic knowledge base and the extended knowledge base are stored in the form of vectors, the matching process can be a process of calculating cosine similarity.
[0190] In an embodiment of the present application, the questions in the basic knowledge base and the extended knowledge base are not always the same. The present application needs to place frequently used questions in the basic knowledge base and infrequently used questions in the extended database to ensure the coverage and simplicity of the basic knowledge base. Therefore, the present application also includes:
[0191] When performing a question-answering task, matching the question sentence input by the user with the question-answering template in the basic knowledge base, and when there is no matching question-answering template in the basic knowledge base, matching the question sentence input by the user with the question-answering template in the extended knowledge base;
[0192] When a question in any question-answer template matches a question input by a user, a record is made, and the number of successful matches of each question in the basic knowledge base and the extended knowledge base is counted;
[0193] In each use cycle, the questions in the extended knowledge base with a number of successful matches greater than or equal to a number threshold are moved to the basic knowledge base.
[0194] Questions in the basic knowledge base with a number of successful matches less than a threshold number may also be moved to the extended knowledge base to streamline the basic knowledge base.
[0195] In this embodiment, each successfully matched question will be counted in the system, and adjusted according to the number of successful matches in each use cycle. Under the condition that each question and answer template has at least one question, it is ensured that the questions in the basic database are consistent with the user's questioning habits.
[0196] In addition, the present application also deletes the questions that have been successfully matched in multiple use cycles from the extended knowledge base to streamline the extended knowledge base.
[0197] A method for constructing a question-answering model database of the present invention obtains knowledge materials of the same industry, and then establishes a basic knowledge base based on the knowledge materials, thereby constructing some question-answering templates with high accuracy and frequency of use. In order to cover more scenarios, the present application also expands the questions in the question-answering template through a language model, obtains network corpus, and constructs a confidence evaluation model through the network corpus, thereby evaluating the confidence of the extended questions, placing the extended questions with lower confidence in the extended knowledge base, and placing the extended questions with higher confidence in the basic knowledge base. When performing question-answering, question matching is now performed in the basic knowledge base, and when the basic knowledge base cannot be matched, matching is performed in the extended knowledge base. The retrieval speed and the conciseness of the basic knowledge base in most question-answering processes are guaranteed, and the extended questions are automatically verified at the same time, with high verification efficiency and low cost.
[0198] like Figure 6As shown, the present application also includes a device for constructing a question-answer model database, including:
[0199] An acquisition module is used to acquire knowledge materials and network corpus of the target industry, wherein the knowledge materials include text materials, picture materials, audio materials and video materials, and the network corpus is crawled from the Internet at a regular interval;
[0200] A first construction module is used to construct a basic knowledge base based on the knowledge material, wherein the basic knowledge base includes a plurality of question and answer templates, associated audios of the plurality of question and answer templates, and associated videos of the plurality of question and answer templates;
[0201] An extension module, used to expand the basic question sentence in the question-answer template to obtain an extended question sentence;
[0202] A second construction module is used to construct a confidence evaluation model based on the network corpus, and determine the confidence of the extended question based on the confidence evaluation model, wherein the confidence evaluation model includes confidences when multiple groups of entities and relations are used together;
[0203] The third construction module is used to place the extended questions with confidence greater than or equal to the preset threshold in the basic knowledge base, and place the extended questions with confidence less than the preset threshold in the extended knowledge base, and construct a question-answering model database based on the basic knowledge base and the extended knowledge base, wherein the extended database is used to perform supplementary retrieval on questions that are not retrieved in the basic knowledge base, and there is a mapping relationship between the extended questions in the extended database and the corresponding question-answering templates in the basic knowledge base.
[0204] The present invention provides a device for constructing a question-answering model database, which obtains knowledge materials of the same industry and then establishes a basic knowledge base based on the knowledge materials, thereby constructing some question-answering templates with high accuracy and frequency of use. In order to cover more scenarios, the present application also uses a language model to expand the questions in the question-answering template, and obtains network corpus, and constructs a confidence evaluation model through the network corpus, thereby evaluating the confidence of the extended questions, placing the extended questions with lower confidence in the extended knowledge base, and placing the extended questions with higher confidence in the basic knowledge base. When performing question-answering, question matching is now performed in the basic knowledge base, and when the basic knowledge base cannot be matched, matching is performed in the extended knowledge base. The retrieval speed and the conciseness of the basic knowledge base in most question-answering processes are guaranteed, and the extended questions are automatically verified at the same time, with high verification efficiency and low cost.
[0205] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, any one of the methods in this embodiment is implemented, wherein the method is the execution logic of this device.
[0206] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0207] The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the terminal executes any one of the methods in this embodiment.
[0208] The computer-readable storage medium in this embodiment can be understood by ordinary technicians in this field: all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[0209] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication with each other. The memory is used to store computer programs, the communication interface is used to communicate, and the processor and the transceiver are used to run computer programs so that the electronic terminal executes each step of the above method.
[0210] In this embodiment, the memory may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0211] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0212] In the above-mentioned embodiments, although the present invention has been described in conjunction with the specific embodiments of the present invention, many replacements, modifications and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. The embodiments of the present invention are intended to cover all such replacements, modifications and variations falling within the broad scope of the appended claims.
[0213] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A method for constructing a question-answering model database, characterized in that: include: Acquire knowledge materials and network corpus of the target industry, wherein the knowledge materials include text materials, picture materials, audio materials and video materials, and the network corpus is crawled from the Internet at regular intervals; Building a basic knowledge base based on the knowledge material, wherein the basic knowledge base includes a plurality of question-and-answer templates, associated audios of the plurality of question-and-answer templates, and associated videos of the plurality of question-and-answer templates; expanding the basic question sentences in the question-and-answer templates to obtain extended question sentences; Constructing a confidence evaluation model based on the network corpus, and determining the confidence of the extended question based on the confidence evaluation model, wherein the confidence evaluation model includes confidences when multiple groups of entities and relations are used together; Extended questions with a confidence greater than or equal to a preset threshold are placed in the basic knowledge base, and extended questions with a confidence less than a preset threshold are placed in the extended knowledge base, and a question-answering model database is constructed based on the basic knowledge base and the extended knowledge base, wherein the extended knowledge base is used to perform supplementary retrieval on questions that are not retrieved in the basic knowledge base, and there is a mapping relationship between the extended questions in the extended knowledge base and the corresponding question-answering templates in the basic knowledge base.
2. According to the method for constructing a question-answer model database according to claim 1, it is characterized in that: When the knowledge material is a text material, a basic knowledge base is constructed based on the knowledge material, including: Segmenting the text material to obtain multiple text segments; Performing triple extraction on the multiple text segments to obtain multiple triples, wherein the structure of the triples is head entity-relation-tail entity; The triple entities are taken as nodes, and the nodes are connected based on the relationship between the triples to obtain the triple knowledge graph; Calling a language model, generating multiple questions based on multiple text fragments, and building a basic knowledge base based on the multiple questions and corresponding text fragments, or building multiple questions according to the triple knowledge graph, and building a basic knowledge base based on the multiple questions and corresponding text fragments.
3. The method for constructing a question-answer model database according to claim 1, characterized in that: When the knowledge material is a picture material, an audio material or a video material, building a basic knowledge base based on the knowledge material includes: Extracting features from the knowledge material to obtain material features; Converting the knowledge material into text to obtain a description text; and extracting keywords from the description text to obtain keywords; The material characteristics are converted into a first feature vector by a pre-established coding table , and convert the keyword into a second feature vector through a pre-established coding table ; Based on the first feature vector and the second eigenvector Construct the composite vector C\left [ {A,B} \right ] , and the resultant vector C\left [ {A,B} \right ] Mixing into the pre-labeled objects to obtain a mixed data set, wherein the labels include question labels and answer labels; Cluster the mixed data set to obtain multiple data clusters, and combine them with the synthetic vector C\left [ {A,B} \right ] The labels of objects in the same cluster are used as the composite vector C\left [ {A,B} \right ] Labels; Based on the synthetic vector C\left [ {A,B} \right ] And the resultant vector C\left [ {A,B} \right ] The basic knowledge base is constructed based on the tags.
4. The method for constructing a question-answer model database according to claim 3, characterized in that: Also includes: In the resultant vector C\left [ {A,B} \right ] When the target word is included, the synthetic vector C\left [ {A,B} \right ] Directly delineate to the corresponding cluster, and use the label in the corresponding cluster as the C\left [ {A,B} \right ] .
5. The method for constructing a question-answer model database according to claim 1, characterized in that: Constructing a confidence evaluation model based on the network corpus, including: Dividing the network corpus to obtain multiple single sentences; Extract related phrases from each single sentence, where the related phrases at least include the head entity ,relation And the tail entity Two of them; An associated word library is constructed based on a plurality of associated word groups, and a confidence evaluation model is constructed by counting associated words of each word in the associated word library.
6. The method for constructing a question-answer model database according to claim 5, characterized in that: The confidence evaluation model is constructed by counting the associated words of each word in the associated word library, including: Select a current word from the associated word library ; Statistics of the current word Frequency of occurrence , and the current word Each associated word Frequency of occurrence ; Based on the current word Frequency of occurrence , and the current word The frequency of occurrence of each associated word Calculate the current word The confidence of each associated word , confidence The mathematical expression is: In the formula, For the current word No. The weight of the associated words; Select the next word from the associated word library as the current word , and calculate the current word All related words of Confidence , until the confidence calculation of the associated words of all words in the associated word library is completed, and the confidence evaluation model is obtained.
7. The method for constructing a question-answer model database according to claim 1, characterized in that: Determining the confidence of the extended question based on the confidence evaluation model includes: Extract the keywords in the extended question, where the keywords are the head entities ,relation And the tail entity Two of them; The confidence of the keyword is determined by querying the confidence evaluation model, and the confidence of the keyword is used as the confidence of the extended question.
8. The method for constructing a question-answer model database according to claim 1, characterized in that: Also includes: When performing a question-answering task, matching the question sentence input by the user with the question-answering template in the basic knowledge base, and when there is no matching question-answering template in the basic knowledge base, matching the question sentence input by the user with the question-answering template in the extended knowledge base; When a question in any question-answer template matches a question input by a user, a record is made, and the number of successful matches of each question in the basic knowledge base and the extended knowledge base is counted; In each use cycle, the questions in the extended knowledge base with a number of successful matches greater than or equal to a number threshold are moved to the basic knowledge base.
9. The method for constructing a question-answer model database according to claim 8, characterized in that: Also includes: Questions that are successfully matched in multiple use cycles are deleted from the extended knowledge base.
10. A device for constructing a question-answer model database, characterized in that: include: An acquisition module is used to acquire knowledge materials and network corpus of the target industry, wherein the knowledge materials include text materials, picture materials, audio materials and video materials, and the network corpus is crawled from the Internet at a regular interval; A first construction module is used to construct a basic knowledge base based on the knowledge material, wherein the basic knowledge base includes a plurality of question and answer templates, associated audios of the plurality of question and answer templates, and associated videos of the plurality of question and answer templates; An extension module, used to expand the basic question sentence in the question-answer template to obtain an extended question sentence; A second construction module is used to construct a confidence evaluation model based on the network corpus, and determine the confidence of the extended question based on the confidence evaluation model, wherein the confidence evaluation model includes confidences when multiple groups of entities and relations are used together; The third construction module is used to place the extended questions with confidence greater than or equal to the preset threshold in the basic knowledge base, and place the extended questions with confidence less than the preset threshold in the extended knowledge base, and construct a question-answering model database based on the basic knowledge base and the extended knowledge base, wherein the extended knowledge base is used to perform supplementary retrieval on questions not retrieved in the basic knowledge base, and there is a mapping relationship between the extended questions in the extended knowledge base and the corresponding question-answering templates in the basic knowledge base.
