WO2021093755A1 - 问题的匹配方法及装置、问题的回复方法及装置 - Google Patents

问题的匹配方法及装置、问题的回复方法及装置 Download PDF

Info

Publication number
WO2021093755A1
WO2021093755A1 PCT/CN2020/128016 CN2020128016W WO2021093755A1 WO 2021093755 A1 WO2021093755 A1 WO 2021093755A1 CN 2020128016 W CN2020128016 W CN 2020128016W WO 2021093755 A1 WO2021093755 A1 WO 2021093755A1
Authority
WO
WIPO (PCT)
Prior art keywords
question
pair
matched
layer
questions
Prior art date
Application number
PCT/CN2020/128016
Other languages
English (en)
French (fr)
Inventor
祝官文
孟函可
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2021093755A1 publication Critical patent/WO2021093755A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • This application relates to the field of artificial intelligence technology, and in particular to a question matching method and device, and a question reply method and device.
  • Question answering technology refers to the technology in which the user asks questions and the machine automatically answers during the human-computer interaction process.
  • Common question and answer technologies include FAQ (Frequently Asked Questions, question and answer technology based on frequently asked questions list) and CQA (Community-based Question and Answer, question and answer technology based on community question and answer).
  • the FAQ stores frequently asked questions and corresponding answers in the form of a list. After receiving the questions from the user, look for similar frequently asked questions from the list, and use the corresponding answers to the frequently asked questions to reply to the user .
  • the stored frequently asked questions are used as training data to train the classifier, and the trained classifier is used to classify the questions raised by the user, and then to find similar frequently asked questions.
  • the classifier classifies the question based on the characters included in the question, and does not involve the semantics of the question, so the determination of similar questions is not accurate enough.
  • This application provides a question matching method and device, and a question reply method and device to realize the use of a trained question pair-based semantic similarity calculation model to calculate the semantic similarity of the question pair, taking the semantics as Finding reference factors for similar candidate questions improves the accuracy of determining similar questions.
  • this application provides a question matching method, the method includes: obtaining the question to be matched; using a dictionary tree to match the question to be matched; if the matching fails, searching from a preset question library A plurality of candidate questions similar to the question to be matched; using the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question; wherein the question-based pair
  • the semantic similarity calculation model includes an input layer, a coding layer, a local interaction layer, an aggregation layer, and an output layer.
  • the input layer is used to input the word information of the question pair
  • the coding layer is used to center the question Perform semantic analysis on the question to determine the importance of each word included in the question and learn the structural characteristics of the question.
  • the local interaction layer is used to perform semantic relevance on the two questions in the question pair Analyzing
  • the aggregation layer is used for feature extraction and aggregation of the output of the local interaction layer
  • the output layer is used for calculating the semantic similarity of the question pair.
  • the method further includes: updating the dictionary tree, the preset question library, and the corresponding index library.
  • the using the dictionary tree to match the question to be matched includes: removing modal particles in the question to be matched; unifying the punctuation marks in the question to be matched; and
  • the question to be matched is replaced by synonyms to generate multiple similar questions of the question to be matched; each of the similar questions is matched separately by using the dictionary tree.
  • the using the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question includes: separately matching each of the candidate questions with the question to be matched
  • the question is composed of question pairs; the question pairs are input into the semantic similarity calculation model based on the question pairs; according to the semantic similarity of each question pair, the question to be matched and the candidate question are performed match.
  • the semantic similarity calculation model based on the question pair is trained through the following steps: obtaining a reference question pair and a reference semantic similarity corresponding to the reference question pair; wherein the reference question pair includes a first reference Question and second reference question; respectively perform word segmentation processing on the first reference question and the second reference question to generate a first reference word set corresponding to the first reference question, which corresponds to the second reference question A second set of reference words; determining the part of speech corresponding to each reference word in the first set of reference words and the second set of reference words to generate a first set of reference words corresponding to the first set of reference words, and A second reference part-of-speech set corresponding to the second reference word set; determining a synonym corresponding to each of the reference words in the first reference word set and the second reference word set to generate the first reference word A first reference synonym set corresponding to the set, and a second reference synonym set corresponding to the second reference word set; combining the first reference word set, the second reference word set, and the first reference part of speech set,
  • the coding layer includes a bidirectional cyclic neural network layer, a first normalization layer and a stacked bidirectional self-attention layer.
  • the local interaction layer includes a two-way multi-angle similarity analysis layer and a second normalization layer.
  • this application provides a method for replying to a question, the method includes: obtaining a question to be answered; using the aforementioned question matching method to determine a candidate question that matches the question to be answered; Reply to the candidate answer corresponding to the candidate question.
  • the present application provides a question matching device.
  • the device includes: a first obtaining module for obtaining a question to be matched; a first matching module for using a dictionary tree to match the question to be matched Perform matching; a retrieval module, which is used to retrieve multiple candidate questions similar to the question to be matched from a preset question library when the first matching module fails to match; the second matching module is used to use the completed training
  • the semantic similarity calculation model based on the question pair matches the question to be matched with the candidate question; wherein the semantic similarity calculation model based on the question pair includes an input layer, an encoding layer, and a local interaction layer, An aggregation layer and an output layer.
  • the input layer is used to input the word information of the question pair, and the coding layer is used to perform semantic analysis on the questions in the question pair to determine the importance of each word included in the question
  • the local interaction layer is used to analyze the semantic relevance of the two questions in the question pair, and the aggregation layer is used to analyze the output of the local interaction layer. Feature extraction and aggregation, and the output layer is used to calculate the semantic similarity of the question pair.
  • the device further includes: an update module, configured to update the dictionary tree, the preset question library, and the corresponding index library.
  • the first matching module includes: a removal sub-module, which is used to remove modal particles in the question to be matched; and a unification sub-module, which is used to unify the punctuation marks in the question to be matched ; Replacement sub-module, used to substitute synonyms for the question to be matched, to generate a plurality of similar questions of the question to be matched; the first matching sub-module, used to use the dictionary tree for each of the The similar problems are described for matching.
  • a removal sub-module which is used to remove modal particles in the question to be matched
  • a unification sub-module which is used to unify the punctuation marks in the question to be matched
  • Replacement sub-module used to substitute synonyms for the question to be matched, to generate a plurality of similar questions of the question to be matched
  • the first matching sub-module used to use the dictionary tree for each of the The similar problems are described for matching.
  • the second matching module includes: a pairing sub-module, which is used to form a pair of each candidate question with the question to be matched; an input sub-module, which is used to pair the question Input the semantic similarity calculation model based on the question pair; the second matching sub-module is used to match the question to be matched with the candidate question according to the semantic similarity corresponding to each question pair.
  • the device further includes: a second obtaining module, configured to obtain a reference question pair and a reference semantic similarity corresponding to the reference question pair; wherein, the reference question pair includes a first reference question and a second reference question.
  • Reference question a processing module for performing word segmentation processing on the first reference question and the second reference question respectively to generate a first reference word set corresponding to the first reference question, and the second reference question Corresponding second reference word set;
  • a first determining module configured to determine the part of speech corresponding to each reference word in the first reference word set and the second reference word set, so as to generate the corresponding part of the first reference word set The first reference part-of-speech set and the second reference part-of-speech set corresponding to the second reference word set;
  • the second determining module is used to determine each of the first reference word set and the second reference word set
  • the synonym corresponding to the reference word to generate a first reference synonym set corresponding to the first reference word set, and a second reference synonym set corresponding to the second reference word
  • the coding layer includes a bidirectional cyclic neural network layer, a first normalization layer and a stacked bidirectional self-attention layer.
  • the local interaction layer includes a two-way multi-angle similarity analysis layer and a second normalization layer.
  • the present application provides a question answering device, the device comprising: a third obtaining module for obtaining a question to be answered; a third determining module for using the aforementioned question matching method to determine and The candidate question that matches the question to be answered; the reply module is used to reply with the candidate answer corresponding to the candidate question.
  • this application provides a question and answer system, which includes: a question and answer interface for receiving user input and displaying the generated response content; a distribution agent for receiving user input content; Type, the user’s input content is distributed to the corresponding reply device; the aforementioned question reply device is used to receive the question to be answered sent by the distribution agent and determine the corresponding answer from the preset question library.
  • the present application provides an electronic device including: a memory, a processor, and a computer program stored in the memory and running on the processor.
  • the processor executes the computer program, the following steps are performed: obtain The question to be matched; the dictionary tree is used to match the question to be matched; if the matching fails, multiple candidate questions similar to the question to be matched are retrieved from the preset question library; the trained question-based pair is used
  • the input layer is used to input word information of the question pair
  • the coding layer is used to perform semantic analysis on the questions in the question pair, and determine the importance and learning point of each word included in the question.
  • the local interaction layer is used to analyze the semantic relevance of the two questions in the question pair
  • the aggregation layer is used to extract and aggregate the output of the local interaction layer.
  • the output layer is used to calculate the semantic similarity of the question pair.
  • the following step is further performed: updating the dictionary tree, the preset question library, and the corresponding index library.
  • the electronic device uses a dictionary tree to match the question to be matched, which specifically includes the following steps: removing modal particles in the question to be matched; and performing punctuation in the question to be matched Unification; performing synonym substitution on the question to be matched to generate multiple similar questions of the question to be matched; using the dictionary tree to match each of the similar questions separately.
  • the electronic device uses a trained question pair-based semantic similarity calculation model to match the question to be matched with the candidate question, which specifically includes the following steps: separate each candidate question Form a question pair with the question to be matched; input the question pair into the semantic similarity calculation model based on the question pair; according to the semantic similarity corresponding to each question pair, compare the question to be matched with The candidate questions are matched.
  • the electronic device when training the semantic similarity calculation model based on the question pair, performs the following steps: obtaining a reference question pair and the reference semantic similarity corresponding to the reference question pair; wherein, The reference question pair includes a first reference question and a second reference question; word segmentation processing is performed on the first reference question and the second reference question respectively to generate a first reference word set corresponding to the first reference question, A second reference word set corresponding to the second reference question; determining the part of speech corresponding to each reference word in the first reference word set and the second reference word set, to generate the first reference word set correspondence The first reference part-of-speech set of the first reference word set, and the second reference part-of-speech set corresponding to the second reference word set; determine the synonym corresponding to each of the reference words in the first reference word set and the second reference word set, To generate a first reference synonym set corresponding to the first reference word set, and a second reference synonym set corresponding to the second reference word set; combine the first reference word set and the second reference word set
  • the coding layer includes a bidirectional cyclic neural network layer, a first normalization layer and a stacked bidirectional self-attention layer.
  • the local interaction layer includes a two-way multi-angle similarity analysis layer and a second normalization layer.
  • the present application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and capable of running on the processor.
  • the processor executes the computer program, the following steps are performed: Question to be answered; using the method described in the first aspect to determine a candidate question that matches the question to be answered; using the candidate answer corresponding to the candidate question to reply.
  • the present application provides a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer executes the method described in the first or second aspect .
  • Figure 1 is a schematic structural diagram of a classification-based question answering system in the prior art
  • Fig. 2a is a schematic flowchart of a method for constructing a deep learning model in the prior art
  • FIG. 2b is a schematic flowchart of a question answering method based on a deep learning model in the prior art
  • FIG. 3 is a schematic flowchart of a problem matching method proposed by an embodiment of this application.
  • FIG. 4 is a schematic diagram of a flow of the homogenization process proposed in an embodiment of the application.
  • FIG. 5 is a schematic flowchart of the training steps of a semantic similarity calculation model based on a question pair provided by an embodiment of the application;
  • FIG. 6 is a schematic diagram of the flow of generating training positive examples and training negative examples proposed in an embodiment of the application
  • FIG. 7 is a schematic flowchart of a question matching method provided by an embodiment of the application.
  • FIG. 8 is a schematic diagram of initial loading in FIG. 7;
  • FIG. 9 is a schematic structural diagram of a semantic similarity calculation model based on a question pair provided by an embodiment of the application.
  • FIG. 10 is a schematic diagram of the process of answering questions raised by an embodiment of the application.
  • FIG. 11 is a schematic structural diagram of a matching device for a problem proposed by an embodiment of the application.
  • FIG. 12 is a schematic structural diagram of a first matching module proposed in an embodiment of the application.
  • FIG. 13 is a schematic structural diagram of a second matching module proposed in an embodiment of the application.
  • FIG. 14 is a schematic diagram of another structure of the matching device for the problem posed by the embodiment of the application.
  • FIG. 15 is a schematic structural diagram of a device for replying to a question raised by an embodiment of the application.
  • FIG. 16 is a schematic structural diagram of a question answering system proposed by an embodiment of the application.
  • FIG. 17 is a schematic diagram of an electronic device proposed in an embodiment of the application.
  • Question Answering technology namely Question Answering (QA)
  • QA Question Answering
  • QA means that the machine automatically answers the questions raised by the user to meet the user's demand for relevant information. It is generally used in various application scenarios such as corporate customer service and intelligent information.
  • Typical applications are mobile life assistants represented by Apple's Siri, Google Now, and Microsoft Cortana.
  • Question answering technology as an intelligent human-computer interaction technology, can be implemented on various electronic devices.
  • electronic devices may include mobile terminals (mobile phones), smart screens, drones, ICVs (Intelligent Connected Vehicles), smart/intelligent cars (smart/intelligent cars), or in-vehicle devices.
  • mobile terminals mobile phones
  • smart screens drones
  • ICVs Intelligent Connected Vehicles
  • smart/intelligent cars smart/intelligent cars
  • in-vehicle devices in-vehicle devices.
  • question answering technology has gradually evolved from a simple keyword as the core to a deep question and answer technology.
  • question answering technology systems can be roughly divided into: question answering systems based on structured data, question answering systems based on free text, and question answering systems based on question and answer pairs.
  • question and answer system based on question and answer pairs includes: a question and answer system (FAQ) based on a frequently asked question list and a question and answer system (CQA) based on a community question and answer.
  • FAQ question and answer system
  • CQA question and answer system
  • the question and answer system (FAQ) based on the frequently asked questions list has the advantages of large amount of data, high question quality and good data structure, so it is very suitable for mobile life assistant applications.
  • the first implementation is to use the trained classifier to classify the questions posed by the user, and then find similar frequently asked questions from similar questions, and use the answer corresponding to the frequently asked question to reply to the user.
  • Fig. 1 is a schematic structural diagram of a question answering system based on classification in the prior art. As shown in Figure 1, an existing question and answer system based on classification divides frequently asked questions stored in a question file and corresponding answers stored in an answer file into different question groups. Different problem groups are used as training data to train the classifier, so that the classifier can classify different types of problems.
  • the user enters a question through the user interface module, and the classifier determines the category of the question according to the question asked by the user, and then retrieves multiple frequently asked questions similar to the question in the same category. From the answers corresponding to these frequently asked questions, select the answer that best matches the user's question, and display it to the customer through the user interface module.
  • the classifier when the classifier classifies the problem, it is implemented based on the number of characters and the number of characters, and does not solve the semantic gap problem that exists in the traditional search technology. And as the number of frequently asked questions increases, the accuracy of the classifier is getting lower and lower, and it cannot be applied to different types of application scenarios.
  • the second implementation is to grab a question and answer data set from the Internet and store it as a list of frequently asked questions. Find multiple frequently asked questions similar to the user's question from the question and answer data set, and the corresponding answers to these questions, and use the neural network-based question and answer matching model to match the answers with the questions raised by the user, and determine the most common question raised by the user Matching answer.
  • Fig. 2a is a schematic flowchart of a method for constructing a deep learning model in the prior art.
  • Fig. 2b is a schematic flowchart of a question answering method based on a deep learning model in the prior art.
  • the network question and answer data is captured from the network and stored in a relational database as a question and answer data set, and a full-text search service is established.
  • Perform Chinese word segmentation on the questions stored in the relational database and generate BOW (Bag of Words) vector, TF-IDF (Term Frequency-Inverse Document Frequency) value and word2vec based on the result of Chinese word segmentation Word vector, and then generate the corresponding text representation vector.
  • BOW Bit of Words
  • TF-IDF Term Frequency-Inverse Document Frequency
  • the full-text search service provided by the relational database is used to generate a set of similar questions with multiple questions similar to the user's question, and the text representation vector of each similar question in the similar question set is obtained.
  • Chinese word segmentation is performed on the user's question, and the BOW vector, TF-IDF value and word2dev word vector are generated according to the result of Chinese word segmentation, and then the text representation vector corresponding to the user's question is generated.
  • the questions in the question and answer data set need to be continuously added or deleted (for example, there will be new questions that need to be added to the question and answer data set, or some questions are duplicated or unnecessary , Need to be deleted from the Q&A data set).
  • the steps of the deep learning model construction method need to be executed again to update the full-text search service, text representation vector, and neural network-based question and answer matching model, which cannot achieve real-time dynamic updates. That is to say, as time goes by, the previously established full-text search service, text representation vector, and neural network-based question-and-answer matching model are relatively outdated, and the determined answers to user questions are also relatively outdated and inconsistent with the actual situation.
  • the question answering matching model based on neural network is not suitable for question answering system based on frequently asked questions.
  • the semantic space of the question and the answer is different, and it is difficult to set a reasonable corresponding semantic feature, resulting in inaccurate question and answer matching.
  • the answers corresponding to the same question will change. Therefore, the question-and-answer matching model is closely related to the application scenarios and is not universal.
  • FIG. 3 is a schematic flowchart of a problem matching method proposed in an embodiment of the application. As shown in Figure 3, the method includes:
  • Step S101 Obtain the question to be matched.
  • the question to be matched is the question raised by the user.
  • Step S102 Use the dictionary tree to match the question to be matched.
  • the embodiment of the present application matches the question from two aspects of character and semantics, specifically uses a dictionary tree for character matching, and uses a semantic similarity calculation model based on question pairs to perform semantic matching.
  • the dictionary tree also known as the word search tree, is a tree structure.
  • the root node does not contain characters. Each node except the root node contains only one character. From the root node to a certain node, The characters passed on the path are connected to form the string corresponding to the node, and all the sub-nodes of each node contain different characters.
  • the embodiment of the present application stores a plurality of frequently asked questions in advance, and uses each frequently asked question as a character string to fill in the dictionary tree, and the nodes in the dictionary tree can be corresponding to the frequently asked questions. Split the string corresponding to the question to be matched into multiple characters, and use the dictionary tree to match multiple characters in sequence. If the node that matches the string corresponding to the question to be matched can be found in the dictionary tree, then It can be determined that the question to be matched is matched with the frequently asked question corresponding to the node.
  • the dictionary tree can be used to complete the matching of the problem to be matched, then the character matching of the problem to be matched is completed. That is to say, the question raised by the user is exactly the same in content as a candidate question, so in the subsequent reply process, the answer corresponding to the candidate question can be directly used to answer the question raised by the user.
  • Step S103 if the matching fails, retrieve multiple candidate questions similar to the question to be matched from the preset question library.
  • step S102 if the matching of the question to be matched is not completed in step S102, it means that there is no candidate question exactly the same as the question asked by the user in the pre-stored frequently asked questions, and the question to be matched needs to be matched by means of semantic analysis.
  • the frequently asked questions in the preset question library can be preliminarily screened. Specifically, multiple candidate questions similar to the question to be matched are retrieved from the preset question library, and then each candidate question and the question to be matched are input into the semantic similarity calculation model together to determine that it matches the question to be matched Candidate questions.
  • the retrieval results are sorted backwards according to the similarity, and then the first N frequently asked questions are taken as candidate questions, and N is a positive integer.
  • Step S104 using the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question.
  • the semantic similarity calculation model based on the question pair includes the input layer, the coding layer, the local interaction layer, the aggregation layer and the output layer.
  • the input layer is used to input the word information of the question pair
  • the coding layer is used to perform the problem of the question pair.
  • Semantic analysis is used to determine the importance of each word included in the question and the structural characteristics of the learning problem.
  • the local interaction layer is used to analyze the semantic relevance of the two questions in the question pair, and the aggregation layer is used to perform the output of the local interaction layer.
  • Feature extraction and aggregation, and the output layer is used to calculate the semantic similarity of the question pair.
  • the questions to be matched need to be matched in terms of semantics.
  • the embodiment of the application adopts a semantic similarity calculation model based on question pairs to match the question to be matched with the candidate question.
  • One possible implementation is to form a question pair with each candidate question and the question to be matched, and the question pair input is based on the semantic similarity calculation model of the question pair, and the matching is treated according to the semantic similarity corresponding to each question pair.
  • the question is matched with the candidate question.
  • the semantic similarity calculation model based on question pairs is a deep learning sentence pair model technology.
  • the deep learning sentence pair model determines the relationship between sentences by identifying the semantic information of the source sentence and the target sentence after encoding.
  • each example is a triple (source sentence, target sentence, the relationship between the source sentence and the target sentence), through training a depth Learning models (such as recurrent neural network models) to learn to predict the probability of the relationship between any two sentences.
  • a depth Learning models such as recurrent neural network models
  • the word information input in the input layer of the question pair-based semantic similarity calculation model includes a word set generated after word segmentation is performed on the question, and each word in the word set is After the part-of-speech is recognized, the generated part-of-speech set, and the synonym set generated after the synonym recognition of each word in the word set.
  • the coding layer learns the context information of each word in the question and the structural feature information of the question from the multiple words generated after word segmentation processing of the question. Specifically, the information of the left and right words of each word in the question can be learned through the two-way cyclic neural network, and each word in the question can be calculated with other words separately to determine the importance of each word included in the question And the structural characteristics of the learning problem.
  • the local interaction layer analyzes the semantic relevance of the two questions in the question pair on this basis. It can be understood that when the local interaction layer is performing semantic relevance analysis, the higher the importance of words, the greater the impact on the semantic relevance analysis.
  • each word in question 1 and question 2 can be weighted for semantic relevance, and the weight is the importance of the word, so as to obtain the semantic relevance of each word in question 1 to question 2, through similar steps The semantic relevance of each word in question two to question one can be obtained.
  • the aggregation layer uses maximum/minimum pooling to extract features from the output of the local interaction layer, and uses splicing to aggregate the extracted features, and the output layer is based on the aggregated features Calculate the semantic similarity of the question pair.
  • the coding layer includes a bidirectional cyclic neural network layer, a first normalization layer and a stacked bidirectional self-attention layer.
  • the bidirectional cyclic neural network is a special type of cyclic neural network.
  • the cyclic neural network is a recursive neural network that takes sequence data as input, recursively in the evolution direction of the sequence, and all nodes (cyclic units) are connected in a chain. The internet. The difference is that the recurrent neural network performs recursive calculations in one direction (usually the evolution direction of the sequence), while the bidirectional recurrent neural network performs recursive calculations in two directions (usually the evolution direction and the opposite direction of the sequence).
  • the first normalization layer can perform normalization processing on the data, which is convenient for subsequent data processing.
  • the stacked two-way self-attention layer uses the self-attention mechanism to determine the importance of each word in the question from the natural language, so as to provide weight for the subsequent calculation of the semantic relevance between the word and the question.
  • the local interaction layer includes a two-way multi-angle similarity analysis layer and a second normalization layer.
  • the two-way multi-angle similarity analysis layer provided by the embodiment of the present application first calculates the semantic relevance between words and questions from multiple angles, and comprehensively processes the calculation results to obtain the semantic relevance calculation The overall result.
  • the first possible perspective is that the semantic relevance between the word and each word included in the question can be calculated, and the calculation result can be used as the semantic relevance between the word and the question.
  • the second possible angle is that the semantic relevance between the word and the most important word in the question can be calculated, and the calculation result can be used as the semantic relevance between the word and the question.
  • the third possible perspective is that based on the importance of multiple words included in the question, the semantic features of the question can be generated first, and then the semantic relevance of the semantic features of the word and the question can be calculated as the semantic relevance between the word and the question .
  • the multiple angles used may include any of the above-mentioned possible angles, and may also include other possible angles, which are not limited in the embodiment of the present application. .
  • the question matching method includes: obtaining the question to be matched, and using a dictionary tree to match the question to be matched. If the matching fails, retrieve multiple candidate questions similar to the question to be matched from the preset question library, and use the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question.
  • the semantic similarity calculation model based on the question pair includes the input layer, the coding layer, the local interaction layer, the aggregation layer and the output layer.
  • the input layer is used to input the word information of the question pair
  • the coding layer is used to perform the problem of the question pair. Semantic analysis is used to determine the importance of each word included in the question and the structural characteristics of the learning problem.
  • the local interaction layer is used to analyze the semantic relevance of the two questions in the question pair, and the aggregation layer is used to perform the output of the local interaction layer. Feature extraction and aggregation, and the output layer is used to calculate the semantic similarity of the question pair.
  • the trained semantic similarity calculation model based on the question pair is used to calculate the semantic similarity of the question pair, and the semantics is used as a reference factor for finding similar candidate questions, which improves the accuracy of determining similar problems. .
  • step S101 before obtaining the problem to be matched, the method further includes: The dictionary tree, the preset question library, and the corresponding index library are updated.
  • the dictionary tree and the preset question library in the embodiment of this application are both a storage form of frequently asked questions.
  • the required frequently asked questions are different, and over time Over time, frequently asked questions will also change. Therefore, before obtaining the question to be matched, the dictionary tree and the preset question library may be updated first, so as to ensure the accuracy of the question matching method in the embodiment of the present application.
  • the corresponding index library also needs to be updated to realize the search function of the dictionary tree and the preset question library.
  • the embodiment of this application uses the full-text search technology in the preset question The library is searched.
  • Search engine technology refers to the technology that automatically collects information from the Internet and provides users with queries after sorting it out.
  • Search engine technology includes steps such as web crawling, web indexing, web search, and search result ranking.
  • Search engine technology supports dynamic update of web index and near real-time search, and is currently used in a large number of retrieval scenarios.
  • search engine technology can achieve near real-time retrieval of network information.
  • the preset question library can be updated continuously through data crawling, data indexing, data retrieval, search results sorting and other steps to ensure that the preset question library is close Real-time search.
  • step S102 using the dictionary tree to match the question to be matched can quickly complete the matching of the question to be matched.
  • the semantic similarity calculation model is used to match the problem to be matched, the amount of calculation is large and the efficiency is low.
  • FIG. 4 is a schematic diagram of the homogenization process proposed in an embodiment of the application. As shown in Fig. 4, based on the method flow shown in Fig. 3, step S102, using a dictionary tree to match the question to be matched, includes:
  • Step S11 removing the modal particles in the question to be matched.
  • modal particles refer to function words that express mood. They are often used at the end of a sentence or at a pause in a sentence to express various moods. Common modal particles include “Ah”, “N”, “Ma” and so on.
  • step S12 the punctuation marks in the questions to be matched are unified.
  • the punctuation marks can be set to "," or "/", that is, the effect of the punctuation marks to express the tone is removed, and it is only regarded as a pause sign.
  • step S13 since multiple similar questions of the question to be matched need to be generated in step S13, considering that different users have different habits of using modal particles and punctuation marks, and modal particles and punctuation marks have no effect on the essence of the question. Therefore, the modal particles can be removed first, and the punctuation marks can be uniformly converted into symbols used for pauses to facilitate subsequent processing.
  • step S13 synonym replacement is performed on the question to be matched to generate multiple similar questions of the question to be matched.
  • Step S14 Use the dictionary tree to match each similar question separately.
  • the dictionary tree can be used to complete the matching problem match. Therefore, synonym substitution can be performed on the question to be matched to generate multiple similar questions that are different from the question to be matched. Use the dictionary tree to match multiple similar questions. If any one of the similar questions is matched successfully, the question to be matched can be considered to be matched successfully.
  • FIG. 5 is a schematic flowchart of the training steps of a question-pair-based semantic similarity calculation model provided by an embodiment of the application. . As shown in Figure 5, the semantic similarity calculation model based on question pairs is trained through the following steps:
  • Step S201 Obtain a reference question pair and a reference semantic similarity corresponding to the reference question pair.
  • the reference question pair includes the first reference question and the second reference question.
  • the reference question pair and the reference semantic similarity refer to training examples used to train the semantic similarity calculation model based on the question pair.
  • the reference question pair and the reference semantic similarity form a triple in the training example.
  • the first reference question included in the reference question pair can be used as the source sentence.
  • the reference question is the target sentence, then the reference semantic similarity is the relationship between the source sentence and the target sentence.
  • the data in the frequently asked question list is used as the reference question pair and the reference semantic similarity in the embodiment of the present application.
  • the question pair formed by the two questions can be used as a training positive example, and the reference semantic similarity is set higher, for example, set to 1.
  • the question pair formed by the two questions can be used as a training counterexample, and the reference voice similarity is set to a low level, for example, set to 0. It can be understood that the number of training positive examples that can be formed in the frequently asked questions list is much smaller than the number of training negative examples, so that the impact of training positive examples on model training is too small.
  • Figure 6 is a schematic diagram of the process of generating training positive examples and training negative examples proposed in an embodiment of this application, as shown in Figure As shown in 6, the method includes:
  • Step S21 Perform data cleaning on the frequently asked questions list.
  • the frequently asked questions list there are data with similar questions and similar answers, and the questions and corresponding answers can be merged, and there are also data with the same questions but different answers, and the answers can be unbound.
  • Step S22 Determine multiple questions corresponding to each answer.
  • Step S23 Generate training positive examples according to multiple questions corresponding to each answer.
  • training positive examples are that the answers to the two questions are the same, so training positive examples can be generated from multiple questions corresponding to the answers.
  • the number of training positive examples corresponding to each answer can be preset to be similar.
  • Step S24 Generate training counterexamples according to the questions corresponding to different answers.
  • the number of training counterexamples needs to be controlled to make it close to the number of training positive examples.
  • part of the training examples generated above can be used as a development data set, and a part as a training data set.
  • 10% of training samples can be used for development, and 90% of training samples can be used for training, which is not limited in the embodiment of the present application.
  • Step S202 Perform word segmentation processing on the first reference question and the second reference question respectively to generate a first reference word set corresponding to the first reference question and a second reference word set corresponding to the second reference question.
  • Step S203 Determine the part of speech corresponding to each reference word in the first reference word set and the second reference word set to generate a first reference part of speech set corresponding to the first reference word set, and a second reference corresponding to the second reference word set Part of speech collection.
  • Step S204 Determine the synonyms corresponding to each reference word in the first reference word set and the second reference word set to generate a first reference synonym set corresponding to the first reference word set, and a second reference corresponding to the second reference word set Synonym collection.
  • Step S205 Input the first reference word set, the second reference word set, the first reference part-of-speech set, the second reference part-of-speech set, the first reference synonym set and the second reference synonym set into the semantic similarity calculation model based on the question pair. Coding layer.
  • the word information input by the input layer includes a word set, a part-of-speech set, and a synonym set.
  • the input layer needs to perform word segmentation, part-of-speech recognition, and synonym recognition for the first reference question and the second reference question in the input reference question pair, respectively.
  • the input first reference question and second reference question are processed by the input layer to obtain the first reference word set corresponding to the first reference question, the first reference part-of-speech set and the first synonym set, and the second The second reference word set, the second reference part-of-speech set and the second reference synonym set corresponding to the reference question.
  • Step S206 training the parameters of the semantic similarity calculation model based on the question pair according to the output of the semantic similarity calculation model based on the question pair and the reference semantic similarity.
  • the function of the input layer is to transform the problem of the problem pair into a set of words, a set of parts of speech, and a set of synonyms suitable for model processing. Therefore, during the model training process, the parameters of the input layer remain unchanged.
  • training is mainly for the parameters in the coding layer, the local interaction layer, the aggregation layer and the output layer.
  • Step S207 When the accuracy of the semantic similarity calculation model based on the question pair is greater than the preset threshold, the training of the semantic similarity calculation model based on the question pair is completed.
  • the accuracy of the semantic similarity calculation model is greater than the preset threshold, it indicates that the trained model can be used to meet actual needs, and the trained semantic similarity calculation model based on the question pair can be obtained.
  • FIG. 7 is a schematic flowchart of a problem matching method provided by an embodiment of the application.
  • Fig. 8 is a schematic diagram of initial loading in Fig. 7. As shown in Figure 7 and Figure 8, the initial loading is performed first, and the frequently asked question-based dictionary tree is constructed offline according to the pre-stored frequently asked question list, the preset question library with full-text retrieval technology, and used for training question-based pairs The reference question pair and the reference semantic similarity of the semantic similarity calculation model of the semantic similarity calculation model complete the training of the semantic similarity calculation model based on the question pair.
  • the dictionary tree, the preset question library, and the update of the corresponding index library are triggered based on the message event, mainly the index library of the dictionary tree and the preset question library
  • the inverted index library is updated.
  • the question to be matched is preprocessed, modal particles are removed, punctuation is unified, and synonyms are replaced to generate multiple similar questions. Use the dictionary tree to match each similar question separately. If the matching is successful, the matching of the question to be matched is completed.
  • the full-text search technology of the preset question library is used to find multiple candidate questions similar to the question to be matched from the preset question library.
  • the question to be matched is matched with the candidate question, and the matching of the question to be matched is completed, so as to determine the frequently asked questions of the match.
  • FIG. 9 is a schematic structural diagram of a semantic similarity calculation model based on a question pair provided by an embodiment of the application.
  • the question to be matched and the candidate question are taken as a question to the input model, and the input layer processes the question to be matched and the candidate question separately to generate corresponding word sets, part-of-speech sets, and synonym sets.
  • Input the above multiple sets of information into the coding layer.
  • the two-way recurrent neural network layer in the coding layer extracts the relationship between each word and the preceding and following words, and the two-way self-attention layer in the coding layer determines the importance of each word in the question degree.
  • the words in the question to be matched and the candidate question are calculated for semantic relevance
  • the words in the candidate question are calculated for the semantic relevance of the question to be matched.
  • a comprehensive semantic relevance calculation is obtained. result.
  • the output layer After the aggregation layer performs feature extraction and aggregation on the output of the local interaction layer, the output layer outputs the semantic similarity between each candidate question and the question to be matched, and selects the candidate question with the highest semantic similarity as the matching result of the question to be matched .
  • FIG. 10 is a schematic diagram of the process of answering questions raised in an embodiment of this application. As shown in FIG. 10, the method includes:
  • step S301 the question to be answered is obtained.
  • the question to be answered is the question raised by the user through the human-computer interaction interface in the question and answer system, and the machine needs to reply.
  • Step S302 using the question matching method described in the foregoing embodiment to determine a candidate question that matches the question to be answered.
  • the aforementioned question matching method can be used to determine the frequently asked questions with the same semantics as the questions raised by the user from the pre-stored frequently asked questions as candidate questions.
  • Step S303 using the candidate answer corresponding to the candidate question to reply.
  • the candidate question has the same semantics as the question posed by the user, the corresponding answer is also the same, and the candidate answer corresponding to the candidate question can be used for reply.
  • FIG. 11 is a schematic structural diagram of a problem matching device proposed by an embodiment of the application. As shown in FIG. 11, the device includes: a first acquisition module 410, a first matching module 420, a retrieval module 430, and a second matching module 440.
  • the first obtaining module 410 is used to obtain the question to be matched.
  • the question to be matched is the question raised by the user.
  • the first matching module 420 is configured to use a dictionary tree to match the question to be matched.
  • the dictionary tree also known as the word search tree, is a tree structure.
  • the root node does not contain characters. Each node except the root node contains only one character. From the root node to a certain node, The characters passed on the path are connected to form the string corresponding to the node, and all the sub-nodes of each node contain different characters.
  • the retrieval module 430 is configured to retrieve multiple candidate questions similar to the question to be matched from the preset question library when the first matching module fails to match.
  • the retrieval results are sorted backwards according to the similarity, and then the first N frequently asked questions are taken as candidate questions, and N is a positive integer.
  • the second matching module 440 is configured to use the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question.
  • the semantic similarity calculation model based on the question pair includes the input layer, the coding layer, the local interaction layer, the aggregation layer and the output layer.
  • the input layer is used to input the word information of the question pair
  • the coding layer is used to perform the problem of the question pair. Semantic analysis, to determine the importance of each word included in the question and the structural characteristics of the learning problem.
  • the local interaction layer is used to analyze the semantic relevance of the problem in the question pair
  • the aggregation layer is used to extract features from the output of the local interaction layer Unlike aggregation, the output layer is used to calculate the semantic similarity of question pairs.
  • the device further includes: an update module 450 , Used to update the dictionary tree, the preset question library, and the corresponding index library.
  • the corresponding index library also needs to be updated to realize the search function of the dictionary tree and the preset question library.
  • the embodiment of this application uses the full-text search technology in the preset question The library is searched.
  • FIG. 12 is a schematic structural diagram of the first matching module proposed in an embodiment of this application. As shown in FIG. 12, based on the device structure shown in FIG. 11, the first matching module 420 includes:
  • the removing sub-module 421 is used to remove modal particles in the question to be matched.
  • modal particles refer to function words that express mood. They are often used at the end of a sentence or at a pause in a sentence to express various moods. Common modal particles include “Ah”, “N”, “Ma” and so on.
  • the unification sub-module 422 is used to unify the punctuation marks in the question to be matched.
  • the punctuation marks can be set to "," or "/", that is, the effect of the punctuation marks to express the tone is removed, and it is only regarded as a pause sign.
  • the replacement sub-module 423 is used to perform synonym replacement on the question to be matched to generate multiple similar questions of the question to be matched.
  • the first matching sub-module 424 is configured to use a dictionary tree to respectively match each similar question.
  • FIG. 13 is the structure of the second matching module proposed in the embodiment of this application. Schematic. As shown in FIG. 13, based on the device structure shown in FIG. 11, the second matching module 440 includes:
  • the pairing sub-module 441 is used to form a pair of each candidate question with the question to be matched.
  • the input sub-module 442 is used to input the question pair based on the semantic similarity calculation model of the question pair.
  • the second matching sub-module 443 is configured to match the question to be matched with the candidate question according to the corresponding semantic similarity of each question pair.
  • FIG. 14 is another schematic structural diagram of the question matching device proposed in the embodiment of the application, as shown in FIG. 14 As shown, based on the device structure shown in FIG. 11, the device further includes:
  • the second obtaining module 510 is configured to obtain the reference question pair and the reference semantic similarity corresponding to the reference question pair.
  • the reference question pair includes the first reference question and the second reference question.
  • the reference question pair and reference semantic similarity refer to training examples used to train the semantic similarity calculation model based on the question pair.
  • the processing module 520 is configured to perform word segmentation processing on the first reference question and the second reference question respectively to generate a first reference word set corresponding to the first reference question and a second reference word set corresponding to the second reference question.
  • the first determining module 530 is configured to determine the part of speech corresponding to each reference word in the first reference word set and the second reference word set to generate a first reference part of speech set corresponding to the first reference word set, and a second reference word set The corresponding second reference part of speech collection.
  • the second determining module 540 is configured to determine the synonyms corresponding to each reference word in the first reference word set and the second reference word set to generate the first reference synonym set corresponding to the first reference word set and the second reference word set The corresponding second reference synonym set.
  • the input module 550 is used to input the first reference word set, the second reference word set, the first reference part-of-speech set, the second reference part-of-speech set, the first reference synonym set and the second reference synonym set into the semantic similarity based on the question pair
  • the coding layer of the computational model is used to input the first reference word set, the second reference word set, the first reference part-of-speech set, the second reference part-of-speech set, the first reference synonym set and the second reference synonym set into the semantic similarity based on the question pair The coding layer of the computational model.
  • the training module 560 is configured to train the parameters of the semantic similarity calculation model based on the question pair according to the output of the output layer of the semantic similarity calculation model based on the question pair and the reference semantic similarity.
  • the training is mainly for the parameters in the coding layer, the local interaction layer, the aggregation layer and the output layer, and the parameters of the input layer remain unchanged.
  • the completion module 570 is configured to complete the training of the semantic similarity calculation model based on the question pair when the accuracy of the semantic similarity calculation model based on the question pair is greater than the preset threshold.
  • the accuracy of the semantic similarity calculation model is greater than the preset threshold, it indicates that the trained model can be used to meet actual needs, and the trained semantic similarity calculation model based on the question pair can be obtained.
  • the coding layer includes a two-way cyclic neural network Layer, the first normalized layer and the stacked bidirectional self-attention layer.
  • the local interaction layer includes a two-way multi-angle similarity analysis layer and a second normalization layer.
  • the question matching device obtains the question to be matched when matching the question, and uses the dictionary tree to match the question to be matched. If the matching fails, retrieve multiple candidate questions similar to the question to be matched from the preset question library, and use the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question.
  • the semantic similarity calculation model based on the question pair includes the input layer, the coding layer, the local interaction layer, the aggregation layer and the output layer. The input layer is used to input the word information of the question pair, and the coding layer is used to perform the problem of the question pair.
  • Semantic analysis is used to determine the importance of each word included in the question and the structural characteristics of the learning problem.
  • the local interaction layer is used to analyze the semantic relevance of the two questions in the question pair, and the aggregation layer is used to perform the output of the local interaction layer.
  • Feature extraction and aggregation, and the output layer is used to calculate the semantic similarity of the question pair.
  • the trained semantic similarity calculation model based on the question pair is used to calculate the semantic similarity of the question pair, and the semantics is used as a reference factor for finding similar candidate questions, which improves the accuracy of determining similar problems. .
  • Fig. 15 is a schematic structural diagram of the device for replying to the question raised by the embodiment of the application. As shown in FIG. 15, the device includes: a third acquisition module 610, a third determination module 620, and a reply module 630.
  • the third obtaining module 610 is used to obtain the question to be answered.
  • the question to be answered is the question raised by the user through the human-computer interaction interface in the question and answer system, and the machine needs to reply.
  • the third determining module 620 is configured to use the question matching method as in the foregoing embodiment to determine a candidate question that matches the question to be answered.
  • a frequently asked question with the same semantics as the question asked by the user can be determined as a candidate question.
  • the reply module 630 is used for replying with the candidate answer corresponding to the candidate question.
  • the candidate question has the same semantics as the question posed by the user, the corresponding answer is also the same, and the candidate answer corresponding to the candidate question can be used for reply.
  • FIG. 16 is a schematic structural diagram of the question and answer system proposed in the embodiment of the application. As shown in FIG. 16, the question and answer system includes:
  • the question and answer interface 710 is used to receive the user's input content and display the generated response content.
  • the distribution agent 720 is configured to distribute the user's input content to the corresponding reply device according to the type of the user's input content.
  • the answering device includes a question answering device 730, a natural language understanding device, and a natural language processing device.
  • the question answering device 730 is configured to receive the question to be answered sent by the distribution agent 720, and determine the corresponding answer from the preset question library 740.
  • the question and answer system also includes data message middleware and automatic programs.
  • the automatic programs will update the preset question library at a preset time. Specifically, the frequently asked questions in the preset question library and the corresponding index library are updated.
  • the data message middleware sends a message updating the preset question library to the question replying device 730.
  • the distribution agent transmits the question raised by the user to the answering device for the aforementioned question, and the answering device generates the answer to the question to reply, and displays it through the question and answer interface.
  • the embodiment of the present application also proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and capable of running on the processor.
  • a processor executes the computer program, , Perform the following steps:
  • Step S101 Obtain the question to be matched.
  • the question to be matched is the question raised by the user.
  • Step S102 Use the dictionary tree to match the question to be matched.
  • the embodiment of the present application matches the question from two aspects of character and semantics, specifically uses a dictionary tree for character matching, and uses a semantic similarity calculation model based on question pairs to perform semantic matching.
  • the dictionary tree also known as the word search tree, is a tree structure.
  • the root node does not contain characters. Each node except the root node contains only one character. From the root node to a certain node, The characters passed on the path are connected to form the string corresponding to the node, and all the sub-nodes of each node contain different characters.
  • the embodiment of the present application stores a plurality of frequently asked questions in advance, and uses each frequently asked question as a character string to fill in the dictionary tree, and the nodes in the dictionary tree can be corresponding to the frequently asked questions. Split the string corresponding to the question to be matched into multiple characters, and use the dictionary tree to match multiple characters in sequence. If the node that matches the string corresponding to the question to be matched can be found in the dictionary tree, then It can be determined that the question to be matched is matched with the frequently asked question corresponding to the node.
  • the dictionary tree can be used to complete the matching of the problem to be matched, then the character matching of the problem to be matched is completed. That is to say, the question raised by the user is exactly the same in content as a candidate question, so in the subsequent reply process, the answer corresponding to the candidate question can be directly used to answer the question raised by the user.
  • Step S103 if the matching fails, retrieve multiple candidate questions similar to the question to be matched from the preset question library.
  • step S102 if the matching of the question to be matched is not completed in step S102, it means that there is no candidate question exactly the same as the question asked by the user in the pre-stored frequently asked questions, and the question to be matched needs to be matched by means of semantic analysis.
  • the frequently asked questions in the preset question library can be preliminarily screened. Specifically, multiple candidate questions similar to the question to be matched are retrieved from the preset question library, and then each candidate question and the question to be matched are input into the semantic similarity calculation model together to determine that it matches the question to be matched Candidate questions.
  • the retrieval results are sorted backwards according to the similarity, and then the first N frequently asked questions are taken as candidate questions, and N is a positive integer.
  • Step S104 using the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question.
  • the semantic similarity calculation model based on the question pair includes the input layer, the coding layer, the local interaction layer, the aggregation layer and the output layer.
  • the input layer is used to input the word information of the question pair
  • the coding layer is used to perform the problem of the question pair.
  • Semantic analysis is used to determine the importance of each word included in the question and the structural characteristics of the learning problem.
  • the local interaction layer is used to analyze the semantic relevance of the two questions in the question pair, and the aggregation layer is used to perform the output of the local interaction layer.
  • Feature extraction and aggregation, and the output layer is used to calculate the semantic similarity of the question pair.
  • the questions to be matched need to be matched in terms of semantics.
  • the embodiment of the application adopts a semantic similarity calculation model based on question pairs to match the question to be matched with the candidate question.
  • One possible implementation is to form a question pair with each candidate question and the question to be matched, and the question pair input is based on the semantic similarity calculation model of the question pair, and the matching is treated according to the semantic similarity corresponding to each question pair.
  • the question is matched with the candidate question.
  • the semantic similarity calculation model based on question pairs is a deep learning sentence pair model technology.
  • the deep learning sentence pair model determines the relationship between sentences by identifying the semantic information of the source sentence and the target sentence after encoding.
  • each example is a triple (source sentence, target sentence, the relationship between the source sentence and the target sentence), through training a depth Learning models (such as recurrent neural network models) to learn to predict the probability of the relationship between any two sentences.
  • a depth Learning models such as recurrent neural network models
  • the word information input in the input layer of the question pair-based semantic similarity calculation model includes a word set generated after word segmentation is performed on the question, and each word in the word set is After the part-of-speech is recognized, the generated part-of-speech set, and the synonym set generated after the synonym recognition of each word in the word set.
  • the coding layer learns the context information of each word in the question and the structural feature information of the question from the multiple words generated after word segmentation processing of the question. Specifically, the information of the left and right words of each word in the question can be learned through the two-way cyclic neural network, and each word in the question can be calculated with other words separately to determine the importance of each word included in the question And the structural characteristics of the learning problem.
  • the local interaction layer analyzes the semantic relevance of the two questions in the question pair on this basis. It can be understood that when the local interaction layer is performing semantic relevance analysis, the higher the importance of words, the greater the impact on the semantic relevance analysis.
  • each word in question 1 and question 2 can be weighted for semantic relevance, and the weight is the importance of the word, so as to obtain the semantic relevance of each word in question 1 to question 2, through similar steps The semantic relevance of each word in question two to question one can be obtained.
  • the aggregation layer uses maximum/minimum pooling to extract features from the output of the local interaction layer, and uses splicing to aggregate the extracted features, and the output layer is based on the aggregated features Calculate the semantic similarity of the question pair.
  • the coding layer includes a bidirectional cyclic neural network layer, a first normalization layer and a stacked bidirectional self-attention layer.
  • the bidirectional cyclic neural network is a special type of cyclic neural network.
  • the cyclic neural network is a recursive neural network that takes sequence data as input, recursively in the evolution direction of the sequence, and all nodes (cyclic units) are connected in a chain. The internet. The difference is that the recurrent neural network performs recursive calculations in one direction (usually the evolution direction of the sequence), while the bidirectional recurrent neural network performs recursive calculations in two directions (usually the evolution direction and the opposite direction of the sequence).
  • the first normalization layer can perform normalization processing on the data, which is convenient for subsequent data processing.
  • the stacked two-way self-attention layer uses the self-attention mechanism to determine the importance of each word in the question from the natural language, so as to provide weight for the subsequent calculation of the semantic relevance between the word and the question.
  • the local interaction layer includes a two-way multi-angle similarity analysis layer and a second normalization layer.
  • the two-way multi-angle similarity analysis layer provided by the embodiment of the present application first calculates the semantic relevance between words and questions from multiple angles, and comprehensively processes the calculation results to obtain the semantic relevance calculation The overall result.
  • the first possible perspective is that the semantic relevance between the word and each word included in the question can be calculated, and the calculation result can be used as the semantic relevance between the word and the question.
  • the second possible angle is that the semantic relevance between the word and the most important word in the question can be calculated, and the calculation result can be used as the semantic relevance between the word and the question.
  • the third possible perspective is that based on the importance of multiple words included in the question, the semantic features of the question can be generated first, and then the semantic relevance of the semantic features of the word and the question can be calculated as the semantic relevance between the word and the question .
  • the multiple angles used may include any of the above-mentioned possible angles, and may also include other possible angles, which are not limited in the embodiment of the present application. .
  • the electronic device obtains the question to be matched when performing question matching, and uses the dictionary tree to match the question to be matched. If the matching fails, retrieve multiple candidate questions similar to the question to be matched from the preset question library, and use the trained semantic similarity calculation model based on the question pair to match the question to be matched with the candidate question.
  • the semantic similarity calculation model based on the question pair includes the input layer, the coding layer, the local interaction layer, the aggregation layer and the output layer.
  • the input layer is used to input the word information of the question pair
  • the coding layer is used to perform the problem of the question pair. Semantic analysis is used to determine the importance of each word included in the question and the structural characteristics of the learning problem.
  • the local interaction layer is used to analyze the semantic relevance of the two questions in the question pair, and the aggregation layer is used to perform the output of the local interaction layer. Feature extraction and aggregation, and the output layer is used to calculate the semantic similarity of the question pair.
  • the trained semantic similarity calculation model based on the question pair is used to calculate the semantic similarity of the question pair, and the semantics is used as a reference factor for finding similar candidate questions, which improves the accuracy of determining similar problems. .
  • step S101 before obtaining the question to be matched, the method further includes: checking the dictionary tree And the preset question library, and the corresponding index library are updated.
  • the dictionary tree and the preset question library in the embodiment of this application are both a storage form of frequently asked questions.
  • the required frequently asked questions are different, and over time Over time, frequently asked questions will also change. Therefore, before obtaining the question to be matched, the dictionary tree and the preset question library may be updated first, so as to ensure the accuracy of the question matching method in the embodiment of the present application.
  • the corresponding index library also needs to be updated to realize the search function of the dictionary tree and the preset question library.
  • the embodiment of this application uses the full-text search technology in the preset question The library is searched.
  • Search engine technology refers to the technology that automatically collects information from the Internet and provides users with queries after sorting it out.
  • Search engine technology includes steps such as web crawling, web indexing, web search, and search result ranking.
  • Search engine technology supports dynamic update of web index and near real-time search, and is currently used in a large number of retrieval scenarios.
  • search engine technology can achieve near real-time retrieval of network information.
  • the preset question library can be updated continuously through data crawling, data indexing, data retrieval, search results sorting and other steps to ensure that the preset question library is close Real-time search.
  • step S102 using the dictionary tree to match the question to be matched can quickly complete the matching of the question to be matched.
  • the semantic similarity calculation model is used to match the problem to be matched, the amount of calculation is large and the efficiency is low.
  • Step S102 use the dictionary tree to match the question to be matched, including:
  • Step S11 removing the modal particles in the question to be matched.
  • modal particles refer to function words that express mood. They are often used at the end of a sentence or at a pause in a sentence to express various moods. Common modal particles include “Ah”, “N”, “Ma” and so on.
  • step S12 the punctuation marks in the questions to be matched are unified.
  • the punctuation marks can be set to "," or "/", that is, the effect of the punctuation marks to express the tone is removed, and it is only regarded as a pause sign.
  • step S13 since multiple similar questions of the question to be matched need to be generated in step S13, considering that different users have different habits of using modal particles and punctuation marks, and modal particles and punctuation marks have no effect on the essence of the question. Therefore, the modal particles can be removed first, and the punctuation marks can be uniformly converted into symbols used for pauses to facilitate subsequent processing.
  • step S13 synonym replacement is performed on the question to be matched to generate multiple similar questions of the question to be matched.
  • Step S14 Use the dictionary tree to match each similar question separately.
  • the dictionary tree can be used to complete the matching problem match. Therefore, synonym substitution can be performed on the question to be matched to generate multiple similar questions that are different from the question to be matched. Use the dictionary tree to match multiple similar questions. If any one of the similar questions is matched successfully, the question to be matched can be considered to be matched successfully.
  • the electronic device it is necessary to use the trained question pair-based semantic similarity calculation model to match the question to be matched with the candidate model.
  • the electronic device performs the following steps:
  • Step S201 Obtain a reference question pair and a reference semantic similarity corresponding to the reference question pair.
  • the reference question pair includes the first reference question and the second reference question.
  • the reference question pair and the reference semantic similarity refer to training examples used to train the semantic similarity calculation model based on the question pair.
  • the reference question pair and the reference semantic similarity form a triple in the training example.
  • the first reference question included in the reference question pair can be used as the source sentence.
  • the reference question is the target sentence, then the reference semantic similarity is the relationship between the source sentence and the target sentence.
  • the data in the frequently asked question list is used as the reference question pair and the reference semantic similarity in the embodiment of the present application.
  • the question pair formed by the two questions can be used as a training positive example, and the reference semantic similarity is set higher, for example, set to 1.
  • the question pair formed by the two questions can be used as a training counterexample, and the reference voice similarity is set to a low level, for example, set to 0. It can be understood that the number of training positive examples that can be formed in the frequently asked questions list is much smaller than the number of training negative examples, so that the impact of training positive examples on model training is too small.
  • an embodiment of the present application proposes a possible implementation method, which includes:
  • Step S21 Perform data cleaning on the frequently asked questions list.
  • the frequently asked questions list there are data with similar questions and similar answers, and the questions and corresponding answers can be merged, and there are also data with the same questions but different answers, and the answers can be unbound.
  • Step S22 Determine multiple questions corresponding to each answer.
  • Step S23 Generate training positive examples according to multiple questions corresponding to each answer.
  • training positive examples are that the answers to the two questions are the same, so training positive examples can be generated from multiple questions corresponding to the answers.
  • the number of training positive examples corresponding to each answer can be preset to be similar.
  • Step S24 Generate training counterexamples according to the questions corresponding to different answers.
  • the number of training counterexamples needs to be controlled to make it close to the number of training positive examples.
  • part of the training examples generated above can be used as a development data set, and a part as a training data set.
  • 10% of training samples can be used for development, and 90% of training samples can be used for training, which is not limited in the embodiment of the present application.
  • Step S202 Perform word segmentation processing on the first reference question and the second reference question respectively to generate a first reference word set corresponding to the first reference question and a second reference word set corresponding to the second reference question.
  • Step S203 Determine the part of speech corresponding to each reference word in the first reference word set and the second reference word set to generate a first reference part of speech set corresponding to the first reference word set, and a second reference corresponding to the second reference word set Part of speech collection.
  • Step S204 Determine the synonyms corresponding to each reference word in the first reference word set and the second reference word set to generate a first reference synonym set corresponding to the first reference word set, and a second reference corresponding to the second reference word set Synonym collection.
  • Step S205 Input the first reference word set, the second reference word set, the first reference part-of-speech set, the second reference part-of-speech set, the first reference synonym set and the second reference synonym set into the semantic similarity calculation model based on the question pair. Coding layer.
  • the word information input by the input layer includes a word set, a part-of-speech set, and a synonym set.
  • the input layer needs to perform word segmentation, part-of-speech recognition, and synonym recognition for the first reference question and the second reference question in the input reference question pair, respectively.
  • the input first reference question and second reference question are processed by the input layer to obtain the first reference word set corresponding to the first reference question, the first reference part-of-speech set and the first synonym set, and the second The second reference word set, the second reference part-of-speech set and the second reference synonym set corresponding to the reference question.
  • Step S206 training the parameters of the semantic similarity calculation model based on the question pair according to the output of the semantic similarity calculation model based on the question pair and the reference semantic similarity.
  • the function of the input layer is to transform the problem of the problem pair into a set of words, a set of parts of speech, and a set of synonyms suitable for model processing. Therefore, during the model training process, the parameters of the input layer remain unchanged.
  • training is mainly for the parameters in the coding layer, the local interaction layer, the aggregation layer and the output layer.
  • Step S207 When the accuracy of the semantic similarity calculation model based on the question pair is greater than the preset threshold, the training of the semantic similarity calculation model based on the question pair is completed.
  • the accuracy of the semantic similarity calculation model is greater than the preset threshold, it indicates that the trained model can be used to meet actual needs, and the trained semantic similarity calculation model based on the question pair can be obtained.
  • FIG. 17 is a schematic diagram of the electronic device proposed in the embodiment of the present application. As shown in FIG. 17, it includes a memory, a processor, and a computer program stored on the memory and capable of running on the processor. When the processor executes the computer program, the following steps are performed:
  • step S301 the question to be answered is obtained.
  • the question to be answered is the question raised by the user through the human-computer interaction interface in the question and answer system, and the machine needs to reply.
  • Step S302 using the aforementioned question matching method to determine a candidate question that matches the question to be answered.
  • the aforementioned question matching method can be used to determine the frequently asked questions with the same semantics as the questions raised by the user from the pre-stored frequently asked questions as candidate questions.
  • Step S303 using the candidate answer corresponding to the candidate question to reply.
  • the candidate question has the same semantics as the question posed by the user, the corresponding answer is also the same, and the candidate answer corresponding to the candidate question can be used for reply.
  • the embodiments of the present application also propose a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer can execute the problems in the above-mentioned embodiments.
  • the matching method is a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer can execute the problems in the above-mentioned embodiments.
  • the embodiments of the present application also propose a computer-readable storage medium in which a computer program is stored, and when it runs on a computer, the computer can execute the problems in the above-mentioned embodiments. ’S reply method.
  • At least one refers to one or more
  • multiple refers to two or more.
  • And/or describes the association relationship of the associated objects, indicating that there can be three types of relationships, for example, A and/or B, which can mean that A exists alone, A and B exist at the same time, and B exists alone. Among them, A and B can be singular or plural.
  • the character “/” generally indicates that the associated objects before and after are in an “or” relationship.
  • the following at least one item” and similar expressions refer to any combination of these items, including any combination of single items or plural items.
  • At least one of a, b, and c can represent: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, and c can be single, or There can be more than one.
  • any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of the present application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as ROM), random access memory (Random Access Memory; hereinafter referred to as RAM), magnetic disks or optical disks, etc.
  • ROM read-only memory
  • RAM random access memory
  • magnetic disks or optical disks etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Databases & Information Systems (AREA)
  • Artificial Intelligence (AREA)
  • Software Systems (AREA)
  • Biomedical Technology (AREA)
  • Computing Systems (AREA)
  • Molecular Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Biophysics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Machine Translation (AREA)

