ABI question and answer method and system for aligning large model with database
By matching and adjusting the keywords entered by the user in the machine question and answering system, combining length, structure and semantic differences, the matching inaccuracy caused by text noise interference in the prior art is solved, and the accuracy of the question and answer system is improved.
Patent Information
- Application Number
- CN202411820914.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-11
AI Technical Summary
The existing machine Q&A system causes inaccurate keyword matching due to text noise interference, which reduces the accuracy of the Q&A system.
A method of ABI question and answer is proposed to align large models with databases. By obtaining multiple keywords and answer sentences in the user-entered question statement, matching keywords and answer sentences, combining length, structure and semantic differences, adjusting the matching degree, and obtaining the true matching degree, thereby filtering out the best answer sentence and generating the final best answer.
It improves the accuracy of matching degree analysis between keywords and answer sentences, enhances the accuracy of answers of the ABI question and answer system, and solves the matching error problem caused by noise interference.
Smart Images

Figure CN119760106A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine question answering, and in particular to an ABI question answering method and system for aligning a large model with a database. Background Art
[0002] ABI Q&A is a machine question-answering system. Users input the questions they want to query or ask into it. The large language model embedded in it analyzes the questions raised by the users and filters out information that solves the questions from the relevant database, and then outputs the corresponding answers to the users, meeting the users' needs to obtain information anytime and anywhere.
[0003] In the related art, keywords are usually extracted from the questions asked by the user, and the keywords are matched with the information in the database, and the information with a higher matching degree is selected as the best answer and output. However, due to the interference of text noise in the questions asked by the user and the information in the database, the accuracy of keyword matching is affected, which makes it impossible to accurately output the answers to relevant questions through existing methods, thereby reducing the accuracy of the question-answering system. Summary of the invention
[0004] In order to solve the technical problem that the existing methods cannot accurately output answers to relevant questions and reduce the accuracy of the question-answering system, the purpose of the present invention is to provide an ABI question-answering method and system that aligns a large model with a database. The technical solutions adopted are as follows:
[0005] The present invention proposes an ABI question-answering method for aligning a large model with a database, the method comprising:
[0006] Acquire multiple keywords in a question sentence input by a user and multiple answer sentences to the question sentence;
[0007] Take any answer sentence as the target answer sentence, match each keyword with the target answer sentence, and obtain the label value of each keyword with respect to the target answer sentence; take any keyword as the target keyword, and obtain the initial matching degree of the target keyword with respect to the target answer sentence according to the label values of other keywords except the target keyword with respect to the target answer sentence;
[0008] According to the difference in length and structure between the question sentence and the target answer sentence, the initial matching degree of the target keyword with respect to the target answer sentence is adjusted to obtain the adjusted matching degree of the target keyword with respect to the target answer sentence; according to the difference in semantics between the question sentence and the target answer sentence, the adjusted matching degree of the target keyword with respect to the target answer sentence is adjusted to obtain the real matching degree of the target keyword with respect to the target answer sentence; based on the real matching degree of the target keyword with respect to each answer sentence, the best answer sentence of the target keyword is screened out from all answer sentences;
[0009] Based on the best answer sentence of all keywords of the question sentence, the best answer to the question sentence is generated.
[0010] Furthermore, obtaining the initial matching degree of the target keyword with respect to the target answer sentence includes:
[0011] Keywords other than the target keyword are used as reference keywords for the target keyword, and the accumulated value of the label values of all reference keywords with respect to the target answer sentence is used as the initial matching degree of the target keyword with respect to the target answer sentence.
[0012] Furthermore, obtaining the adjusted matching degree of the target keyword with respect to the target answer sentence includes:
[0013] Use any one of the question sentence and the target answer sentence as the sentence to be tested;
[0014] Counting the number of characters contained in the sentence to be tested as the text length of the sentence to be tested, and performing negative correlation mapping on the absolute value of the difference in text length between the question sentence and the target answer sentence to obtain the length similarity between the question sentence and the target answer sentence;
[0015] Use a word segmentation tool to segment the sentence to be tested, obtain the phrases of the sentence to be tested, and select the content phrases of the sentence to be tested from all the phrases. According to the difference in the proportion of the content phrases in all the phrases between the question sentence and the target answer sentence, obtain the structural similarity between the question sentence and the target answer sentence;
[0016] The length similarity and the structure similarity are integrated to obtain the integrated similarity between the question sentence and the target answer sentence;
[0017] The product value of the comprehensive similarity and the initial matching degree of the target keyword with respect to the target answer sentence is used as the adjusted matching degree of the target keyword with respect to the target answer sentence.
[0018] Furthermore, obtaining the structural similarity between the question sentence and the target answer sentence includes:
[0019] The number of content phrases in the sentence to be tested is used as the numerator, the number of all phrases in the sentence to be tested is used as the denominator, and the ratio is used as the content word density of the sentence to be tested;
[0020] The absolute value of the difference in the density of the content words between the question sentence and the target answer sentence is negatively correlated to obtain the structural similarity between the question sentence and the target answer sentence.
[0021] Furthermore, obtaining the comprehensive similarity between the question sentence and the target answer sentence includes:
[0022] The sum of the length similarity and the structure similarity between the question sentence and the target answer sentence is used as the comprehensive similarity between the question sentence and the target answer sentence.
[0023] Furthermore, obtaining the true matching degree of the target keyword with respect to the target answer sentence includes:
[0024] Input the question sentence and the target answer sentence into the DSSM model to obtain the semantic similarity between the question sentence and the target answer sentence;
[0025] The product value of the semantic similarity between the question sentence and the target answer sentence and the adjusted matching degree of the target keyword with respect to the target answer sentence is taken as the true matching degree of the target keyword with respect to the target answer sentence.
[0026] Furthermore, the method of filtering out the best answer sentence for the target keyword from all answer sentences includes:
[0027] The answer sentence corresponding to the maximum value of the true matching degree of the target keyword with respect to all answer sentences is taken as the best answer sentence for the target keyword.
[0028] Furthermore, the best answer to the generated question statement includes:
[0029] Perform different permutations and combinations of the best answer sentences for all keywords to obtain multiple combined answer sentences;
[0030] Input each combined answer sentence into the N-gram model to obtain the fluency of each combined answer sentence;
[0031] The combined answer sentence corresponding to the maximum value of the fluency is taken as the best answer to the question sentence.
[0032] Furthermore, obtaining the label value of each keyword with respect to the target answer sentence includes:
[0033] For any keyword, keyword matching is performed between the keyword and the target answer sentence based on the regular expression method. If the target answer sentence contains the keyword, the label value of the keyword with respect to the target answer sentence is set to the value 1. If the target answer sentence does not contain the keyword, the label value of the keyword with respect to the target answer sentence is set to the value 0.
[0034] The present invention also proposes an ABI question-and-answer system for aligning a large model with a database. The system includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any one of the steps of an ABI question-and-answer method for aligning a large model with a database.
[0035] The present invention has the following beneficial effects:
[0036] The present invention takes into account that the existing methods cannot accurately output answers to relevant questions, thereby reducing the accuracy of the question-answering system. Therefore, the present invention first obtains multiple keywords in the question sentence input by the user and multiple answer sentences of the question sentence. Since there are multiple answer sentences in the question sentence, and the correlation between different answer sentences and the question sentence is different, each keyword of the question sentence is first matched with the target answer sentence. The label value can intuitively reflect whether a certain keyword of the question sentence is in the target answer sentence and the correlation between each keyword and the target answer sentence, thereby providing a data basis for the subsequent matching degree analysis between the keyword and the target answer sentence. Considering that the text noise existing in the question sentence and the answer sentence will interfere with the accuracy of the above-mentioned keyword matching analysis, resulting in matching errors between each keyword and the target answer sentence, and considering that each keyword comes from the same question sentence and there is a logical connection between the keywords, The initial matching degree preliminarily reflects the degree of association between the target keyword and the target answer sentence. Considering that the impact of noise on the sentence is relatively random, and the impact on the length and structure of the overall content of the sentence is relatively small, for the answer sentence that is closely related to the question sentence, the content length and content structure between it and the question sentence are relatively similar. Therefore, the initial matching degree can be adjusted through this feature to improve the accuracy of the matching degree analysis between the keyword and the answer sentence. Considering that text noise does not change the semantics of the sentence to a large extent, and for the answer sentence that is closely related to the question sentence, the semantics between it and the question sentence are also relatively similar, the matching degree can be adjusted again based on this feature to obtain a more accurate real matching degree, further improving the accuracy of the matching degree analysis between the keyword and the answer sentence, and then accurately generating the best answer to the question sentence through the best answer sentence of each keyword screened out, thereby improving the accuracy of the ABI question-answering system. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 A flowchart of an ABI question-answering method for aligning a large model with a database provided by one embodiment of the present invention;
[0039] Figure 2 A flow chart of a method for obtaining an adjusted matching degree of a target keyword with respect to a target answer sentence provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the specific implementation method, structure, features and effects of an ABI question-and-answer method and system for aligning a large model with a database proposed by the present invention in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0041] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0042] The following is a detailed description of a specific scheme of an ABI question-and-answer method and system for aligning a large model with a database provided by the present invention in conjunction with the accompanying drawings.
[0043] See also Figure 1 , which shows a flow chart of an ABI question-answering method for aligning a large model with a database provided by an embodiment of the present invention, the method comprising:
[0044] Step S1: Acquire multiple keywords in a question sentence input by a user and multiple answer sentences to the question sentence.
[0045] As a machine question-answering system, ABI Q&A can output corresponding answers to questions raised by users, thereby meeting the users' needs for obtaining information anytime and anywhere. In related technologies, the best answer is usually generated and output by extracting keywords from the questions raised by users, and matching the keywords with the information in the database. However, due to the interference of text noise in the questions raised by users and the information in the database, the accuracy of keyword matching is affected, which makes it impossible to accurately output answers to relevant questions through existing methods, resulting in irrelevant answers, thereby reducing the accuracy of the question-answering system. Therefore, an embodiment of the present invention proposes an ABI question-answering method that aligns a large model with a database, so as to improve the accuracy of the large language model in retrieving information in the database, thereby improving the accuracy of the ABI question-answering system.
[0046] The embodiment of the present invention first obtains a question sentence input by a user in the ABI question-and-answer system, and then uses a large language model embedded in the ABI question-and-answer system to process the question sentence input by the user, extracts multiple keywords in the question sentence, and performs information retrieval from a related database to obtain multiple answer sentences corresponding to the question sentence, wherein the large language model includes an LLaMA language model or a GPT series language model, etc., which are not limited or elaborated here.
[0047] Step S2: Take any answer sentence as the target answer sentence, match each keyword with the target answer sentence, and obtain the label value of each keyword with respect to the target answer sentence; take any keyword as the target keyword, and obtain the initial matching degree of the target keyword with respect to the target answer sentence based on the label values of other keywords except the target keyword with respect to the target answer sentence.
[0048] Since there are multiple answer statements for a question statement, different answer statements have different relevance to the question statement, that is, some answer statements are irrelevant to the question statement. Therefore, in order to improve the ability of the answer output by the ABI question-answering system to accurately solve the corresponding problem, it is necessary to select answer statements with strong relevance to the question statement from among the numerous answer statements as the output of the ABI question-answering system to improve the accuracy of the ABI question-answering system. In an embodiment of the present invention, any answer statement is first analyzed, and any answer statement is used as a target answer statement. Since the keywords come from the question statement, the relevance between the keywords and the target answer statement can reflect the relevance between the question statement and the target answer statement to a certain extent. If the target answer statement contains a keyword, it means that the target answer statement is more relevant to the keyword. Therefore, in an embodiment of the present invention, each keyword is first matched with the target answer statement, and the label value is used to intuitively reflect whether a keyword of the question statement appears in the target answer statement, and the label value is used to intuitively reflect the relevance of each keyword to the target answer statement, so as to provide a data basis for subsequent matching analysis between the keywords and the target answer statement.
[0049] Preferably, in one embodiment of the present invention, the method for obtaining the label value of each keyword with respect to the target answer sentence specifically includes:
[0050] Regular expression is a powerful text processing tool used to perform pattern matching, search, replacement and other operations in text. Therefore, for any keyword, the keyword can be matched with the target answer sentence based on the regular expression method. If the target answer sentence contains the keyword, the label value of the keyword with respect to the target answer sentence is set to a value of 1. If the target answer sentence does not contain the keyword, the label value of the keyword with respect to the target answer sentence is set to a value of 0. The label value of each keyword of the question sentence with respect to the target answer sentence can be obtained by the same method as above. Among them, regular expressions are a technical field well known to technicians in this field and will not be elaborated here.
[0051] Considering that the text noise existing in the question statement and the answer statement will interfere with the accuracy of the above-mentioned keyword matching analysis, resulting in matching errors between each keyword and the target answer statement, the above-mentioned set label value cannot accurately reflect the correlation between each keyword and the target answer statement. At the same time, considering that each keyword comes from the same question statement, there is a logical connection between the keywords. Therefore, if the matching degree between other keywords and the target answer statement is high, then the matching degree between the target keyword and the target answer statement is also high. Therefore, the overall level of the label values of other keywords other than a certain keyword with respect to the target answer statement can be used to reflect the correlation between the keyword and the target answer statement. Therefore, the embodiment of the present invention first analyzes any keyword in the question statement, takes any keyword as the target keyword, and obtains the initial matching degree of the target keyword with respect to the target answer statement based on the label values of other keywords other than the target keyword with respect to the target answer statement. The initial matching degree preliminarily reflects the degree of correlation between the target keyword and the target answer statement. The larger the initial matching degree, the stronger the correlation between the target answer statement and the target keyword. The initial matching degree can be further adjusted later to accurately generate the best answer to the question statement and improve the accuracy of the ABI question-answering system.
[0052] Preferably, in one embodiment of the present invention, the method for obtaining the initial matching degree of the target keyword with respect to the target answer sentence specifically includes:
[0053] Keywords other than the target keyword are used as reference keywords for the target keyword. The more reference keywords there are in the target answer sentence, the stronger the connection between the target keyword and the target answer sentence is. Therefore, the accumulated value of the label values of all reference keywords with respect to the target answer sentence can be used as the initial matching degree of the target keyword with respect to the target answer sentence.
[0054] As an example, in one embodiment of the present invention, the expression of the initial matching degree of the target keyword with respect to the target answer sentence may be specifically, for example, as follows:
[0055]
[0056] Where A represents the initial matching degree of the target keyword to the target answer sentence; q n Represents the label value of the nth reference keyword of the target keyword with respect to the target answer sentence; N represents the number of keywords in the question sentence, and N-1 represents the number of reference keywords of the target keyword.
[0057] At this point, the initial matching degree of the target keyword with respect to the target answer sentence is obtained. The initial matching degree can be further adjusted subsequently to reduce the interference of text noise on the matching degree analysis and improve the accuracy of the matching degree analysis between the keyword and the answer sentence.
[0058] Step S3: According to the difference in length and structure between the question sentence and the target answer sentence, the initial matching degree of the target keyword with respect to the target answer sentence is adjusted to obtain the adjusted matching degree of the target keyword with respect to the target answer sentence; according to the difference in semantics between the question sentence and the target answer sentence, the adjusted matching degree of the target keyword with respect to the target answer sentence is adjusted to obtain the real matching degree of the target keyword with respect to the target answer sentence; based on the real matching degree of the target keyword with respect to each answer sentence, the best answer sentence of the target keyword is screened out from all answer sentences.
[0059] Since the impact of text noise on sentences is relatively random, it will only interfere with some phrases or words in the sentence, and has little impact on the length and structure of the overall content of the sentence. Therefore, for answer sentences that are closely related to the question sentence, the content length and content structure between them are relatively similar. Therefore, we can first analyze the length differences and structural differences between the question sentence and the target answer sentence, and adjust the initial matching degree of the target keyword with respect to the target answer sentence, so as to reduce the interference of text noise on the matching degree analysis between the question sentence keywords and the answer sentence, and accurately reflect the correlation between the target keyword and the target answer sentence through the obtained adjusted matching degree. The larger the adjusted matching degree, the stronger the correlation between the target keyword and the target answer sentence.
[0060] Preferably, in one embodiment of the present invention, the method for obtaining the adjusted matching degree of the target keyword with respect to the target answer sentence specifically includes:
[0061] See also Figure 2 , which shows a flow chart of a method for obtaining an adjusted matching degree of a target keyword with respect to a target answer sentence provided by an embodiment of the present invention.
[0062] Step S301: Take any one of the question sentence and the target answer sentence as the sentence to be tested, count the number of characters contained in the sentence to be tested as the text length of the sentence to be tested, perform negative correlation mapping on the absolute value of the difference in text length between the question sentence and the target answer sentence, and obtain the length similarity between the question sentence and the target answer sentence.
[0063] From the above analysis, it can be seen that if the number of characters contained in the question sentence is more, the amount of information contained in the answer sentence with a stronger correlation with the question sentence is also more. That is to say, if the correlation between the target answer sentence and the question sentence is stronger, the content length between the target answer sentence and the question sentence is more similar. Therefore, we can first use any one of the question sentence and the target answer sentence as the test sentence, and use, for example, the built-in len() function of the Python programming language or other methods to count the number of characters contained in the test sentence as the text length of the test sentence. The above method can be used to obtain the text length of the question sentence and the target answer sentence respectively, and then the absolute value of the difference in text length between the question sentence and the target answer sentence can be negatively correlated to obtain the length similarity between the question sentence and the target answer sentence. The greater the length similarity, the more similar the content length between the question sentence and the target answer sentence is, which provides a data basis for the subsequent adjustment of the initial matching degree of the target keyword with respect to the target answer sentence.
[0064] Step S302: Use a word segmentation tool to perform word segmentation on the sentence to be tested, obtain the phrases of the sentence to be tested, and filter out the content phrases of the sentence to be tested from all the phrases, and obtain the structural similarity between the question sentence and the target answer sentence based on the difference in the proportion of the content phrases in all the phrases between the question sentence and the target answer sentence.
[0065] From the above analysis, we can see that for answer sentences that are closely related to question sentences, their content structures are similar to those of question sentences. Here, content structure mainly refers to the content phrases contained in the sentence, such as nouns, verbs, adjectives, and adverbs. These types of phrases constitute the main content of a sentence. In other words, the proportion of content phrases contained in answer sentences that are closely related to question sentences is close to the proportion of content phrases contained in question sentences. Since existing word segmentation tools such as NLTK or Jieba can segment sentences and mark the parts of speech of the segmented phrases, the content phrases in the sentence can be filtered out. Therefore, a word segmentation tool can be used to segment the sentence to be tested to obtain the phrases of the sentence to be tested, and the content phrases of the sentence to be tested can be screened out from all the phrases. The same method as above can be used to obtain the phrases and content phrases of the question sentence and the target answer sentence respectively. Then, according to the difference in the proportion of content phrases in all phrases between the question sentence and the target answer sentence, the structural similarity between the question sentence and the target answer sentence can be obtained. The greater the structural similarity, the more similar the content structures between the question sentence and the target answer sentence are, which provides a data basis for the subsequent adjustment of the initial matching degree of the target keyword with respect to the target answer sentence.
[0066] Preferably, in one embodiment of the present invention, the method for obtaining the structural similarity between the question sentence and the target answer sentence specifically includes:
[0067] The number of content phrases in the sentence to be tested is taken as the numerator, the number of all phrases in the sentence to be tested is taken as the denominator, and the ratio is taken as the content word density of the sentence to be tested. The content word density can reflect the proportion of the number of content phrases in the sentence to be tested. The larger the content word density, the larger the proportion of the number of content phrases in the sentence to be tested. The content word density of the question sentence and the target answer sentence can be obtained respectively by the same method as mentioned above, and then the absolute value of the difference in content word density between the question sentence and the target answer sentence is negatively correlated to obtain the structural similarity between the question sentence and the target answer sentence.
[0068] Step S303: The length similarity and the structure similarity are integrated to obtain the integrated similarity between the question sentence and the target answer sentence.
[0069] Then, we can combine the length similarity and the structural similarity at the same time, integrate the two, and obtain the comprehensive similarity between the question sentence and the target answer sentence. The greater the comprehensive similarity, the more similar the question sentence and the target answer sentence are in length and structure. Subsequently, based on the comprehensive similarity, we can adjust the initial matching degree of the target keywords with respect to the target answer sentence to improve the accuracy of the matching analysis between the target keywords and the target answer sentence.
[0070] Preferably, in one embodiment of the present invention, the sum of the length similarity and the structure similarity between the question sentence and the target answer sentence can be used as the comprehensive similarity between the question sentence and the target answer sentence.
[0071] In other embodiments of the present invention, the product value of the length similarity and the structure similarity may also be used as the comprehensive similarity between the question sentence and the target answer sentence, which is not limited here.
[0072] As an example, in one embodiment of the present invention, the expression of the comprehensive similarity between the question sentence and the target answer sentence can be specifically, for example, as follows:
[0073]
[0074] Among them, S represents the comprehensive similarity between the question sentence and the target answer sentence; L represents the text length of the question sentence; L ′ Indicates the text length of the target answer sentence; represents the length similarity between the question sentence and the target answer sentence; ρ represents the content word density of the question sentence; ρ ′ Indicates the content word density of the target answer sentence; Represents the structural similarity between the question sentence and the target answer sentence; ε1 and ε2 represent the preset first adjustment parameter and the preset second adjustment parameter respectively, the value range of ε1 and ε2 is [0.001, 0.01]. In one embodiment of the present invention, ε1 and ε2 are set to 0.01. The specific values of ε1 and ε2 can also be set by the implementer according to the specific implementation scenario, which is not limited here.
[0075] It should be noted that in other embodiments of the present invention, negative correlation mapping may be achieved through other basic mathematical operations, which will not be elaborated herein.
[0076] Step S304: The product value of the comprehensive similarity and the initial matching degree of the target keyword with respect to the target answer sentence is used as the adjusted matching degree of the target keyword with respect to the target answer sentence.
[0077] The greater the comprehensive similarity, the more relevant the target answer sentence is to the question sentence, and the target keyword belongs to the question sentence, which is the key content of the question sentence. Therefore, the greater the comprehensive similarity, the stronger the correlation between the target keyword and the target answer sentence. Therefore, the comprehensive similarity can be used to make a weighted adjustment to the initial matching degree of the target keyword with respect to the target answer sentence, and the product value of the comprehensive similarity and the initial matching degree of the target keyword with respect to the target answer sentence is used as the adjusted matching degree of the target keyword with respect to the target answer sentence.
[0078] As an example, in one embodiment of the present invention, the expression of the adjusted matching degree of the target keyword with respect to the target answer sentence may be specifically, for example, as follows:
[0079] B=S×A
[0080] Among them, B represents the adjusted matching degree of the target keyword with respect to the target answer sentence; S represents the comprehensive similarity between the question sentence and the target answer sentence; A represents the initial matching degree of the target keyword with respect to the target answer sentence.
[0081] For answer sentences that are closely related to question sentences, their semantics are also similar to the question sentences. Text noise interference is highly random. When text noise interferes with a sentence, it does not significantly change the semantics of the sentence. Therefore, the semantic differences between the question sentence and the target answer sentence can be analyzed, and the adjusted matching degree of the target keyword with respect to the target answer sentence can be further adjusted to obtain the true matching degree of the target keyword with respect to the target answer sentence, thereby further improving the accuracy of the matching degree analysis of the target keyword and the target answer sentence, so that the ABI question and answer system can make accurate answers to question sentences and improve the accuracy of the ABI question and answer system.
[0082] Preferably, in one embodiment of the present invention, the method for obtaining the true matching degree of the target keyword with respect to the target answer sentence specifically includes:
[0083] The DSSM model can analyze the semantic similarity between texts. Therefore, the question sentence and the target answer sentence can be input into the DSSM model to obtain the semantic similarity between the question sentence and the target answer sentence. The greater the semantic similarity, the more similar the semantics between the question sentence and the target answer sentence. Then, the product value of the semantic similarity between the question sentence and the target answer sentence and the adjusted matching degree of the target keyword with respect to the target answer sentence can be used as the true matching degree of the target keyword with respect to the target answer sentence. Among them, the DSSM model is a technical means well known to technicians in this field and will not be elaborated here.
[0084] As an example, in one embodiment of the present invention, the expression of the actual matching degree of the target keyword with respect to the target answer sentence may be specifically, for example, as follows:
[0085] C=E×B
[0086] Among them, C represents the true matching degree of the target keyword with respect to the target answer sentence; E represents the semantic similarity between the question sentence and the target answer sentence; and B represents the adjusted matching degree of the target keyword with respect to the target answer sentence.
[0087] The same method as above can be used to obtain the true matching degree of the target keyword for each answer sentence. Since the true matching degree of the target keyword for different answer sentences is different, the greater the true matching degree of the target keyword for a certain answer sentence, the stronger the correlation between the answer sentence and the target keyword, and further the more relevant the answer sentence is to the question sentence. Therefore, based on the true matching degree of the target keyword for each answer sentence, the best answer sentence for the target keyword is screened out from all answer sentences. Subsequently, based on the best answer sentence for each keyword in the question sentence, the best answer to the question sentence can be accurately generated, thereby improving the accuracy of the ABI question-answering system.
[0088] Preferably, in one embodiment of the present invention, the answer sentence corresponding to the maximum value of the true matching degree of the target keyword with respect to all answer sentences may be used as the best answer sentence for the target keyword.
[0089] The best answer sentence for each keyword in the question sentence can be obtained by the same method as above.
[0090] Step S4: Generate the best answer to the question sentence based on the best answer sentence of all keywords in the question sentence.
[0091] The above steps provide the best answer for each keyword. Keywords are the key content of question statements. Therefore, the best answer for each keyword is highly correlated with the question statement and contains accurate information for answering the question statement. Therefore, the best answer for the question statement can be generated based on the best answer for all keywords in the question statement, thereby improving the accuracy of the ABI question-answering system.
[0092] Preferably, in one embodiment of the present invention, the method for obtaining the best answer to the question statement specifically includes:
[0093] Since there are multiple best answer sentences, in order to achieve unified output, firstly, the best answer sentences of all keywords are arranged and combined in different ways to obtain multiple combined answer sentences. The combined answer sentences obtained after the arrangement and combination may not be smooth when reading, so each combined answer sentence is input into the N-gram model to obtain the fluency of each combined answer sentence, and the combined answer sentence corresponding to the maximum value of the fluency is taken as the best answer to the question sentence, wherein the N-gram model is a technical means well known to technicians in this field and will not be elaborated here.
[0094] It should be noted that when the best answer statements for all keywords are arranged and combined, there may be a situation where the best answer statements for different keywords are the same. In this case, you only need to select one best answer statement from multiple identical best answer statements. In other words, the best answer statements in the arrangement and combination are different from each other.
[0095] In other embodiments of the present invention, the best answer sentences for all keywords may be input into a large language model, and the large language model extracts the core content from each best answer sentence to generate the best answer to the question sentence.
[0096] An embodiment of the present invention provides an ABI question-and-answer system for aligning a large model with a database, the system comprising a memory, a processor and a computer program, wherein the memory is used to store the corresponding computer program, the processor is used to run the corresponding computer program, and when the computer program runs in the processor, the method described in steps S1 to S4 can be implemented.
[0097] In summary, the embodiment of the present invention first obtains multiple keywords in the question sentence input by the user and multiple answer sentences of the question sentence; takes any answer sentence as the target answer sentence, matches each keyword with the target answer sentence, and obtains the label value of each keyword with respect to the target answer sentence; takes any keyword as the target keyword, and obtains the initial matching degree of the target keyword with respect to the target answer sentence based on the label values of other keywords except the target keyword with respect to the target answer sentence; adjusts the initial matching degree of the target keyword with respect to the target answer sentence based on the length difference and structure difference between the question sentence and the target answer sentence, and obtains the adjusted matching degree of the target keyword with respect to the target answer sentence; adjusts the adjusted matching degree of the target keyword with respect to the target answer sentence based on the semantic difference between the question sentence and the target answer sentence, and obtains the real matching degree of the target keyword with respect to the target answer sentence; based on the real matching degree of the target keyword with respect to each answer sentence, screens out the best answer sentence of the target keyword from all answer sentences; and generates the best answer to the question sentence based on the best answer sentences of all keywords in the question sentence.
[0098] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0099] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. An ABI question-answering method for aligning a large model with a database, characterized in that: The method comprises: Acquire multiple keywords in a question sentence input by a user and multiple answer sentences to the question sentence; Take any answer sentence as the target answer sentence, match each keyword with the target answer sentence, and obtain the label value of each keyword with respect to the target answer sentence; take any keyword as the target keyword, and obtain the initial matching degree of the target keyword with respect to the target answer sentence according to the label values of other keywords except the target keyword with respect to the target answer sentence; According to the difference in length and structure between the question sentence and the target answer sentence, the initial matching degree of the target keyword with respect to the target answer sentence is adjusted to obtain the adjusted matching degree of the target keyword with respect to the target answer sentence; according to the difference in semantics between the question sentence and the target answer sentence, the adjusted matching degree of the target keyword with respect to the target answer sentence is adjusted to obtain the real matching degree of the target keyword with respect to the target answer sentence; based on the real matching degree of the target keyword with respect to each answer sentence, the best answer sentence of the target keyword is screened out from all answer sentences; Based on the best answer sentence of all keywords of the question sentence, the best answer to the question sentence is generated.
2. The ABI question-answering method for aligning a large model with a database according to claim 1, characterized in that: The step of obtaining the initial matching degree of the target keyword with respect to the target answer sentence includes: Keywords other than the target keyword are used as reference keywords for the target keyword, and the accumulated value of the label values of all reference keywords with respect to the target answer sentence is used as the initial matching degree of the target keyword with respect to the target answer sentence.
3. The ABI question-answering method for aligning a large model with a database according to claim 1, characterized in that: The step of obtaining the adjusted matching degree of the target keyword with respect to the target answer sentence includes: Use any one of the question sentence and the target answer sentence as the sentence to be tested; Counting the number of characters contained in the sentence to be tested as the text length of the sentence to be tested, and performing negative correlation mapping on the absolute value of the difference in text length between the question sentence and the target answer sentence to obtain the length similarity between the question sentence and the target answer sentence; Use a word segmentation tool to segment the sentence to be tested, obtain the phrases of the sentence to be tested, and select the content phrases of the sentence to be tested from all the phrases. According to the difference in the proportion of the content phrases in all the phrases between the question sentence and the target answer sentence, obtain the structural similarity between the question sentence and the target answer sentence; The length similarity and the structure similarity are integrated to obtain the integrated similarity between the question sentence and the target answer sentence; The product value of the comprehensive similarity and the initial matching degree of the target keyword with respect to the target answer sentence is used as the adjusted matching degree of the target keyword with respect to the target answer sentence.
4. The ABI question-answering method for aligning a large model with a database according to claim 3, characterized in that: The obtaining of the structural similarity between the question sentence and the target answer sentence comprises: The number of content phrases in the sentence to be tested is used as the numerator, the number of all phrases in the sentence to be tested is used as the denominator, and the ratio is used as the content word density of the sentence to be tested; The absolute value of the difference in the density of the content words between the question sentence and the target answer sentence is negatively correlated to obtain the structural similarity between the question sentence and the target answer sentence.
5. The ABI question-answering method for aligning a large model with a database according to claim 3, characterized in that: The obtaining of the comprehensive similarity between the question sentence and the target answer sentence comprises: The sum of the length similarity and the structure similarity between the question sentence and the target answer sentence is used as the comprehensive similarity between the question sentence and the target answer sentence.
6. The ABI question-answering method for aligning a large model with a database according to claim 1, characterized in that: The obtaining of the true matching degree of the target keyword with respect to the target answer sentence comprises: Input the question sentence and the target answer sentence into the DSSM model to obtain the semantic similarity between the question sentence and the target answer sentence; The product value of the semantic similarity between the question sentence and the target answer sentence and the adjusted matching degree of the target keyword with respect to the target answer sentence is taken as the true matching degree of the target keyword with respect to the target answer sentence.
7. The ABI question-answering method for aligning a large model with a database according to claim 1, characterized in that: The best answer sentence for the target keyword selected from all answer sentences includes: The answer sentence corresponding to the maximum value of the true matching degree of the target keyword with respect to all answer sentences is taken as the best answer sentence for the target keyword.
8. The ABI question-answering method for aligning a large model with a database according to claim 1, characterized in that: The best answers to the generated question statements include: Perform different permutations and combinations of the best answer sentences for all keywords to obtain multiple combined answer sentences; Input each combined answer sentence into the N-gram model to obtain the fluency of each combined answer sentence; The combined answer sentence corresponding to the maximum value of the fluency is taken as the best answer to the question sentence.
9. The ABI question-answering method for aligning a large model with a database according to claim 1, characterized in that: The step of obtaining the label value of each keyword with respect to the target answer sentence includes: For any keyword, keyword matching is performed between the keyword and the target answer sentence based on the regular expression method. If the target answer sentence contains the keyword, the label value of the keyword with respect to the target answer sentence is set to the value 1. If the target answer sentence does not contain the keyword, the label value of the keyword with respect to the target answer sentence is set to the value 0.
10. An ABI question-answering system for aligning a large model with a database, the system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Answer generation method and device based on artificial intelligence, equipment and storage medium
CN113239169A
Knowledge question-answering method and device, equipment and storage medium
CN117573821A
Social learning system using question-answering
KR102061893B1
Cited By
Intelligent assistant question answering method and device based on large language model, equipment and medium
CN120705270A