Sentence question answering method and device, equipment, storage medium and computer program product
By constructing a keyword matching tree and logical node attributes, the problem of questions not being included in the intelligent question answering system was solved, achieving higher matching accuracy and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2021-10-15
- Publication Date
- 2026-05-05
AI Technical Summary
In existing intelligent question-answering systems, user-initiated questions may not be included in the question-answering database, resulting in low accuracy of answers, inability to accurately match deep semantic similarity, and low matching efficiency.
By constructing a keyword matching tree, the matching relationship between candidate keywords and target questions, as well as the attributes of logical nodes, is used to determine the response results, thereby improving matching accuracy and efficiency.
It improves the accuracy and speed of matching target question statements, thereby enhancing the matching efficiency of the question-and-answer system.
Smart Images

Figure CN114297351B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a question-and-answer method, apparatus, device, storage medium, and computer program product. Background Technology
[0002] Intelligent question answering, as a common form of human-computer interaction, has been widely used in many fields, such as the medical field. In intelligent question answering, users ask questions to an intelligent question-answering robot, which then finds matching answers based on the user's question and provides feedback to the user, thus achieving intelligent dialogue through the question and answer process.
[0003] In the process of intelligent question answering, the questions raised by users may take many forms, but the corresponding answers are the same. That is, a single answer may have multiple sets of similar questions. The intelligent question answering robot needs to judge the similarity of the questions and determine the correct answer corresponding to the similar questions from the intelligent question answering database.
[0004] However, due to the limited set of similar questions in the intelligent question-answering database, some user-initiated questions are not included in the database, resulting in lower accuracy of intelligent question-answering and thus lower accuracy of the answers received by users. Summary of the Invention
[0005] This application provides a question-and-answer method, apparatus, device, storage medium, and computer program product that can improve the accuracy of obtaining the response result corresponding to the target question statement. The technical solution is as follows:
[0006] On the one hand, a question-and-answer method for statements is provided, the method comprising:
[0007] Obtain the target question statement;
[0008] The target question statement is matched with a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword in the keyword matching tree and the target question statement. The first node attribute is used to indicate the matching relationship between the target question statement and the candidate keyword.
[0009] Based on the first node attribute, the second node attribute corresponding to the candidate keyword and the specified logical node in the keyword matching tree is determined. The second node attribute is used to indicate the combined logical relationship of the candidate keyword at the logical node.
[0010] The response result corresponding to the target question statement is determined based on the second node attribute, and the response result is the result in the keyword matching tree that corresponds to the target attribute requirement.
[0011] On the other hand, a question-and-answer device is provided, the device comprising:
[0012] The acquisition module is used to acquire the target query statement;
[0013] The matching module is used to match the target question statement with a keyword matching tree to obtain the first node attribute corresponding to the candidate keywords in the keyword matching tree and the target question statement. The first node attribute is used to indicate the matching relationship between the target question statement and the candidate keywords.
[0014] The determining module is used to determine, based on the first node attribute, the second node attribute corresponding to the candidate keyword and the specified logical node in the keyword matching tree, wherein the second node attribute is used to indicate the combined logical relationship of the candidate keyword at the logical node;
[0015] The determining module is further configured to determine the response result corresponding to the target question statement based on the second node attribute, wherein the response result is the result in the keyword matching tree that corresponds to the target attribute requirement.
[0016] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the question-and-answer method as described in any of the above embodiments of this application.
[0017] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the question-and-answer method as described in any of the embodiments of this application above.
[0018] On the other hand, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the question-and-answer methods described in the above embodiments.
[0019] The beneficial effects of the technical solutions provided in this application include at least the following:
[0020] The target query is matched with candidate keywords in the keyword matching tree to obtain the first node attribute corresponding to the candidate keyword and the target query. The first node attribute indicates the matching relationship between the candidate keyword and the target query after matching. Based on the first node attribute, the second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and the specified logical node in the keyword matching tree, and it is used to indicate the combination logic relationship of the candidate keyword at the logical node. The response result corresponding to the target query is determined by the second node attribute. That is, by matching the target query with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target query. This improves the matching accuracy of the corresponding candidate keywords in the target query, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching process. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a schematic diagram of an implementation environment provided by an exemplary embodiment of this application;
[0023] Figure 2 This is a schematic diagram of the overall process of a question-and-answer method provided in an exemplary embodiment of this application;
[0024] Figure 3 This is a flowchart of a question-and-answer method provided in an exemplary embodiment of this application;
[0025] Figure 4 This is a flowchart of a question-and-answer method provided in another exemplary embodiment of this application;
[0026] Figure 5 This is a schematic diagram of a keyword matching tree provided in an exemplary embodiment of this application;
[0027] Figure 6 This is a flowchart of a question-and-answer method provided in another exemplary embodiment of this application;
[0028] Figure 7 This is a schematic diagram of the classification model training process provided in an exemplary embodiment of this application;
[0029] Figure 8 This is a flowchart of a question-and-answer method provided in another exemplary embodiment of this application;
[0030] Figure 9 This is a schematic diagram of the interface of the FAQ question and answer project provided in an exemplary embodiment of this application.
[0031] Figure 10 This is a structural diagram of an apparatus for an FAQ question-and-answer project provided in an exemplary embodiment of this application;
[0032] Figure 11 This is a structural diagram of a device for an FAQ question-and-answer project provided in another exemplary embodiment of this application;
[0033] Figure 12 This is a schematic diagram of the structure of a server provided in an exemplary embodiment of this application. Detailed Implementation
[0034] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0035] First, a brief introduction to the terms used in the embodiments of this application:
[0036] Artificial Intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0037] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0038] Intelligent Traffic Systems (ITS), also known as Intelligent Transportation Systems, effectively integrate advanced science and technology (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operations research, artificial intelligence, etc.) into transportation, service control, and vehicle manufacturing. This strengthens the connection between vehicles, roads, and users, thereby forming a comprehensive transportation system that ensures safety, improves efficiency, improves the environment, and saves energy.
[0039] A query request is a message sent by a search engine or database to find a specific file, website, or record.
[0040] Question answering systems are a more advanced form of information retrieval system that uses accurate and concise natural language to answer user questions posed in natural language.
[0041] Frequently Asked Questions (FAQ): Commonly used in intelligent question-answering systems, an FAQ system contains questions and their corresponding answers. Based on the user's input, the FAQ system can find the standard questions and their corresponding answers that match the user's input and provide the answers to the user.
[0042] The Aho-Corasick Automaton (ACA) is a multi-modal matching algorithm that can quickly match keywords in user input text given a list of keywords. It constructs a keyword matching tree, where leaf nodes contain candidate keywords. The candidate keywords in the tree form the keyword list. For a user input query, the ACA is used to match and obtain the corresponding candidate keywords. The boolean value of the leaf node corresponding to a matched candidate keyword is set to true, and the leaf node for a non-matched candidate keyword is set to false. The boolean values of the leaf nodes are propagated upwards to the nodes corresponding to each logical relation to determine whether each rule is activated, and then the question category corresponding to the activated rule is returned.
[0043] BERT (Bidirectional Encoder Representations from Transformers) is a language model that trains deep bidirectional representations by jointly using bidirectional transformers across all layers. BERT combines the advantages of numerous natural language processing models, achieving superior performance in various natural language processing tasks. In related technologies, the input vector of the BERT model is the sum of token embeddings, position embeddings, and segment embeddings. Token embeddings represent the vectorized representation of characters, position embeddings represent the position of characters in the text, and segment embeddings represent the order of sentences in the text.
[0044] In related technologies, FAQ (Frequency Question Answering) databases typically include standard questions, answers to the standard questions, and a set of similar questions. The core task of an FAQ system is matching the target question. When a user inputs a target question, the FAQ system matches it with the standard questions and the set of similar questions in the FAQ database. If a matching question exists, its answer is provided to the user as the answer to the target question. Therefore, the edit distance algorithm is often used in the target question matching task. The Distance method calculates the similarity between the first string in the target question input by the user and the second string in the FAQ database. It transforms the first string into the second string through conversion methods including insertion, replacement, and deletion. The similarity between the first and second strings is determined based on the complexity of the conversion methods. When the similarity between the first string in the target question and the second string in the FAQ database reaches a similarity threshold, the answer to the question corresponding to the second string (including at least one standard question or a set of similar questions) is taken as the response to the target question. This method of using similarity calculation to complete the target question matching task can only calculate the string similarity between the target question and the question; it cannot calculate the deep semantic similarity between the statements.
[0045] Furthermore, when training samples are insufficient, rule engines are often introduced into question-answering methods to assist the model in completing the question answering process. Rule engines typically use regular expressions. The user inputs the target question, and the FAQ system iterates through all the regular expressions to coarsely filter the question categories corresponding to standard questions in the FAQ system. Then, the model is called to further refine the filtering to obtain the matching results corresponding to the target question. However, each question answering operation requires traversing the regular expressions. When there are many regular expressions, the matching efficiency is low, and regular expressions cannot accurately express the logical relationships between keywords in the target question (including whether logical relationships exist or are unordered).
[0046] The question-and-answer method provided in this application matches the target question statement with candidate keywords in a keyword matching tree to obtain a first node attribute corresponding to the candidate keyword and the target question statement. The first node attribute is used to indicate the matching relationship between the candidate keyword and the target question statement after matching. Based on the first node attribute, a second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and a specified logical node in the keyword matching tree, and is used to indicate the combined logical relationship of the candidate keyword at the logical node. The response result corresponding to the target question statement is determined through the second node attribute. That is, by matching the target question statement with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target question statement. This improves the matching accuracy of the corresponding keywords in the target question statement, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching process.
[0047] Based on the above brief introduction of terms, the application scenarios of the embodiments of this application are illustrated with examples:
[0048] 1. In search scenarios, users input a target question (which may be a sentence or several sentences) via voice or text input using a search engine or other programs with search functionality. The server contains an FAQ database. The server matches the target question with a keyword matching tree, obtaining the first node attribute corresponding to the candidate keywords in the keyword matching tree and the target question. Based on the first node attribute, the server determines the second node attribute corresponding to the candidate keywords and a specified logical node. The server then determines the standard question or similar question corresponding to the target question in the FAQ database based on the second node attribute. The server then returns the answer to the standard question or similar question as the response to the target question to the user.
[0049] In a demonstrative manner, the user inputs the target question "Can COVID-19 vaccine and HPV vaccine be injected together?" via text input. The candidate keywords in the keyword matching tree include "COVID-19 vaccine," "HPV vaccine," "injection," and "population." The target question is matched against the candidate keywords to obtain the first node attribute of the candidate keywords (e.g., "COVID-19 vaccine," "HPV vaccine," and "injection" match the target question successfully, but "population" does not). Based on the first node attribute, the second node attribute corresponding to the candidate keyword and a specified logical node is determined (e.g., "COVID-19 vaccine" and "HPV vaccine" are connected to the specified logical node, and the two are in a comparative relationship). Based on the second node attribute, the corresponding standard question in the FAQ database for the target question is determined to be "Can COVID-19 vaccine and other vaccines be injected together?" The answer to the standard question ("Experts do not recommend simultaneous injection") is then fed back to the user as the answer to the target question.
[0050] The server matches the target query with candidate entity words to obtain the first node attribute and the second node attribute. This matching method will be described in detail in subsequent embodiments.
[0051] 2. In a scenario where the in-vehicle terminal receives a voice-based help request, the terminal has an application installed that includes a FAQ (Frequency and Answer) service. The terminal receives a voice request from the user, converts it into a text-based target question, matches it against a keyword matching tree, and obtains the first node attributes corresponding to candidate keywords in the keyword matching tree. Based on the first node attributes, it determines the second node attributes corresponding to the candidate keywords and a specified logical node. Based on the second node attributes, it determines the standard question (or similar question) corresponding to the target question in the FAQ database and provides the answer to the standard question to the user in text or voice format. For example, if a user experiences a flashing fuel tank light while driving, they can input "How to solve the problem of the flashing fuel tank light while driving" into the in-vehicle terminal via voice or text. The terminal will match the request with candidate keywords and determine the standard question corresponding to the candidate keywords in the FAQ database based on the node attributes, providing the corresponding answer—the solution to the flashing fuel tank light—to the user.
[0052] It is worth noting that the question-and-answer method provided in this application can be implemented by a terminal, a server, or by a combination of both.
[0053] When the terminal and the server work together to implement the solution provided in the embodiments of this application, the terminal and the server can be directly or indirectly connected through wired or wireless communication, and the embodiments of this application do not limit this.
[0054] This is illustrative; please refer to it. Figure 1 It illustrates a schematic diagram of an implementation environment provided by an exemplary embodiment of this application, such as... Figure 1 As shown, the implementation environment includes a terminal 110 and a server 120, which are connected via a communication network 130.
[0055] In this embodiment, a query scenario is used to describe the implementation environment. Terminal 110 has an application with search functionality installed. This application providing search functionality can be a browser, video player, e-book reader, instant messaging application, utility application, etc., and this embodiment does not limit it to any particular type. Terminal 110 inputs a target query statement via text input or voice input, and then sends the target query statement to server 120.
[0056] Server 120 includes a keyword matching tree 121 containing candidate keywords. Server 120 also includes an FAQ question-and-answer database 122 and a classification model 123. The FAQ question-and-answer database 122 includes standard questions, sets of similar questions, and corresponding answers. The classification model 123 includes an attention network. When server 120 receives a target question sent by terminal 110 via communication network 130, it matches the target question with the candidate keywords in the keyword matching tree 121 to obtain the first node attribute corresponding to the candidate keywords and the target question. Based on the first node attribute, it determines the second node attribute corresponding to the candidate keywords and a specified logical node. Based on the second node attribute, it determines the standard question (or similar question) corresponding to the target question in the FAQ question-and-answer database 122. When multiple questions correspond, further response analysis is performed through classification model 123 to obtain the answer corresponding to the standard question as the response result corresponding to the target question.
[0057] The server 120 feeds back the response result to the terminal 110 through the communication network 130. The terminal 110 displays the response result, wherein the display method includes at least one of voice display or interface display.
[0058] Among them, terminal 110 includes at least one of the following terminals: smartphone, tablet computer, portable laptop, desktop computer, smart speaker, smart wearable device, smart voice interaction device, smart home appliance, vehicle terminal, etc. Server 120 can be applied to scenarios of command operation in the fields of smart transportation, vehicle terminal and Internet of Things.
[0059] It is worth noting that the aforementioned communication network 130 can be implemented as a wired network or a wireless network, and the communication network 130 can be implemented as any one of a local area network, a metropolitan area network, or a wide area network. This application embodiment does not limit this.
[0060] It is worth noting that the aforementioned server 120 can be implemented as a cloud server in the cloud. Cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Cloud technology is a general term encompassing network technology, information technology, integration technology, management platform technology, and application technology applied to the cloud computing business model. It can form resource pools, available on demand, and offers flexibility and convenience. Cloud computing technology will become a crucial support. Backend services of technical network systems require substantial computing and storage resources, such as video websites, image websites, and many portal websites. With the rapid development and application of the internet industry, every item may have its own identification mark in the future, requiring transmission to a backend system for logical processing. Data at different levels will be processed separately, and various industry data will require robust system support, which can only be achieved through cloud computing.
[0061] In some embodiments, the server 120 can also be implemented as a node in a blockchain system. Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0062] In this embodiment of the application, the question-and-answer method and its implementation provided in server 120 are business services in the application service layer.
[0063] Based on the above description, the entity word recognition method in the embodiments of this application will be introduced.
[0064] In this embodiment, the target question is matched with candidate keywords in the keyword matching tree, and the first node attribute and the second node attribute are obtained sequentially. Based on the second node attribute, the response result corresponding to the final target question is determined. For illustrative purposes, please refer to [reference needed]. Figure 2 It illustrates a schematic diagram of the overall process of a question-and-answer method provided in an exemplary embodiment of this application, such as... Figure 2As shown, the characters in the target question statement 210 are input into the character matching model 220, which includes a keyword matching tree 230. The characters in the target question statement 210 are matched with the candidate keywords in the keyword matching tree 230 to obtain the first node attribute 240 corresponding to the candidate keywords and characters. Based on the first node attribute, the second node attribute 250 corresponding to the candidate keywords and specified logical nodes is determined. Based on the second node attribute 250, the standard question (or similar question) corresponding to the target question statement 210 in the FAQ question-and-answer database 260 is determined, and the answer corresponding to the standard question is output as the response result 270 corresponding to the target question statement 210.
[0065] Based on the above introduction to terminology and application scenarios, the entity recognition method provided in this application embodiment will be described, using the example of a server executing the method. This is illustrative; please refer to [the provided text for illustrative purposes]. Figure 3 The diagram illustrates a flowchart of a question-and-answer method provided in an exemplary embodiment of this application, the method comprising the following steps:
[0066] Step 301: Obtain the target question statement.
[0067] Optionally, the target question statement includes statements containing question words, such as "whether," "when and where," "under what circumstances," etc., or it may not include question words. The target question statement includes one or more sentences. When the target question statement is multiple sentences, it is segmented according to punctuation or sentence meaning, and the segmented individual sentences are then analyzed. In some embodiments, the target question statement is obtained in at least one of the following ways:
[0068] 1. The target query is the query entered by the user through a search engine or an application with search functionality. The query can be in the form of text input or voice input. When the query is voice input, it must be converted into text before further processing.
[0069] 2. The target question is a set of data obtained from a publicly authorized open platform, including the set of questions that are viewed or queried most frequently on the open platform, or the solutions that the open platform can provide;
[0070] 3. The target question is a response question compiled based on the knowledge points in the collected knowledge graph. For example, if it is known that "there are certain side effects after the COVID-19 vaccine is injected", the target question would be "what are the side effects after the COVID-19 vaccine is injected".
[0071] It is worth noting that the above description of the method for obtaining the target question statement is only an illustrative example, and this implementation does not impose any restrictions on the specific method for obtaining the target question statement.
[0072] In illustrative terms, target queries may include those entered voluntarily by the user, meaning the target query is determined by the user's own will, or a set of queries obtained from a publicly available and authorized data platform, without limitation.
[0073] In some embodiments, the content of the target query statement includes at least one of the following forms:
[0074] 1. The target question is a judgment statement, which includes judgment words such as "whether" or "can / cannot", such as "Is the COVID-19 vaccine harmful?" or "Can I eat spicy food before receiving the COVID-19 vaccine?"
[0075] 2. The target question is a content-based question, that is, the target question asks about the content of a certain thing, such as: "What are the signs of late-stage lung cancer?" or "What medicine should I take for diarrhea?"
[0076] 3. The target question is a declarative statement, meaning it does not contain any words that contain questions or inquiries, such as "the origin of smallpox" or "the mode of transmission of AIDS".
[0077] It is worth noting that the above description of the content format of the target question statement is only an illustrative example, and no specific limitations are made on the content of the target question statement in this implementation.
[0078] Optionally, the target question may contain words with specific semantic meaning, such as "pneumonia" or "common cold," or may include words without semantic meaning, such as "hello" or "goodbye," without any limitation.
[0079] Step 302: Match the target query statement with the keyword matching tree to obtain the first node attribute of the candidate keywords in the keyword matching tree corresponding to the target query statement.
[0080] The first node attribute is used to indicate the matching relationship between the target question and the candidate keywords.
[0081] The keyword matching tree is constructed using some preset question statements. As an example, keywords from the preset question statements are extracted as candidate keywords in the keyword matching tree. Based on the logical relationship between the candidate keywords and the preset question statements, a specified logical node corresponding to the candidate keyword is generated, and the specified logical node is connected to its corresponding candidate keyword to obtain the keyword matching tree.
[0082] Optionally, the keyword matching tree includes multiple candidate keywords, which are keywords with completely different semantics, or keywords that contain some similar semantics.
[0083] In some embodiments, the keyword matching tree is displayed in at least one of the following formats:
[0084] 1. The keyword matching tree includes keyword nodes and logical nodes. Keyword nodes are the nodes corresponding to candidate keywords (they may or may not have similar semantics). Logical nodes are the nodes corresponding to the logical relationships between the keyword nodes. For example, "injection" and "injection" have a replaceable relationship, that is, they are synonyms. Then "injection" and "injection" can be connected by the "or" logical node.
[0085] 2. The keyword matching tree includes multiple keyword nodes, each corresponding to a candidate keyword. Each keyword node includes a corresponding first node attribute. Keyword nodes with logical relationships are interconnected, and the connecting lines indicate the logical relationships between candidate keywords, such as... Figure 5 In the case of "injection" and "injection", if they are interchangeable, meaning they are synonyms, then the two keyword nodes corresponding to "injection" and "injection" are connected to each other (represented by a straight line). For example, if "HPV vaccine" and "COVID-19 vaccine" are parallel, then these two candidate keywords are connected to each other by a bidirectional arrow. No restrictions are imposed here.
[0086] 3. The keyword matching tree includes keyword nodes and logical nodes. Keyword nodes are divided into main bytes and sub-bytes. Since a character can form semantically similar keywords with multiple characters or words, the main bytes are the common characters of these keywords. A main byte connects one or more sub-bytes. The main bytes of each candidate keyword with logical relationship are connected through logical nodes.
[0087] It is worth noting that the above-described display format of the keyword matching tree is only an illustrative example, and this embodiment does not impose any limitations on the specific display format of the keyword matching tree.
[0088] When the target query is matched against the keyword matching tree, keywords in the target query that correspond to candidate keywords (including semantically similar or identical keywords) are retrieved based on the keyword matching tree. For illustrative purposes, candidate keywords in the keyword matching tree are retrieved using at least one of the following methods:
[0089] 1. Candidate keywords are semantically meaningful words obtained from known knowledge graphs. In other words, any semantically meaningful words existing in the knowledge graph can be used as candidate keywords.
[0090] 2. Candidate keywords are words contained in access data obtained from publicly authorized platforms with search functions. That is, the search keywords or question statements entered by users are publicly available on platforms with search functions. These keywords in the publicly available data and the semantically meaningful words in the question statements are used as candidate keywords.
[0091] 3. Candidate keywords are obtained from the historical queries entered by authorized users. That is, after each query is entered by the user, the server records the query and selects words with semantic meaning as candidate keywords to store in the keyword matching tree.
[0092] It is worth noting that the above-mentioned methods for obtaining candidate keywords are merely illustrative examples, and this embodiment does not impose any limitations on the specific methods for obtaining candidate keywords.
[0093] Optionally, when the target query is matched against candidate keywords in the keyword matching tree, the matching method includes at least one of the following:
[0094] 1. Match the question characters in the target question with the candidate characters in the candidate keywords. That is, when the target question contains the question characters "eat" and "medicine", match "eat" and "medicine" with the candidate characters in the candidate keywords. It is worth noting that the words formed by the question characters are words with semantic meaning, that is, the position of the question characters is fixed. The matching condition is that there are candidate keywords formed by candidate characters in the same fixed position for a successful match.
[0095] 2. Set a matching threshold. When the matching degree between the target question and the candidate keyword reaches the matching threshold, it is considered a successful match. That is, the question characters in the target question are matched with the candidate characters in the candidate keywords. If the number of words in the candidate keywords that correspond to the question characters reaches the matching threshold, then the candidate keyword is a keyword that matches the target question.
[0096] 3. Segment the target query statement to obtain the query words, and use keywords with the same or similar meaning in the keyword matching tree as candidate keywords to match the query words.
[0097] It is worth noting that the above examples of matching are merely illustrative, and no specific form of matching is limited in this embodiment.
[0098] This illustration shows the matching relationship between the target query and candidate keywords. The matching relationship includes successful and unsuccessful matches. A successful match occurs when the target query contains a candidate keyword, or a word semantically similar or identical to the candidate keyword. An unsuccessful match occurs when the target query does not contain a candidate keyword, but this is not explicitly defined. Based on the matching relationship, the first-node attribute corresponding to the candidate keyword is obtained; that is, whether the candidate keyword matches the target query successfully, the candidate keyword will have a first-node attribute.
[0099] Optionally, the first node attribute can be distinguished by a "true" or "false" value. If the candidate keyword matches the target query statement, the first node attribute of the candidate keyword can be "true", that is, the match is successful. If the candidate keyword does not match the target query statement, that is, the match fails, the first node attribute of the candidate keyword can be "false".
[0100] It is worth noting that the first node attribute of the candidate keyword is only determined relative to the target query statement of the same input. When a second target query statement is input, the first node attribute of the candidate keyword in the keyword matching tree will be reset.
[0101] Step 303: Determine the second node attributes corresponding to the candidate keywords and the specified logical nodes in the keyword matching tree based on the first node attributes.
[0102] The second node attribute is used to indicate the combined logical relationship of candidate keywords at a specified logical node.
[0103] In some embodiments, the keyword matching tree includes multiple logical nodes, each logical node being connected to at least one candidate keyword. A designated logical node is a logical node connecting candidate keywords in the keyword matching tree that have a semantic relationship (or no semantic relationship). Semantic relationships include synonym relationships, such as "taking medicine" and "taking medication," which are near-synonyms; or comparison relationships, such as "HPV vaccine" and "COVID-19 vaccine," which are two different types of vaccines often used for comparison queries, thus they have a comparison relationship; or non-existence relationships, such as "aspirin" being a candidate keyword, and the target query being "Should I drink hot water if I have a fever?" "Aspirin" does not exist in this target query, meaning there is no matching relationship between "aspirin" and the target query. Therefore, the semantic relationship corresponding to "aspirin" is a non-existence relationship, which is not limited here.
[0104] A specified logical node corresponds to at least one candidate keyword. The specified logical nodes may be the same or different, which is not limited here.
[0105] Optionally, the connection method between the specified logical node and the candidate keyword includes at least one of the following methods:
[0106] 1. Connect candidate keywords that have the same characters and similar or identical meanings to the specified logical node;
[0107] 2. Connect candidate keywords with semantic relationships to specified logical nodes. This means connecting candidate keywords with combined logical relationships, such as comparison or synonymy, to specified logical nodes. In other words, each candidate keyword connected to a specified logical node must contain no identical characters.
[0108] It is worth noting that the above-mentioned connection methods between specified logical nodes and candidate keywords are merely illustrative examples, and no specific limitations are made on the connection methods between specified logical nodes and candidate keywords in this implementation.
[0109] The second node attribute, determined based on the first node attribute, is used to indicate the combined logical relationship of candidate keywords at logical nodes. Optionally, the second node attribute of the specified logical nodes corresponding to different logical relationships may be judged in the same or different ways. The second node attribute is determined by the first node attribute of at least one candidate keyword. The methods for distinguishing the first node attribute and the second node attribute may be the same or different, which is not limited here.
[0110] In some embodiments, the determination of the second node attribute includes at least one of the following methods:
[0111] 1. Employing AND, OR, and NOT logical relationships, that is, using AND, OR, and NOT logical relationships to judge the second node attribute of the candidate keyword corresponding to the specified logical node. The first node attribute and the second node attribute are represented by "true" or "false" values. (Illustrative example) Figure 5 Taking the keyword matching tree shown as an example, the keyword matching tree contains candidate keywords "HPV vaccine" and "COVID-19 vaccine". "HPV vaccine" and "COVID-19 vaccine" are connected by a specified logical node (the logical relationship corresponding to this specified logical node is "AND"). When the input target question is "What is the difference between HPV vaccine and COVID-19 vaccine", by matching the target question with the candidate keywords in the keyword matching, it is found that the candidate keywords "HPV vaccine" and "COVID-19 vaccine" have a matching relationship with the target question. That is, the first node attribute corresponding to these two candidate keywords is "true", and therefore the second node attribute of the specified logical node (whose logical relationship is "AND") connected to these two candidate keywords is "true".
[0112] 2. When a specified logical node has a first node attribute of "true" corresponding to a candidate keyword, that is, the candidate keyword has a matching relationship with the target query statement, then the second node attribute of the specified logical node is "true".
[0113] 3. Set a threshold for the number of nodes. When a specified logical node has a corresponding candidate keyword that satisfies the first node attribute as "true", and the number of candidate keywords reaches the threshold, then the second node attribute of the specified logical node is "true".
[0114] It is worth noting that the above method for determining the attributes of the second node is only an illustrative example, and this embodiment does not limit the specific method for determining the attributes of the second node.
[0115] Step 304: Determine the response result corresponding to the target question statement based on the attributes of the second node.
[0116] The response result is the result in the keyword matching tree that corresponds to the target attribute requirement.
[0117] Optionally, based on the second node attribute, one or more results are obtained, and the result corresponding to the target attribute requirement is determined as the response result for the target query statement. The target attribute requirement includes at least one of the following methods:
[0118] 1. When a relevant knowledge graph is established, the knowledge graph stores text statements that can be used as response results. Based on the second node attribute, that is, the combination logic relationship of the candidate keywords at the specified logical node, the text statement that satisfies the combination logic relationship is determined as the response result in the knowledge graph.
[0119] 2. Given a set of questions and corresponding answers (such as a FAQ database, etc., without limitation), based on the second node attribute, determine the questions in the question set that satisfy the combinational logic relationship, and use the answer to the question as the response result to the target question statement;
[0120] 3. Based on the second node attribute, the candidate keywords are rearranged and combined to generate a standard question statement. The text statement that satisfies the combinational logic relationship in the knowledge graph is then used as the response result.
[0121] It is worth noting that the above-described methods for determining the response results are merely illustrative examples, and no specific limitations are made on the methods for determining the response results in this implementation.
[0122] In the examples of target attribute requirements mentioned above, there are also cases where multiple text statements / questions / standard question statements are obtained based on the second node attribute. In this case, a logical threshold is set. When the number of text statements / questions / standard question statements that satisfy the combinational logical relationship reaches or exceeds the logical threshold, the answer to the text statement / question / text statement corresponding to the standard question is selected as the response result (when all reach or exceed the logical threshold, the one with the most is selected).
[0123] In summary, the question-and-answer method provided in this application matches the target question statement with candidate keywords in a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword and the target question statement. The first node attribute is used to indicate the matching relationship between the candidate keyword and the target question statement after matching. Based on the first node attribute, a second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and a specified logical node in the keyword matching tree, and is used to indicate the combined logical relationship of the candidate keyword at the logical node. The response result corresponding to the target question statement is determined through the second node attribute. That is, by matching the target question statement with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target question statement. This improves the matching accuracy of the corresponding candidate keywords in the target question statement, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching process.
[0124] In some optional embodiments, the second node attribute is determined by the logical matching result of the specified logical node; for illustrative purposes, please refer to [reference needed]. Figure 4 It illustrates a flowchart of a question-and-answer method provided in an exemplary embodiment of this application, such as... Figure 4 As shown, the method includes the following steps:
[0125] Step 401: Obtain the target question statement.
[0126] The description of the target question statement in step 401 has been explained in detail in step 301 above, and will not be repeated here.
[0127] Step 402: Match the target query statement with the keyword matching tree to obtain the first node attribute of the candidate keywords in the keyword matching tree corresponding to the target query statement.
[0128] The first node attribute is used to indicate the matching relationship between the target question and the candidate keywords.
[0129] In some embodiments, characters in the target query statement are input into a character matching model, which includes a keyword matching tree; the character matching model is used to match the characters with candidate keywords in the keyword matching tree to determine the matching result between the target query statement and the candidate keywords; and the first node attribute corresponding to the candidate keyword is determined based on the matching result.
[0130] Optionally, candidate keywords are first extracted from the keyword matching tree to form a keyword list. A Trie tree structure based on the AC automaton is then constructed (matching can also be performed using methods such as maximum backward matching or maximum forward matching; this is an example of AC automaton). The characters in the target query are input into the character matching model. The character matching model traverses the candidate keywords in the keyword matching tree using the AC automaton to determine the characters or character combinations that match the candidate keywords, and obtains the matching results between each candidate keyword and the target query. Illustratively, each leaf node in the Trie tree structure represents a candidate character corresponding to a candidate keyword. Candidate characters that can form a candidate keyword are connected. The Trie tree structure also includes a Fail pointer. When the input character cannot match the current leaf node, the Fail pointer corresponding to that leaf node is pointed to another leaf node containing the same candidate character. If a match still cannot be found, the Fail pointer will change its pointer again until it points to the root node (the root node is the starting node in the Trie tree, and all leaf nodes expand outward from the root node), at which point the matching process ends. When characters from the target query are input into the character matching model, the model uses the AC automaton to match each character sequentially with candidate keywords in the Trie tree. For example, if the target query is "symptoms of COVID-19", which contains seven characters: "new", "coronavirus", "lung", "inflammation", "of", "symptom", and "state", let's take the character "new" as an example. Starting from the root node, "new" is matched with the first-level leaf nodes connected to the root node. If a leaf node containing "new" exists, the character is successfully matched. From that leaf node, the character "coronavirus" is matched with the second-level characters connected to it. If a match is found, the remaining characters are matched layer by layer. If no leaf node containing "coronavirus" exists, the process jumps to another branch containing the leaf node corresponding to "new". The next level leaf node of that branch is then matched with "coronavirus". If no branch containing "coronavirus" exists, the process returns to the root node, and the matching ends. It's worth noting that when all characters in the target query have been matched with the Trie tree, the matching result is obtained, and the attributes of the first node corresponding to each candidate keyword in the keyword matching tree are also determined. The first node attribute is distinguished by a Boolean value (i.e., "true" or "false" value). If the candidate keyword can match the characters in the target query statement, the first node attribute corresponding to the candidate keyword is recorded as "true". If the candidate keyword cannot match the characters in the target query statement, the first node attribute corresponding to the candidate keyword is recorded as "false".
[0131] Step 403: Obtain the logical relationship of the specified logical nodes corresponding to the candidate keywords in the keyword matching tree.
[0132] In some embodiments, the logical relationship of a specified logical node includes any one of AND logical relationship, OR logical relationship and non-logical relationship.
[0133] Optionally, the keyword matching tree consists of candidate keywords and specified logical nodes. For an illustration, please refer to [reference needed]. Figure 5 This illustrates a schematic diagram of a keyword matching tree provided in an exemplary embodiment of this application, such as... Figure 5 As shown, the keyword matching tree includes candidate keywords 510 and specified logical nodes 520, where the specified logical nodes correspond to AND logical relations 521, OR logical relations 522, and non-logical relations 523. Taking "vaccination," "injection," and "powdering" from candidate keywords 510 as an example, these three candidate keywords are connected through a specified logical node 520, thus obtaining the OR logical relation corresponding to the specified logical node 520.
[0134] Step 404: Determine the logical matching result of the specified logical node based on the attributes of the first node.
[0135] In some embodiments, the first node attribute is matched with a preset logical relationship of a specified logical node; in response to the first node attribute conforming to the preset logical relationship of the specified logical node, the logical matching result of the specified logical node is determined to be a matching relationship; in response to the first node attribute not conforming to the preset logical relationship of the specified logical node, the logical matching result of the specified logical node is determined to be a mismatch relationship.
[0136] Optionally, the default logical relationship is that the Boolean value of the specified logical node is true (it can also be false, but we will use a Boolean value of true here), such as... Figure 5 As shown, when the first node attribute corresponding to candidate keyword 510 is determined (that is, the Boolean value of the leaf node where the candidate keyword is located), the matching is performed in a progressive manner from bottom to top in the keyword matching tree. The method for judging the Boolean value of a specified logical node in the keyword matching tree is as shown in Formula 1:
[0137] Formula 1:
[0138] Where vnode represents the boolean value corresponding to node, v ci The boolean value representing the child nodes of a node (child nodes include candidate keywords or specified logical nodes), where k represents the number of child nodes.
[0139] Indicative, to Figure 5Taking "vaccination," "injection," and "injection" from candidate keywords 510 as examples, these three candidate keywords are connected by a specified logical node with an OR logical relationship. That is, as long as there is at least one candidate keyword whose first node attribute has a true Boolean value, it meets the preset logical relationship of the specified logical node (or the Boolean value corresponding to the logical relationship is true), which means the logical matching result of the specified logical node is a matching relationship. If the Boolean values of the first node attributes corresponding to the three candidate keywords are all false (that is, there is no candidate keyword that matches the characters in the target query statement), then the Boolean value of the logical relationship is false, which means it does not meet the preset logical relationship of the specified logical node. Therefore, the logical matching result of the specified logical node is a mismatch relationship.
[0140] Step 405: Use the logical matching result of the specified logical node as the attribute of the second node.
[0141] In some embodiments, the second node attributes corresponding to the specified logical node include matching relationship and mismatch relationship.
[0142] The description of the second node's attributes in step 405 has been explained in detail in steps 303 and 404 above, and will not be repeated here.
[0143] Step 406: Determine the response result corresponding to the target question statement based on the attributes of the second node.
[0144] The response result is the result in the keyword matching tree that corresponds to the target attribute requirement.
[0145] In some embodiments, the server includes a FAQ database. Based on the second node attribute, the server finds the standard question (or similar question) corresponding to the target question in the FAQ database and uses the answer to the standard question as the response result.
[0146] Indicative, such as Figure 5 As shown, the keyword matching tree also includes rule text 530, which is defined as a function in the form of "operation (parameter 1 parameter 2 parameter 3 ...)". The "operation" function includes three logical functions: AND (&), OR (|), and NOT (^), which correspond to the logical relationship of the specified logical node. The parameters of the function include candidate keywords or another function, which supports function nesting.
[0147] Each rule text corresponds to standard question 540 in the FAQ database. For example, the rule text "&(HPV vaccine COVID-19 vaccine|(vaccination injection))" in rule text 530 corresponds to the standard question "Can the COVID-19 vaccine be administered together with other vaccines?" in the FAQ database. In other words, once the second node attribute is determined, the logical relationships between candidate keywords and specified logical nodes are organized into rule text based on the second node attribute. This allows us to determine the standard question corresponding to the rule text in the FAQ question-and-answer database. The logical relationships between candidate keywords in the standard question correspond to the logical functions in the rule text. Optionally, in practical applications, the functions in the rule text can be transformed based on synonyms. For example, since "two weeks", "two weeks" and "14 days" are synonyms, the rule text "&(COVID-19 vaccine interval two weeks)" can be transformed into "&(COVID-19 vaccine interval | (14 days two weeks two weeks))". This expands the coverage of the rule text and improves the matching rate between the rule text and the standard questions in the FAQ question-and-answer database. In other words, in response to the second node attribute meeting the target attribute requirements, the result corresponding to the target attribute requirements is determined as the response result.
[0148] In this embodiment, assuming there are K rule texts, n candidate keywords (average text length L), and the average text length of the input target query is M, the characters in the target query are input into a character matching model. The time complexity of the character matching model, based on the AC automaton, matching characters and candidate keywords is O(M+nL). Assuming the number of specified logical nodes corresponding to each rule text is comparable to the number of candidate keywords, the time complexity of determining the rule text by progressively moving upwards from determining the first node attribute in the keyword matching tree is O(n). Therefore, the time complexity of predicting an input target query is O(M+nL+n) = O(M+nL), which increases linearly with the text length of the target query and the total length of the candidate keywords. Compared with rule engines based on regular expression matching in related technologies, the scheme in this embodiment significantly improves the matching speed in determining the first node attribute, specifically in the following two aspects:
[0149] 1. Regular expression-based rule engines need to traverse all regular expressions to determine whether the target query statement contains candidate keywords. However, keyword matching trees can simultaneously obtain all matching relationships between the target query statement and candidate keywords. The computational complexity is independent of the number of rule texts and depends on the candidate keywords, thus improving matching performance.
[0150] 2. By using the AC automaton to match characters in the target query with candidate keywords to determine the first node attribute corresponding to the candidate keywords, the matching speed between candidate keywords and the target query is improved.
[0151] Firstly, unlike regular expression engines, it does not require iterating through all regular expressions to check if the query matches. Instead, it can obtain the matching results of all rules simultaneously. The computational complexity is related to the number of keywords, but not to the number of rules. This invention only needs to scan the input text once to obtain the matching results of all rules simultaneously. Secondly, it adopts multi-pattern matching as a string search method, which significantly improves the keyword matching speed.
[0152] In summary, the question-and-answer method provided in this application matches the target question statement with candidate keywords in a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword and the target question statement. The first node attribute is used to indicate the matching relationship between the candidate keyword and the target question statement after matching. Based on the first node attribute, a second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and a specified logical node in the keyword matching tree, and is used to indicate the combined logical relationship of the candidate keyword at the logical node. The response result corresponding to the target question statement is determined through the second node attribute. That is, by matching the target question statement with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target question statement. This improves the matching accuracy of the corresponding candidate keywords in the target question statement, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching process.
[0153] In this embodiment, the first node attribute corresponding to the candidate keyword is determined by using an AC automaton, and the second node attribute is determined by using Boolean values. After the character input character matching model of the target question statement is established, the AC automaton can quickly obtain all character matching results between the input character and each candidate keyword, thereby improving the accuracy of the matching results and increasing the matching speed of the character matching model.
[0154] In some embodiments, matching the target question statement with the keyword matching tree may result in multiple matches or no matching of candidate keywords in the FAQ answer library. In such cases, a classification model is used to further analyze the response to the target question statement to obtain the response result. That is, if the response indicates that the second node attribute does not meet the target attribute requirements, a classification model is used to analyze the response to the target question statement to obtain the response result. For illustrative purposes, please refer to [reference needed]. Figure 6 It illustrates a flowchart of a question-and-answer method provided in an exemplary embodiment of this application, such as... Figure 6 As shown, the method includes the following steps:
[0155] Step 601: Obtain the target question statement.
[0156] The description of the target question statement in step 601 has been explained in detail in step 301 above, and will not be repeated here.
[0157] Step 602: Match the target query statement with the keyword matching tree to obtain the first node attribute of the candidate keywords in the keyword matching tree corresponding to the target query statement.
[0158] The description of the keyword matching tree and the attributes of the first node in step 602 has been explained in detail in steps 302 and 402 above, and will not be repeated here.
[0159] Step 603: Determine the second node attributes corresponding to the candidate keywords and the specified logical nodes in the keyword matching tree based on the first node attributes.
[0160] The description of specifying the logical node and the second node attributes in step 603 has been explained in detail in step 303 above, and will not be repeated here.
[0161] Step 604: In response to the second node attribute not meeting the target attribute requirements, a weight analysis is performed on the characters in the target query statement using a classification model to obtain the weight analysis results.
[0162] Optionally, based on the second node attributes, the standard questions (or similar questions) corresponding to the candidate keywords matching the target question statement in the FAQ question-and-answer database are determined. When there is no corresponding standard question or there are multiple corresponding standard questions, further weight analysis of the characters in the target question statement is required through a classification model.
[0163] In some embodiments, characters from the target query are input into a classification model. The encoder in the classification model extracts features from the characters in the target query to obtain character features. Then, a vector generator in the encoder generates a statement vector corresponding to the target query and a character vector for each character. These character vectors are then input into an attention generation network to obtain the attention weight for each character. The attention generation network follows the formula in Formula 2.
[0164] Formula 2: α i =σ(Wh i +b)
[0165] Where, α i Here, W represents the attention weights for the characters, b is the vector coefficient, and h is an adjustable parameter. i Let σ be the character vector, and σ be the weight factor. According to Formula 3, the attention weight corresponding to a character is positively correlated with the character vector. Based on the attention weight corresponding to each character, the character vectors are weighted and summed to obtain the weighted character vector. Refer to Formula 3 for the specific formula:
[0166] Formula 3:
[0167] Among them, L att This is a weighted character vector. As can be seen from Formula 3, the higher the attention weight corresponding to a character, the larger the weighted character vector becomes.
[0168] Input the obtained text vector and weighted character vector into the classification network to obtain the matching probability between the target question and the candidate keywords. The classification network is referenced from Formula 4.
[0169] Formula 4: p = softmax(W1h) [sent] +W2h [char] +b)
[0170] Where p is the matching probability corresponding to the target query statement, and h [sent] As shown in Formula 4, the larger the weighted character vector, that is, the higher the attention weight corresponding to the character, the higher the matching probability between the characters in the target question and the candidate keywords.
[0171] Step 605: Based on the weight analysis results, determine the response results corresponding to the target question statement.
[0172] In a schematic way, based on the matching probability between the target question and the candidate keywords, the candidate keyword with the highest matching probability is selected, and the answer to the standard question corresponding to the candidate keyword in the FAQ database is determined as the response result corresponding to the target question.
[0173] In summary, the question-and-answer method provided in this application matches the target question statement with candidate keywords in a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword and the target question statement. The first node attribute is used to indicate the matching relationship between the candidate keyword and the target question statement after matching. Based on the first node attribute, a second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and a specified logical node in the keyword matching tree, and is used to indicate the combinational logical relationship of the candidate keyword at the logical node. The response result corresponding to the target question statement is determined through the second node attribute. That is, by matching the target question statement with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target question statement. This improves the matching accuracy of the corresponding candidate keywords in the target question statement, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching performance.
[0174] In this embodiment, the attention weights of the character vectors corresponding to the characters in the target question are determined by the attention network in the classification model, thereby obtaining the matching probability between the target question and the candidate keywords. This improves the matching performance of the classification model. Obtaining the matching probability based on the attention weights allows the classification model to perform weight analysis on the characters in the target question more quickly and accurately, thus improving the matching speed.
[0175] In some embodiments, during the initial stage of building the FAQ question-answering database, there may be a shortage of similar question sets, resulting in low matching accuracy between the target question and candidate keywords. Therefore, during the training of the classification model, attention vectors can be used to guide the classification model and improve the classification performance. Thus, the classification model also includes a loss function during the training phase. Please refer to Formula 5 for the loss function:
[0176] Formula 5: L = L cls +γ×β s ×L att
[0177] Where L is the loss function of the classification model, L cls For cross-entropy loss, L att Here, γ is the regularization loss coefficient, and β is the regularization loss coefficient. s β is the decay coefficient, 0 < β < 1, and s is the number of training iterations. As the number of training iterations increases, the classification model's ability to analyze the weights of characters in the input target question statement improves, and the regularization loss function gradually decreases, eventually becoming 0. The formula for the cross-entropy function can be found in Formula Six:
[0178] Formula 6: L cls =-∑y i lo g p i
[0179] Among them, when the target question statement matches the candidate keywords, y i If y is 1, otherwise y i p is 0 i The matching probability of the query statement for the target.
[0180] The formula for regularization loss can be found in Formula 7:
[0181] Formula 7:
[0182] g∈R T This represents the standard attention vector obtained by matching the characters of the target query with candidate keywords, where T is the text length of the target query, and KL represents the KL divergence, which measures the distance between the attention distribution in the classification model and the standard attention.
[0183] During the prediction phase, the classification model only needs to consider cross-entropy loss as the loss function. It is worth noting that when the target question in the target question cannot match the candidate keywords, only cross-entropy loss is considered.
[0184] The standard attention vector is obtained by training a keyword extractor (such as the TextRank keyword extractor). The keyword extractor extracts keywords from standard questions (including similar questions) in the FAQ database to obtain a candidate keyword set. The target question is input, and the maximum backward matching algorithm determines the position of the candidate keyword matching the target question within the corresponding character in the target question. Each character position generates a multi-hot vector g', where g' = 1 if and only if the i-th character in the target question is a character in a candidate keyword; otherwise, the vector g' = 0. For example, if the candidate keyword set includes {contraindications, key vaccination populations, drivers, customs, adverse reactions, COVID-19 vaccine}, and the target question is "Hello, I am a truck driver, can I get the COVID-19 vaccine?", the generated vector g' corresponding to the target question is [000000000110000111100], where the positions of "driver" and "COVID-19 vaccine" are 1, and the positions of other characters are 0. The standard attention vector g is obtained by normalizing g', as detailed in Formula 8.
[0185] Formula 8:
[0186] This is illustrative; please refer to it. Figure 7 It illustrates a schematic diagram of the classification model training process provided in an exemplary embodiment of this application, such as... Figure 7 As shown, the characters 701 in the target question are input into encoder 702 to generate character vector 703 and text vector (not shown). Character vector 703 is input into attention generation network to obtain attention weights 704 corresponding to character vector 703, and then weighted character vector (not shown). Text vector and weighted character vector are input into classification network 705 to obtain matching probabilities 706 between characters in the target question and candidate keywords. At the same time, candidate keywords are extracted from standard questions in FAQ question-answering database 707 to obtain candidate keywords 708. Multi-hot vector combinations 709 are obtained from characters in the target question and normalized to obtain standard attention vectors, which are used to assist in training classification model 700, adjust the model parameters of classification model 700, and improve the weight analysis performance of classification model.
[0187] In addition, to address the issue of insufficient similar question sets corresponding to standard questions in the FAQ question base during the training phase, question expansion can be performed by augmenting the similar question sets. This augmentation can be achieved through at least one of the following methods:
[0188] 1. Based on the synonym and hyponymy relationships in the corpus, the method of synonym transformation is used to expand the questions. For example, "vaccination" and "getting vaccinated" are synonyms, so the standard question "In which special circumstances can one also get vaccinated?" can be transformed into the similar question "In which special circumstances can one also get vaccinated?". "Fever" and "high fever" are hyponyms (fever is the hypernym, high fever is the hyponym, and fever includes the situation of high fever), so the standard question "Can a child with fever get vaccinated?" can be transformed into the similar question "Can a child with high fever get vaccinated?". It is worth noting that synonym substitution is bidirectional, while hyponymy substitution is unidirectional, that is, it can only replace the hypernym in the standard question with its hyponym to generate a similar question.
[0189] 2. Question expansion is achieved by introducing statement templates. A statement template is defined as a target question statement containing slot markers, such as: "Is vaccination still not available at #location#?" or "Can I start booking COVID-19 vaccines at #time#?" #Time# and #Location# are the slot markers. There are two usage methods: First, during the training phase, the slot markers in the statement template are replaced with slot words to expand the training samples. For example, based on the above template, questions like "Is vaccination still not available in Shenzhen?" or "Can I start booking COVID-19 vaccines tomorrow?" can be added. Second, during the training phase, the statement template is added as a similar question to the FAQ question-and-answer database to train the classification model. During the prediction phase, the slot words in the user-input target question statement are replaced with slot markers, and then candidate keyword matching is performed.
[0190] 3. Expanding questions by introducing answer text: During the training phase, since the standard questions corresponding to candidate keywords in the FAQ question-answering database are relatively broad, such as the standard question corresponding to the candidate keyword "key population for vaccination" is usually "who are the key populations for COVID-19 vaccination", rather than more detailed questions such as "can customs and border inspection personnel be given priority for vaccination", introducing answer text can assist the classification model in training and improve the generalization performance of the classification model.
[0191] 4. Question expansion is achieved by mining training samples from the seed corpus. Seed corpora refer to the standard questions and their similar question sets already stored in the FAQ database during the training phase. Based on seed corpora, similar question statements can be mined from some publicly authorized corpora. Specifically, three schemes are used to mine question statements in the corpus: keyword-based, literal similarity, and sentence vector similarity. After manual verification, these are added to the FAQ database as similar questions. In the keyword-based scheme, a keyword matching tree is used to traverse the question statements in the corpus and select those that meet the matching rules as similar questions to be added to the FAQ database. In the literal similarity-based scheme, the ElasticSearch framework is used, employing BM25 and the vector space model to retrieve similar questions for addition to the FAQ database. In the sentence vector similarity-based scheme, an open-source pre-trained word vector matrix is used, with the IDF weighted average of the word vectors as the sentence vector. A fast nearest neighbor search is used to obtain similar expressions from the seed corpus as similar questions to be added to the FAQ database.
[0192] In summary, the question-and-answer method provided in this application matches the target question statement with candidate keywords in a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword and the target question statement. The first node attribute is used to indicate the matching relationship between the candidate keyword and the target question statement after matching. Based on the first node attribute, a second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and a specified logical node in the keyword matching tree, and is used to indicate the combined logical relationship of the candidate keyword at the logical node. The response result corresponding to the target question statement is determined through the second node attribute. That is, by matching the target question statement with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target question statement. This improves the matching accuracy of the corresponding candidate keywords in the target question statement, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching process.
[0193] In this embodiment, by generating standard attention vectors to assist in training the classification model, the classification model can perform weight analysis on the characters in the target question statement and finally obtain the matching probability between the target question statement and candidate keywords based on the classification network. The candidate keyword with the highest matching probability is selected to determine the answer to the corresponding standard question in the FAQ question and answer database, which improves the matching analysis accuracy of the classification model. Furthermore, by expanding the questions in the FAQ question and answer database during the training phase, the accuracy of the question and answer is enhanced.
[0194] In some illustrative embodiments, please refer to Figure 8 It illustrates a flowchart of a question-and-answer method provided in an exemplary embodiment of this application, such as... Figure 8As shown, the input target question statement 810 is used to match the target question statement 810 with the candidate keywords in the keyword matching tree 820, obtaining the first node attribute corresponding to the candidate keyword. Based on the first node attribute, the second node attribute corresponding to the specified logical node is determined. When the second node attribute meets the target attribute requirement (i.e., the candidate keyword matching the characters of the target question statement corresponds to one question in the FAQ question-and-answer database), the answer corresponding to question 830 in the FAQ question-and-answer database is selected as the response result 840 and output. When the second node attribute does not meet the target attribute requirement (i.e., the candidate keyword matching the characters of the target question statement corresponds to multiple questions in the FAQ question-and-answer database or no corresponding question), the target question statement 810 is input into the classification model 850 for response analysis, finally obtaining the corresponding question 830 in the FAQ question-and-answer database, and selecting its corresponding answer as the response result 840 and output. During the training phase, the questions in the FAQ question-and-answer database are expanded by question 860 to assist in the training of the classification model 850 and improve the model's generalization performance.
[0195] Based on the above question-and-answer method, this process can be used for question queries on user terminals. For illustrative purposes, please refer to [the provided text]. Figure 9 This illustrates a schematic diagram of the interface of a FAQ question-and-answer item provided in an exemplary embodiment of this application, such as... Figure 9 As shown, the display interface is a program interface 900 running a FAQ project. The interface includes multiple different categories of FAQ services 910. Taking the "COVID-19 vaccine" Q&A service as an example, the user clicks on the "COVID-19 vaccine" prompt box to enter the "COVID-19 vaccine" running interface 920. Clicking on the "Consultation Assistant" prompt box 930 enters the Q&A interface 940 of the "COVID-19 vaccine" Q&A service. The interface includes some standard questions 950 displayed in the FAQ Q&A library, as well as candidate keywords 960. After the user enters the target question in the dialog box, the terminal interface will automatically display the response results (not shown) that match the target question.
[0196] In summary, the question-and-answer method provided in this application matches the target question statement with candidate keywords in a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword and the target question statement. The first node attribute is used to indicate the matching relationship between the candidate keyword and the target question statement after matching. Based on the first node attribute, a second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and a specified logical node in the keyword matching tree, and is used to indicate the combined logical relationship of the candidate keyword at the logical node. The response result corresponding to the target question statement is determined through the second node attribute. That is, by matching the target question statement with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target question statement. This improves the matching accuracy of the corresponding candidate keywords in the target statement, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching process.
[0197] The question-and-answer method in this embodiment can be applied to any FAQ intelligent question-and-answer service that needs to be launched quickly. It can quickly improve the accuracy of answers and enable rapid development and launch of services while ensuring user experience, providing strong technical support for product tracks that need to race against time.
[0198] In the classification model, the feature extractor and encoder used to extract features from the target query statement to generate vectors can be replaced by other models based on self-attention mechanisms, such as BERT, Tiny-BERT, and ELMO. KL divergence can be replaced with other methods that measure the distance / similarity of probability distributions, such as Wasserstein distance and F-divergence; no specific restrictions are imposed here.
[0199] Figure 10 This is a structural block diagram of a question-and-answer device provided in an exemplary embodiment of this application, such as... Figure 10 As shown, the device includes:
[0200] Module 1010 is used to retrieve the target query statement;
[0201] The matching module 1020 is used to match the target question statement with a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword in the keyword matching tree and the target question statement. The first node attribute is used to indicate the matching relationship between the target question statement and the candidate keyword.
[0202] The determining module 1030 is used to determine, based on the first node attribute, the second node attribute corresponding to the candidate keyword and the specified logical node in the keyword matching tree, wherein the second node attribute is used to indicate the combined logical relationship of the candidate keyword at the logical node;
[0203] The determining module 1030 is further configured to determine the response result corresponding to the target question statement based on the second node attribute, wherein the response result is the result in the keyword matching tree that corresponds to the target attribute requirement.
[0204] In an optional embodiment, the determining module 1030 includes:
[0205] The acquisition unit 1031 is used to acquire the logical relationship of the specified logical node corresponding to the candidate keyword in the keyword matching tree;
[0206] The determining unit 1032 is used to determine the logical matching result of the specified logical node based on the attributes of the first node;
[0207] The determining unit 1032 is further configured to use the logical matching result of the specified logical node as the second node attribute.
[0208] In an optional embodiment, the determining unit 1032 is further configured to match the first node attribute with the preset logical relationship of the specified logical node; in response to the first node attribute conforming to the preset logical relationship of the specified logical node, determine the logical matching result of the specified logical node as a matching relationship; in response to the first node attribute not conforming to the preset logical relationship of the specified logical node, determine the logical matching result of the specified logical node as a mismatch relationship.
[0209] In an optional embodiment, the logical relationship of the specified logical node includes any one of AND logical relationship, OR logical relationship and non-logical relationship.
[0210] In an optional embodiment, the matching module 1020 is further configured to input the characters in the target question statement into a character matching model, the character matching model including the keyword matching tree; match the characters with candidate keywords in the keyword matching tree through the character matching model to determine the matching result between the target question statement and the candidate keywords; and determine the first node attribute corresponding to the candidate keyword based on the matching result.
[0211] In an optional embodiment, the determining module 1030 is further configured to, in response to the second node attribute meeting the target attribute requirement, determine the result corresponding to the target attribute requirement as the response result; and in response to the second node attribute not meeting the target attribute requirement, perform response analysis on the target question statement through a classification model to obtain the response result.
[0212] In an optional embodiment, the determining module 1030 is further configured to perform weight analysis on the characters in the target question statement using a classification model to obtain a weight analysis result; and determine the response result corresponding to the target question statement based on the weight analysis result.
[0213] In summary, the question-and-answer device provided in this application matches the target question statement with candidate keywords in a keyword matching tree to obtain a first node attribute corresponding to the candidate keyword and the target question statement. The first node attribute indicates the matching relationship between the candidate keyword and the target question statement after matching. Based on the first node attribute, a second node attribute is determined. The second node attribute is the attribute corresponding to the candidate keyword and a specified logical node in the keyword matching tree, and is used to indicate the combined logical relationship of the candidate keyword at the logical node. The response result corresponding to the target question statement is determined through the second node attribute. That is, by matching the target question statement with the keyword matching tree, the node attributes of each node in the keyword matching tree are determined, thereby obtaining the response result corresponding to the target question statement. This improves the matching accuracy of the corresponding candidate keywords in the target statement, enhances the matching efficiency, and the determination of the response result based on the node attribute can speed up the matching process.
[0214] It should be noted that the statement question-and-answer device provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the statement question-and-answer device and the statement question-and-answer method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0215] Figure 12 A schematic diagram of the structure of a server provided in an exemplary embodiment of this application is shown. Specifically:
[0216] Server 1200 includes a Central Processing Unit (CPU) 1201, a system memory 1204 including Random Access Memory (RAM) 1202 and Read Only Memory (ROM) 1203, and a system bus 1205 connecting the system memory 1204 and the CPU 1201. Server 1200 also includes a mass storage device 1206 for storing an operating system 1213, application programs 1214, and other program modules 1215.
[0217] Mass storage device 1206 is connected to central processing unit 1201 via a mass storage controller (not shown) connected to system bus 1205. Mass storage device 1206 and its associated computer-readable media provide non-volatile storage for server 1200. That is, mass storage device 1206 may include computer-readable media (not shown) such as hard disk or compact disc read-only memory (CD-ROM) drives.
[0218] Without loss of generality, computer-readable media can include computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state storage technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that computer storage media are not limited to the above-mentioned types. The system memory 1204 and mass storage device 1206 described above can be collectively referred to as memory.
[0219] According to various embodiments of this application, server 1200 can also be connected to a remote computer on a network, such as the Internet. That is, server 1200 can be connected to network 1212 via network interface unit 1211 connected to system bus 1205, or network interface unit 1211 can be used to connect to other types of networks or remote computer systems (not shown).
[0220] The aforementioned memory also includes one or more programs, which are stored in the memory and configured to be executed by the CPU.
[0221] Embodiments of this application also provide a computer device, which includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set, or instruction set, and the at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor to implement the statement question-and-answer method provided in the above-described method embodiments.
[0222] Embodiments of this application also provide a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, wherein the at least one instruction, at least one program, code set, or instruction set is loaded and executed by a processor to implement the question-and-answer method provided in the above-described method embodiments.
[0223] Embodiments of this application also provide a computer program product, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the question-and-answer methods described in the above embodiments.
[0224] Optionally, the computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), solid-state drives (SSDs), or optical discs, etc. The random access memory may include resistive random access memory (ReRAM) and dynamic random access memory (DRAM). The sequence numbers of the embodiments in this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0225] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0226] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A question-and-answer method, characterized in that, The method includes: Obtain the target question statement; The target question statement is matched with a keyword matching tree to obtain the first node attribute corresponding to the candidate keyword in the keyword matching tree and the target question statement. The first node attribute is used to indicate the matching relationship between the target question statement and the candidate keyword. Based on the first node attribute, the second node attribute corresponding to the candidate keyword and the specified logical node in the keyword matching tree is determined. The second node attribute is used to indicate the combined logical relationship of the candidate keyword at the specified logical node. The second node attribute corresponding to the candidate keyword at the specified logical node is determined using AND, OR, and NOT logical relationships. The response result corresponding to the target question statement is determined based on the second node attribute. The response result is the result in the keyword matching tree that corresponds to the target attribute requirement. The response result is the answer to the question after determining the question that satisfies the combined logical relationship in the question set based on the second node attribute.
2. The method according to claim 1, characterized in that, The step of determining the second node attribute corresponding to the candidate keyword and the specified logical node in the keyword matching tree based on the first node attribute includes: Obtain the logical relationship between the specified logical nodes corresponding to the candidate keywords in the keyword matching tree; The logical matching result of the specified logical node is determined based on the attributes of the first node; The logical matching result of the specified logical node is used as the attribute of the second node.
3. The method according to claim 2, characterized in that, The step of determining the logical matching result of the specified logical node based on the first node attribute includes: Match the attributes of the first node with the preset logical relationship of the specified logical node; In response to the first node attribute matching the preset logical relationship of the specified logical node, the logical matching result of the specified logical node is determined to be a matching relationship; In response to the first node attribute not conforming to the preset logical relationship of the specified logical node, the logical matching result of the specified logical node is determined to be a mismatch relationship.
4. The method according to claim 2, characterized in that, The logical relationship of the specified logical node includes any one of the following: AND logical relationship, OR logical relationship, and non-logical relationship.
5. The method according to any one of claims 1 to 4, characterized in that, The step of matching the target query statement with a keyword matching tree to obtain the first node attribute corresponding to the candidate keywords in the keyword matching tree and the target query statement includes: The characters in the target query are input into a character matching model, which includes the keyword matching tree; The character matching model is used to match the characters with candidate keywords in the keyword matching tree to determine the matching result between the target question and the candidate keywords; The first node attribute corresponding to the candidate keyword is determined based on the matching result.
6. The method according to any one of claims 1 to 4, characterized in that, The step of determining the response result corresponding to the target question statement based on the second node attribute includes: In response to the second node attribute meeting the target attribute requirement, the result corresponding to the target attribute requirement is determined as the response result; In response to the second node attribute not meeting the target attribute requirements, the target question statement is analyzed using a classification model to obtain the response result.
7. The method according to claim 6, characterized in that, The step of analyzing the response to the target question using a classification model to obtain the response result includes: The characters in the target question statement are weighted using a classification model to obtain the weighting analysis results; Based on the weight analysis results, the response result corresponding to the target question is determined.
8. A question-and-answer device, characterized in that, The device includes: The acquisition module is used to acquire the target query statement; The matching module is used to match the target question statement with a keyword matching tree to obtain the first node attribute corresponding to the candidate keywords in the keyword matching tree and the target question statement. The first node attribute is used to indicate the matching relationship between the target question statement and the candidate keywords. The determining module is used to determine the second node attribute corresponding to the candidate keyword and the specified logical node in the keyword matching tree based on the first node attribute. The second node attribute is used to indicate the combined logical relationship of the candidate keyword at the logical node. The second node attribute corresponding to the candidate keyword of the specified logical node is determined by AND, OR and NOT logical relationships. The determining module is further configured to determine the response result corresponding to the target question statement based on the second node attribute. The response result is the result in the keyword matching tree that corresponds to the target attribute requirement. The response result is the answer to the question after determining the question that satisfies the combined logical relationship in the question set based on the second node attribute.
9. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing at least one program, which is loaded and executed by the processor to implement the question-and-answer method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The storage medium stores at least one program segment, which is loaded and executed by a processor to implement the question-and-answer method as described in any one of claims 1 to 7.
11. A computer program product, characterized in that, It includes a computer program or instructions that, when executed by a processor, implement the question-and-answer method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Knowledge data providing method and device, electronic equipment and storage medium
CN109739964A
Question and answer method, question and answer system, electronic equipment and storage medium
CN111460116A
Information query method based on FAQ matching model and related equipment thereof
CN111797217A
Intelligent question and answer method and device and computer equipment
CN112052324A