Abstract

一种问题的匹配方法及装置、问题的回复方法及装置,涉及人工智能技术领域。问题的匹配方法包括:获取待匹配的问题,使用字典树对待匹配的问题进行匹配。若匹配失败,从预设问题库中检索与待匹配的问题相似的多个候选问题,使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与所述候选问题进行匹配。其中,模型包括输入层、编码层、局部交互层、聚合层和输出层。由此,实现了使用训练完的基于问题对的语义相似度计算模型,来对问题对的语义相似度进行计算,将语义作为寻找相似的候选问题的参考因素,提升了确定相似问题的准确度。方法用于问答系统,该问答系统在手机等电子设备上运行,通过自然语言处理技术,实现智能回答。

Description

问题的匹配方法及装置、问题的回复方法及装置
本申请要求于2019年11月14日提交中国专利局、申请号为201911115389.3、申请名称为“问题的匹配方法及装置、问题的回复方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能技术领域,特别涉及一种问题的匹配方法及装置、问题的回复方法及装置。
背景技术
问答技术是指人机交互过程中,用户提出问题,机器自动进行回答的技术。常见的问答技术包括FAQ(Frequently Asked Questions,基于常问问题列表的问答技术)和CQA(Community-based Question and Answeri,基于社区问答的问答技术)。其中,FAQ将常问问题和对应的回答以列表的形式进行存储,在收到用户提出的问题后,从列表中寻找相似的常问问题,并使用该常问问题对应的回答向用户进行答复。
相关技术中,将存储的常问问题作为训练数据对分类器进行训练,使用训练完的分类器对用户提出的问题进行分类,进而寻找相似的常问问题。其中,分类器基于问题中包括的字符来对问题进行分类,没有涉及问题的语义,因此对于相似问题的确定不够准确。
发明内容
本申请提供了一种问题的匹配方法及装置、问题的回复方法及装置,以实现使用训练完的基于问题对的语义相似度计算模型,来对问题对的语义相似度进行计算,将语义作为寻找相似的候选问题的参考因素,提升了确定相似问题的准确度。
第一方面,本申请提供了一种问题的匹配方法,所述方法包括:获取待匹配的问题;使用字典树对所述待匹配的问题进行匹配;若匹配失败,从预设问题库中检索与所述待匹配的问题相似的多个候选问题;使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配;其中,所述基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,所述输入层用于输入所述问题对的词语信息,所述编码层用于对所述问题对中的问题进行语义分析,确定所述问题包括的每个词语的重要度和学习所述问题的结构特征,所述局部交互层用于对所述问题对中的两个所述问题进行语义相关度分析,所述聚合层用于对所述局部交互层的输出进行特征提取和聚合,所述输出层用于计算所述问题对的语义相似度。
可选地,在所述获取待匹配的问题之前,还包括:对所述字典树和所述预设问题库,以及对应的索引库进行更新。
可选地,所述使用字典树对所述待匹配的问题进行匹配,包括:去除所述待匹配的问题中的语气词;将所述待匹配的问题中的标点符号进行统一;对所述待匹配的问 题进行同义词替换,以生成所述待匹配的问题的多个相似问题;使用所述字典树分别对每个所述相似问题进行匹配。
可选地,所述使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配,包括:将每个所述候选问题分别与所述待匹配的问题组成问题对;将所述问题对输入所述基于问题对的语义相似度计算模型;根据每个所述问题对对应的语义相似度,对所述待匹配的问题与所述候选问题进行匹配。
可选地,所述基于问题对的语义相似度计算模型通过以下步骤进行训练:获取参考问题对,以及所述参考问题对对应的参考语义相似度;其中,所述参考问题对包括第一参考问题和第二参考问题;分别对所述第一参考问题和所述第二参考问题进行分词处理,以生成所述第一参考问题对应的第一参考词语集合,和所述第二参考问题对应的第二参考词语集合;确定所述第一参考词语集合和所述第二参考词语集合中每个参考词语对应的词性,以生成所述第一参考词语集合对应的第一参考词性集合,和所述第二参考词语集合对应的第二参考词性集合;确定所述第一参考词语集合和所述第二参考词语集合中每个所述参考词语对应的同义词,以生成所述第一参考词语集合对应的第一参考同义词集合,和所述第二参考词语集合对应的第二参考同义词集合;将所述第一参考词语集合,所述第二参考词语集合,所述第一参考词性集合,所述第二参考词性集合,所述第一参考同义词集合和所述第二参考同义词集合输入所述基于问题对的语义相似度计算模型的所述编码层;根据所述基于问题对的语义相似度计算模型的所述输出层的输出和所述参考语义相似度,对所述基于问题对的语义相似度计算模型的参数进行训练;在所述基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对所述基于问题对的语义相似度计算模型的训练。
可选地,所述编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
可选地,所述局部交互层包括双向多角度相似度分析层和第二归一化层。
第二方面,本申请提供了一种问题的回复方法,所述方法包括:获取待回复的问题;使用前述的问题的匹配方法,确定与所述待回复的问题相匹配的候选问题;使用所述候选问题对应的候选答案进行回复。
第三方面,本申请提供了一种问题的匹配装置,所述装置包括:第一获取模块,用于获取待匹配的问题;第一匹配模块,用于使用字典树对所述待匹配的问题进行匹配;检索模块,用于当所述第一匹配模块匹配失败时,从预设问题库中检索与所述待匹配的问题相似的多个候选问题;第二匹配模块,用于使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配;其中,所述基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,所述输入层用于输入所述问题对的词语信息,所述编码层用于对所述问题对中的问题进行语义分析,确定所述问题包括的每个词语的重要度和学习所述问题的结构特征,所述局部交互层用于对所述问题对中的两个所述问题进行语义相关度分析,所述聚合层用于对所述局部交互层的输出进行特征提取与聚合,所述输出层用于计算所述问题对的语义相似度。
可选地,所述装置还包括:更新模块,用于对所述字典树和所述预设问题库,以及对应的索引库进行更新。
可选地,所述第一匹配模块,包括:去除子模块,用于去除所述待匹配的问题中的语气词;统一子模块,用于将所述待匹配的问题中的标点符号进行统一;替换子模块,用于对所述待匹配的问题进行同义词替换,以生成所述待匹配的问题的多个相似问题;第一匹配子模块,用于使用所述字典树分别对每个所述相似问题进行匹配。
可选地,所述第二匹配模块,包括:组对子模块,用于将每个所述候选问题分别与所述待匹配的问题组成问题对;输入子模块,用于将所述问题对输入所述基于问题对的语义相似度计算模型;第二匹配子模块,用于根据每个所述问题对对应的语义相似度,对所述待匹配的问题与所述候选问题进行匹配。
可选地,所述装置还包括:第二获取模块,用于获取参考问题对,以及所述参考问题对对应的参考语义相似度;其中,所述参考问题对包括第一参考问题和第二参考问题;处理模块,用于分别对所述第一参考问题和所述第二参考问题进行分词处理,以生成所述第一参考问题对应的第一参考词语集合,和所述第二参考问题对应的第二参考词语集合;第一确定模块,用于确定所述第一参考词语集合和所述第二参考词语集合中每个参考词语对应的词性,以生成所述第一参考词语集合对应的第一参考词性集合,和所述第二参考词语集合对应的第二参考词性集合;第二确定模块,用于确定所述第一参考词语集合和所述第二参考词语集合中每个所述参考词语对应的同义词,以生成所述第一参考词语集合对应的第一参考同义词集合,和所述第二参考词语集合对应的第二参考同义词集合;输入模块,用于将所述第一参考词语集合,所述第二参考词语集合,所述第一参考词性集合,所述第二参考词性集合,所述第一参考同义词集合和所述第二参考同义词集合输入所述基于问题对的语义相似度计算模型的所述编码层;训练模块,用于根据所述基于问题对的语义相似度计算模型的所述输出层的输出和所述参考语义相似度,对所述基于问题对的语义相似度计算模型的参数进行训练;完成模块,用于在所述基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对所述基于问题对的语义相似度计算模型的训练。
可选地,所述编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
可选地,所述局部交互层包括双向多角度相似度分析层和第二归一化层。
第四方面,本申请提供了一种问题的回复装置,所述装置包括:第三获取模块,用于获取待回复的问题;第三确定模块,用于使用前述的问题的匹配方法,确定与所述待回复的问题相匹配的候选问题;回复模块,用于使用所述候选问题对应的候选答案进行回复。
第五方面,本申请提供了一种问答系统,所述系统包括:问答界面,用于接收用户的输入内容,并将生成的回复内容进行展示;分发代理,用于根据所述用户的输入内容的类型,将所述用户的输入内容分发给对应的回复装置;前述的问题的回复装置,用于接收所述分发代理发送的待回复的问题,并从预设问题库中确定对应的答案。
第六方面,本申请提供一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,执行以下步骤:获取待匹配的问题;使用字典树对所述待匹配的问题进行匹配;若匹配失败,从预设问题库中检索与所述待匹配的问题相似的多个候选问题;使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配;其中,所述基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,所述输入层用于输入所述问题对的词语信息,所述编码层用于对所述问题对中的问题进行语义分析,确定所述问题包括的每个词语的重要度和学习所述问题的结构特征,所述局部交互层用于对所述问题对中的两个所述问题进行语义相关度分析,所述聚合层用于对所述局部交互层的输出进行特征提取与聚合,所述输出层用于计算所述问题对的语义相似度。
可选地,在所述电子设备获取待匹配的问题之前,还执行以下步骤:对所述字典树和所述预设问题库,以及对应的索引库进行更新。
可选地,所述电子设备使用字典树对所述待匹配的问题进行匹配,具体包括以下步骤:去除所述待匹配的问题中的语气词;将所述待匹配的问题中的标点符号进行统一;对所述待匹配的问题进行同义词替换,以生成所述待匹配的问题的多个相似问题;使用所述字典树分别对每个所述相似问题进行匹配。
可选地,所述电子设备使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配,具体包括以下步骤:将每个所述候选问题分别与所述待匹配的问题组成问题对;将所述问题对输入所述基于问题对的语义相似度计算模型;根据每个所述问题对对应的语义相似度,对所述待匹配的问题与所述候选问题进行匹配。
可选地,在对所述基于问题对的语义相似度计算模型进行训练时,所述电子设备执行以下步骤:获取参考问题对,以及所述参考问题对对应的参考语义相似度;其中,所述参考问题对包括第一参考问题和第二参考问题;分别对所述第一参考问题和所述第二参考问题进行分词处理,以生成所述第一参考问题对应的第一参考词语集合,和所述第二参考问题对应的第二参考词语集合;确定所述第一参考词语集合和所述第二参考词语集合中每个参考词语对应的词性,以生成所述第一参考词语集合对应的第一参考词性集合,和所述第二参考词语集合对应的第二参考词性集合;确定所述第一参考词语集合和所述第二参考词语集合中每个所述参考词语对应的同义词,以生成所述第一参考词语集合对应的第一参考同义词集合,和所述第二参考词语集合对应的第二参考同义词集合;将所述第一参考词语集合,所述第二参考词语集合,所述第一参考词性集合,所述第二参考词性集合,所述第一参考同义词集合和所述第二参考同义词集合输入所述基于问题对的语义相似度计算模型的所述编码层;根据所述基于问题对的语义相似度计算模型的所述输出层的输出和所述参考语义相似度,对所述基于问题对的语义相似度计算模型的参数进行训练;在所述基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对所述基于问题对的语义相似度计算模型的训练。
可选地,所述编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注 意力层。
可选地,所述局部交互层包括双向多角度相似度分析层和第二归一化层。
第七方面,本申请提供一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,执行以下步骤:获取待回复的问题;使用如第一方面所述的方法,确定与所述待回复的问题相匹配的候选问题;使用所述候选问题对应的候选答案进行回复。
第八方面,本申请提供一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如第一方面或第二方面所述的方法。
附图说明
图1为现有技术中的一种基于分类的问答系统的结构示意图;
图2a为现有技术中的一种深度学习模型的构建方法的流程示意图;
图2b为现有技术中的一种基于深度学习模型的问答方法的流程示意图;
图3为本申请实施例所提出的一种问题的匹配方法的流程示意图;
图4为本申请实施例提出的同一化处理的流程示意图;
图5为本申请实施例所提供的一种基于问题对的语义相似度计算模型的训练步骤的流程示意图;
图6为本申请实施例所提出的生成训练正例和训练反例的流程示意图;
图7为本申请实施例所提供的问题的匹配方法的流程示意图;
图8为图7中初始化加载的示意图;
图9为本申请实施例所提供的基于问题对的语义相似度计算模型的结构示意图;
图10为本申请实施例所提出的问题回复的流程示意图;
图11为本申请实施例所提出的一种问题的匹配装置的结构示意图;
图12为本申请实施例所提出的第一匹配模块的结构示意图;
图13为本申请实施例所提出的第二匹配模块的结构示意图;
图14为本申请实施例所提出的问题的匹配装置的另一种结构示意图;
图15为本申请实施例所提出的问题的回复装置的结构示意图;
图16为本申请实施例所提出的一种问答系统的结构示意图;以及
图17为本申请实施例所提出的电子设备的示意图。
具体实施方式
下面详细描述本申请的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,旨在用于解释本申请,而不能理解为对本申请的限制。
下面参考附图描述本申请实施例的问题的匹配方法及装置、问题的回复方法及装置,以及问答系统、计算机可读存储介质。
为了更加清楚地说明本申请实施例所提供的问题的匹配方法,下面首先对相关技 术进行说明。
问答技术,即Question Answering(QA),是指机器自动回答用户提出的问题,从而满足用户对相关信息的需求。一般应用于企业客服,智能资讯等多种应用场景,其典型的应用就是以苹果公司的Siri、Google Now、微软Cortana等为代表的移动生活助手。
问答技术作为一种智能化的人机交互技术,可以在各种电子设备上实现。具体来说,电子设备可以包括移动终端(手机)、智慧屏、无人机、ICV(Intelligent Connected Vehicle,智能网联车)、智能(汽)车(smart/intelligent car)或车载设备等设备。
在传统搜索技术中,输入的是关键词,输出的是一系列相关文档列表。和传统搜索技术不同的是,问答技术的输入通常为自然语言形式的问题,输出是一个简洁答案,或者多个可能答案的列表。
近年来,随着人工智能、自然语言处理和移动互联网技术的快速发展,问答技术逐渐从以简单关键词为核心,发展为以深度问答技术为核心。
基于目标数据源类型的不同,可以将常见的问答技术系统大致分为:基于结构化数据的问答系统,基于自由文本的问答系统和基于问答对的问答系统。其中,基于问答对的问答系统又包括:基于常问问题列表的问答系统(FAQ)和基于社区问答的问答系统(CQA)。
基于常问问题列表的问答系统(FAQ)具有数据量大,问题质量高和数据结构好等优点,因此十分适用于移动生活助手类应用。
现有技术中,对于基于常问问题列表的问答系统存在多种实现方式。
第一种实现方式是,使用训练完的分类器对用户提出的问题进行分类,进而从同类问题中寻找相似的常问问题,并使用该常问问题对应的回答向用户进行答复。图1为现有技术中的一种基于分类的问答系统的结构示意图。如图1所示,现有的一种基于分类的问答系统,将问题文件中存储的常问问题及答案文件中存储的对应答案,分成不同的问题组。将不同的问题组作为训练数据对分类器进行训练,使得分类器能够对不同类型的问题进行分类。
在使用过程中,用户通过用户界面模块输入问题,分类器根据用户提出的问题,确定该问题的类别,进而在相同类别中检索与该问题相似的多个常问问题。从这些常问问题对应的答案中,选取与用户提出的问题最为匹配的回答,通过用户界面模块展示给客户。
第一种实现方式中,分类器在对问题进行分类时,是基于字符和字符数量实现的,没有解决传统搜索技术中存在的语义鸿沟问题。并且随着常问问题数量的增大,分类器的准确度越来越低,无法适用于不同类型的应用场景。
此外,随着时间的迁移,不断有新的问答对产生,旧的问答对删除或者部分问答对更新,而上述分类器在训练完成后,无法根据问答对的更新进行实时更新,使得分类器检索到的相似常问问题较为陈旧。
第二种实现方式是,从网上抓取问答数据集进行存储,作为常问问题列表。从问答数据集中寻找与用户提出的问题相似的多个常问问题,以及这些问题对应的回答,使用基于神经网络的问答匹配模型将回答与用户提出的问题进行匹配,确定与用户提 出的问题最为匹配的回答。图2a为现有技术中的一种深度学习模型的构建方法的流程示意图。图2b为现有技术中的一种基于深度学习模型的问答方法的流程示意图。如图2a所示,在深度学习模型构建过程中,从网络抓取网络问答数据,存入关系型数据库中,作为问答数据集,并建立全文检索服务。对关系型数据库中存储的问题进行中文分词,根据中文分词后的结果生成BOW(Bag of Words,词袋)向量,TF-IDF(Term Frequency–Inverse Document Frequency,词频-逆文件频率)值和word2vec词向量,进而生成对应的文本表示向量。将问答数据集中的问答数据作为训练数据,用于训练基于神经网络的问答匹配模型。如图2b所示,在接收到用户提问后,使用关系型数据库提供的全文检索服务,与用户提问相似的多个问题,生成相似问题集,获取相似问题集中每个相似问题的文本表示向量。对用户提问进行中文分词,根据中文分词后的结果生成BOW向量,TF-IDF值和word2dev词向量,进而生成用户提问对应的文本表示向量。
通过计算相似问题的文本表示向量和用户提问的文本表示向量的余弦相似度,生成多个相似问题,将这些相似问题对应的回答作为候选答案。将用户提问和候选答案输入训练完的基于神经网络的问答匹配模型中,确定用户提问的答案。
第二种实现方式中,随着业务的需要和时间的推移,问答数据集中的问题需要不断地增加或者删除(比如会有新的问题需要增加到问答数据集中,或者有些问题存在重复或者不必要的情况,需要从问答数据集中进行删除)。在问答数据集发生变化后,需要再次执行深度学习模型的构建方法的步骤,才能对全文检索服务、文本表示向量和基于神经网络的问答匹配模型进行更新,无法实现实时动态的更新。也就是说,随着时间的推移,之前建立的全文检索服务、文本表示向量和基于神经网络的问答匹配模型较为陈旧,确定出的用户提问的答案也较为陈旧,与实际情况不符。
此外,基于神经网络的问答匹配模型不适用于基于常问问题的问答系统。具体来说,对于问答匹配模型来说,问题和答案的语义空间存在区别,设定合理的相对应的语义特征较为困难,导致问答匹配不准确。而且随着应用场景的变化,同一个问题对应的答案会发生变化,因此问答匹配模型与应用场景的联系较为紧密,不具有通用性。
基于上述对相关技术的说明,可以知道,相关技术中在存储的问题集中寻找与用户提问相似的问题时,对于相似问题的确定不够准确。
为了解决上述问题,本申请实施例提出了一种问题的匹配方法,图3为本申请实施例所提出的一种问题的匹配方法的流程示意图。如图3所示,该方法包括:
步骤S101,获取待匹配的问题。
基于前述对问答系统的说明,可以知道,待匹配的问题是用户提出的问题。
获取用户提出的问题的方式有多种,具体可以通过人机交互界面实现,用户通过人机交互的界面提出问题可以通过键盘输入、语音输入等各种输入手段实现。
步骤S102,使用字典树对待匹配的问题进行匹配。
需要说明的是,本申请实施例从字符和语义两个方面对问题进行匹配,具体使用字典树进行字符的匹配,使用基于问题对的语义相似度计算模型进行语义的匹配。
其中,字典树(trie树),又被称为单词查找树,是一种树形结构,根节点不包含 字符,除根节点外每一个节点都只包含一个字符,从根节点到某一节点,路径上经过的字符连接起来,为该节点对应的字符串,每个节点的所有子节点包含的字符都不相同。
可以理解,本申请实施例预先对多个常问问题进行存储,并将每个常问问题作为一个字符串,填入字典树中,可以将字典树中的节点与该常问问题相对应。将待匹配的问题所对应的字符串拆分为多个字符,使用字典树对多个字符进行依次匹配,若在字典树中能够找到与待匹配的问题所对应的字符串匹配的节点,就能够确定待匹配的问题与该节点对应的常问问题完成匹配。
需要说明的是,若使用字典树能够完成对待匹配问题的匹配,则完成了对待匹配的问题的字符匹配。也就是说,用户提出的问题与某个候选问题在内容上一模一样,那么在后续的回复过程中,可以直接将该候选问题对应的答案用来回答用户提出的问题。
步骤S103,若匹配失败,从预设问题库中检索与待匹配的问题相似的多个候选问题。
需要说明的是,若步骤S102中没有完成对待匹配的问题的匹配,说明预先存储的常问问题中没有与用户提出的问题一模一样的候选问题,需要通过语义分析的方式对待匹配的问题进行匹配。
可以理解,在预设问题库中,存在着大量的常问问题,若将每个常问问题都与待匹配的问题一起输入语义相似度计算模型,计算量太大,且效率很低。
为了减少后续过程中的计算量,可以先对预设问题库中的常问问题进行初步筛选。具体地,从预设问题库中检索与待匹配的问题相似的多个候选问题,再将每个候选问题与待匹配的问题一起输入语义相似度计算模型,从中确定与待匹配的问题相匹配的候选问题。
和前述使用字典树进行匹配不同的是,此处在对预设问题库进行检索时,只需要从中检索出与待匹配的问题存在相同关键词的常问问题即可,无需在内容形式上完全一致。可以理解,预设问题库中的常问问题,与待匹配的问题具有的相同关键词的数量越多,说明该常问问题与待匹配的问题在内容形式上的相似度越高,因此本申请实施例对检索结果按照相似度进行倒排序,然后取前N个常问问题作为候选问题,N为正整数。
步骤S104,使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选问题进行匹配。
其中,基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,输入层用于输入问题对的词语信息,编码层用于对问题对中的问题进行语义分析,确定问题包括的每个词语的重要度和学习问题的结构特征,局部交互层用于对问题对中的两个问题进行语义相关度分析,聚合层用于对局部交互层的输出进行特征提取与聚合,输出层用于计算问题对的语义相似度。
在步骤S103从内容形式上完成了对候选问题的初步筛选后,需要从语义方面对待匹配的问题进行匹配。
本申请实施例采用了基于问题对的语义相似度计算模型,来对待匹配的问题与候选问题进行匹配。
一种可能的实现方式是,将每个候选问题分别与待匹配的问题组成问题对,将问题对输入基于问题对的语义相似度计算模型,根据每个问题对对应的语义相似度,对待匹配的问题与候选问题进行匹配。
需要说明的是,本申请实施例所提供的基于问题对的语义相似度计算模型是一种深度学习句子对模型技术。随着近年来人工智能和深度学习技术的不断发展,越来越多的自然语言处理任务使用深度学习架构来进行处理,比较常见的有神经网络语言模型,循环神经网络模型,句子对模型等。具体地,深度学习句子对模型通过识别出源句和目标句编码后的语义信息来确定句子之间的关系。
在使用深度学习句子对模型技术时,先给定一组训练样例,每个样例为一个三元组(源句,目标句,源句与目标句之间的关系),通过训练一个深度学习模型(如循环神经网络模型),来学习预测任意两个句子之间的关系的概率。
需要特别说明的是,本申请实施例所提供的基于问题对的语义相似度计算模型中的输入层中输入的词语信息包括对问题进行分词后生成的词语集合,对词语集合中的每个词语进行词性进行识别后,生成的词性集合,以及对词语集合中的每个词语进行同义词识别后,生成的同义词集合。
编码层在将输入层输入的词语进行语义分析后,从问题进行分词处理后生成的多个词语中,学习该问题中每个词语的上下文信息以及学习该问题的结构特征信息。具体可以通过双向循环神经网络学习问题中每个词语的左右两边词语的信息,并且将该问题中的每个词语分别与其他词语进行语义相关度计算,从而确定问题包括的每个词语的重要度和学习问题的结构特征。
在编码层确定了问题对中的两个问题各自包括的每个词语的重要度和学习问题的结构特征之后,局部交互层在此基础上对问题对中的两个问题进行语义相关度分析。可以理解,由于局部交互层在进行语义相关度分析时,重要度越高的词语对于语义相关度分析的影响越大。具体可以将问题一中的每个词语分别与问题二进行语义相关度加权计算,权重为该词语的重要度,从而得到问题一中的每个词语与问题二的语义相关度,通过类似的步骤可以得到问题二中的每个词语与问题一的语义相关度。
为了减少后续语义相似度的计算量,聚合层采用最大/最小池化的方式对局部交互层的输出进行特征提取,以及采用拼接的方式对提取的特征进行聚合,由输出层根据聚合后的特征计算问题对的语义相似度。
为了让编码层能够实现上述功能,一种可能的实现方式是,编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
需要说明的是,双向循环神经网络一种特殊的循环神经网络,循环神经网络是一种以序列数据为输入,在序列的演进方向进行递归且所有节点(循环单元)按链式连接的递归神经网络。区别在于,循环神经网络沿一个方向进行递归计算(通常为序列的演进方向),双向循环神经网络则沿两个方向进行递归计算(通常为序列的演进方 向和反方向)。
可以理解,自然语言作为一种序列数据,通常具有较强的关联性,而双向循环神经网络能够结合数据在序列中的前后数据,对数据进行编码,提升了数据编码的合理性。
第一归一化层能够对将数据进行归一化处理,便于后续数据的处理。
堆叠的双向自注意力层通过自注意力机制,从自然语言中确定每个词语在问题中的重要度,从而为后续计算词语与问题之间的语义相关度提供权重。
为了让局部交互层实现上述功能,一种可能的实现方式是,局部交互层包括双向多角度相似度分析层和第二归一化层。
需要说明的是,本申请实施例提供的双向多角度相似度分析层,先从多个角度计算词语与问题之间的语义相关度,将计算结果进行综合处理后,即可得到语义相关度计算的综合结果。
第一种可能的角度是,可以计算词语与问题中包括的每个词语的语义相关度,将计算结果作为词语和问题之间的语义相关度。
第二种可能的角度是,可以计算词语与问题中重要度最高的词语的语义相关度,将计算结果作为词语和问题之间的语义相关度。
第三种可能的角度是,可以基于问题包括的多个词语的重要度,先生成问题的语义特征,再计算词语与问题的语义特征的语义相关度,作为词语和问题之间的语义相关度。
可以理解,在生成语义相关度计算的综合结果过程中,采用的多个角度可以包括上述的可能的角度中的任一种,还可以包括其他可能的角度,本申请实施例对此不做限定。
综上所述,本申请实施例所提供的问题的匹配方法,包括:获取待匹配的问题,使用字典树对待匹配的问题进行匹配。若匹配失败,从预设问题库中检索与待匹配的问题相似的多个候选问题,使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选问题进行匹配。其中,基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,输入层用于输入问题对的词语信息,编码层用于对问题对中的问题进行语义分析,确定问题包括的每个词语的重要度和学习问题的结构特征,局部交互层用于对问题对中的两个问题进行语义相关度分析,聚合层用于对局部交互层的输出进行特征提取与聚合,输出层用于计算问题对的语义相似度。由此,实现了使用训练完的基于问题对的语义相似度计算模型,来对问题对的语义相似度进行计算,将语义作为寻找相似的候选问题的参考因素,提升了确定相似问题的准确度。
此外,为了让本申请实施例所提出的问题的匹配方法能够适用于不同的业务场景,并且能够随着时间的推移不断更新,在步骤S101,获取待匹配的问题之前,该方法还包括:对字典树和预设问题库,以及对应的索引库进行更新。
基于前述说明可以知道,本申请实施例中的字典树和预设问题库都是常问问题的一种存储形式,在不同的业务场景下,所需的常问问题不同,并且随着时间的推移,常问问题也会发生改变,因此在获取待匹配的问题之前,可以先进行对字典树和预设 问题库的更新,从而保证本申请实施例的问题的匹配方法的准确度。
需要说明的是,当字典树和预设问题库出现更新后,对应的索引库也需要进行更新才能实现字典树和预设问题库的检索功能,本申请实施例使用全文检索技术在预设问题库进行检索。
全文检索技术本质上是一种搜索引擎技术,搜索引擎技术指从互联网上自动搜集信息,经过整理后给用户提供查询的技术。搜索引擎技术包括网页爬虫,网页索引,网页检索,搜索结果排序等步骤。搜索引擎技术支持网页的索引动态更新和近实时搜索,目前应用在大量检索类的场景中。
可以理解,由于互联网上的信息不断在进行更新,因此搜索引擎技术能够实现对网络信息的近实时检索。使用全文检索技术对预设问题库进行检索时,可以在预设问题库不断进行更新的情况下,通过数据爬虫,数据索引,数据检索,搜索结果排序等步骤,保证对预设问题库进行近实时搜索。
基于前述说明可以知道,步骤S102,使用字典树对待匹配的问题进行匹配,能够快速完成对待匹配的问题的匹配。而采用语义相似度计算模型对待匹配的问题进行匹配时,计算量大,效率低。
为了让尽量多的待匹配问题能够通过字典树完成匹配,一种可能的实现方式是,将相同问题的不同表述进行同一化处理,图4为本申请实施例提出的同一化处理的流程示意图。如图4所示,基于图3所示的方法流程,步骤S102,用字典树对待匹配的问题进行匹配,包括:
步骤S11,去除待匹配的问题中的语气词。
其中,语气词是指表示语气的虚词,常用在句尾或句中停顿处表示种种语气,常见的语气词有“啊”、“呢”、“吗”等。
步骤S12,将待匹配的问题中的标点符号进行统一。
具体地,可以将标点符号设置为“,”或者“/”,也就是说,将标点符号表示语气的作用去除,仅将其看作停顿的符号。
需要说明的是,由于步骤S13中需要生成待匹配的问题的多个相似问题,考虑到不同用户对语气词和标点符号的使用习惯不同,并且语气词和标点符号对于问题的实质内容没有影响,因此可以先将语气词去除,将标点符号统一转化为用于停顿的符号,以便于后续处理。
步骤S13,对待匹配的问题进行同义词替换,以生成待匹配的问题的多个相似问题。
步骤S14,使用字典树分别对每个相似问题进行匹配。
可以理解,为了让待匹配的问题能够与字典树中存储的常问问题进行匹配,在生成字典树时,将常问问题的语气词去除,标点符号进行统一处理。在使用字典树时,对待匹配的问题进行同样的操作,以提升待匹配的问题与常问问题匹配成功的可能性。
此外,考虑到自然语言中对待匹配的问题的表述方式有多种,但实质内容相同,若字典树中预先存储了这些表述方式中的任意一种,即可使用字典树完成对待匹配的 问题的匹配。因此,可以对待匹配的问题进行同义词替换,来生成与待匹配的问题的表述方式不同的多个相似问题。使用字典树对多个相似问题进行匹配,若任意一个相似问题匹配成功,则可认为待匹配的问题匹配成功。
在本申请实施例所提供的问题的匹配方法中,需要使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选模型进行匹配。为了对该基于问题对的语义相似度计算模型进行训练,一种可能的实现方式是,图5为本申请实施例所提供的一种基于问题对的语义相似度计算模型的训练步骤的流程示意图。如图5所示,该基于问题对的语义相似度计算模型通过以下步骤进行训练:
步骤S201,获取参考问题对,以及参考问题对对应的参考语义相似度。
其中,参考问题对包括第一参考问题和第二参考问题。
参考问题对和参考语义相似度是指用于训练基于问题对的语义相似度计算模型的训练样例。
基于前述对深度学习句子对模型技术的说明,可以知道,参考问题对和参考语义相似度形成了训练样例中的三元组,可以将参考问题对包括的第一参考问题作为源句,第二参考问题作为目标句,那么参考语义相似度就是源句和目标句之间的关系。
需要特别说明的是,本申请实施例中使用常问问题列表中的数据作为参考问题对和参考语义相似度。但是,可能会出现训练样例不平衡的情况。具体来说,若两个问题的答案相同,则这两个问题形成的问题对可以作为训练正例,将参考语义相似度设置的较高,比如设为1。若两个问题的答案不同,则这两个问题形成的问题对可以作为训练反例,将参考语音相似度设置的较低,比如设为0。可以理解,常问问题列表中能够形成的训练正例数量远小于训练反例的数量,从而使得训练正例对模型训练的影响太小。
为了平衡训练正例和训练反例对模型训练的影响,本申请实施例提出了一种可能的实现方式,图6为本申请实施例所提出的生成训练正例和训练反例的流程示意图,如图6所示,该方法包括:
步骤S21,对常问问题列表进行数据清洗。
具体来说,在常问问题列表中,存在着问题相似并且对应答案相似的数据,可以将问题和对应答案进行合并,还存在问题相同但对应答案不同的数据,可以将答案进行解绑。此外,还可以将常问问题列表中的英文问题进行删除。
步骤S22,确定每个答案对应的多个问题。
步骤S23,根据每个答案对应的多个问题,生成训练正例。
基于前述说明,可以知道,常问问题列表中能够形成的训练正例数量远小于训练反例的数量,因此需要优先形成训练正例。
训练正例的特点在于两个问题的答案相同,因此可以根据答案对应的多个问题,从中生成训练正例。
此外,考虑到不同答案对应的问题数量不同,可以预先设置每个答案对应的训练正例数量相近。
步骤S24,根据不同答案对应的问题,生成训练反例。
应当理解,为了减少反例对模型训练的影响,对于训练反例的生成采用更加精细化的策略。
具体来说,对于不同答案,可能对应有说法相似的问题,为了让训练后的模型能够对说法相似的问题进行区分,需要尽可能将这种情况作为训练反例。
其次,对于训练反例的数量需要进行控制,使其与训练正例的数量相近。
为了避免同一个问题在不同的训练反例中出现,需要在训练反例的选取过程中对已经选取的问题进行标记。
通过上述训练样例的生成方法,能够从常问问题列表中较为实用的参考问题对和参考语义相似度。
在实际使用中,可以将上述生成的训练样例中的一部分作为开发数据集,一部分作为训练数据集。比如可以将10%的训练样例用于开发,90%的训练样例用于训练,本申请实施例对此不做限定。
步骤S202,分别对第一参考问题和第二参考问题进行分词处理,以生成第一参考问题对应的第一参考词语集合,和第二参考问题对应的第二参考词语集合。
步骤S203,确定第一参考词语集合和第二参考词语集合中每个参考词语对应的词性,以生成第一参考词语集合对应的第一参考词性集合,和第二参考词语集合对应的第二参考词性集合。
步骤S204,确定第一参考词语集合和第二参考词语集合中每个参考词语对应的同义词,以生成第一参考词语集合对应的第一参考同义词集合,和第二参考词语集合对应的第二参考同义词集合。
步骤S205,将第一参考词语集合,第二参考词语集合,第一参考词性集合,第二参考词性集合,第一参考同义词集合和第二参考同义词集合输入基于问题对的语义相似度计算模型的编码层。
基于前述对基于问题对的语义相似度计算模型的说明可以知道,输入层输入的词语信息包括词语集合,词性集合以及同义词集合。相应地,在模型训练过程中,输入层需要对输入的参考问题对中的第一参考问题和第二参考问题分别进行分词、词性识别、同义词识别处理。
需要说明的是,输入的第一参考问题和第二参考问题,经过输入层的处理后,得到第一参考问题对应的第一参考词语集合,第一参考词性集合和第一同义词集合,第二参考问题对应的第二参考词语集合,第二参考词性集合和第二参考同义词集合。
步骤S206,根据基于问题对的语义相似度计算模型的输出和参考语义相似度,对基于问题对的语义相似度计算模型的参数进行训练。
需要说明的是,基于前述说明可以知道,输入层的作用是将问题对中的问题转化为适合模型处理的词语集合、词性集合和同义词集合。因此在模型训练过程中,输入层的参数保持不变。
对于模型参数的训练,主要是针对编码层,局部交互层,聚合层和输出层中的参数进行训练。
步骤S207,在基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对基于问题对的语义相似度计算模型的训练。
当语义相似度计算模型的准确度大于预设阈值时,说明训练后的模型能够用于满足实际需求,即可得到训练完的基于问题对的语义相似度计算模型。
从而,实现了对基于问题对的语义相似度计算模型的训练。
为了更加清楚地说明本申请实施例所提供的问题的匹配方法,下面进行举例说明。
图7为本申请实施例所提供的问题的匹配方法的流程示意图。图8为图7中初始化加载的示意图。如图7和图8所示,首先进行初始化加载,根据预先存储的常问问题列表离线构建基于常问问题的字典树,带有全文检索技术的预设问题库,以及用于训练基于问题对的语义相似度计算模型的参考问题对和参考语义相似度,完成对基于问题对的语义相似度计算模型的训练。
当常问问题列表发生问答对的添加、删除、更新时,基于消息事件触发字典树和预设问题库,以及对应的索引库的更新,主要是对字典树的索引库以及预设问题库的倒排索引库进行更新。
在获取待匹配的问题之后,对待匹配的问题进行预处理,去除语气词,对标点符号进行统一,进行同义词替换,以生成多个相似问题。使用字典树分别对每个相似问题进行匹配,若匹配成功,则完成了对待匹配的问题的匹配。
若匹配失败,则使用预设问题库的全文检索技术,从预设问题库中寻找与待匹配的问题相似的多个候选问题。使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选问题进行匹配,完成对待匹配的问题的匹配,从而确定匹配的常问问题。
图9为本申请实施例所提供的基于问题对的语义相似度计算模型的结构示意图。如图9所示,将待匹配的问题与候选问题作为一个问题对输入模型,输入层将待匹配的问题和候选问题分别进行处理,生成对应的词语集合、词性集合和同义词集合。将上述多个集合的信息输入编码层,编码层中的双向循环神经网络层提取每个词语与前后词语之间的关系,编码层中的双向自注意力层确定每个词语在问题中的重要度。在局部交互层中,待匹配的问题中词语与候选问题发生语义相关度计算,候选问题中的词语与待匹配的问题发生语义相关度计算,经过多角度分析后,得到语义相关度计算的综合结果。
聚合层对局部交互层的输出进行特征提取和聚合后,由输出层输出每个候选问题与待匹配的问题的语义相似度,选取语义相似度最高的候选问题,作为待匹配的问题的匹配结果。
基于前述对问答系统的说明,可以知道,对于语义相似的多个问题,可以使用相同的答案进行回复。因此,而本申请实施例所提出的问题的匹配方法可以用于确定与 待匹配的问题语义相同的常问问题,因此,可以将本申请实施例所提出的问题的匹配方法用于问题的回复。具体来说,图10为本申请实施例所提出的问题回复的流程示意图,如图10所示,该方法包括:
步骤S301,获取待回复的问题。
其中,待回复的问题即为问答系统中用户通过人机交互界面提出的问题,需要机器做出回复。
步骤S302,使用如前述实施例所述的问题的匹配方法,确定与待回复的问题相匹配的候选问题。
在基于常问问题列表的问答系统中,可以采用前述的问题的匹配方法,从预先存储的常问问题中,确定与用户提出的问题语义相同的常问问题作为候选问题。
步骤S303,使用候选问题对应的候选答案进行回复。
可以理解,由于候选问题与用户提出的问题语义相同,因此对应的答案也相同,可以使用候选问题对应的候选答案进行回复。
从而,实现了通过问题匹配的方式,将预先存储的常问问题的答案,作为用户提出的问题的答案,进行回复。
为了实现上述实施例,本申请实施例还提出了一种问题的匹配装置。图11为本申请实施例所提出的一种问题的匹配装置的结构示意图,如图11所示,该装置包括:第一获取模块410,第一匹配模块420,检索模块430,第二匹配模块440。
第一获取模块410,用于获取待匹配的问题。
其中,待匹配的问题是用户提出的问题。
第一匹配模块420,用于使用字典树对待匹配的问题进行匹配。
其中,字典树(trie树),又被称为单词查找树,是一种树形结构,根节点不包含字符,除根节点外每一个节点都只包含一个字符,从根节点到某一节点,路径上经过的字符连接起来,为该节点对应的字符串,每个节点的所有子节点包含的字符都不相同。
检索模块430,用于当第一匹配模块匹配失败时,从预设问题库中检索与待匹配的问题相似的多个候选问题。
在对预设问题库进行检索时,只需要从中检索出与待匹配的问题存在相同关键词的常问问题即可,无需在内容形式上完全一致。可以理解,预设问题库中的常问问题,与待匹配的问题具有的相同关键词的数量越多,说明该常问问题与待匹配的问题在内容形式上的相似度越高,因此本申请实施例对检索结果按照相似度进行倒排序,然后取前N个常问问题作为候选问题,N为正整数。
第二匹配模块440,用于使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选问题进行匹配。
其中,基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,输入层用于输入问题对的词语信息,编码层用于对问题对中的问题进 行语义分析,确定问题包括的每个词语的重要度和学习问题的结构特征,局部交互层用于对问题对中的问题进行语义相关度分析,聚合层用于对局部交互层的输出进行特征提取与聚合,输出层用于计算问题对的语义相似度。
进一步地,为了让本申请实施例所提出的问题的匹配方法能够适用于不同的业务场景,并且能够随着时间的推移不断更新,一种可能的实现方式是,该装置还包括:更新模块450,用于对字典树和预设问题库,以及对应的索引库进行更新。
需要说明的是,当字典树和预设问题库出现更新后,对应的索引库也需要进行更新才能实现字典树和预设问题库的检索功能,本申请实施例使用全文检索技术在预设问题库进行检索。
进一步地,为了让尽量多的待匹配问题能够通过字典树完成匹配,一种可能的实现方式是,图12为本申请实施例所提出的第一匹配模块的结构示意图。如图12所示,基于图11所示的装置结构,第一匹配模块420,包括:
去除子模块421,用于去除待匹配的问题中的语气词。
其中,语气词是指表示语气的虚词,常用在句尾或句中停顿处表示种种语气,常见的语气词有“啊”、“呢”、“吗”等。
统一子模块422,用于将待匹配的问题中的标点符号进行统一。
具体地,可以将标点符号设置为“,”或者“/”,也就是说,将标点符号表示语气的作用去除,仅将其看作停顿的符号。
替换子模块423,用于对待匹配的问题进行同义词替换,以生成待匹配的问题的多个相似问题。
第一匹配子模块424,用于使用字典树分别对每个相似问题进行匹配。
进一步地,为了使用基于问题对的语义相似度计算模型,来对待匹配的问题与候选问题进行匹配,一种可能的实现方式是,图13为本申请实施例所提出的第二匹配模块的结构示意图。如图13所示,基于图11所示的装置结构,第二匹配模块440,包括:
组对子模块441,用于将每个候选问题分别与待匹配的问题组成问题对。
输入子模块442,用于将问题对输入基于问题对的语义相似度计算模型。
第二匹配子模块443,用于根据每个问题对对应的语义相似度,对待匹配的问题与候选问题进行匹配。
进一步地,为了对该基于问题对的语义相似度计算模型进行训练,一种可能的实现方式是,图14为本申请实施例所提出的问题的匹配装置的另一种结构示意图,如图14所示,基于图11所示的装置结构,该装置还包括:
第二获取模块510,用于获取参考问题对,以及参考问题对对应的参考语义相似度。
其中,参考问题对包括第一参考问题和第二参考问题。
参考问题对和参考语义相似度是指用于训练基于问题对的语义相似度计算模型的 训练样例。
处理模块520,用于分别对第一参考问题和第二参考问题进行分词处理,以生成第一参考问题对应的第一参考词语集合,和第二参考问题对应的第二参考词语集合。
第一确定模块530,用于确定第一参考词语集合和第二参考词语集合中每个参考词语对应的词性,以生成第一参考词语集合对应的第一参考词性集合,和第二参考词语集合对应的第二参考词性集合。
第二确定模块540,用于确定第一参考词语集合和第二参考词语集合中每个参考词语对应的同义词,以生成第一参考词语集合对应的第一参考同义词集合,和第二参考词语集合对应的第二参考同义词集合。
输入模块550,用于将第一参考词语集合,第二参考词语集合,第一参考词性集合,第二参考词性集合,第一参考同义词集合和第二参考同义词集合输入基于问题对的语义相似度计算模型的编码层。
训练模块560,用于根据基于问题对的语义相似度计算模型的输出层的输出和参考语义相似度,对基于问题对的语义相似度计算模型的参数进行训练。
对于模型参数的训练,主要是针对编码层,局部交互层,聚合层和输出层中的参数进行训练,输入层的参数保持不变。
完成模块570,用于在基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对基于问题对的语义相似度计算模型的训练。
当语义相似度计算模型的准确度大于预设阈值时,说明训练后的模型能够用于满足实际需求,即可得到训练完的基于问题对的语义相似度计算模型。
进一步地,为了让编码层能够对问题对中的问题进行语义分析,确定问题包括的每个词语的重要度和学习问题的结构特征,一种可能的实现方式是,编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
进一步地,为了让局部交互层能够对问题对中的两个问题进行语义相关度分析,局部交互层包括双向多角度相似度分析层和第二归一化层。
需要说明的是,前述对问题的匹配方法实施例的说明,也适用于本申请实施例的问题的匹配装置,此处不再赘述。
综上所述,本申请实施例所提供的问题的匹配装置,在进行问题的匹配时,获取待匹配的问题,使用字典树对待匹配的问题进行匹配。若匹配失败,从预设问题库中检索与待匹配的问题相似的多个候选问题,使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选问题进行匹配。其中,基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,输入层用于输入问题对的词语信息,编码层用于对问题对中的问题进行语义分析,确定问题包括的每个词语的重要度和学习问题的结构特征,局部交互层用于对问题对中的两个问题进行语义相关度分析,聚合层用于对局部交互层的输出进行特征提取与聚合,输出层用于计算问题对的语义相似度。由此,实现了使用训练完的基于问题对的语义相似度计算模型,来对问题对的语义相似度进行计算,将语义作为寻找相似的候选问题的参考因素,提升了确定相似问题的准确度。
为了实现上述实施例,本申请实施例还提出了一种问题的回复装置,图15为本申 请实施例所提出的问题的回复装置的结构示意图。如图15所示,该装置包括:第三获取模块610,第三确定模块620,回复模块630。
第三获取模块610,用于获取待回复的问题。
其中,待回复的问题即为问答系统中用户通过人机交互界面提出的问题,需要机器做出回复。
第三确定模块620,用于使用如前述实施例中的问题的匹配方法,确定与待回复的问题相匹配的候选问题。
具体可以从预先存储的常问问题中,确定与用户提出的问题语义相同的常问问题作为候选问题。
回复模块630,用于使用候选问题对应的候选答案进行回复。
可以理解,由于候选问题与用户提出的问题语义相同,因此对应的答案也相同,可以使用候选问题对应的候选答案进行回复。
需要说明的是,前述对问题的回复方法实施例的说明,也适用于本申请实施例的问题的回复装置,此处不再赘述。
从而,实现了通过问题匹配的方式,将预先存储的常问问题的答案,作为用户提出的问题的答案,进行回复。
为了实现上述实施例,本申请实施例还提出了一种问答系统,图16为本申请实施例所提出的一种问答系统的结构示意图,如图16所示,该问答系统包括:
问答界面710,用于接收用户的输入内容,并将生成的回复内容进行展示。
分发代理720,用于根据用户的输入内容的类型,将用户的输入内容分发给对应的回复装置。其中,回复装置包括问题的回复装置730,自然语言理解装置,自然语言处理装置。
问题的回复装置730,用于接收分发代理720发送的待回复的问题,并从预设问题库740中确定对应的答案。
此外,该问答系统还包括数据消息中间件和自动程序,自动程序每隔预设时间会对预设问题库进行更新,具体是对预设问题库中的常问问题,以及对应的索引库进行删除和添加操作,由数据消息中间件将对预设问题库进行更新的消息发送给问题的回复装置730。
需要说明的是,前述对问题的回复装置实施例的说明,也适用于本申请实施例的问答系统,此处不再赘述。
从而,实现了通过问答系统的问答界面接收用户的输入内容,分发代理将用户提出的问题传输给前述的问题的回复装置,由问题的回复装置生成问题的答案进行回复,通过问答界面进行展示。
为了实现上述实施例,本申请实施例还提出了一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,执行以下步骤:
步骤S101,获取待匹配的问题。
基于前述对问答系统的说明,可以知道,待匹配的问题是用户提出的问题。
获取用户提出的问题的方式有多种,具体可以通过人机交互界面实现,用户通过人机交互的界面提出问题可以通过键盘输入、语音输入等各种输入手段实现。
步骤S102,使用字典树对待匹配的问题进行匹配。
需要说明的是,本申请实施例从字符和语义两个方面对问题进行匹配,具体使用字典树进行字符的匹配,使用基于问题对的语义相似度计算模型进行语义的匹配。
其中,字典树(trie树),又被称为单词查找树,是一种树形结构,根节点不包含字符,除根节点外每一个节点都只包含一个字符,从根节点到某一节点,路径上经过的字符连接起来,为该节点对应的字符串,每个节点的所有子节点包含的字符都不相同。
可以理解,本申请实施例预先对多个常问问题进行存储,并将每个常问问题作为一个字符串,填入字典树中,可以将字典树中的节点与该常问问题相对应。将待匹配的问题所对应的字符串拆分为多个字符,使用字典树对多个字符进行依次匹配,若在字典树中能够找到与待匹配的问题所对应的字符串匹配的节点,就能够确定待匹配的问题与该节点对应的常问问题完成匹配。
需要说明的是,若使用字典树能够完成对待匹配问题的匹配,则完成了对待匹配的问题的字符匹配。也就是说,用户提出的问题与某个候选问题在内容上一模一样,那么在后续的回复过程中,可以直接将该候选问题对应的答案用来回答用户提出的问题。
步骤S103,若匹配失败,从预设问题库中检索与待匹配的问题相似的多个候选问题。
需要说明的是,若步骤S102中没有完成对待匹配的问题的匹配,说明预先存储的常问问题中没有与用户提出的问题一模一样的候选问题,需要通过语义分析的方式对待匹配的问题进行匹配。
可以理解,在预设问题库中,存在着大量的常问问题,若将每个常问问题都与待匹配的问题一起输入语义相似度计算模型,计算量太大,且效率很低。
为了减少后续过程中的计算量,可以先对预设问题库中的常问问题进行初步筛选。具体地,从预设问题库中检索与待匹配的问题相似的多个候选问题,再将每个候选问题与待匹配的问题一起输入语义相似度计算模型,从中确定与待匹配的问题相匹配的候选问题。
和前述使用字典树进行匹配不同的是,此处在对预设问题库进行检索时,只需要从中检索出与待匹配的问题存在相同关键词的常问问题即可,无需在内容形式上完全一致。可以理解,预设问题库中的常问问题,与待匹配的问题具有的相同关键词的数量越多,说明该常问问题与待匹配的问题在内容形式上的相似度越高,因此本申请实施例对检索结果按照相似度进行倒排序,然后取前N个常问问题作为候选问题,N为正整数。
步骤S104,使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选问题进行匹配。
其中,基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,输入层用于输入问题对的词语信息,编码层用于对问题对中的问题进行语义分析,确定问题包括的每个词语的重要度和学习问题的结构特征,局部交互层用于对问题对中的两个问题进行语义相关度分析,聚合层用于对局部交互层的输出进行特征提取与聚合,输出层用于计算问题对的语义相似度。
在步骤S103从内容形式上完成了对候选问题的初步筛选后,需要从语义方面对待匹配的问题进行匹配。
本申请实施例采用了基于问题对的语义相似度计算模型,来对待匹配的问题与候选问题进行匹配。
一种可能的实现方式是,将每个候选问题分别与待匹配的问题组成问题对,将问题对输入基于问题对的语义相似度计算模型,根据每个问题对对应的语义相似度,对待匹配的问题与候选问题进行匹配。
需要说明的是,本申请实施例所提供的基于问题对的语义相似度计算模型是一种深度学习句子对模型技术。随着近年来人工智能和深度学习技术的不断发展,越来越多的自然语言处理任务使用深度学习架构来进行处理,比较常见的有神经网络语言模型,循环神经网络模型,句子对模型等。具体地,深度学习句子对模型通过识别出源句和目标句编码后的语义信息来确定句子之间的关系。
在使用深度学习句子对模型技术时,先给定一组训练样例,每个样例为一个三元组(源句,目标句,源句与目标句之间的关系),通过训练一个深度学习模型(如循环神经网络模型),来学习预测任意两个句子之间的关系的概率。
需要特别说明的是,本申请实施例所提供的基于问题对的语义相似度计算模型中的输入层中输入的词语信息包括对问题进行分词后生成的词语集合,对词语集合中的每个词语进行词性进行识别后,生成的词性集合,以及对词语集合中的每个词语进行同义词识别后,生成的同义词集合。
编码层在将输入层输入的词语进行语义分析后,从问题进行分词处理后生成的多个词语中,学习该问题中每个词语的上下文信息以及学习该问题的结构特征信息。具体可以通过双向循环神经网络学习问题中每个词语的左右两边词语的信息,并且将该问题中的每个词语分别与其他词语进行语义相关度计算,从而确定问题包括的每个词语的重要度和学习问题的结构特征。
在编码层确定了问题对中的两个问题各自包括的每个词语的重要度和学习问题的结构特征之后,局部交互层在此基础上对问题对中的两个问题进行语义相关度分析。可以理解,由于局部交互层在进行语义相关度分析时,重要度越高的词语对于语义相关度分析的影响越大。具体可以将问题一中的每个词语分别与问题二进行语义相关度加权计算,权重为该词语的重要度,从而得到问题一中的每个词语与问题二的语义相 关度,通过类似的步骤可以得到问题二中的每个词语与问题一的语义相关度。
为了减少后续语义相似度的计算量,聚合层采用最大/最小池化的方式对局部交互层的输出进行特征提取,以及采用拼接的方式对提取的特征进行聚合,由输出层根据聚合后的特征计算问题对的语义相似度。
为了让编码层能够实现上述功能,一种可能的实现方式是,编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
需要说明的是,双向循环神经网络一种特殊的循环神经网络,循环神经网络是一种以序列数据为输入,在序列的演进方向进行递归且所有节点(循环单元)按链式连接的递归神经网络。区别在于,循环神经网络沿一个方向进行递归计算(通常为序列的演进方向),双向循环神经网络则沿两个方向进行递归计算(通常为序列的演进方向和反方向)。
可以理解,自然语言作为一种序列数据,通常具有较强的关联性,而双向循环神经网络能够结合数据在序列中的前后数据,对数据进行编码,提升了数据编码的合理性。
第一归一化层能够对将数据进行归一化处理,便于后续数据的处理。
堆叠的双向自注意力层通过自注意力机制,从自然语言中确定每个词语在问题中的重要度,从而为后续计算词语与问题之间的语义相关度提供权重。
为了让局部交互层实现上述功能,一种可能的实现方式是,局部交互层包括双向多角度相似度分析层和第二归一化层。
需要说明的是,本申请实施例提供的双向多角度相似度分析层,先从多个角度计算词语与问题之间的语义相关度,将计算结果进行综合处理后,即可得到语义相关度计算的综合结果。
第一种可能的角度是,可以计算词语与问题中包括的每个词语的语义相关度,将计算结果作为词语和问题之间的语义相关度。
第二种可能的角度是,可以计算词语与问题中重要度最高的词语的语义相关度,将计算结果作为词语和问题之间的语义相关度。
第三种可能的角度是,可以基于问题包括的多个词语的重要度,先生成问题的语义特征,再计算词语与问题的语义特征的语义相关度,作为词语和问题之间的语义相关度。
可以理解,在生成语义相关度计算的综合结果过程中,采用的多个角度可以包括上述的可能的角度中的任一种,还可以包括其他可能的角度,本申请实施例对此不做限定。
综上所述,本申请实施例所提供的电子设备,在进行问题匹配时,获取待匹配的问题,使用字典树对待匹配的问题进行匹配。若匹配失败,从预设问题库中检索与待匹配的问题相似的多个候选问题,使用训练完的基于问题对的语义相似度计算模型, 对待匹配的问题与候选问题进行匹配。其中,基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,输入层用于输入问题对的词语信息,编码层用于对问题对中的问题进行语义分析,确定问题包括的每个词语的重要度和学习问题的结构特征,局部交互层用于对问题对中的两个问题进行语义相关度分析,聚合层用于对局部交互层的输出进行特征提取与聚合,输出层用于计算问题对的语义相似度。由此,实现了使用训练完的基于问题对的语义相似度计算模型,来对问题对的语义相似度进行计算,将语义作为寻找相似的候选问题的参考因素,提升了确定相似问题的准确度。
此外,为了让本申请实施例所提出的电子设备能够适用于不同的业务场景,并且能够随着时间的推移不断更新,在步骤S101,获取待匹配的问题之前,该方法还包括:对字典树和预设问题库,以及对应的索引库进行更新。
基于前述说明可以知道,本申请实施例中的字典树和预设问题库都是常问问题的一种存储形式,在不同的业务场景下,所需的常问问题不同,并且随着时间的推移,常问问题也会发生改变,因此在获取待匹配的问题之前,可以先进行对字典树和预设问题库的更新,从而保证本申请实施例的问题的匹配方法的准确度。
需要说明的是,当字典树和预设问题库出现更新后,对应的索引库也需要进行更新才能实现字典树和预设问题库的检索功能,本申请实施例使用全文检索技术在预设问题库进行检索。
全文检索技术本质上是一种搜索引擎技术,搜索引擎技术指从互联网上自动搜集信息,经过整理后给用户提供查询的技术。搜索引擎技术包括网页爬虫,网页索引,网页检索,搜索结果排序等步骤。搜索引擎技术支持网页的索引动态更新和近实时搜索,目前应用在大量检索类的场景中。
可以理解,由于互联网上的信息不断在进行更新,因此搜索引擎技术能够实现对网络信息的近实时检索。使用全文检索技术对预设问题库进行检索时,可以在预设问题库不断进行更新的情况下,通过数据爬虫,数据索引,数据检索,搜索结果排序等步骤,保证对预设问题库进行近实时搜索。
基于前述说明可以知道,步骤S102,使用字典树对待匹配的问题进行匹配,能够快速完成对待匹配的问题的匹配。而采用语义相似度计算模型对待匹配的问题进行匹配时,计算量大,效率低。
为了让尽量多的待匹配问题能够通过字典树完成匹配,一种可能的实现方式是,将相同问题的不同表述进行同一化处理,步骤S102,用字典树对待匹配的问题进行匹配,包括:
步骤S11,去除待匹配的问题中的语气词。
其中,语气词是指表示语气的虚词,常用在句尾或句中停顿处表示种种语气,常见的语气词有“啊”、“呢”、“吗”等。
步骤S12,将待匹配的问题中的标点符号进行统一。
具体地,可以将标点符号设置为“,”或者“/”,也就是说,将标点符号表示语气的作用去除,仅将其看作停顿的符号。
需要说明的是,由于步骤S13中需要生成待匹配的问题的多个相似问题,考虑到不同用户对语气词和标点符号的使用习惯不同,并且语气词和标点符号对于问题的实质内容没有影响,因此可以先将语气词去除,将标点符号统一转化为用于停顿的符号,以便于后续处理。
步骤S13,对待匹配的问题进行同义词替换,以生成待匹配的问题的多个相似问题。
步骤S14,使用字典树分别对每个相似问题进行匹配。
可以理解,为了让待匹配的问题能够与字典树中存储的常问问题进行匹配,在生成字典树时,将常问问题的语气词去除,标点符号进行统一处理。在使用字典树时,对待匹配的问题进行同样的操作,以提升待匹配的问题与常问问题匹配成功的可能性。
此外,考虑到自然语言中对待匹配的问题的表述方式有多种,但实质内容相同,若字典树中预先存储了这些表述方式中的任意一种,即可使用字典树完成对待匹配的问题的匹配。因此,可以对待匹配的问题进行同义词替换,来生成与待匹配的问题的表述方式不同的多个相似问题。使用字典树对多个相似问题进行匹配,若任意一个相似问题匹配成功,则可认为待匹配的问题匹配成功。
在本申请实施例所提供的电子设备中,需要使用训练完的基于问题对的语义相似度计算模型,对待匹配的问题与候选模型进行匹配。为了对该基于问题对的语义相似度计算模型进行训练,一种可能的实现方式是,在对基于问题对的语义相似度计算模型进行训练时,电子设备执行以下步骤:
步骤S201,获取参考问题对,以及参考问题对对应的参考语义相似度。
其中,参考问题对包括第一参考问题和第二参考问题。
参考问题对和参考语义相似度是指用于训练基于问题对的语义相似度计算模型的训练样例。
基于前述对深度学习句子对模型技术的说明,可以知道,参考问题对和参考语义相似度形成了训练样例中的三元组,可以将参考问题对包括的第一参考问题作为源句,第二参考问题作为目标句,那么参考语义相似度就是源句和目标句之间的关系。
需要特别说明的是,本申请实施例中使用常问问题列表中的数据作为参考问题对和参考语义相似度。但是,可能会出现训练样例不平衡的情况。具体来说,若两个问题的答案相同,则这两个问题形成的问题对可以作为训练正例,将参考语义相似度设置的较高,比如设为1。若两个问题的答案不同,则这两个问题形成的问题对可以作为训练反例,将参考语音相似度设置的较低,比如设为0。可以理解,常问问题列表中能够形成的训练正例数量远小于训练反例的数量,从而使得训练正例对模型训练的影响太小。
为了平衡训练正例和训练反例对模型训练的影响,本申请实施例提出了一种可能的实现方式,该方法包括:
步骤S21,对常问问题列表进行数据清洗。
具体来说,在常问问题列表中,存在着问题相似并且对应答案相似的数据,可以将问题和对应答案进行合并,还存在问题相同但对应答案不同的数据,可以将答案进行解绑。此外,还可以将常问问题列表中的英文问题进行删除。
步骤S22,确定每个答案对应的多个问题。
步骤S23,根据每个答案对应的多个问题,生成训练正例。
基于前述说明,可以知道,常问问题列表中能够形成的训练正例数量远小于训练反例的数量,因此需要优先形成训练正例。
训练正例的特点在于两个问题的答案相同,因此可以根据答案对应的多个问题,从中生成训练正例。
此外,考虑到不同答案对应的问题数量不同,可以预先设置每个答案对应的训练正例数量相近。
步骤S24,根据不同答案对应的问题,生成训练反例。
应当理解,为了减少反例对模型训练的影响,对于训练反例的生成采用更加精细化的策略。
具体来说,对于不同答案,可能对应有说法相似的问题,为了让训练后的模型能够对说法相似的问题进行区分,需要尽可能将这种情况作为训练反例。
其次,对于训练反例的数量需要进行控制,使其与训练正例的数量相近。
为了避免同一个问题在不同的训练反例中出现,需要在训练反例的选取过程中对已经选取的问题进行标记。
通过上述训练样例的生成方法,能够从常问问题列表中较为实用的参考问题对和参考语义相似度。
在实际使用中,可以将上述生成的训练样例中的一部分作为开发数据集,一部分作为训练数据集。比如可以将10%的训练样例用于开发,90%的训练样例用于训练,本申请实施例对此不做限定。
步骤S202,分别对第一参考问题和第二参考问题进行分词处理,以生成第一参考问题对应的第一参考词语集合,和第二参考问题对应的第二参考词语集合。
步骤S203,确定第一参考词语集合和第二参考词语集合中每个参考词语对应的词性,以生成第一参考词语集合对应的第一参考词性集合,和第二参考词语集合对应的第二参考词性集合。
步骤S204,确定第一参考词语集合和第二参考词语集合中每个参考词语对应的同义词,以生成第一参考词语集合对应的第一参考同义词集合,和第二参考词语集合对 应的第二参考同义词集合。
步骤S205,将第一参考词语集合,第二参考词语集合,第一参考词性集合,第二参考词性集合,第一参考同义词集合和第二参考同义词集合输入基于问题对的语义相似度计算模型的编码层。
基于前述对基于问题对的语义相似度计算模型的说明可以知道,输入层输入的词语信息包括词语集合,词性集合以及同义词集合。相应地,在模型训练过程中,输入层需要对输入的参考问题对中的第一参考问题和第二参考问题分别进行分词、词性识别、同义词识别处理。
需要说明的是,输入的第一参考问题和第二参考问题,经过输入层的处理后,得到第一参考问题对应的第一参考词语集合,第一参考词性集合和第一同义词集合,第二参考问题对应的第二参考词语集合,第二参考词性集合和第二参考同义词集合。
步骤S206,根据基于问题对的语义相似度计算模型的输出和参考语义相似度,对基于问题对的语义相似度计算模型的参数进行训练。
需要说明的是,基于前述说明可以知道,输入层的作用是将问题对中的问题转化为适合模型处理的词语集合、词性集合和同义词集合。因此在模型训练过程中,输入层的参数保持不变。
对于模型参数的训练,主要是针对编码层,局部交互层,聚合层和输出层中的参数进行训练。
步骤S207,在基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对基于问题对的语义相似度计算模型的训练。
当语义相似度计算模型的准确度大于预设阈值时,说明训练后的模型能够用于满足实际需求,即可得到训练完的基于问题对的语义相似度计算模型。
从而,实现了对基于问题对的语义相似度计算模型的训练。
为了实现上述实施例,本申请实施例还提出了一种电子设备,图17为本申请实施例所提出的电子设备的示意图。如图17所示,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,执行以下步骤:
步骤S301,获取待回复的问题。
其中,待回复的问题即为问答系统中用户通过人机交互界面提出的问题,需要机器做出回复。
步骤S302,使用如前述的问题的匹配方法,确定与待回复的问题相匹配的候选问题。
在基于常问问题列表的问答系统中,可以采用前述的问题的匹配方法,从预先存储的常问问题中,确定与用户提出的问题语义相同的常问问题作为候选问题。
步骤S303,使用候选问题对应的候选答案进行回复。
可以理解,由于候选问题与用户提出的问题语义相同,因此对应的答案也相同,可以使用候选问题对应的候选答案进行回复。
从而,实现了通过问题匹配的方式,将预先存储的常问问题的答案,作为用户提出的问题的答案,进行回复。
为了实现上述实施例,本申请实施例还提出了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行前述实施例中的问题的匹配方法。
为了实现上述实施例,本申请实施例还提出了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行前述实施例中的问题的回复方法。
本申请实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示单独存在A、同时存在A和B、单独存在B的情况。其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项”及其类似表达,是指的这些项中的任意组合,包括单项或复数项的任意组合。例如,a,b和c中的至少一项可以表示:a,b,c,a和b,a和c,b和c或a和b和c,其中a,b,c可以是单个,也可以是多个。
本领域普通技术人员可以意识到,本文中公开的实施例中描述的各单元及算法步骤,能够以电子硬件、计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,任一功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory;以下简称:ROM)、随机存取存储器(Random Access Memory;以下简称:RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。 本申请的保护范围应以所述权利要求的保护范围为准。

Claims (27)

  1. 一种问题的匹配方法,其特征在于,包括:
    获取待匹配的问题;
    使用字典树对所述待匹配的问题进行匹配;
    若匹配失败,从预设问题库中检索与所述待匹配的问题相似的多个候选问题;
    使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配;
    其中,所述基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,所述输入层用于输入所述问题对的词语信息,所述编码层用于对所述问题对中的问题进行语义分析,确定所述问题包括的每个词语的重要度和学习所述问题的结构特征,所述局部交互层用于对所述问题对中的两个所述问题进行语义相关度分析,所述聚合层用于对所述局部交互层的输出进行特征提取与聚合,所述输出层用于计算所述问题对的语义相似度。
  2. 根据权利要求1所述的方法,其特征在于,在所述获取待匹配的问题之前,还包括:
    对所述字典树和所述预设问题库,以及对应的索引库进行更新。
  3. 根据权利要求1所述的方法,其特征在于,所述使用字典树对所述待匹配的问题进行匹配,包括:
    去除所述待匹配的问题中的语气词;
    将所述待匹配的问题中的标点符号进行统一;
    对所述待匹配的问题进行同义词替换,以生成所述待匹配的问题的多个相似问题;
    使用所述字典树分别对每个所述相似问题进行匹配。
  4. 根据权利要求1所述的方法,其特征在于,所述使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配,包括:
    将每个所述候选问题分别与所述待匹配的问题组成问题对;
    将所述问题对输入所述基于问题对的语义相似度计算模型;
    根据每个所述问题对对应的语义相似度,对所述待匹配的问题与所述候选问题进行匹配。
  5. 根据权利要求1-4中任一项所述的方法,其特征在于,所述基于问题对的语义相似度计算模型通过以下步骤进行训练:
    获取参考问题对,以及所述参考问题对对应的参考语义相似度;其中,所述参考问题对包括第一参考问题和第二参考问题;
    分别对所述第一参考问题和所述第二参考问题进行分词处理,以生成所述第一参考问题对应的第一参考词语集合,和所述第二参考问题对应的第二参考词语集合;
    确定所述第一参考词语集合和所述第二参考词语集合中每个参考词语对应的词性,以生成所述第一参考词语集合对应的第一参考词性集合,和所述第二参考词语集合对应的第二参考词性集合;
    确定所述第一参考词语集合和所述第二参考词语集合中每个所述参考词语对应的同义词,以生成所述第一参考词语集合对应的第一参考同义词集合,和所述第二参考 词语集合对应的第二参考同义词集合;
    将所述第一参考词语集合,所述第二参考词语集合,所述第一参考词性集合,所述第二参考词性集合,所述第一参考同义词集合和所述第二参考同义词集合输入所述基于问题对的语义相似度计算模型的所述编码层;
    根据所述基于问题对的语义相似度计算模型的所述输出层的输出和所述参考语义相似度,对所述基于问题对的语义相似度计算模型的参数进行训练;
    在所述基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对所述基于问题对的语义相似度计算模型的训练。
  6. 根据权利要求1-4中任一项所述的方法,其特征在于,所述编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
  7. 根据权利要求1-4中任一项所述的方法,其特征在于,所述局部交互层包括双向多角度相似度分析层和第二归一化层。
  8. 一种问题的回复方法,其特征在于,包括:
    获取待回复的问题;
    使用如权利要求1-7中任一项所述的问题的匹配方法,确定与所述待回复的问题相匹配的候选问题;
    使用所述候选问题对应的候选答案进行回复。
  9. 一种问题的匹配装置,其特征在于,包括:
    第一获取模块,用于获取待匹配的问题;
    第一匹配模块,用于使用字典树对所述待匹配的问题进行匹配;
    检索模块,用于当所述第一匹配模块匹配失败时,从预设问题库中检索与所述待匹配的问题相似的多个候选问题;
    第二匹配模块,用于使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配;
    其中,所述基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,所述输入层用于输入所述问题对的词语信息,所述编码层用于对所述问题对中的问题进行语义分析,确定所述问题包括的每个词语的重要度和学习所述问题的结构特征,所述局部交互层用于对所述问题对中的两个所述问题进行语义相关度分析,所述聚合层用于对所述局部交互层的输出进行特征提取与聚合,所述输出层用于计算所述问题对的语义相似度。
  10. 根据权利要求9所述的装置,其特征在于,所述装置还包括:
    更新模块,用于对所述字典树和所述预设问题库,以及对应的索引库进行更新。
  11. 根据权利要求9所述的装置,其特征在于,所述第一匹配模块,包括:
    去除子模块,用于去除所述待匹配的问题中的语气词;
    统一子模块,用于将所述待匹配的问题中的标点符号进行统一;
    替换子模块,用于对所述待匹配的问题进行同义词替换,以生成所述待匹配的问题的多个相似问题;
    第一匹配子模块,用于使用所述字典树分别对每个所述相似问题进行匹配。
  12. 根据权利要求9所述的装置,其特征在于,所述第二匹配模块,包括:
    组对子模块,用于将每个所述候选问题分别与所述待匹配的问题组成问题对;
    输入子模块,用于将所述问题对输入所述基于问题对的语义相似度计算模型;
    第二匹配子模块,用于根据每个所述问题对对应的语义相似度,对所述待匹配的问题与所述候选问题进行匹配。
  13. 根据权利要求9-12任一项所述的装置,其特征在于,所述装置还包括:
    第二获取模块,用于获取参考问题对,以及所述参考问题对对应的参考语义相似度;其中,所述参考问题对包括第一参考问题和第二参考问题;
    处理模块,用于分别对所述第一参考问题和所述第二参考问题进行分词处理,以生成所述第一参考问题对应的第一参考词语集合,和所述第二参考问题对应的第二参考词语集合;
    第一确定模块,用于确定所述第一参考词语集合和所述第二参考词语集合中每个参考词语对应的词性,以生成所述第一参考词语集合对应的第一参考词性集合,和所述第二参考词语集合对应的第二参考词性集合;
    第二确定模块,用于确定所述第一参考词语集合和所述第二参考词语集合中每个所述参考词语对应的同义词,以生成所述第一参考词语集合对应的第一参考同义词集合,和所述第二参考词语集合对应的第二参考同义词集合;
    输入模块,用于将所述第一参考词语集合,所述第二参考词语集合,所述第一参考词性集合,所述第二参考词性集合,所述第一参考同义词集合和所述第二参考同义词集合输入所述基于问题对的语义相似度计算模型的所述编码层;
    训练模块,用于根据所述基于问题对的语义相似度计算模型的所述输出层的输出和所述参考语义相似度,对所述基于问题对的语义相似度计算模型的参数进行训练;
    完成模块,用于在所述基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对所述基于问题对的语义相似度计算模型的训练。
  14. 根据权利要求9-12中任一项所述的装置,其特征在于,所述编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
  15. 根据权利要求9-12中任一项所述的装置,其特征在于,所述局部交互层包括双向多角度相似度分析层和第二归一化层。
  16. 一种问题的回复装置,其特征在于,所述装置包括:
    第三获取模块,用于获取待回复的问题;
    第三确定模块,用于使用如权利要求1-7中任一项所述的问题的匹配方法,确定与所述待回复的问题相匹配的候选问题;
    回复模块,用于使用所述候选问题对应的候选答案进行回复。
  17. 一种问答系统,其特征在于,所述系统包括:
    问答界面,用于接收用户的输入内容,并将生成的回复内容进行展示;
    分发代理,用于根据所述用户的输入内容的类型,将所述用户的输入内容分发给对应的回复装置;
    如权利要求16所述的问题的回复装置,用于接收所述分发代理发送的待回复的问题,并从预设问题库中确定对应的答案。
  18. 一种电子设备,其特征在于,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,执行以下步骤:
    获取待匹配的问题;
    使用字典树对所述待匹配的问题进行匹配;
    若匹配失败,从预设问题库中检索与所述待匹配的问题相似的多个候选问题;
    使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配;
    其中,所述基于问题对的语义相似度计算模型包括输入层,编码层,局部交互层,聚合层和输出层,所述输入层用于输入所述问题对的词语信息,所述编码层用于对所述问题对中的问题进行语义分析,确定所述问题包括的每个词语的重要度和学习所述问题的结构特征,所述局部交互层用于对所述问题对中的两个所述问题进行语义相关度分析,所述聚合层用于对所述局部交互层的输出进行特征提取与聚合,所述输出层用于计算所述问题对的语义相似度。
  19. 如权利要求18所述的电子设备,其特征在于,在所述电子设备获取待匹配的问题之前,还执行以下步骤:
    对所述字典树和所述预设问题库,以及对应的索引库进行更新。
  20. 如权利要求18所述的电子设备,其特征在于,所述电子设备使用字典树对所述待匹配的问题进行匹配,具体包括以下步骤:
    去除所述待匹配的问题中的语气词;
    将所述待匹配的问题中的标点符号进行统一;
    对所述待匹配的问题进行同义词替换,以生成所述待匹配的问题的多个相似问题;
    使用所述字典树分别对每个所述相似问题进行匹配。
  21. 如权利要求18所述的电子设备,其特征在于,所述电子设备使用训练完的基于问题对的语义相似度计算模型,对所述待匹配的问题与所述候选问题进行匹配,具体包括以下步骤:
    将每个所述候选问题分别与所述待匹配的问题组成问题对;
    将所述问题对输入所述基于问题对的语义相似度计算模型;
    根据每个所述问题对对应的语义相似度,对所述待匹配的问题与所述候选问题进行匹配。
  22. 如权利要求18-21中任一项所述电子设备,其特征在于,在对所述基于问题对的语义相似度计算模型进行训练时,所述电子设备执行以下步骤:
    获取参考问题对,以及所述参考问题对对应的参考语义相似度;其中,所述参考问题对包括第一参考问题和第二参考问题;
    分别对所述第一参考问题和所述第二参考问题进行分词处理,以生成所述第一参 考问题对应的第一参考词语集合,和所述第二参考问题对应的第二参考词语集合;
    确定所述第一参考词语集合和所述第二参考词语集合中每个参考词语对应的词性,以生成所述第一参考词语集合对应的第一参考词性集合,和所述第二参考词语集合对应的第二参考词性集合;
    确定所述第一参考词语集合和所述第二参考词语集合中每个所述参考词语对应的同义词,以生成所述第一参考词语集合对应的第一参考同义词集合,和所述第二参考词语集合对应的第二参考同义词集合;
    将所述第一参考词语集合,所述第二参考词语集合,所述第一参考词性集合,所述第二参考词性集合,所述第一参考同义词集合和所述第二参考同义词集合输入所述基于问题对的语义相似度计算模型的所述编码层;
    根据所述基于问题对的语义相似度计算模型的所述输出层的输出和所述参考语义相似度,对所述基于问题对的语义相似度计算模型的参数进行训练;
    在所述基于问题对的语义相似度计算模型的准确度大于预设阈值时,完成对所述基于问题对的语义相似度计算模型的训练。
  23. 如权利要求18-21中任一项所述的电子设备,其特征在于,所述编码层包括双向循环神经网络层,第一归一化层和堆叠的双向自注意力层。
  24. 如权利要求18-21中任一项所述的电子设备,其特征在于,所述局部交互层包括双向多角度相似度分析层和第二归一化层。
  25. 一种电子设备,其特征在于,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时,执行以下步骤:
    获取待回复的问题;
    使用如权利要求1-7中任一项所述的问题的匹配方法,确定与所述待回复的问题相匹配的候选问题;
    使用所述候选问题对应的候选答案进行回复。
  26. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如权利要求1-7任一项所述的问题的匹配方法。
  27. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机执行如权利要求8所述的问题的回复方法。
PCT/CN2020/128016 2019-11-14 2020-11-11 问题的匹配方法及装置、问题的回复方法及装置 WO2021093755A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911115389.3A CN112800170A (zh) 2019-11-14 2019-11-14 问题的匹配方法及装置、问题的回复方法及装置
CN201911115389.3 2019-11-14

Publications (1)

Publication Number Publication Date
WO2021093755A1 true WO2021093755A1 (zh) 2021-05-20

Family

ID=75803851

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/128016 WO2021093755A1 (zh) 2019-11-14 2020-11-11 问题的匹配方法及装置、问题的回复方法及装置

Country Status (2)

Country Link
CN (1) CN112800170A (zh)
WO (1) WO2021093755A1 (zh)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026853A (zh) * 2019-12-02 2020-04-17 支付宝(杭州)信息技术有限公司 目标问题的确定方法、装置、服务器和客服机器人
CN113221531A (zh) * 2021-06-04 2021-08-06 西安邮电大学 一种多模型动态协同的语义匹配方法
CN113536807A (zh) * 2021-08-03 2021-10-22 中国航空综合技术研究所 基于语义的不完全最大匹配分词方法
CN113591474A (zh) * 2021-07-21 2021-11-02 西北工业大学 一种基于加权融合的Loc2vec模型的重复数据检测方法
CN113792153A (zh) * 2021-08-25 2021-12-14 北京百度网讯科技有限公司 问答推荐方法及其装置
CN113822034A (zh) * 2021-06-07 2021-12-21 腾讯科技(深圳)有限公司 一种复述文本的方法、装置、计算机设备及存储介质
CN114358023A (zh) * 2022-01-11 2022-04-15 平安科技(深圳)有限公司 智能问答召回方法、装置、计算机设备及存储介质
CN114697280A (zh) * 2022-03-01 2022-07-01 西安博纳吉生物科技有限公司 一种预设内容即时通信方法
CN114897183A (zh) * 2022-05-16 2022-08-12 北京百度网讯科技有限公司 问题数据处理方法、深度学习模型的训练方法和装置
CN115878924A (zh) * 2021-09-27 2023-03-31 小沃科技有限公司 一种基于双字典树数据处理方法、装置、介质及电子设备

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342842A (zh) * 2021-06-10 2021-09-03 南方电网数字电网研究院有限公司 基于计量知识的语义查询方法、装置和计算机设备
CN114090747A (zh) * 2021-10-14 2022-02-25 特斯联科技集团有限公司 基于多重语义匹配的自动问答方法、装置、设备及介质
CN115129424B (zh) * 2022-07-07 2023-05-12 江苏红网技术股份有限公司 一种数据资产管理平台及其方法
CN116910225B (zh) * 2023-09-13 2023-11-21 北京三五通联科技发展有限公司 一种基于云平台的主动应答方法及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050255438A1 (en) * 2004-05-13 2005-11-17 John Manos Worksheet wizard
CN101076184A (zh) * 2006-07-31 2007-11-21 腾讯科技(深圳)有限公司 一种实现自动应答的系统及方法
US20090175134A1 (en) * 2008-01-04 2009-07-09 Compal Communications, Inc. Alarm and managing method thereof
CN102368246A (zh) * 2011-09-15 2012-03-07 张德长 一种自动应答机器人系统
CN107092602A (zh) * 2016-02-18 2017-08-25 朗新科技股份有限公司 一种自动应答方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050255438A1 (en) * 2004-05-13 2005-11-17 John Manos Worksheet wizard
CN101076184A (zh) * 2006-07-31 2007-11-21 腾讯科技(深圳)有限公司 一种实现自动应答的系统及方法
US20090175134A1 (en) * 2008-01-04 2009-07-09 Compal Communications, Inc. Alarm and managing method thereof
CN102368246A (zh) * 2011-09-15 2012-03-07 张德长 一种自动应答机器人系统
CN107092602A (zh) * 2016-02-18 2017-08-25 朗新科技股份有限公司 一种自动应答方法及系统

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111026853A (zh) * 2019-12-02 2020-04-17 支付宝(杭州)信息技术有限公司 目标问题的确定方法、装置、服务器和客服机器人
CN113221531A (zh) * 2021-06-04 2021-08-06 西安邮电大学 一种多模型动态协同的语义匹配方法
CN113822034A (zh) * 2021-06-07 2021-12-21 腾讯科技(深圳)有限公司 一种复述文本的方法、装置、计算机设备及存储介质
CN113822034B (zh) * 2021-06-07 2024-04-19 腾讯科技(深圳)有限公司 一种复述文本的方法、装置、计算机设备及存储介质
CN113591474A (zh) * 2021-07-21 2021-11-02 西北工业大学 一种基于加权融合的Loc2vec模型的重复数据检测方法
CN113591474B (zh) * 2021-07-21 2024-04-05 西北工业大学 一种基于加权融合的Loc2vec模型的重复数据检测方法
CN113536807A (zh) * 2021-08-03 2021-10-22 中国航空综合技术研究所 基于语义的不完全最大匹配分词方法
CN113536807B (zh) * 2021-08-03 2023-05-05 中国航空综合技术研究所 基于语义的不完全最大匹配分词方法
CN113792153A (zh) * 2021-08-25 2021-12-14 北京百度网讯科技有限公司 问答推荐方法及其装置
CN113792153B (zh) * 2021-08-25 2023-12-12 北京度商软件技术有限公司 问答推荐方法及其装置
CN115878924B (zh) * 2021-09-27 2024-03-12 小沃科技有限公司 一种基于双字典树数据处理方法、装置、介质及电子设备
CN115878924A (zh) * 2021-09-27 2023-03-31 小沃科技有限公司 一种基于双字典树数据处理方法、装置、介质及电子设备
CN114358023B (zh) * 2022-01-11 2023-08-22 平安科技(深圳)有限公司 智能问答召回方法、装置、计算机设备及存储介质
CN114358023A (zh) * 2022-01-11 2022-04-15 平安科技(深圳)有限公司 智能问答召回方法、装置、计算机设备及存储介质
CN114697280A (zh) * 2022-03-01 2022-07-01 西安博纳吉生物科技有限公司 一种预设内容即时通信方法
CN114897183B (zh) * 2022-05-16 2023-06-13 北京百度网讯科技有限公司 问题数据处理方法、深度学习模型的训练方法和装置
CN114897183A (zh) * 2022-05-16 2022-08-12 北京百度网讯科技有限公司 问题数据处理方法、深度学习模型的训练方法和装置

Also Published As

Publication number Publication date
CN112800170A (zh) 2021-05-14

Similar Documents

Publication Publication Date Title
WO2021093755A1 (zh) 问题的匹配方法及装置、问题的回复方法及装置
US10586155B2 (en) Clarification of submitted questions in a question and answer system
US9720944B2 (en) Method for facet searching and search suggestions
US9373075B2 (en) Applying a genetic algorithm to compositional semantics sentiment analysis to improve performance and accelerate domain adaptation
US9239875B2 (en) Method for disambiguated features in unstructured text
CN112507715A (zh) 确定实体之间关联关系的方法、装置、设备和存储介质
CN111767716B (zh) 企业多级行业信息的确定方法、装置及计算机设备
KR101508260B1 (ko) 문서 특징을 반영하는 요약문 생성 장치 및 방법
CN112069298A (zh) 基于语义网和意图识别的人机交互方法、设备及介质
US9720962B2 (en) Answering superlative questions with a question and answer system
US9536444B2 (en) Evaluating expert opinions in a question and answer system
US20180341686A1 (en) System and method for data search based on top-to-bottom similarity analysis
US20170169355A1 (en) Ground Truth Improvement Via Machine Learned Similar Passage Detection
CN111090771B (zh) 歌曲搜索方法、装置及计算机存储介质
CN112115232A (zh) 一种数据纠错方法、装置及服务器
CN112131876A (zh) 一种基于相似度确定标准问题的方法及系统
CN109359302A (zh) 一种领域化词向量的优化方法及基于其的融合排序方法
CN115062621A (zh) 标签提取方法、装置、电子设备和存储介质
CN113486143A (zh) 一种基于多层级文本表示及模型融合的用户画像生成方法
CN116049376B (zh) 一种信创知识检索回复的方法、装置和系统
US20230274161A1 (en) Entity linking method, electronic device, and storage medium
US20160085760A1 (en) Method for in-loop human validation of disambiguated features
CN113779981A (zh) 一种基于指针网络和知识图谱的推荐方法及装置
CN114372148A (zh) 一种基于知识图谱技术的数据处理方法及终端设备
TWI842359B (zh) 問答系統及其操作方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20887116

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20887116

Country of ref document: EP

Kind code of ref document: A1