Question-answering method and device
By using the ontology model and word vector generation model in the city question-answering system to calculate the similarity of question statements, the problem of inaccurate keyword matching in city question-answering is solved, and personalized answers with higher accuracy are achieved.
Patent Information
- Application Number
- CN202310799810.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-06-30
AI Technical Summary
In the existing technology, electronic devices are unable to effectively identify the intent and slots of question sentences in the field of urban question answering, resulting in poor answering results, mainly due to inaccurate keyword matching, resulting in low similarity.
The ontology model is used to determine the structural similarity and conceptual similarity between the keywords of the question sentence and the candidate question sentences. The similarity between the keyword hierarchical structures is constructed through the ontology model. Combined with the word vector generation model and user similarity, the accuracy and personalization of the response are improved.
The accuracy, robustness and explainability of responses have been improved, ensuring that responses are personalized to meet the needs of different users and enhancing the intelligence level of the city's question-answering system.
Smart Images

Figure CN117009479B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a question-answering method and device. Background Art
[0002] In the field of urban question-answering, after an electronic device receives a question from a user, it parses the question, identifies the intent and slot corresponding to the question, and generates and outputs a corresponding answer based on the intent and slot.
[0003] In actual applications, the electronic device may not be able to identify the slot corresponding to the question statement. Based on this, the electronic device will search for a target question statement similar to the question statement in the pre-stored case library, and output the target answer statement corresponding to the target question statement as the answer statement.
[0004] However, in the prior art, in order to find a target question statement similar to the question statement in the case library, a simple keyword matching is performed. However, the same keyword may have different meanings in different statements, which results in a low similarity between the question statement and the found target question statement, resulting in poor answering effect. Summary of the Invention
[0005] The present application provides a question-answering method and device to solve the problem in the prior art that the similarity between question statements and the found target question statements is low, resulting in poor answering effect.
[0006] In a first aspect, an embodiment of the present application provides a question-answering method, the method comprising:
[0007] Receive an input target question sentence, and determine, based on the ontology model, a first node corresponding to a first keyword of the target question sentence and a second node corresponding to a second keyword of the candidate question sentence;
[0008] Determine the structural similarity between the first keyword and the second keyword based on a first number of first upper nodes corresponding to the first node, a second number of second upper nodes corresponding to the second node, and a third number of upper nodes having the same keyword corresponding to the first and second upper nodes;
[0009] If the first keyword is inconsistent with the second keyword, determining the concept similarity between the first keyword and the second keyword based on the candidate structural similarities of the keywords corresponding to the target first upper node adjacent to the first node and the target second upper node adjacent to the second node;
[0010] According to the structural similarity and the conceptual similarity, a target candidate question sentence matching the target question sentence is determined, and a saved reply sentence of the target candidate question sentence is used for reply.
[0011] In a second aspect, an embodiment of the present application further provides an electronic device, comprising a processor, wherein the processor is configured to implement the steps of any of the above-described question-and-answer methods when executing a computer program stored in a memory.
[0012] In an embodiment of the present application, an electronic device receives an input target question sentence and determines, based on an ontology model, a first node corresponding to a first keyword of the target question sentence and a second node corresponding to a second keyword of a candidate question sentence; determines the structural similarity between the first keyword and the second keyword based on the first number of first upper nodes corresponding to the first node, the second number of second upper nodes corresponding to the second node, and the third number of upper nodes with the same keyword corresponding to the first upper node and the second upper node; if the first keyword is inconsistent with the second keyword, determines the conceptual similarity between the first keyword and the second keyword based on the similarity of the keywords corresponding to the target first upper node adjacent to the first node and the target second upper node adjacent to the second node; determines the target candidate question sentence that matches the target question sentence based on the structural similarity and the conceptual similarity, and uses the saved reply sentence of the target candidate question sentence to reply. In an embodiment of the present application, the electronic device determines the structural similarity between the first keyword in the target question sentence and the second keyword in the candidate question sentence based on the ontology model, and determines the conceptual similarity between the first keyword in the target question sentence and the second keyword in the candidate question sentence based on the ontology model. The electronic device determines a target candidate question sentence that matches the target question sentence based on the structural similarity and the conceptual similarity, thereby avoiding direct search in a case library through keywords and improving the accuracy, robustness, interpretability and reliability of the answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0014] Figure 1 A schematic diagram of a reply process provided in an embodiment of the present application;
[0015] Figure 2 A schematic diagram of an ontology model provided in an embodiment of the present application;
[0016] Figure 3A topological structure diagram corresponding to an ontology model provided in an embodiment of the present application;
[0017] Figure 4 A topological structure diagram corresponding to an ontology model provided in an embodiment of the present application;
[0018] Figure 5 A topological structure diagram corresponding to an ontology model provided in an embodiment of the present application;
[0019] Figure 6 A flowchart of the question-and-answer process provided in the embodiment of this application;
[0020] Figure 7 A schematic diagram of the structure of a reply device provided in an embodiment of the present application;
[0021] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] To make the objectives, technical solutions, and advantages of this application more clear, this application will be further described in detail below with reference to the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of this application.
[0023] In order to improve the accuracy of answers, an embodiment of the present application provides a question-answering method and device.
[0024] In an embodiment of the present application, the electronic device determines the first node corresponding to the first keyword of the target question sentence to be replied, and the second node corresponding to the second keyword of the candidate question sentence based on the ontology model; determines the structural similarity between the first keyword and the second keyword according to the first number of first upper nodes corresponding to the first node, the second number of second upper nodes corresponding to the second node, and the third number of upper nodes with the same keywords corresponding to the first upper node and the second upper node; if the first keyword is inconsistent with the second keyword, determines the conceptual similarity between the first keyword and the second keyword according to the similarity of the keywords corresponding to the target first upper node adjacent to the first node and the target second upper node adjacent to the second node; determines the target candidate question sentence that matches the target question sentence based on the structural similarity and the conceptual similarity, and uses the saved reply sentence of the target candidate question sentence to reply.
[0025] Figure 1 A schematic diagram of a question-and-answer process provided in an embodiment of the present application includes:
[0026] S101: Receive an input target question sentence, and determine, based on an ontology model, a first node corresponding to a first keyword of the target question sentence and a second node corresponding to a second keyword of a candidate question sentence.
[0027] A question-and-answer method provided in an embodiment of the present application is applied to an electronic device, which may be a PC or a server.
[0028] In recent years, the scale of smart cities has grown significantly. The "city brain" has made cities more intelligent and easier to achieve integrated coordination between the upper and lower levels, making urban governance more refined and life more convenient. Among them, the leadership cockpit equipped with the city cloud brain is mainly for the leaders of various commissions, offices and bureaus in various districts and cities. Electronic devices equipped with the city cloud brain can enable users to intuitively understand various important tasks and important indicators by integrating various data, and assist in decision-making through conclusion analysis and district-city comparison. Intelligent voice technology empowers the city cloud brain, allowing it to be applied to various application scenarios (such as smart transportation, emergency command, urban dynamics, etc.) and enhance the capabilities of the city cloud brain.
[0029] For users of urban Q&A, different users may receive different answers to the same question due to differences in their identities, permissions, preferences, etc. Therefore, recommending appropriate answers to users from a large amount of data has become a major goal in the urban Q&A field.
[0030] Traditional question-answering methods do not take into account the user's personalized characteristics. When searching for answers to question statements, they use keyword search engines / matching technologies, or when calculating sentence similarity, they only perform simple semantic understanding involving the surface meaning of language processing, and do not involve the connection between the two question statements at the semantic level.
[0031] Based on this, in the embodiment of the present application, it is proposed to determine the similarity between the question sentence to be answered and the candidate sentences in the case library based on the ontology model. Among them, the ontology clarifies the commonly recognized concept terms in the field, and the ontology model stipulates the relationship between these concept terms.
[0032] Specifically, in an embodiment of the present application, a plurality of candidate question statements and the intention of each candidate statement are pre-saved in the electronic device. After the electronic device receives the input target question statement, the electronic device performs keyword recognition on the target question statement, determines at least one keyword contained in the target question statement, and the electronic device also obtains the keywords contained in the pre-saved candidate question statements.
[0033] The electronic device determines a first node corresponding to a first keyword of a target question sentence and a second node corresponding to a second keyword of a candidate question sentence based on an ontology model, and determines a similarity between the target question sentence and a pre-stored candidate question sentence based on the first node and the second node. If the similarity meets a preset requirement, the electronic device can determine that the candidate question sentence is similar to the target question sentence. Figure 1 To.
[0034] Among them, the embodiment of this application takes the urban field question and answer as the starting point, refers to the various commissions and bureaus and the "New Smart City Evaluation Indicators" and the division of functional departments in the urban field, and constructs an ontology model for common commissions and bureaus, slots, question and answer needs, etc.
[0035] Figure 2 The schematic diagram of the ontology model provided in the embodiment of the present application is shown in FIG. Figure 2 As shown in the figure, the ontology model includes commissions, offices, slots, question and answer requirements, etc.
[0036] The electronic device may construct a structure diagram corresponding to the ontology model based on the ontology model, so that similarity calculation between question statements may be performed subsequently based on the structure diagram.
[0037] Figure 3 A topological structure diagram corresponding to an ontology model provided in an embodiment of the present application, such as the Figure 3 As shown in the figure, concepts and their sub-concepts form a hierarchical relationship. Taking the type of scenic spot as an example, its superordinate concept is slot, and its subordinate sub-concepts include history and humanities, urban entertainment, red tourism, natural ecology, etc.
[0038] S102: Determine the structural similarity between the first keyword and the second keyword based on the first number of first upper nodes corresponding to the first node, the second number of second upper nodes corresponding to the second node, and the third number of upper nodes having the same keywords as the first upper node and the second upper node.
[0039] In an embodiment of the present application, the electronic device may calculate the similarity between the target question sentence and the candidate question sentence in the keyword hierarchical structure based on the ontology model, wherein the similarity between the keyword hierarchical structures includes structural similarity and conceptual similarity.
[0040] When calculating structural similarity, electronic devices can calculate based on the keywords corresponding to the nodes or based on the distance between the nodes. If the calculation is based on the keywords corresponding to the nodes, the larger the upper node shared by the first keyword corresponding to the first node and the second keyword corresponding to the second node, the higher the structural similarity. If the calculation is based on the distance between the nodes, the structural similarity is determined based on the distance between the first node and the second node in the ontology model.
[0041] In an embodiment of the present application, structural similarity is determined based on the keywords corresponding to the nodes. Specifically, the electronic device determines a first number of first superordinate nodes corresponding to the first node in the ontology model, a second number of second superordinate nodes corresponding to the second node, and a third number of repeated superordinate nodes between the first superordinate node and the second superordinate node. The electronic device determines the structural similarity between the first keyword and the second keyword based on the first number, the second number, and the third number.
[0042] Among them, the electronic device can determine the structural similarity by the following formula:
[0043]
[0044]
[0045] Among them, Sim concept Indicates structural similarity, Sim k(keywordi,keywordj) Indicates keyword i and keyword j Substructure similarity,|super(keyword i ,Keyword)|indicates keyword i The first number of the corresponding first upper node, |super(keyword j ,Keyword)|indicates keyword j The second number of the corresponding second upper node, |super(keyword i ,Keyword)∩super(keyword j ,Keyword)|indicates keyword i and keyword j The third number of corresponding identical upper nodes.
[0046] Figure 4 A topological structure diagram corresponding to an ontology model provided in an embodiment of the present application, such as the Figure 4 As shown, assuming that the first keyword is Qingdao and the second keyword is Jufeng, then according to the Figure 4 It can be seen that the first number of the first superordinate nodes corresponding to Qingdao is three, which are the location, slot and city domain question and answer ontology, and the second number of the second superordinate nodes corresponding to Jufeng is three, which are the scenic spot, slot and city domain question and answer ontology. The electronic device determines that the third number of superordinate nodes with the same keywords corresponding to the first superordinate node and the second superordinate node is two. Based on this, the electronic device determines the substructure similarity between Qingdao and Jufeng.
[0047] S103: If the first keyword is inconsistent with the second keyword, determine the concept similarity between the first keyword and the second keyword based on the candidate structural similarities of the keywords corresponding to the target first upper node adjacent to the first node and the target second upper node adjacent to the second node.
[0048] In the embodiment of the present application, after the electronic device determines the structural similarity between the first keyword and the second keyword, the electronic device further determines the conceptual similarity between the first keyword and the second keyword.
[0049] Specifically, the conceptual similarity between the first keyword and the second keyword is closely related to the categories to which the first keyword and the second keyword belong. Based on this, the electronic device can determine the conceptual similarity based on the categories to which the first keyword and the second keyword belong.
[0050] Specifically, the electronic device determines, based on the ontology model, the first category to which each first keyword in the target question sentence belongs, and the second category to which each second keyword in the candidate question sentence belongs. The first category to which the first keyword belongs is the keyword corresponding to the target first upper-level node adjacent to the first node corresponding to the first keyword in the ontology model, and the second category to which the second keyword belongs is the keyword corresponding to the target second upper-level node adjacent to the second node corresponding to the second keyword in the ontology model. A first keyword can have multiple target first upper-level nodes, and a second keyword can have multiple target second upper-level nodes.
[0051] The electronic device obtains each candidate structural similarity between a keyword corresponding to each target first upper node and a keyword corresponding to each target second upper node, and determines a concept similarity between the first keyword and the second keyword based on each candidate structural similarity.
[0052] Furthermore, in an embodiment of the present application, if the first keyword of the target question sentence is consistent with the second keyword of the candidate question sentence, the electronic device determines that the conceptual similarity between the first keyword and the second keyword is a preset value, wherein the preset value is generally 1.
[0053] Among them, the electronic device can determine the concept similarity through the following formula:
[0054]
[0055]
[0056] Among them, Sim individual (I1, I2) represents the concept similarity, Sim class(C(I1), C(I2)) represents the class similarity between the target question statement I1 and the candidate question statement I2, C(I1) represents the target first upper node, C(I2) represents the target second upper node, |C(I1)| represents the total number of target first upper nodes for each first keyword in the target question statement, |C(I2)| represents the total number of target second upper nodes for each second keyword in the candidate question statement, α is a preset coefficient ranging from 0 to 1, Sim(C i (I1), C j (I2)) represents the target first upper node C i (I1) and the target second upper node C j (I2) candidate structure similarity.
[0057] It should be noted that, in the embodiment of the present application, if the target first superordinate node and the target second superordinate node are the same node, or the target first superordinate node and the target second superordinate node are different expressions of the same concept, then the candidate structural similarity between the target first superordinate node and the target second superordinate node is 1. If the electronic device determines that the relationship between the target first superordinate node and the target second superordinate node stored in the ontology model is a sameAs relationship, then the electronic device determines that the target first superordinate node and the target second superordinate node are different expressions of the same concept.
[0058] Figure 5 A topological structure diagram corresponding to an ontology model provided in an embodiment of the present application, such as the Figure 5 As shown in the figure, assuming that the target question sentence is where is the address of Jufeng in Qingdao, and the candidate question sentence is the trend of GDP in Qingdao in 2023, then according to the Figure 5 As can be seen, the target question statement corresponds to four target first-level nodes: indicators, location target, address query, and Culture and Tourism Bureau. The candidate question statements correspond to six target second-level nodes: indicators, location target, time target, indicator query, Veterans Affairs Bureau, and Finance Bureau. This means that the electronic device determines |C(I1)| = 4 and |C(I2)| = 6.
[0059] S104: Determine a target candidate question sentence that matches the target question sentence based on the structural similarity and the conceptual similarity, and use the saved reply sentence of the target candidate question sentence to reply.
[0060] In an embodiment of the present application, after determining the structural similarity and conceptual similarity between the first keyword of the target question sentence and the second keyword of each candidate question sentence, the electronic device determines the total similarity between the target question sentence and each candidate question sentence based on the structural similarity and conceptual similarity. Based on the total similarity, the electronic device determines the target candidate question sentence with the highest similarity to the target question sentence among each candidate question sentence.
[0061] Specifically, in an embodiment of the present application, for each candidate question statement, the electronic device determines the sum of the structural similarity and conceptual similarity between the first keyword in the target question statement and the second keyword in the candidate question statement, and determines the sum as the total similarity between the target question statement and the candidate question statement.
[0062] In an embodiment of the present application, an electronic device determines the structural similarity between a first keyword in a target question sentence and a second keyword in a candidate question sentence based on an ontology model, and also determines the conceptual similarity between the first keyword in the target question sentence and the second keyword in the candidate question sentence based on the ontology model. Based on this structural and conceptual similarity, the electronic device determines a target candidate question sentence that matches the target question sentence, avoiding the need to directly search the case library based on keywords, thereby improving the accuracy, robustness, interpretability, and reliability of the response.
[0063] In an embodiment of the present application, the electronic device determines the structural similarity between the first keyword and the second keyword, and the conceptual similarity between the target question sentence and the candidate question sentence, and based on the structural similarity and conceptual similarity, determines the target candidate question sentence that matches the target question sentence, avoiding direct search in the case library through keywords, and improving the accuracy, robustness, interpretability and reliability of the answer.
[0064] In order to improve the accuracy of the answer, based on the above embodiment, in the embodiment of the present application, before determining the target candidate question sentence matching the target question sentence based on the structural similarity and conceptual similarity, the method further includes:
[0065] Inputting the target question sentence into a word vector generation model, and obtaining a first word vector corresponding to the target question sentence output by the word vector generation model;
[0066] Inputting the candidate question sentence into the word vector generation model, and obtaining a second word vector corresponding to the candidate question sentence output by the word vector generation model;
[0067] Determining sentence similarity between the target question sentence and the candidate question sentence based on the first word vector and the second word vector;
[0068] Determining a target candidate question sentence matching the target question sentence based on the structural similarity and the conceptual similarity includes:
[0069] A target candidate question sentence matching the target question sentence is determined according to the structural similarity, the concept similarity and the sentence similarity.
[0070] In an embodiment of the present application, in order to improve the accuracy of question answering, the electronic device can also calculate the sentence similarity between the target question sentence and the candidate question sentence, and determine the target candidate question sentence that matches the target question sentence based on the sentence similarity.
[0071] Specifically, the electronic device inputs the target question sentence into the word vector generation model, the word vector generation model generates and outputs a first word vector corresponding to the target question sentence, and the electronic device obtains the first word vector output by the word vector model. The electronic device inputs the candidate question sentence into the word vector generation model, the word vector generation model generates and outputs a second word vector corresponding to the candidate question sentence, and the electronic device obtains the second word vector output by the word vector model.
[0072] The word vector generation model may be a model built based on TFIDF or Word2Vec calculation method.
[0073] The electronic device calculates the vector similarity between the first word vector and the second word vector, and determines the vector similarity as the sentence similarity between the target question sentence and the candidate question sentence. If the sentence similarity value is 1, it means that the target question sentence and the candidate question sentence are completely consistent; if the sentence similarity value is 0, it means that the target question sentence and the candidate question sentence have no relationship at all.
[0074] Based on this, the electronic device can determine a target candidate question sentence that matches the target question sentence according to the structural similarity, the conceptual similarity and the sentence similarity.
[0075] In order to improve the accuracy of the answer, based on the above embodiments, in an embodiment of the present application, after determining the sentence similarity between the target question sentence and the candidate question sentence based on the first word vector and the second word vector, the method further includes:
[0076] Obtaining a first user vector of a first user corresponding to the target question statement and a second user vector of a second user corresponding to the candidate question statement;
[0077] Determining user similarity between the target question statement and the candidate question statement based on the first user vector and the second user vector;
[0078] Determining a target candidate question sentence matching the target question sentence based on the structural similarity and the conceptual similarity includes:
[0079] A target candidate question sentence matching the target question sentence is determined according to the structural similarity, the concept similarity and the user similarity.
[0080] In an embodiment of the present application, in order to improve the accuracy of question and answer, the electronic device can also calculate the user similarity between the target question statement and the candidate question statement, and based on the user similarity, determine the target candidate question statement that matches the target question statement.
[0081] Specifically, the electronic device stores a first user vector of the first user corresponding to the target question statement and a second user vector of the second user corresponding to the candidate question statement. -Dice coefficient calculation method, based on the first user vector and the second user vector, calculates the user similarity between the target question statement and the candidate question statement.
[0082] The electronic device can determine the user similarity using the following formula:
[0083]
[0084] Among them, v i represents the first user vector, v j represents the second user vector.
[0085] For example, user vector v = {user authority, user identity, user preference...}, then the first user vector can be v i ={Bureau of Industry and Information Technology, Director, humorous style…}.
[0086] Based on this, the electronic device may determine a target candidate question sentence that matches the target question sentence according to the structural similarity, the conceptual similarity, and the user similarity.
[0087] Specifically, in the embodiment of the present application, the electronic device implements personalized question and answer through user portrait, which corresponds to the module numbered 1 in the overall architecture diagram. This part is implemented using a rule-based method.
[0088] To improve the efficiency of responses, based on the above embodiments, in an embodiment of the present application, before determining, based on the ontology model, the first node corresponding to the first keyword of the target question sentence to be responded to and the second node corresponding to the second keyword of the candidate question sentence, the method further includes:
[0089] Inputting the target question sentence into the semantic recognition model;
[0090] If the semantic recognition model fails to identify the target intent and target slot corresponding to the target question statement, a subsequent step is executed based on the ontology model to determine the first node corresponding to the first keyword of the target question statement to be answered and the second node corresponding to the second keyword of the candidate question statement.
[0091] In order to improve the efficiency of question answering, in an embodiment of the present application, only when the electronic device fails to recognize the target intention and target slot corresponding to the target question sentence, the electronic device will determine the target candidate sentence matching the target question sentence based on the ontology model.
[0092] Specifically, in an embodiment of the present application, after receiving the target question statement, the electronic device inputs the target question statement into the semantic recognition model. If the semantic recognition model fails to recognize the target intention and target slot corresponding to the target question statement, the electronic device determines the target candidate statement that matches the target question statement based on the ontology model.
[0093] In order to improve the accuracy of question answering, based on the above embodiments, in an embodiment of the present application, if the semantic recognition model recognizes the target intent and target slot corresponding to the target question sentence, the method further includes:
[0094] Obtaining the first user corresponding to the saved target question statement;
[0095] In a pre-saved case library, the question statement corresponding to the first user, the target intention and the target slot is searched, and the saved answer statement of the question statement is used to answer.
[0096] Existing question-and-answer systems do not consider personalized question-and-answer based on user information and user preferences. When retrieving answers to user questions, they only query based on the intent slots identified by the algorithm. However, users with different identities may require different answers to the same question, resulting in low accuracy of question-and-answer systems.
[0097] For example, when the mayor of Qingdao asked about "last year's economic income and expenditure situation", he was referring to the economic income and expenditure situation of Qingdao in 2022. When the department director of the Bureau of Industry and Information Technology asked the same question, he was referring to the economic income and expenditure situation of the Bureau of Industry and Information Technology in 2022, etc.
[0098] Based on this, the embodiment of the present application can provide personalized questions and answers for users. Specifically, in the embodiment of the present application, after the electronic device obtains the target intent and target slot corresponding to the target question sentence output by the semantic recognition model, the electronic device obtains the first user corresponding to the target question sentence; in the pre-saved case library, the electronic device searches for the question sentence corresponding to the first user, the target intent, and the target slot, and uses the saved answer sentence of the question sentence to answer.
[0099] In this embodiment of the present application, the electronic device can determine the first user corresponding to the target question statement based on the user's login information.
[0100] In order to improve the accuracy of question answering, based on the above embodiments, in the embodiment of the present application, if the question statement is not found, the method further includes:
[0101] According to the target intention and the target slot, a reply sentence corresponding to the target question sentence is generated and output.
[0102] Based on the above embodiment, in an embodiment of the present application, if the electronic device does not find the question statement corresponding to the first user, the target intention and the target slot in the case library, the electronic device generates and outputs a reply statement corresponding to the target question statement based on the target intention and the target slot.
[0103] In order to improve the accuracy of question answering, based on the above embodiments, in an embodiment of the present application, if the first keyword and the second keyword are the same, the method further includes:
[0104] Determining a preset value as the concept similarity between the first keyword and the second keyword;
[0105] According to the structural similarity and the conceptual similarity, a target candidate question sentence matching the target question sentence is determined, and a saved reply sentence of the target candidate question sentence is used for reply.
[0106] In this embodiment of the present application, if the first keyword of the target question sentence matches the second keyword of the candidate question sentence, the electronic device determines a preset value as the conceptual similarity between the first keyword and the second keyword. Based on the structural similarity and conceptual similarity, the electronic device determines a target candidate question sentence that matches the target question sentence and responds using the saved response sentence for the target candidate question sentence.
[0107] Among them, the process in which the electronic device determines the target candidate question sentence that matches the target question sentence based on the structural similarity and conceptual similarity, and uses the saved reply sentence of the target candidate question sentence to reply is consistent with the process in the above embodiment and will not be repeated here.
[0108] Figure 6 A flowchart of the question-and-answer process provided in the embodiment of this application is shown in the figure. Figure 6 As shown, the process includes:
[0109] S601: Determine whether the target intent and target slot corresponding to the target question sentence can be identified. If not, execute S602; if so, execute S607.
[0110] S602: Determine the structural similarity between the first keyword of the target question sentence and the second keyword of the candidate question sentence based on the ontology model.
[0111] S603: Determine the conceptual similarity between the first keyword of the target question sentence and the second keyword of the candidate question sentence based on the ontology model.
[0112] S604: Determine the sentence similarity between the target question sentence and the candidate question sentence based on the word vector generation model.
[0113] S605: Determine the user similarity between the target question statement and the candidate question statement based on the saved first user vector of the first user corresponding to the target question statement and the second user vector of the second user corresponding to the candidate question statement.
[0114] S606: Determine a target candidate question sentence that matches the target question sentence based on the structural similarity, concept similarity, sentence similarity, and user similarity, and use the saved reply sentence of the target candidate question sentence to reply.
[0115] It should be noted that, in the embodiment of the present application, the electronic device may determine the similarity between the candidate question sentence and the target question sentence based on structural similarity, conceptual similarity, sentence similarity, and user similarity.
[0116] The electronic device may determine the similarity between the candidate question statement and the target question statement according to the following formula:
[0117] Sim sentence =coef1*(Sim concept +Sim individual )+coef2*Sim general +coef3*Sim user
[0118] Among them, Sim concept is the structural similarity, Sim individual is the concept similarity, Sim general is the sentence similarity, Sim user is the user similarity, coef n They represent the coefficients corresponding to each similarity, and can be determined according to different rules, and coef1+coef2+coef3=1.
[0119] S607: Obtain the first user corresponding to the saved target question statement; search for the question statement corresponding to the first user, the target intention and the target slot in the pre-saved case library, and use the saved reply statement of the question statement to reply.
[0120] In order to improve the accuracy of question answering, based on the above embodiments, in the embodiment of the present application, determining the target candidate question sentence that matches the target question sentence based on the structural similarity and conceptual similarity includes:
[0121] Determining a preset number of target candidate question sentences that match the target question sentence based on the structural similarity and the conceptual similarity;
[0122] The step of answering the target candidate question using the saved answer statement includes:
[0123] The preset number of target candidate question sentences saved will be used to answer in sequence.
[0124] In order to improve the accuracy of question and answer, in an embodiment of the present application, the electronic device can determine a preset number of target candidate question sentences that have a high similarity with the target sentence, and use the saved reply sentences of the preset number of target candidate question sentences to reply in sequence, ensuring that the user can obtain the information they want.
[0125] In order to improve the accuracy of question and answer, based on the above embodiments, in the embodiment of the present application, the method further includes:
[0126] receiving input feedback information carrying a target response sentence;
[0127] The target question statement and the target answer statement are saved correspondingly.
[0128] In an embodiment of the present application, after the electronic device responds to the target question statement, the electronic device can also receive feedback information from the user that carries the target response statement, and save the target question statement and the target response statement correspondingly in a case library.
[0129] Figure 7 A schematic diagram of the structure of a reply device provided in an embodiment of the present application, the device comprising:
[0130] A determination module 701 is configured to receive an input target question sentence and determine, based on an ontology model, a first node corresponding to a first keyword of the target question sentence and a second node corresponding to a second keyword of a candidate question sentence;
[0131] Processing module 702 is configured to determine the structural similarity between the first keyword and the second keyword based on a first number of first upper-level nodes corresponding to the first node, a second number of second upper-level nodes corresponding to the second node, and a third number of upper-level nodes having the same keyword as the first and second upper-level nodes; if the first keyword is inconsistent with the second keyword, determine the conceptual similarity between the first keyword and the second keyword based on the candidate structural similarities of the keywords corresponding to the target first upper-level node adjacent to the first node and the target second upper-level node adjacent to the second node; and determine a target candidate question sentence that matches the target question sentence based on the structural similarity and the conceptual similarity;
[0132] The reply module 703 is configured to reply using the saved reply statement of the target candidate question statement.
[0133] In one possible implementation, the processing module 702 is further configured to input the target question sentence into a word vector generation model to obtain a first word vector corresponding to the target question sentence output by the word vector generation model; input the candidate question sentence into the word vector generation model to obtain a second word vector corresponding to the candidate question sentence output by the word vector generation model; determine the sentence similarity between the target question sentence and the candidate question sentence based on the first word vector and the second word vector; and determine a target candidate question sentence that matches the target question sentence based on the structural similarity, the conceptual similarity, and the sentence similarity.
[0134] In a possible implementation, the processing module 702 is further used to obtain the first user vector of the first user corresponding to the saved target question statement and the second user vector of the second user corresponding to the candidate question statement; determine the user similarity between the target question statement and the candidate question statement based on the first user vector and the second user vector; and determine the target candidate question statement that matches the target question statement based on the structural similarity, conceptual similarity and user similarity.
[0135] In one possible implementation, the processing module 702 is further used to input the target question statement into a semantic recognition model; if the semantic recognition model fails to recognize the target intent and target slot corresponding to the target question statement, a subsequent step of determining the first node corresponding to the first keyword of the target question statement to be answered and the second node corresponding to the second keyword of the candidate question statement based on the ontology model is executed.
[0136] In a possible implementation, the processing module 702 is further configured to obtain a first user corresponding to the stored target question statement; search a pre-stored case library for a question statement corresponding to the first user, the target intent, and the target slot;
[0137] The reply module 703 is further configured to reply using the saved reply statement to the question statement.
[0138] In a possible implementation, the processing module 702 is further configured to generate and output a response statement corresponding to the target question statement based on the target intent and the target slot if the question statement is not found.
[0139] In a possible implementation, the processing module 702 is further configured to determine a preset value as the conceptual similarity between the first keyword and the second keyword if the first keyword and the second keyword are consistent; determine a target candidate question statement that matches the target question statement based on the structural similarity and the conceptual similarity, and use the saved reply statement of the target candidate question statement to reply.
[0140] In a possible implementation, the processing module 702 is specifically configured to determine a preset number of target candidate question sentences matching the target question sentence based on the structural similarity and the conceptual similarity;
[0141] The reply module 703 is further configured to reply in sequence using the saved reply sentences of the preset number of target candidate question sentences.
[0142] In a possible implementation, the device further includes:
[0143] A receiving module 704 is configured to receive input feedback information carrying a target response sentence;
[0144] The processing module 702 is further configured to store the target question statement and the target answer statement in correspondence with each other.
[0145] Based on the above embodiments, the present application also provides an electronic device, Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, it includes: a processor 81, a communication interface 82, a memory 83 and a communication bus 84, wherein the processor 81, the communication interface 82, and the memory 83 communicate with each other through the communication bus 84;
[0146] The memory 83 stores a computer program, which, when executed by the processor 81 , causes the processor 81 to perform any of the steps of the above-mentioned question-and-answer method.
[0147] Since the principle of problem solving by the above electronic device is similar to that of the question-answering method, the implementation of the above electronic device can refer to the embodiment of the method, and repeated parts will be omitted.
[0148] The communication bus mentioned in the above-mentioned electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 82 is used for communication between the above-mentioned electronic device and other devices. The memory can include a random access memory (RAM) and can also include a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory can also be at least one storage device located away from the aforementioned processor.
[0149] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processing processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0150] Based on the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program that can be executed by a processor. When the program runs on the processor, the processor executes the steps of any of the above-mentioned question-and-answer methods.
[0151] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the question-answering method, the implementation of the above-mentioned computer-readable storage medium can refer to the embodiment of the method, and the repeated parts will not be repeated.
[0152] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0153] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0154] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0155] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0156] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
Claims
1. A question-answering method, characterized in that: The method comprises: Receive an input target question sentence, and determine, based on the ontology model, a first node corresponding to a first keyword of the target question sentence and a second node corresponding to a second keyword of the candidate question sentence; Determine the structural similarity between the first keyword and the second keyword based on a first number of first upper nodes corresponding to the first node, a second number of second upper nodes corresponding to the second node, and a third number of upper nodes having the same keyword corresponding to the first and second upper nodes; If the first keyword is inconsistent with the second keyword, determining the concept similarity between the first keyword and the second keyword based on the candidate structural similarities of the keywords corresponding to the target first upper node adjacent to the first node and the target second upper node adjacent to the second node; Determine a target candidate question sentence that matches the target question sentence based on the structural similarity and the conceptual similarity, and respond with a saved response sentence of the target candidate question sentence; Among them, the structural similarity is determined by the following formula: in, represents the structural similarity, represents the substructure similarity, represents the first number of the first upper nodes, represents the second number of the second upper node, Indicates the third number of upper nodes corresponding to the first upper node and the second upper node having the same keyword; The concept similarity is determined by the following formula: in, represents the similarity of the concepts, represents the similarity between the target question statement and the candidate question statement class, represents the first upper node of the target, represents the target second upper node, represents the total number of target first superordinate nodes for each first keyword in the target question sentence, represents the total number of target second upper nodes for each second keyword in the candidate question sentence, is a preset coefficient with a value range of 0-1, Indicates the candidate structural similarity between the target first upper node and the target second upper node.
2. The method according to claim 1, characterized in that Before determining a target candidate question sentence matching the target question sentence based on the structural similarity and the conceptual similarity, the method further includes: Inputting the target question sentence into a word vector generation model, and obtaining a first word vector corresponding to the target question sentence output by the word vector generation model; Inputting the candidate question sentence into the word vector generation model, and obtaining a second word vector corresponding to the candidate question sentence output by the word vector generation model; Determining sentence similarity between the target question sentence and the candidate question sentence based on the first word vector and the second word vector; Determining a target candidate question sentence matching the target question sentence based on the structural similarity and the conceptual similarity includes: A target candidate question sentence matching the target question sentence is determined according to the structural similarity, the concept similarity and the sentence similarity.
3. The method according to claim 1 or 2, characterized in that After determining the sentence similarity between the target question sentence and the candidate question sentence based on the first word vector and the second word vector, the method further includes: Obtaining a first user vector of a first user corresponding to the target question statement and a second user vector of a second user corresponding to the candidate question statement; Determining user similarity between the target question statement and the candidate question statement based on the first user vector and the second user vector; Determining a target candidate question sentence matching the target question sentence based on the structural similarity and the conceptual similarity includes: A target candidate question sentence matching the target question sentence is determined according to the structural similarity, the concept similarity and the user similarity.
4. The method according to claim 1, wherein Before determining, based on the ontology model, a first node corresponding to a first keyword of a target question sentence to be answered and a second node corresponding to a second keyword of a candidate question sentence, the method further includes: Inputting the target question sentence into the semantic recognition model; If the semantic recognition model fails to identify the target intent and target slot corresponding to the target question statement, a subsequent step is executed based on the ontology model to determine the first node corresponding to the first keyword of the target question statement to be answered and the second node corresponding to the second keyword of the candidate question statement.
5. The method according to claim 4, characterized in that If the semantic recognition model recognizes the target intent and target slot corresponding to the target question sentence, the method further includes: Obtaining the first user corresponding to the saved target question statement; In a pre-saved case library, the question statement corresponding to the first user, the target intention and the target slot is searched, and the saved answer statement of the question statement is used to answer.
6. The method according to claim 5, characterized in that If the question statement is not found, the method further includes: According to the target intention and the target slot, a reply sentence corresponding to the target question sentence is generated and output.
7. The method according to claim 1, characterized in that If the first keyword and the second keyword are consistent, the method further includes: Determining a preset value as the concept similarity between the first keyword and the second keyword; According to the structural similarity and the conceptual similarity, a target candidate question sentence matching the target question sentence is determined, and a saved reply sentence of the target candidate question sentence is used for reply.
8. The method according to claim 1, characterized in that Determining a target candidate question sentence matching the target question sentence based on the structural similarity and the conceptual similarity includes: Determining a preset number of target candidate question sentences that match the target question sentence based on the structural similarity and the conceptual similarity; The step of answering the target candidate question using the saved answer statement includes: The preset number of target candidate question sentences saved will be used to answer in sequence.
9. The method according to claim 8, characterized in that The method further comprises: receiving input feedback information carrying a target response sentence; The target question statement and the target answer statement are saved correspondingly.
10. An electronic device, characterized in that: The electronic device includes a processor, and the processor is configured to implement the steps of the question-answering method according to any one of claims 1 to 9 when executing a computer program stored in a memory.
Citation Information
Patent Citations
Medical question-answering method based on ontology semantic similarity
CN110706807A
Similarity joint model training and semantic matching method and device
CN113868377A