WO2020042925A1 - 人机对话方法、装置、电子设备及计算机可读介质 - Google Patents

人机对话方法、装置、电子设备及计算机可读介质 Download PDF

Info

Publication number
WO2020042925A1
WO2020042925A1 PCT/CN2019/101038 CN2019101038W WO2020042925A1 WO 2020042925 A1 WO2020042925 A1 WO 2020042925A1 CN 2019101038 W CN2019101038 W CN 2019101038W WO 2020042925 A1 WO2020042925 A1 WO 2020042925A1
Authority
WO
WIPO (PCT)
Prior art keywords
sentences
sentence
similarity
score
vector
Prior art date
Application number
PCT/CN2019/101038
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 WO2020042925A1 publication Critical patent/WO2020042925A1/zh
Priority to US17/013,705 priority Critical patent/US11775760B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • 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
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Definitions

  • the embodiments of the present application relate to the field of computer information processing, and in particular, to a human-machine dialogue method, device, electronic device, and computer-readable medium.
  • a chatbot is a program used to simulate human conversation or chat.
  • chatbots are widely used in various instant messaging platforms, learning and education platforms, and various information service platforms.
  • the chatbot can chat with the user based on the knowledge in the database.
  • the developer puts the answer of interest in the database.
  • chatbot finds the most appropriate answer from the database and responds to it.
  • Chat partner This simple conversational chat method has a narrower scope for users to obtain information and gradually withdraws from the market.
  • chatbots can use the words spoken by users as input to the model and the sentences output by the model as responses for human-computer interaction.
  • the embodiments of the present application provide a human-machine dialog method, device, electronic device, and computer-readable medium, which can enable a robot to generate an informative answer during a human-machine dialog, and assist a user to exchange views with external information.
  • An embodiment of the present application proposes a human-computer dialogue method executed by an electronic device.
  • the method includes: extracting keywords from user input information; determining candidate articles based on the keywords; obtaining multiple sentences in the candidate articles And determine the score of each of the plurality of sentences; and extracting a part of the sentences from the plurality of sentences to generate return information based on the score results.
  • An embodiment of the present application proposes a human-machine dialogue device, which includes: a keyword module for extracting keywords from user input information; an article module for determining candidate articles based on the keywords; a scoring module for For obtaining a plurality of sentences in the candidate article and determining a score of each of the plurality of sentences; and a return information module for extracting a part of the sentences from the plurality of sentences to generate return information based on the score results.
  • An embodiment of the present application provides an electronic device including: one or more processors; a storage device for storing one or more programs; and when one or more programs are executed by one or more processors, One or more processors are caused to implement the method described in any embodiment of the present application.
  • An embodiment of the present application proposes a computer-readable medium on which a computer program is stored.
  • the program is executed by a processor, the method described in any embodiment of the present application is implemented.
  • Fig. 1 is a system block diagram of a man-machine dialogue method and device according to an exemplary embodiment
  • Fig. 2 is an application scenario diagram of a human-machine dialog method according to an exemplary embodiment
  • Fig. 3 is an application scenario diagram of a human-machine dialogue method according to an exemplary embodiment
  • Fig. 4 is a flow chart showing a method for man-machine dialogue according to an exemplary embodiment
  • Fig. 5 is a flow chart showing a method for man-machine dialogue according to another exemplary embodiment
  • Fig. 6 is a flow chart showing a method for man-machine dialogue according to another exemplary embodiment
  • Fig. 7 is a flow chart showing a method for man-machine dialogue according to another exemplary embodiment
  • Fig. 8 is a block diagram of a human-machine dialog device according to an exemplary embodiment
  • Fig. 9 is a block diagram of a human-machine dialog device according to another exemplary embodiment.
  • Fig. 10 is a block diagram of an electronic device according to an exemplary embodiment
  • Fig. 11 is a schematic diagram of a computer-readable storage medium according to an exemplary embodiment.
  • first, second, third, etc. may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another. Accordingly, the first component discussed below may be referred to as the second component without departing from the teachings of the concepts of the present application. As used herein, the term "and / or” includes any combination of any one and one or more of the associated listed items.
  • the content of the robot response is relatively empty, does not have the amount of information, and has no extension of the actual content.
  • the actual user experience is average, which is limited in practical applications.
  • the techniques commonly used for chatting by chatbots include a sequence-to-sequence neural network model (seq2seq) generative method.
  • the seq2seq neural network model is an end-to-end model that can process sequences. This model takes one sequence as input and another sequence as output. It is often used in the field of machine translation and dialogue.
  • the generative method based on the seq2seq neural network model first train the seq2seq model on a large amount of dialogue training data, and then when the user chats with the chatbot, directly take what the user said as the input to the model, and then use the output of the model as For user responses.
  • the disadvantage of using the generative method based on the seq2seq model is that a large amount of dialogue training data is required to train the seq2seq model. Because of the wide range and large amount of data, the training data of the seq2seq neural network model is difficult to obtain in actual life.
  • the chatbot using the seq2seq model generative method when chatting, has empty answers to users, does not have the amount of information, has no actual content, and is limited in practical applications. For example, when the user wants to know the external information or communicate with the chatbot about some events or opinions, this method can only simply reply or avoid the user's question, and cannot answer the user's question directly, let alone other informative information. Constructive perspective.
  • the embodiment of the present application proposes a human-machine dialogue method, in order to extract key sentences from related articles as a reply according to a user's question, so as to achieve the purpose of information, opinion, or opinion exchange.
  • Fig. 1 is a system block diagram of a human-machine dialogue method and device according to an exemplary embodiment.
  • the system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105.
  • the network 104 is used as a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105.
  • the network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, and so on.
  • the user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and the like.
  • Various communication client applications can be installed on the terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, and so on.
  • the terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, smart speakers, tablet computers, laptop computers and desktop computers, and so on.
  • the server 105 may be a server that provides various services, for example, a server that provides background data support for a chat robot called by a user using the terminal devices 101, 102, and 103.
  • the server supported by the background data can analyze and process the received user's question, and feed back the processing results (such as returning information and returning voice, etc.) to the terminal device.
  • the terminal devices 101, 102, 103 can extract keywords from the user's voice input information; the terminal devices 101, 102, 103 can also extract keywords from the user's text input information.
  • the terminal devices 101, 102, 103 can extract keywords from the user's input information; the terminal devices 101, 102, 103 can determine candidate articles based on the keywords; the terminal devices 101, 102, 103 can obtain the candidate articles in the candidate articles Multiple sentences, and determine the score of each of the multiple sentences; the terminal device 101, 102, 103 may extract part of the sentences from the multiple sentences based on the score results to generate return information.
  • the terminal devices 101, 102, 103 can forward the user's input information to the server 105 for processing; the server 105 can extract keywords from the user's input information; the server 105 can determine candidate articles based on the keywords; the server 105 can obtain Multiple sentences in the candidate article, and determine a score for each of the multiple sentences; the server 105 may extract a part of the sentences from the multiple sentences to generate return information based on the score results; the server 105 may convert the The return information is sent to the terminal devices 101, 102, 103 in response to the user's input information.
  • the human-machine dialog method provided in the embodiment of the present application may be executed by the server 105 and / or the terminal devices 101, 102, and 103. Accordingly, the human-machine dialog device may be set on the server 105 and / or the terminal device 101 , 102, 103.
  • the requesting end provided to the user for information input is generally located in the terminal devices 101, 102, and 103.
  • the human-machine dialogue method and device can be applied to chat robot related products, such as smart speakers, chat robots in instant messaging software, etc., and are mainly applied in scenarios where users chat with chat robots.
  • the human-machine dialogue method and device in the embodiments of the present application can implement functions such as news summary broadcasting and opinion exchange.
  • understanding news is a common requirement of users.
  • it will take a long time to broadcast the complete news, making the user impatient and reducing the user experience.
  • it is necessary to broadcast the news summary.
  • the news summary For example, when a user wants to know the recent hot news, he can say "I want to listen to the latest hot news” or "Are there any hot news recently" to the chat robot?
  • the device will retrieve several hot news articles from the recent public account articles, and extract a few key sentences in the article as a summary and broadcast it to the user.
  • the user wants to know specific aspects such as the news of the Sino-US trade war, he can say to the chat robot "What is the situation in the Sino-US trade war now".
  • the human-machine dialogue method and device of the embodiment of this application will retrieve the Key sentences are extracted from the most relevant news in this aspect, and a summary reply is formed to the user.
  • Fig. 2 is an application scenario diagram of a human-machine dialog method according to an exemplary embodiment.
  • a user can have a conversation with a chat robot in an instant chat window or on an information interaction platform.
  • the user can input questions through text.
  • the chatbot processes the user's questions, it returns text messages and / or voice messages as responses to user questions.
  • the human-machine dialogue method and device in the embodiments of the present application search according to the information asked by the user. Relevant articles then form a return message to reply to the user, and the user can obtain the latest college entrance examination policy and college entrance examination score from the return information.
  • the human-machine dialogue method and device in the embodiments of the present application can enable a chat robot to directly answer like a real person, instead of simply replying to a similar sentence such as "good” or avoiding a user's question.
  • the human-machine dialogue method and device in the embodiments of the present application can extract the review articles for the college entrance examination from a large number of hot articles, extract key review sentences from them, and then organize the key review sentences into reply messages to The idea to be expressed as a robot.
  • Fig. 3 is an application scenario diagram of a human-machine dialog method according to an exemplary embodiment.
  • the user can talk with the chat robot through a voice input terminal, and the voice input terminal can be a smart speaker or a smart robot.
  • the user can ask questions by voice.
  • the chat robot first converts the user's voice question into text information, and then performs data processing, and then returns text and / or voice information as a response to the user's question.
  • the human-machine dialogue method and device in the embodiments of the present application can extract key comment sentences in related articles in the movie information platform, and then return information based on these sentences to reply to the user. .
  • the user can get the movie introduction or evaluation content from the returned information, instead of simply replying to "good-looking" and other similar answers like the seq2seq model-based generative method.
  • the human-machine dialogue method and device in the embodiments of the present application can extract key sentences from relevant articles as their own responses based on the user's questions, thereby realizing the exchange of user opinions with external information, opinions or opinions.
  • Fig. 4 is a flow chart showing a method for man-machine dialogue according to an exemplary embodiment. This method may be executed by an electronic device such as a server or a terminal device.
  • the human-machine dialogue method 40 includes at least steps S402 to S408.
  • keywords are extracted from the user's input information. Keywords can be extracted from the user's voice input information; or keywords can be extracted from the user's text input information.
  • extracting keywords from the user's text input information may specifically include: performing word segmentation processing on the input information to obtain multiple vocabularies; determining a vocabulary vector (also referred to as a word vector) of the multiple vocabulary Determining the similarity between multiple vocabularies based on the cosine similarity and the vocabulary vector; determining the importance of multiple vocabularies according to the similarity; and determining the keywords according to the importance ranking.
  • the number of keywords may be one or more, which is not limited in the embodiment of the present application. The related content of the keyword extraction will be described in detail in the embodiment of FIG. 5 later.
  • keywords are extracted from the user's voice input information, and specifically, the user's voice input audio information can be received through a smart speaker, a smart robot, or other audio device with a sound receiving function. After the audio data is obtained, audio recognition is performed on the user's audio information, and then keywords in the user input information are obtained.
  • the user's audio information can also be converted into text information through audio recognition, and then the keywords in the text information are extracted according to the method in the previous embodiment.
  • a candidate article is determined according to the keywords.
  • a search may be performed in a predetermined platform according to the keywords to determine the candidate article. For example, you can retrieve several hot news articles related to keywords in recent public account articles; you can also search for keywords in mainstream search engines, sort them according to the retrieved results, and sort from highest to lowest The candidate article is determined in the search results.
  • the number of candidate articles may be one or more, which is not limited in the embodiment of the present application.
  • step S406 a plurality of sentences in the candidate article are acquired, and a score of each sentence in the plurality of sentences is determined.
  • the method may include: determining a first score according to the importance of each sentence in the plurality of sentences in the article; and determining the similarity (similarity) between each sentence in the plurality of sentences and the input information.
  • a second score; a score is determined according to the first score and the second score.
  • the first score is determined according to the importance of each sentence in the multiple sentences in the article, and the importance of the sentence can be obtained by a text ranking algorithm, which specifically includes: determining the multiple Determine a sentence vector of each sentence in the sentence; determine the similarity between the sentence vectors of the plurality of sentences; and obtain the importance of each sentence in the article based on the similarity to determine the first score.
  • the text sorting algorithm may be TextRank in Automatic Summarization.
  • TextRank divides the candidate article into several constituent units (words, sentences) and builds a graph model. It uses the voting mechanism to sort the important components in the candidate article, so that it can use only the information of the candidate article itself to rank each sentence in the document. Severity. The content related to determining the importance of a sentence in an article by the TextRank algorithm will be described in detail in the embodiment of FIG. 7 later.
  • the TextRank score only reflects the semantic importance of the corresponding sentence in the article, it does not need to consider the relevance to the user's question, so the sentence cannot be extracted directly based on the importance.
  • the weighted average of the word vectors of the keywords in the question can be used as the vector for the user's question, and the cosine similarity between each sentence vector and the vector is used as the similarity between each sentence and the user's question to determine the second score.
  • determining the second score according to the similarity of each sentence in the plurality of sentences with the input information includes: determining an information vector of user input information; determining each sentence in the plurality of sentences Determine the similarity between the information vector and the sentence vector of each sentence by the cosine similarity; and determine the second score by the similarity of each sentence in the plurality of sentences.
  • the specific steps of calculating the similarity between the sentence in the candidate article and the input information are similar to the process in FIG. 7; the user input information is also used as the sentence, and the similarity between the sentence in the candidate article and the sentence is shown in FIG. 7
  • the sex comparison may be replaced by the similarity comparison between the user input information and the sentence, which is not repeated in the embodiment of the present application.
  • a score is determined according to the first score and the second score.
  • the weighted sum of the importance and similarity of each sentence in the candidate article can be used as the final score of the sentence and ranked.
  • the first score is A and the second score is B.
  • the final score C of the sentence can be expressed as:
  • q is a weight coefficient
  • the value range of q is q ⁇ [0,1].
  • the total score C can be determined by the first score A or the second score B.
  • step S408 a part of sentences is extracted from the plurality of sentences based on the scoring result to generate return information.
  • the plurality of sentences may be sorted according to a scoring result; and a partial sentence is sequentially extracted from the plurality of sentences to generate the return information.
  • sequentially extracting partial sentences from the plurality of sentences to generate the return information includes: performing post-processing on the partial sentences to generate the return information.
  • the sentences of the candidate articles can be ranked and ranked (first and second scores).
  • the highest-scoring sentences are preferably organized into replies, and natural language processing is performed, such as referring to dissolution, deconjunction of the first sentence of the abstract, etc.
  • Generate text results that are easy for users to read and understand, and then return the text results to the user.
  • Referential resolution is an important part of natural language processing, which is the question of determining which noun phrase the pronoun points to in the text.
  • the reference resolution firstly constructs a first candidate record, and then selects multiple choices from the candidates.
  • the method of referential resolution includes: syntactic-based referential resolution, and corpus-based methods, as well as statistical methods, statistical machine learning methods, and so on.
  • a method of generating return information with substantial content and information content can be used to make the robot in the process of human-machine dialogue. Generate informative answers to assist users in communicating ideas with outside information.
  • the human-machine dialogue method of the embodiment of the present application first retrieves and extracts several candidate articles related to the user's question, and uses a text sorting algorithm to calculate each The importance of the sentence, and then comprehensively consider the relevance of each sentence to the user's question to generate the final score and ranking of each sentence in the candidate article, and finally extract several key sentences from the candidate article according to the score to organize the summary and return it to the user as the answer.
  • the human-machine dialogue method in the embodiment of the present application can extract key sentences in related articles so that the reply content of the chat robot contains certain information and is not empty.
  • the human-computer dialogue method of the embodiment of the present application when generating the returned information, the importance of the extracted sentence in the candidate article and the correlation between the extracted sentence and the user's question are comprehensively considered, and it can obtain information that is close to the user's question and has information. The amount of information returned.
  • the method further includes: acquiring the vocabulary vector (word vector) by training text data through a word vector training algorithm.
  • word vector word embedding
  • NLP natural language processing
  • the role of the word vector is to translate words in natural language. A dense vector that the computer can understand.
  • Word2vec and GloVe Global Vectors for Word Representation
  • the word2vec model can train a large number of corpora, and can make the word vector dimensions lower, can capture the similarity between words, and use algebraic operations on words to calculate similar words.
  • the GloVe model is a word vector training model proposed after the word2vec model. Based on the word2vec model, the GloVe model proposes the idea of constructing word vectors based on some statistical information in the corpus. That is, if a vocabulary is associated with which contextual vocabulary, then the meaning of this vocabulary with this contextual vocabulary is greater than that of other vocabulary. Association between two words.
  • news data or article data in the public network may be trained by the GloVe algorithm to obtain word vectors of words used in the embodiments of the present application.
  • the word vectors of the vocabulary used in the embodiments of the present application may also be obtained through other word vector construction algorithms, which is not limited in the embodiments of the present application.
  • Fig. 5 is a flow chart showing a method for man-machine dialogue according to another exemplary embodiment.
  • the human-machine dialogue method 50 shown in FIG. 5 is a detailed description of step S402 “Extracting keywords from user input information” in the human-machine dialogue method 40 shown in FIG. 4.
  • step S502 word segmentation processing is performed on the input information to obtain multiple words.
  • the information input by the user may be in the form of audio or text.
  • the audio information may be converted into text first, and then the word segmentation processing in this embodiment is performed.
  • the word segmentation processing may be Chinese word segmentation processing on Chinese characters.
  • Chinese Word Segmentation refers to segmenting a sequence of Chinese characters into individual words. Word segmentation is the process of recombining consecutive word sequences into word sequences in accordance with certain specifications.
  • Existing word segmentation algorithms can be divided into three categories: word segmentation methods based on string matching, word segmentation methods based on understanding, and word segmentation methods based on statistics. According to whether it is combined with the part-of-speech tagging process, it can be divided into a simple word segmentation method and an integrated method combining word segmentation and labeling.
  • the word segmentation method based on string matching is to match the Chinese character string to be analyzed with the entry in a "sufficiently large" machine dictionary according to a certain strategy. If a certain string is found in the dictionary , The match is successful (a word is recognized).
  • the word segmentation method based on understanding is to let a computer simulate human understanding of a sentence to achieve the effect of identifying words. The basic idea is to perform syntactic and semantic analysis while segmenting words, and use syntactic and semantic information to handle ambiguity.
  • the word segmentation method based on statistics is to count the frequency of combinations of adjacent co-occurring words in the corpus and calculate their mutual occurrence information.
  • the user input information may also be processed by the word segmentation processing method corresponding to other languages, and the specific method of word segmentation processing does not affect the processing steps of the subsequent embodiments of this application.
  • the input information in the embodiment of the present application may be processed by one or more of the foregoing multiple word segmentation methods, and the embodiment of the present application is not limited thereto.
  • step S504 a vocabulary vector of a plurality of vocabularies is determined.
  • the news data or article data in the public network can be trained by the GloVe algorithm to obtain the word vectors of the vocabulary used in the embodiments of the present application.
  • the word vectors obtained through training are word vector labeling for the words obtained after the above word segmentation processing to generate a word vector set.
  • step S506 the similarity between the plurality of words is determined by the cosine similarity and the vocabulary vector.
  • the cosine similarity between word vectors can be used as the similarity between corresponding words.
  • Cosine similarity is calculated by calculating the cosine of the angle between two vectors to evaluate their similarity.
  • multiple words can be sorted and numbered according to the order in which the words appear in the article.
  • the first vocabulary vector can be used as the starting vocabulary vector, and the similarity between the first vocabulary vector and other vocabulary vectors can be compared . After traversing all the vocabulary vectors multiple times and comparing the vocabulary vectors one by one, the similarity between them is determined.
  • two lexical vectors are respectively drawn into a vector space according to their coordinate values, such as the most common two-dimensional space.
  • the angle between them is calculated and the cosine value corresponding to the angle is obtained.
  • This cosine value can be used to characterize the similarity of the two vectors. For example, the smaller the angle between two vocabulary vectors, the closer the cosine value between them is to 1, the more similar the two vocabulary vectors are.
  • step S508 the importance of a plurality of words is determined according to the similarity.
  • the importance of each word can be calculated using the TextRank algorithm.
  • TextRank algorithm uses the relationship between local words (co-occurrence window) to sort subsequent keywords and extracts directly from the text itself. The main steps can be as follows:
  • the weights of the edges between the nodes are set to the similarity between the vocabulary vectors, and the weights of each node are propagated through iteration until convergence.
  • steps and methods please refer to FIG. 7 and the embodiments corresponding to FIG. 7, which are not described in the embodiment of this application.
  • the keywords are determined according to the importance ranking.
  • One or more vocabulary vectors can be selected according to importance from high to low, and the vocabulary corresponding to these vocabulary vectors is used as the keyword in this embodiment.
  • the original N text can also be marked according to the most important N words obtained. If adjacent phrases are formed, they are combined into multi-word keywords. For example, the information text entered by the user contains the sentence "I want to know the weather forecast for today". If both "weather” and “forecast” are candidate keywords, the combination of "weather forecast” can be used as an example in the embodiment of this application Keywords.
  • the human-computer dialogue method in the embodiment of the present application processes the information input by the user through the TextRank algorithm to obtain the keywords of the user input information, which can accurately and quickly extract the key points of the user input information, which is beneficial to the information retrieval processing in the following. .
  • Fig. 6 is a flow chart showing a method for man-machine dialogue according to another exemplary embodiment.
  • the human-machine dialogue method 60 shown in FIG. 6 is a detailed description of step S406 “determining the score of each of the plurality of sentences” in the human-machine dialogue method 40 shown in FIG. 4.
  • step S602 user input information and a plurality of sentences are acquired.
  • the user input information is text information, or text information obtained by converting the user's voice.
  • the multiple sentences are the sentences extracted from the candidate article described above.
  • a sentence vector of each sentence in the plurality of sentences is determined.
  • the sentence vector can be calculated from the word vectors of the words contained in the sentence.
  • Sentence vectors can be obtained, for example, by a combination of different ways of word vectors contained in a sentence.
  • the calculation method of the sentence vector may include:
  • the neural bag model simply averages each word in the text sequence, adds up all the words, and uses the result after the sum as a representation of the entire sequence.
  • a recursive neural network model (Recursive Neural Network), according to a given external topology (such as a component syntactic tree), continuously recursively obtains a representation of the entire sequence.
  • a recurrent neural network treats a text sequence as a time series, which is continuously updated, and finally obtains a representation of the entire sequence.
  • Convolutional neural network (Convolutional Neural Network) through a number of convolutional layers and sub-sampling layers, finally get a fixed-length vector.
  • the embodiment of the present application uses a word bag vector to construct a sentence vector by using a weighted neural word bag model.
  • a word bag vector to construct a sentence vector by using a weighted neural word bag model. The content of this section will be described in detail in the embodiment of FIG. 7.
  • step S606 the similarity between the sentence vectors of the plurality of sentences is determined.
  • the cosine similarity between sentence vectors can be determined according to the method described above, and then the cosine similarity between sentence vectors is used as the semantic similarity between sentences.
  • step S608 the importance of each sentence in the article is obtained based on the similarity.
  • a similarity matrix can be constructed based on the similarity between sentences. According to the similarity matrix, a sentence is used as a point, and the corresponding similarity is used as the weight of the edge to construct a graph model. Based on the graph model, the iterative method of PageRank is used to calculate the final importance of each sentence. This section will be described in detail in the embodiment of FIG. 7.
  • importance may be used as the first score.
  • step S610 an information vector of the user input information is determined.
  • the method of generating the sentence vector may be referred to, and the user input information is used as the sentence, and the information vector of the user input information is calculated by the word vector of the words contained in the sentence.
  • step S612 a sentence vector of each sentence in the plurality of sentences is determined.
  • the sentence vector can be calculated by referring to the above-mentioned method of generating the sentence vector by using the word vectors of the words contained in the sentence.
  • step S614 the similarity between the information vector and the sentence vector of each sentence is determined by the cosine similarity.
  • the cosine similarity between word vectors can be used as the similarity between corresponding words.
  • Cosine similarity is a method of evaluating the similarity of two vectors by calculating the cosine of the angle between them.
  • the similarity may be used as the second score.
  • step S616 the score is determined.
  • the first score is A and the second score is B.
  • the final score C of each sentence can be expressed as:
  • q is a weight coefficient
  • the human-computer dialogue method in the embodiment of the present application comprehensively considers the semantic importance of sentences in candidate articles and the relevance of the content of user questions and sentences in candidate articles, and then determines the sentence score in the candidate articles. Angle and comprehensively score sentences in candidate articles.
  • Fig. 7 is a flow chart showing a method for man-machine dialogue according to another exemplary embodiment.
  • the human-machine conversation method 70 shown in FIG. 7 is based on the similarity between step S604 “determining a sentence vector of each sentence in the plurality of sentences” and step S608 “in the human-machine conversation method 60 shown in FIG. 6 Get a detailed description of the importance of each sentence in the article.
  • step S702 the sentence is segmented to obtain a plurality of words.
  • the input information in the embodiments of the present application may be processed by one or more of the multiple word segmentation methods described above, which is not limited in the embodiments of the present application.
  • step S704 a vocabulary vector of a plurality of vocabularies is determined.
  • the news data or article data in the public network can be trained by the GloVe algorithm to obtain the word vectors of the vocabulary used in the embodiments of the present application.
  • step S706 the word frequency inverse document frequency of the plurality of words is determined.
  • the term frequency inverse document frequency of multiple words can be determined by TF-IDF (term frequency inverse document frequency) technology.
  • TF-IDF is a commonly used weighting technique for information retrieval and data mining.
  • TF is term frequency
  • IDF is inverse document frequency index.
  • the embodiment of the present application considers that the semantics of each word in the sentence has a different degree of influence on the semantics of the sentence, and the TF-IDF value of each word vector can reflect the importance of the word in the sentence, so in this embodiment, , TF-IDF is used to weight the vocabulary vector, and the weighted average of the vocabulary vector is used as the sentence vector.
  • the TF-IDF of a word vector is calculated as follows:
  • TF w number of occurrences of vocabulary vector w in a document / total number of words in the document;
  • IDF w log (total number of documents / (total number of documents with word w + 1));
  • TF-IDF TF ⁇ IDF.
  • the above formula is used to define the inverse document frequency of the word frequency of each lexical vector in the candidate article.
  • a sentence vector of a sentence is determined according to the word frequency inverse document frequency and the vocabulary vector.
  • the semantics of each word in the sentence in the candidate article has a different degree of influence on the semantics of the sentence, and the TF-IDF value of each word can reflect the importance of the word.
  • the TF-IDF value is used.
  • the words are weighted, and the weighted average of the word vectors is used as the sentence vector.
  • V s represents a sentence vector of the sentence s
  • s represents a certain sentence in the candidate article
  • w represents a word
  • V w represents a word vector of the word w
  • TF-IDF w represents a TF-IDF value of the word w.
  • step S710 a degree of similarity between sentence vectors of the plurality of sentences is determined.
  • the cosine similarity of sentence vectors can be used as the similarity between sentences.
  • a similarity matrix is constructed based on the similarity. If the candidate article contains n sentences, a n ⁇ n similarity matrix is constructed, and the value of the element ai j (the element in the i th row and the j th column) in the matrix is the similarity between the i th sentence and the j th sentence .
  • step S714 a sentence is used as a node, and similarity is used as a weight of an edge, and a graph model is constructed based on the similarity matrix.
  • the similarity matrix may be, for example, a 4 ⁇ 4 matrix, the point set is (a 1 , a 2 , a 3 , a 4 ), and the corresponding edge set is (a 12 , a 13 , ... a 34 ) :
  • the graph model constructed based on this similarity matrix has 4 nodes, which can be a 1 , a 2 , a 3 and a 4, respectively .
  • the matrix values corresponding to a 1 , a 2 , a 3 and a 4 are used as the weights of the edges between the nodes. Therefore, in the graph model, the edge a 12 between a 1 and a 2 can be recorded as 0.3; the edge a 13 between a 1 and a 3 can be recorded as 0.5; the edge a 14 between a 1 and a 4 It can be recorded as 0.1; and so on, each node in the graph model and the edge between the nodes can be assigned to construct the graph model.
  • step S716 the importance of the sentence in the article is obtained through iteration based on the graph model.
  • the cosine similarity between sentence vectors can be used as the similarity between sentences, and then the importance of the sentence in the article can be determined by iterative calculation.
  • the similarity between sentences can be calculated by the following formula, which is not limited in the embodiment of the present application:
  • S i represents the i-th sentence
  • S j represents the j-th sentence
  • w k represents the k-th word in the sentence
  • the directed right graph G (V, E) is composed of a point set V (sentence) and an edge set E (similarity), where E is a subset of V ⁇ V.
  • Point importance degree V i (sentences) score is defined as follows:
  • V i is the degree of importance of the sentence score represented ws (V j) is the degree of importance of V j sentence score;
  • d is the damping coefficient.
  • the value ranges from 0 to 1, which represents the probability of pointing from a specific point in the figure to any other point. It can be set according to empirical values.
  • V i Represents the set of all points (sentences) that point to the point of V i (sentence), and V k ⁇ Out (V j ) represents the set of all points (sentences) that point of V i (sentence);
  • w ji and w jk are weights of edges between V i and V j and edges between V j and V k .
  • the importance of each sentence is initialized to 1 during the iterative calculation.
  • the preset value for determining convergence is taken as 0.0001.
  • the human-computer dialogue method of the embodiment of the present application considers the semantics of sentences when extracting key sentences of user input information.
  • the sentence similarity calculation does not consider the semantics of the sentence
  • the human-computer dialogue method of the embodiment of the present application uses the word frequency-inverse document frequency (TF-IDF) as the weight of the words,
  • TF-IDF word frequency-inverse document frequency
  • the weighted average of word vectors is represented as a vector of sentences, and this vector is used to calculate the similarity between sentences.
  • the GloVe model is used for training the word vector, and other word vector models such as the continuous bag-of-words model CBOW, Skip-Gram, etc. may also be used here.
  • the weighted average of the word vectors is used as the vector representation of the sentence.
  • the human-computer dialogue method in the embodiment of the present application may also use other sentence vector representation methods, such as Skip-Thought and other methods.
  • the cosine similarity between sentence vectors is used as the semantic similarity between sentences.
  • Norm is a strengthened concept of distance, which by definition has a number multiplication algorithm over distance.
  • the norm includes the vector norm and the matrix norm.
  • the vector norm represents the size of the vector in the vector space
  • the matrix norm represents the magnitude of the change caused by the matrix.
  • other distance measures such as L1 or L2 norm between vectors can also be considered to represent the similarity.
  • the program may be stored in a computer-readable storage medium, and the storage medium may be a read-only memory, a magnetic disk, or an optical disk.
  • Fig. 8 is a block diagram of a human-machine dialog device according to an exemplary embodiment.
  • the human-machine dialogue device 80 includes a keyword module 802, an article module 804, a scoring module 806, and a return information module 808.
  • the keyword module 802 is configured to extract keywords from the user's input information; extract keywords from the user's voice input information; or extract keywords from the user's text input information.
  • the article module 804 is configured to determine a candidate article according to the keywords; a search may be performed in a predetermined platform according to the keywords to determine the candidate article. Specifically, you can retrieve several hot news articles related to keywords in recent public account articles; you can also search for keywords in mainstream search engines, sort them based on the results retrieved, and sort from highest to lowest The candidate article is determined in a search result.
  • the number of candidate articles may be one or more, which is not limited in the embodiment of the present application.
  • the scoring module 806 is configured to obtain multiple sentences in the candidate article, and determine a score of each sentence in the multiple sentences; the scoring module 806 may be specifically configured to: A first score is determined by the importance in the article; a second score is determined according to the similarity of each sentence in the plurality of sentences with the input information; a score is determined according to the first score and the second score.
  • the return information module 808 is configured to extract partial sentences from the plurality of sentences to generate return information based on the scoring result.
  • the plurality of sentences may be sorted according to a scoring result; and a partial sentence is sequentially extracted (for example, from high to low) from the plurality of sentences to generate the return information.
  • the human-machine dialogue device of the embodiment of the present application by retrieving articles related to user issues and extracting partial sentences in the relevant articles, generating return information with substantial content and information content can enable the robot to generate The amount of information to answer, assist users to exchange views with external information.
  • Fig. 9 is a block diagram of a human-machine dialog device according to another exemplary embodiment.
  • the human-machine dialogue device 90 shown in FIG. 9 further includes a word vector training module 902 in addition to the human-machine dialogue device 80 shown in FIG. 8.
  • the word vector training module 902 is configured to obtain the vocabulary vector by training text data through a word vector training algorithm.
  • news data or article data in a public network may be trained by the GloVe algorithm to obtain word vectors of words used in the embodiments of the present application.
  • the word vectors of the vocabulary used in the embodiments of the present application may also be obtained through other word vector construction algorithms, which is not limited in the embodiments of the present application.
  • Fig. 10 is a block diagram showing an electronic device according to an exemplary embodiment.
  • FIG. 10 An electronic device 1000 according to an embodiment of the present application is described below with reference to FIG. 10.
  • the electronic device 1000 shown in FIG. 10 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present application.
  • the electronic device 1000 is expressed in the form of a general-purpose computing device.
  • the components of the electronic device 1000 may include, but are not limited to, at least one processing unit 1010 (such as a CPU), at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), a display unit 1040, and the like.
  • the storage unit 1020 stores program code, and the program code can be executed by the processing unit 1010, so that the processing unit 1010 executes the steps of the human-machine dialog method described in any one of the foregoing embodiments of this specification.
  • the processing unit 1010 may perform steps as shown in FIGS. 4, 5, 6, and 7.
  • the storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 10201 and / or a cache storage unit 10202, and may further include a read-only storage unit (ROM) 10203.
  • RAM random access storage unit
  • ROM read-only storage unit
  • the storage unit 1020 may further include a program / utility tool 10204 having a group (at least one) of program modules 10205.
  • program modules 10205 include, but are not limited to, an operating system, one or more application programs, other program modules, and programs. Data, each or some combination of these examples may include an implementation of the network environment.
  • the bus 1030 may be one or more of several types of bus structures, including a storage unit bus or a storage unit controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local area using any of a variety of bus structures. bus.
  • the electronic device 1000 may also communicate with one or more external devices 1000 '(such as a keyboard, pointing device, Bluetooth device, etc.), and may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or Communicate with any device (such as a router, modem, etc.) that enables the electronic device 1000 to communicate with one or more other computing devices. This communication can be performed through an input / output (I / O) interface 1050. Moreover, the electronic device 1000 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the network adapter 1060.
  • LAN local area network
  • WAN wide area network
  • public network such as the Internet
  • the network adapter 1060 can communicate with other modules of the electronic device 1000 through the bus 1030. It should be understood that although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives And data backup storage systems.
  • the technical solution according to the embodiment of the present application may be embodied in the form of a software product, and the software product may be stored in a non-volatile storage medium (can be a CD-ROM, a U disk, a mobile hard disk, etc.) or on a network , Including several instructions to enable a computing device (which may be a personal computer, a server, or a network device, etc.) to execute the above method according to the embodiment of the present application.
  • a computing device which may be a personal computer, a server, or a network device, etc.
  • FIG. 11 schematically illustrates a computer-readable storage medium in an exemplary embodiment of the present application.
  • a program product 1100 for implementing the above method according to an embodiment of the present application is described, which may adopt a portable compact disc read-only memory (CD-ROM) and include program code, and may be stored in a terminal device. For example running on a personal computer.
  • the program product of the embodiment of the present application is not limited thereto.
  • the readable storage medium may be any tangible medium containing or storing a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
  • the computer readable medium carries one or more programs, and when the one or more programs are executed by a computing device, the computing device is enabled to perform the following functions: extract keywords from user input information; and according to the keywords Determining a candidate article; obtaining a plurality of sentences in the candidate article, and determining a score of each sentence in the plurality of sentences; and extracting partial sentences from the plurality of sentences to generate return information based on the score results.
  • modules in the above embodiments may be distributed in the device according to the description of the embodiment, or corresponding changes may be made in one or more devices that are different from this embodiment.
  • the modules in the above embodiments may be combined into one module, or further divided into multiple sub-modules.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Human Computer Interaction (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Machine Translation (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请实施例涉及一种人机对话方法、装置、电子设备及计算机可读介质。该方法包括:从用户的输入信息中提取关键词;根据所述关键词确定候选文章;获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;以及基于评分结果从所述多个句子中提取部分句子生成返回信息。

Description

人机对话方法、装置、电子设备及计算机可读介质
本申请要求于2018年8月29日提交中国专利局、申请号为201810995868.8,申请名称为“人机对话方法、装置、电子设备及计算机可读介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及计算机信息处理领域,具体而言,涉及一种人机对话方法、装置、电子设备及计算机可读介质。
背景技术
聊天机器人(chatterbot)是一个用来模拟人类对话或聊天的程序。目前聊天机器人广泛运用于各种即时通讯平台,学习教育平台,以及各种信息服务平台。聊天机器人可基于数据库中知识与用户进行聊天,通常是研发者把自己感兴趣的回答放到数据库中,当一个问题被抛给聊天机器人时,它从数据库中找到最贴切的答案,回复给它的聊伴。这种简单的对话型聊天方式,用户获取信息范围较窄,逐渐退出市场。
随着序列数据的神经网络在人工智能与翻译交流领域的应用,聊天机器人可将用户所说的话作为模型的输入,将模型输出的语句作为回复来进行人机交互。
发明内容
本申请实施例提供一种人机对话方法、装置、电子设备及计算机可读介质,能够使得机器人在人机对话过程中产生具有信息量的回答,辅助用户与外界信息进行观点交流。
本申请实施例的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本申请实施例的实践而习得。
本申请实施例提出一种人机对话方法,由电子设备执行,该方法包括:从用户的输入信息中提取关键词;根据所述关键词确定候选文章; 获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;以及基于评分结果从所述多个句子中提取部分句子生成返回信息。
本申请实施例提出一种人机对话装置,该装置包括:关键词模块,用于从用户的输入信息中提取关键词;文章模块,用于根据所述关键词确定候选文章;评分模块,用于获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;以及返回信息模块,用于基于评分结果从所述多个句子中提取部分句子生成返回信息。
本申请实施例提出一种电子设备,该电子设备包括:一个或多个处理器;存储装置,用于存储一个或多个程序;当一个或多个程序被一个或多个处理器执行时,使得一个或多个处理器实现本申请任一实施例所述的方法。
本申请实施例提出一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现本申请任一实施例所述的方法。
附图说明
通过参照附图详细描述其示例实施例,本申请实施例的上述和其它目标、特征及优点将变得更加显而易见。下面描述的附图仅仅是本申请的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是根据一示例性实施例示出的一种人机对话方法及装置的系统框图;
图2是根据一示例性实施例示出的一种人机对话方法的应用场景图;
图3是根据一示例性实施例示出的一种人机对话方法的应用场景图;
图4是根据一示例性实施例示出的一种人机对话方法的流程图;
图5是根据另一示例性实施例示出的一种人机对话方法的流程图;
图6是根据另一示例性实施例示出的一种人机对话方法的流程图;
图7是根据另一示例性实施例示出的一种人机对话方法的流程图;
图8是根据一示例性实施例示出的一种人机对话装置的框图;
图9是根据另一示例性实施例示出的一种人机对话装置的框图;
图10是根据一示例性实施例示出的一种电子设备的框图;
图11是根据一示例性实施例示出的一种计算机可读存储介质示意图。
具体实施方式
现在将参考附图更全面地描述示例实施例。然而,示例实施例能够以多种形式实施,且不应被理解为限于在此阐述的实施例;相反,提供这些实施例使得本申请将全面和完整,并将示例实施例的构思全面地传达给本领域的技术人员。在图中相同的附图标记表示相同或类似的部分,因而将省略对它们的重复描述。
此外,所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施例中。在下面的描述中,提供许多具体细节从而给出对本申请的实施例的充分理解。然而,本领域技术人员将意识到,可以实践本申请的技术方案而没有特定细节中的一个或更多,或者可以采用其它的方法、组元、装置、步骤等。在其它情况下,不详细示出或描述公知方法、装置、实现或者操作以避免模糊本申请的各方面。
附图中所示的方框图仅仅是功能实体,不一定必须与物理上独立的实体相对应。即,可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。
附图中所示的流程图仅是示例性说明,不是必须包括所有的内容和操作/步骤,也不是必须按所描述的顺序执行。例如,有的操作/步骤还可以分解,而有的操作/步骤可以合并或部分合并,因此实际执行的顺序有可能根据实际情况改变。
应理解,虽然本文中可能使用术语第一、第二、第三等来描述各种组件,但这些组件不应受这些术语限制。这些术语乃用以区分一组件与另一组件。因此,下文论述的第一组件可称为第二组件而不偏离本申请概念的教示。如本文中所使用,术语“及/或”包括相关联的列出项目中的任一个及一或多者的所有组合。
本领域技术人员可以理解,附图只是示例实施例的示意图,附图中的模块或流程并不一定是实施本申请实施例所必须的,因此不能用于限制本申请实施例的保护范围。
在以模型为基础进行人机交互的过程中,机器人回复的内容较为空洞,不具有信息量,并没有实际内容的扩展,用户实际体验一般,在实际应用中受到限制。
目前常用于聊天机器人闲聊的技术有基于序列到序列神经网络模型(seq2seq)生成式方法。seq2seq神经网络模型是一种端到端(end-to-end)模型,能够对序列进行处理。该模型以一个序列作为输入,以另一个序列作为输出,常用于机器翻译和对话领域。而基于seq2seq神经网络模型的生成式方法:首先在大量对话训练数据上训练seq2seq模型,然后在用户与聊天机器人闲聊时,直接将用户所说的话作为该模型的输入,然后将该模型的输出作为对于用户的回复。
采用基于seq2seq模型生成式方法的缺点是训练seq2seq模型时需要大量的对话训练数据,而这些数据由于范围广、数据量大,使得seq2seq神经网络模型的训练数据在实际生活中较难获取。
采用基于seq2seq模型生成式方法的聊天机器人在闲聊时,对用户的回答空洞,不具有信息量,没有实际内容,在实际应用中受到限制。例如,当用户想了解外界资讯或者和聊天机器人交流对一些事件观点或看法的时候,该方法只能简单地回复或回避用户问题,并不能正面回答用户问题,更不能给出其它有信息量的建设性的观点。
有鉴于此,本申请实施例提出了一种人机对话方法,以根据用户的提问,在相关的文章中抽取关键句子作为自己的回复,实现资讯、观点或看法等的交流的目的。
下面将对本申请实施例进行详细描述。
图1是根据一示例性实施例示出的一种人机对话方法及装置的系统框图。
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务 器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等。
终端设备101、102、103可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、智能音箱、平板电脑、膝上型便携计算机和台式计算机等等。
服务器105可以是提供各种服务的服务器,例如对用户利用终端设备101、102、103所调用的聊天机器人提供后台数据支撑的服务器。后台数据支撑的服务器可以对接收到的用户提问问题进行分析等处理,并将处理结果(例如返回信息、返回语音等)反馈给终端设备。
终端设备101、102、103可从用户的语音输入信息中提取关键词;终端设备101、102、103还可从用户的文字输入信息中提取关键词。
终端设备101、102、103可从用户的输入信息中提取关键词;终端设备101、102、103可根据所述关键词确定候选文章;终端设备101、102、103可获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;终端设备101、102、103可基于评分结果从所述多个句子中提取部分句子生成返回信息。
终端设备101、102、103可将用户的输入信息转发至服务器105中进行处理;服务器105可从用户的输入信息中提取关键词;服务器105可根据所述关键词确定候选文章;服务器105可获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;服务器105可基于评分结果从所述多个句子中提取部分句子生成返回信息;服务器105可将所述返回信息发送至终端设备101、102、103以便响应所述用户的输入信息。
需要说明的是,本申请实施例所提供的人机对话方法可以由服务器105和/或终端设备101、102、103执行,相应地,人机对话装置可以设 置于服务器105和/或终端设备101、102、103中。而提供给用户进行信息输入的请求端一般位于终端设备101、102、103中。
根据本申请实施例的人机对话方法及装置可以应用于聊天机器人相关产品中,如智能音箱、即时通讯软件中的聊天机器人等,主要应用在用户与聊天机器人闲聊的场景下。本申请实施例的人机对话方法及装置可以实现新闻概要播报、观点交流等功能。
在一个应用场景中,了解新闻是用户的常用需求,一般情况下播报完整的新闻会占用较长时间,使得用户失去耐心,降低用户体验,这时播报新闻概要就显得十分必要了。例如,当用户想了解近期的热点新闻时,可以对聊天机器人说“我想听下最近的热点新闻”,或“最近有什么热点新闻吗”等其它表述,本申请实施例的人机对话方法及装置会从近期的公众号文章中检索出几篇热点新闻文章,并抽取文章中的几个关键句子作为概要播报给用户。或者,当用户想了解具体方面如中美贸易战的新闻时,可以对聊天机器人说“现在中美贸易战局势怎样了”,本申请实施例的人机对话方法及装置会从所检索出的该方面最相关的几篇新闻中抽取关键句子,组成概要回复给用户。
图2是根据一示例性实施例示出的一种人机对话方法的应用场景图。如图2所述的人机对话场景中,用户可在即时聊天窗口中,或信息交互平台上与聊天机器人进行对话。用户可通过文字输入问题,聊天机器人对用户问题进行数据处理后,返回文字信息和/或语音信息作为用户提问的响应。
闲聊时,用户可能会向聊天机器人提出对事情的看法等观点交流的问题,如“你对这次高考改革怎么看”,本申请实施例的人机对话方法及装置根据用户提问的信息,搜索相关文章进而组成返回信息以答复用户,用户可从返回信息中获取到最近的高考政策及高考分数等。本申请实施例的人机对话方法及装置可以使聊天机器人像真人一样进行直接回答,而不是简单回复“很好啊“等类似语句,或者回避用户提问。针对用户提出的问题,本申请实施例的人机对话方法及装置可通过在大量热点文章中提取出高考改革评论文章,并从中提取出关键的评论句子, 然后将关键评论句子组织成回复信息以作为机器人要表达的看法。
图3是根据一示例性实施例示出的一种人机对话方法的应用场景图。如图3所述的人机对话场景中,用户可通过语音输入终端与聊天机器人进行对话,语音输入终端可为智能音箱或者智能机器人等设备。用户可通过语音提出问题,聊天机器人先将用户的语音问题转化为文字信息,然后再进行数据处理后,返回文字和/或语音信息作为用户提问的响应。
例如,当用户问“XXXX这部电影怎样?”,本申请实施例的人机对话方法及装置可在电影信息平台中提取相关文章中的关键评论句子,然后根据这些句子组成返回信息以答复用户。用户可以从返回信息中获取电影简介或评价内容,而不会像基于seq2seq模型生成式方法那样仅简单地回复“很好看啊”等类似回答。
本申请实施例的人机对话方法及装置可以根据用户的提问,在相关的文章中抽取关键句子作为自己的回复,进而实现用户观点与外界资讯、观点或看法等的交流。
图4是根据一示例性实施例示出的一种人机对话方法的流程图。该方法可由上述的服务器或终端设备等电子设备执行。人机对话方法40至少包括步骤S402至S408。
如图4所示,在步骤S402中,从用户的输入信息中提取关键词。可从用户的语音输入信息中提取关键词;或从用户的文字输入信息中提取关键词。
在一个实施例中,从用户的文字输入信息中提取关键词,具体可包括:将所述输入信息进行分词处理,以获取多个词汇;确定多个词汇的词汇向量(也称为词向量);通过余弦相似度与词汇向量确定多个词汇之间的相似度;根据所述相似度确定多个词汇的重要度;以及依据所述重要度排序确定所述关键词。其中,关键词的数量可为一个或多个,本申请实施例不以此为限。关键词提取的相关内容将在后文图5的实施例中进行详细说明。
在一个实施例中,从用户的语音输入信息中提取关键词,具体可通过智能音箱、智能机器人或者其它带有声音接收功能的音频设备接收用 户语音输入的音频信息。在获取音频数据后对用户的音频信息进行音频识别,进而获取用户输入信息中的关键词。还可将用户的音频信息通过音频识别转化为文字信息,进而根据上一实施例中的方法,提取文字信息中的关键词。
如图4所示,在步骤S404中,根据所述关键词确定候选文章。可根据所述关键词在预定平台中进行检索以确定所述候选文章。例如可在近期的公众号文章中检索出几篇与关键词相关的热点新闻文章;还可在主流搜索引擎中对关键词进行搜索,根据检索出的结果进行排序,根据排序由高至低从检索结果中确定所述候选文章。其中,候选文章数量可为一个或多个,本申请实施例不以此为限。
如图4所示,在步骤S406中,获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分。具体可包括:根据所述多个句子中每一个句子在所述文章中的重要度确定第一评分;根据所述多个句子中每一个句子与所述输入信息的相似性(相似度)确定第二评分;根据所述第一评分与所述第二评分确定评分。
在一个实施例中,根据所述多个句子中每一个句子在所述文章中的重要度确定所述第一评分,句子的重要度可通过文本排序算法获得,具体包括:确定所述多个句子中每一个句子的句子向量;确定所述多个句子的句子向量之间的相似度;基于所述相似度获取每一个句子在所述文章中的重要度以确定所述第一评分。
在一个实施例中,文本排序算法可为Automatic Summarization(自动文摘算法)中的TextRank(文本抽取法)。TextRank通过把候选文章分割成若干组成单元(单词、句子)并建立图模型,利用投票机制对候选文章中的重要成分进行排序,从而能够仅利用候选文章本身的信息对文档中的每个句子的重要程度进行评分。通过TextRank算法确定句子在文章中的重要度的相关内容将在后文图7的实施例中进行详细说明。
因为TextRank评分只体现对应句子在文章中的语义重要度,没要考虑与用户提问的相关性,所以不能直接根据该重要度抽取句子。为此,可用提问中关键词的词向量加权平均作为用户提问的向量表示,用各句 子向量与该向量之间的余弦相似度作为各句子与用户提问的相似性以确定第二评分。
在一个实施例中,根据所述多个句子中每一个句子与所述输入信息的相似性确定所述第二评分包括:确定用户输入信息的信息向量;确定所述多个句子中每一个句子的句子向量;通过余弦相似度确定该信息向量与每一个句子的句子向量之间的相似性;以及通过所述多个句子中每一个句子的相似性确定所述第二评分。候选文章中的句子与所述输入信息之间的相似度计算的具体步骤与图7中的过程相似;将用户输入信息也作为句子,再将图7中将候选文章句子与句子之间的相似性比较,替换为用户输入信息与句子之间的相似性比较即可,本申请实施例在此不再赘述。
在一个实施例中,根据所述第一评分与所述第二评分确定评分。可通过候选文章中,每个句子的重要度与相似性的加权和作为该句子的最终评分并进行排序。例如,第一评分为A,第二评分为B,该句子最终的评分C可表示为:
C=qA+(1-q)B;
其中,q为权重系数,q的取值范围为q∈[0,1];在q取值为1或0时,总的评分C可由第一评分为A或第二评分为B确定。
如图4所示,在步骤S408中,基于评分结果从所述多个句子中提取部分句子生成返回信息。可将所述多个句子按照评分结果进行排序;以及依序从所述多个句子中提取部分句子生成所述返回信息。
在一个实施例中,依序从所述多个句子中提取部分句子生成所述返回信息包括:对所述部分句子进行后处理以生成所述返回信息。具体可将候选文章的句子进行评分排序(第一评分与第二评分),优选出评分最高的几个句子组织成回复,并进行自然语言处理如指代消解、摘要首句首部去连词等,生成便于用户阅读理解的文字结果,然后将文字结果返回给用户。
指代消解是自然语言处理的重要内容,就是在篇章中确定代词指向哪个名词短语的问题。在本申请的一个实施例中,指代消解首先要构造 先行候选录,然后再从候选中作多选一选择。具体而言指代消解的方法包括:基于句法的指代消解,以及基于语料库的方法,还有统计方法,统计机器学习方法等等,本申请实施例中的指代消解过程可通过以上方法中的一种或几种实现。
根据本申请实施例的人机对话方法,通过检索用户问题相关文章,并在相关文章中提取部分语句,生成具有实质内容、包含信息量的返回信息的方式,能够使得机器人在人机对话过程中产生具有信息量的回答,辅助用户与外界信息进行观点交流。
在非任务型对话即闲聊场景下,用户向聊天机器人提问时,本申请实施例的人机对话方法,首先通过检索提取与用户提问相关的几篇候选文章,采用文本排序算法计算候选文章中各句子的重要度,再综合考虑各句子与用户提问的相关性生成候选文章中各句子的最终评分和排序,最后根据评分在候选文章中抽取几个关键句子组织成摘要返回给用户作为回答。根据以上内容的描述,本申请实施例的人机对话方法,能够提取相关文章中的关键句子使得聊天机器人的回复内容包含一定信息而不空洞。本申请实施例的人机对话方法,在生成返回信息时,综合考虑提取的句子在候选文章中的重要度和该提取的句子与用户提问的相关性,能够获得既贴近用户问题,又具有信息量的返回信息。
可以理解,本申请实施例描述了如何形成和使用特定示例,但本申请实施例的原理不限于这些示例的任何细节。相反,基于本申请实施例的教导,这些原理能够应用于许多其它实施例。
在本申请的一种示例性实施例中,还包括:通过词向量训练算法训练文字数据获取所述词汇向量(词向量)。其中,词向量(Word embedding),是自然语言处理(NLP)中的一组语言建模和特征学习技术的统称,在本申请实施例中,词向量的作用就是将自然语言中的字词转为计算机可以理解的稠密向量。构建词向量常用的模型为word2vec模型和GloVe(Global Vectors for word representation)模型。
其中,word2vec模型能训练大量的语料,并且可以使单词向量维度较低,能够捕捉单词之间的相似性,对单词使用代数运算就能计算相似 的单词。GloVe模型是word2vec模型之后提出的词向量训练模型,GloVe模型在word2vec模型的基础上提出了根据语料中的一些统计信息辅助进行词向量构建的想法。也就是说,如果一个词汇和哪个上下文词汇在一起的多,那么这个词汇与这个上下文词汇在一起要比与其它词在一起意义要大,那么在最终词向量的确定过程中,会优先考虑这两个词汇之间的关联关系。
基于以上的词向量模型的特点分析,在本申请的一个实施例中,可通过GloVe算法对公共网络中的新闻数据或者文章数据进行训练以获取本申请实施例中所用的词汇的词向量。在本申请的一个实施例中,还可通过其它词向量构建算法获取本申请实施例中所用的词汇的词向量,本申请实施例不以此为限。
图5是根据另一示例性实施例示出的一种人机对话方法的流程图。如图5所示的人机对话方法50是对图4所示的人机对话方法40中步骤S402“从用户的输入信息中提取关键词”的详细描述。
如图5所述,在步骤S502中,对所述输入信息进行分词处理,以获取多个词汇。如上文所述,用户输入的信息可为音频或文字形式,当用户输入的信息为音频时,可先将音频信息转化为文字,然后再进行本实施例中的分词处理。
在一个实施例中,分词处理可为对汉字进行中文分词处理,中文分词(Chinese Word Segmentation)指的是将一个汉字序列切分成一个一个单独的词。分词就是将连续的字序列按照一定的规范重新组合成词序列的过程。现有的分词算法可分为三大类:基于字符串匹配的分词方法、基于理解的分词方法和基于统计的分词方法。按照是否与词性标注过程相结合,又可以分为单纯分词方法和分词与标注相结合的一体化方法。
在一个实施例中,基于字符串匹配的分词方法,是按照一定的策略将待分析的汉字串与一个“充分大的”机器词典中的词条进行匹配,若在词典中找到某个字符串,则匹配成功(识别出一个词)。基于理解的分词方法,是通过让计算机模拟人对句子的理解,达到识别词的效果。其基本思想就是在分词的同时进行句法、语义分析,利用句法信息和语 义信息来处理歧义现象。基于统计的分词方法,是对语料中相邻共现的各个字的组合的频度进行统计,计算它们的互现信息。
当然,在用户输入的信息为英文或其它语言信息时,也可通过其它语言对应的分词处理方法对用户输入信息进行分词处理,具体分词处理的方法不影响本申请后续实施例的处理步骤。在本申请实施例中,可通过以上多种分词方法中的一种或几种来对本申请实施例中的输入信息进行分词处理,本申请实施例不以此为限。
在步骤S504中,确定多个词汇的词汇向量。可通过GloVe算法对公共网络中的新闻数据或者文章数据进行训练以获取本申请实施例中所用的词汇的词向量。
在一个实施例中,将通过训练得到的词向量为上文分词处理之后得到的词汇进行词向量标注,生成词汇向量集合。
在步骤S506中,通过余弦相似度与词汇向量确定多个词汇之间的相似度。可用词向量间的余弦相似度作为对应词之间的相似度。余弦相似度,是通过计算两个向量的夹角余弦值来评估它们的相似度。
在一个实施例中,可按照文章中词汇出现的顺序,将多个词汇进行排序并编号,可由1号词汇向量作为起始词汇向量,分别比较1号词汇向量与其它词汇向量之间的相似度。在多次遍历所有的词汇向量,并将词汇向量两两比较之后,确定它们之间的相似度。
在一个实施例中,将两个词汇向量根据其坐标值,分别绘制到向量空间中,如最常见的二维空间。计算求得它们的夹角,并得出夹角对应的余弦值,此余弦值就可以用来表征这两个向量的相似性。例如,两个词汇向量之间的夹角越小,他们之间的余弦值越接近于1,则两个词汇向量越相似。
在步骤S508中,根据所述相似度确定多个词汇的重要度。可利用TextRank算法计算各词的重要度。TextRank算法是利用局部词汇之间关系(共现窗口)对后续关键词进行排序,直接从文本本身抽取。其主要步骤可如下:
(1)构建候选关键词图G=(V,E),其中V为节点集(词汇向量集), 然后采用共现关系(co-occurrence)构造任两点之间的边,即为两个节点之间存在边仅当它们对应的词汇在长度为K的窗口中共现,K表示窗口大小,即最多共现K个单词。
(2)根据如图7所述的步骤和公式,将节点之间边的权重设置为词汇向量之间的相似度,通过迭代传播各节点的权重,直至收敛。具体步骤与方法请参考图7以及图7对应的实施例,本申请实施例在此不再赘述。
(3)对节点权重进行倒序排序,从而得到最重要的T个词汇向量,节点的权重即为词汇向量的重要度。
在步骤S510中,依据所述重要度排序确定所述关键词。可按照重要度由高至低选取一个或多个词汇向量,这些词汇向量对应的词汇作为本实施例中的关键词。
在一个实施例中,还可根据得到的最重要的N个单词,在原始文本中进行标记,若形成相邻词组,则组合成多词关键词。例如,用户输入的信息文本中有句子“我想知道今天的天气预报”,如果“天气”和“预报”均属于候选关键词,则可将“天气预报”这一组合作为本申请实施例中的关键词。
本申请实施例的人机对话方法,通过TextRank算法对用户输入的信息进行处理,获取用户输入信息的关键词,能够准确快速地提取出用户输入信息的关键点,有利于后文中的信息检索处理。
图6是根据另一示例性实施例示出的一种人机对话方法的流程图。如图6所示的人机对话方法60是对图4所示的人机对话方法40中步骤S406“确定所述多个句子中每一个句子的评分”的详细描述。
如图6所示,在步骤S602中,获取用户输入信息与多个句子。在本实施例中,用户输入信息为文字信息,或者是将用户的语音进行转化得到的文字信息。多个句子为上文中所述的在待选文章中提取出的句子。
在步骤S604中,确定所述多个句子中每一个句子的句子向量。可通过句子中所包含词的词向量计算句子向量。句子向量可例如通过由句子中包含的词向量的不同方式的组合得到。句子向量的计算方法可包括:
神经词袋模型,简单对文本序列中每个词嵌入进行平均,将所有的词进行加总,并将加总之后的结果作为整个序列的表示。
递归神经网络模型(Recursive Neural Network),按照一个给定的外部拓扑结构(比如成分句法树),不断递归得到整个序列的表示。
循环神经网络(Recurrent Neural Network),将文本序列看作时间序列,不断更新,最后得到整个序列的表示。
卷积神经网络(Convolutional Neural Network),通过多个卷积层和子采样层,最终得到一个固定长度的向量。
在一个实施例中,本申请实施例通过加权表示的神经词袋模型,利用词向量构建句子向量,本部分内容将在图7的实施例中进行详细描述。
在步骤S606中,确定所述多个句子的句子向量之间的相似度。可根据上文所述的方法确定句子向量之间的余弦相似度,进而将句子向量间的余弦相似度作为句子间的语义相似度。
在步骤S608中,基于所述相似度获取每一个句子在所述文章中的重要度。可根据句子之间的相似度构建相似度矩阵。根据该相似度矩阵,以句子为点,对应的相似度作为边的权重,构建图模型。在图模型的基础上,使用PageRank的迭代方法,计算出每个句子的最终重要度。本部分内容将在图7的实施例中进行详细描述。
在一个实施例中,可将重要度作为第一评分。
在步骤S610中,确定用户输入信息的信息向量。可参照上文中句子向量的生成方式,将用户输入信息作为句子,通过该句子中所包含词的词向量来计算用户输入信息的信息向量。
在步骤S612中,确定所述多个句子中每一个句子的句子向量。可参照上文中句子向量的生成方式,通过句子中所包含词的词向量来计算句子向量。
在步骤S614中,通过余弦相似度确定信息向量与每一个句子的句子向量之间的相似性。可用词向量间的余弦相似度作为对应词之间的相似度。余弦相似度,是通过计算两个向量的夹角余弦值来评估它们的相似度的方法。
在一个实施例中,可将相似度作为第二评分。
在步骤S616中,确定评分。综合考虑第一评分与第二评分,例如第一评分为A,第二评分为B,每个句子最终的评分C可表示为:
C=qA+(1-q)B;
其中,q为权重系数。
本申请实施例的人机对话方法,综合考虑了句子在候选文章中的语义重要度以及用户提问的内容与候选文章中句子的相关性,进而确定候选文章中句子评分,能够从多方面、多角度、综合地对候选文章中的句子进行评分。
图7是根据另一示例性实施例示出的一种人机对话方法的流程图。如图7所示的人机对话方法70是对图6所示的人机对话方法60中步骤S604“确定所述多个句子中每一个句子的句子向量”与步骤S608“基于所述相似度获取每一个句子在所述文章中的重要度”的详细描述。
如图7所示,在步骤S702中,将句子进行分词处理获取多个词汇。可通过上文所述的多种分词方法中的一种或几种来对本申请实施例中的输入信息进行分词处理,本申请实施例不以此为限。
在步骤S704中,确定多个词汇的词汇向量。可通过GloVe算法对公共网络中的新闻数据或者文章数据进行训练以获取本申请实施例中所用的词汇的词向量。
在步骤S706中,确定多个词汇的词频逆文档频率。可通过TF-IDF(term frequency inverse document frequency)技术确定多个词汇的词频逆文档频率。其中,TF-IDF是一种用于信息检索与数据挖掘的常用加权技术。TF是词频(Term Frequency),IDF是逆文档频率指数(Inverse Document Frequency)。
本申请实施例考虑到在句子中每个词的语义对句子的语义的影响程度不同,而每个词向量的TF-IDF值能反应该词在句子中的重要程度,所以在本实施例中,采用TF-IDF对词汇向量进行加权,用词汇向量的加权平均作为句子向量。
在一个实施例中,词向量的TF-IDF计算方式如下:
TF w=词汇向量w在某篇文档中出现的次数/该文档的总词数;
IDF w=log(文档总数/(含词w的文档总数+1));
TF-IDF=TF×IDF。
通过以上的公式定义确定每一个词汇向量在待选文章中的词频逆文档频率。
在步骤S708中,根据所述词频逆文档频率与所述词汇向量确定句子的句子向量。由于待选文章中的句子中每个词汇的语义对句子的语义的影响程度不同,而每个词的TF-IDF值能反应该词的重要程度,在本申请实施例中用TF-IDF值对词进行加权,用词向量的加权平均作为句子向量,具体公式如下:
Figure PCTCN2019101038-appb-000001
其中,V s表示句子s的句子向量,s表示待选文章中的某一个句子,w表示词,V w表示词w的词向量,TF-IDF w表示词w的TF-IDF值。
在步骤S710中,确定所述多个句子的句子向量之间的相似度。可用句子向量的余弦相似度作为句子间的相似度。
在步骤S712中,基于所述相似度构建相似度矩阵。若待选文章含n个句子,则构建一个n×n的相似度矩阵,矩阵中元素ai j(第i行第j列元素)的值为第i个句子和第j个句子间的相似度。
在步骤S714中,将句子作为节点,将相似度作为边的权重,基于所述相似度矩阵构建图模型。
其中,所述相似度矩阵可例如为4×4的矩阵,点集合为(a 1,a 2,a 3,a 4),对应的边集合为(a 12,a 13,……a 34):
Figure PCTCN2019101038-appb-000002
基于此相似度矩阵所构建的图模型具有4个节点,可分别为a 1、a 2、 a 3和a 4。a 1、a 2、a 3和a 4之间对应的矩阵值作为节点间的边的权重。由此,图模型中,a 1、a 2之间的边a 12可记为0.3;a 1、a 3之间的边a 13可记为0.5;a 1、a 4之间的边a 14可记为0.1;以此类推可为图模型中的每一个节点与节点之间的边进行赋值,以构建图模型。
在步骤S716中,基于所述图模型通过迭代获取句子在所述文章中的重要度。可将句子向量之间的余弦相似度作为句子间的相似度,进而通过迭代计算确定句子在文章中的重要度。
例如,可以通过下述公式计算句子之间的相似度,本申请实施例不以此为限:
Figure PCTCN2019101038-appb-000003
其中,S i代表的是第i个句子;S j代表的是第j个句子;w k代表的是句子中第k个词汇;
|S i|与|S j|代表的是句子中词汇的个数;
w k∈S i&w k∈S j代表同时在S i和S j中出现的词汇。
根据上述公式,对候选文章中的句子进行遍历迭代计算,以确定句子之间的相似度。
对于本申请实施例中的图模型,即有向有权图G=(V,E),由点集合V(句子)和边集合E(相似度)组成,E是V×V的子集。图中任两点V i和V j之间边的权重为w ji,对于一个给定的点V i,In(V i)为指向该点的点集合,Out(V i)为点V i指向的点集合。点V i(句子)的重要度得分定义如下:
Figure PCTCN2019101038-appb-000004
其中,ws(V i)代表的是V i这个句子的重要度得分,ws(V j)代表的是V j句子的重要度得分;
d为阻尼系数,取值范围为0到1,代表从图中某一特定点指向其 它任意点的概率,可根据经验值进行设置,例如可取值为0.85;
Figure PCTCN2019101038-appb-000005
代表所有指向V i(句子)点的点(句子)集合,V k∈Out(V j)代表所有V i点(句子)指向的点(句子)集合;
w ji与w jk为V i、V j之间的边与V j、V k之间的边的权重。
使用TextRank算法计算图中各点的得分时,需要给图中的点指定任意的初值,并递归计算直到收敛,在图中任意一点的误差率小于给定的预设值时就可以达到收敛。
在一个实施例中,在迭代计算的过程中,将每个句子的重要度初始化为1。在一个实施例中,判断收敛的预设值取为0.0001。
本申请实施例的人机对话方法,在抽取用户输入信息的关键句子时考虑句子的语义。在传统TextRank算法中,句子的相似度计算没有考虑句子的语义,而本申请实施例的人机对话方法用词频-逆文档频率(TF-IDF)作为词的权重,用句子中所包含词的词向量的加权平均作为句子的向量表示,用该向量来计算句子之间的相似度。
需要注意的是,本申请实施例中训练词向量时采用GloVe模型,此处也可以使用其它词向量模型如连续词袋模型CBOW、Skip-Gram等。
本申请实施例中用词向量的加权平均作为句子的向量表示,本申请实施例的人机对话方法也可以采用其它的句子向量表示方法,如Skip-Thought等方法。
本申请实施例中使用TextRank算法计算文章中句子的重要度时,用到了句子向量间的余弦相似度作为句子间的语义相似度。范数是一种强化了的距离概念,在定义上比距离多了一条数乘的运算法则。在数学上,范数包括向量范数和矩阵范数,向量范数表征向量空间中向量的大小,矩阵范数表征矩阵引起变化的大小。在实际使用中,也可以考虑采用向量间的L1或L2范数等其它距离度量来表示该相似度。
本领域技术人员可以理解实现上述实施例的全部或部分步骤被实现为由CPU执行的计算机程序。在该计算机程序被CPU执行时,执行本申请实施例提供的上述方法所限定的上述功能。所述的程序可以存储于一种计算机可读存储介质中,该存储介质可以是只读存储器,磁盘或 光盘等。
此外,需要注意的是,上述附图仅是根据本申请示例性实施例的方法所包括的处理的示意性说明,而不是限制目的。易于理解,上述附图所示的处理并不表明或限制这些处理的时间顺序。另外,也易于理解,这些处理可以是例如在多个模块中同步或异步执行的。
下述为本申请装置实施例,可以用于执行本申请方法实施例。对于本申请装置实施例中未披露的细节,请参照本申请方法实施例。
图8是根据一示例性实施例示出的一种人机对话装置的框图。人机对话装置80包括:关键词模块802,文章模块804,评分模块806,以及返回信息模块808。
关键词模块802用于从用户的输入信息中提取关键词;可从用户的语音输入信息中提取关键词;或从用户的文字输入信息中提取关键词。
文章模块804用于根据所述关键词确定候选文章;可根据所述关键词在预定平台中进行检索以确定所述候选文章。具体可在近期的公众号文章中检索出几篇于关键词相关的热点新闻文章;还可在主流搜索引擎中对关键词进行搜索,根据检索出的结果进行排序,根据排序由高至低从检索结果中确定所述候选文章。其中,候选文章数量可为一个或多个,本申请实施例不以此为限。
评分模块806用于获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;评分模块806具体可用于:根据所述多个句子中每一个句子在所述文章中的重要度确定第一评分;根据所述多个句子中每一个句子与所述输入信息的相似性确定第二评分;根据所述第一评分与所述第二评分确定评分。
返回信息模块808用于基于评分结果从所述多个句子中提取部分句子生成返回信息。可将所述多个句子按照评分结果进行排序;以及依序(例如由高至低)从所述多个句子中提取部分句子生成所述返回信息。
根据本申请实施例的人机对话装置,通过检索用户问题相关文章,并在相关文章中提取部分语句,生成具有实质内容、包含信息量的返回 信息,能够使得机器人在人机对话过程中产生具有信息量的回答,辅助用户与外界信息进行观点交流。
图9是根据另一示例性实施例示出的一种人机对话装置的框图。如图9所示的人机对话装置90,在如图8所示的人机对话装置80的基础上还包括:词向量训练模块902。
词向量训练模块902用于通过词向量训练算法训练文字数据获取所述词汇向量。在本申请的一个实施例中,可通过GloVe算法对公共网络中的新闻数据或者文章数据进行训练以获取本申请实施例中所用的词汇的词向量。在本申请的一个实施例中,还可通过其它词向量构建算法获取本申请实施例中所用的词汇的词向量,本申请实施例不以此为限。
图10是根据一示例性实施例示出的一种电子设备的框图。
下面参照图10描述根据本申请实施例的电子设备1000。图10显示的电子设备1000仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。
如图10所示,电子设备1000以通用计算设备的形式表现。电子设备1000的组件可以包括但不限于:至少一个处理单元1010(如CPU)、至少一个存储单元1020、连接不同系统组件(包括存储单元1020和处理单元1010)的总线1030、显示单元1040等。
其中,所述存储单元1020存储有程序代码,所述程序代码可以被所述处理单元1010执行,使得所述处理单元1010执行本说明书上述任一实施例描述的人机对话方法的步骤。例如,所述处理单元1010可以执行如图4、图5、图6以及图7中所示的步骤。
所述存储单元1020可以包括易失性存储单元形式的可读介质,例如随机存取存储单元(RAM)10201和/或高速缓存存储单元10202,还可以进一步包括只读存储单元(ROM)10203。
所述存储单元1020还可以包括具有一组(至少一个)程序模块10205的程序/实用工具10204,这样的程序模块10205包括但不限于:操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。
总线1030可以为表示几类总线结构中的一种或多种,包括存储单元总线或者存储单元控制器、外围总线、图形加速端口、处理单元或者使用多种总线结构中的任意总线结构的局域总线。
电子设备1000也可以与一个或多个外部设备1000’(例如键盘、指向设备、蓝牙设备等)通信,还可与一个或者多个使得用户能与该电子设备1000交互的设备通信,和/或与使得该电子设备1000能与一个或多个其它计算设备进行通信的任何设备(例如路由器、调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口1050进行。并且,电子设备1000还可以通过网络适配器1060与一个或者多个网络(例如局域网(LAN),广域网(WAN)和/或公共网络,例如因特网)通信。网络适配器1060可以通过总线1030与电子设备1000的其它模块通信。应当明白,尽管图中未示出,可以结合电子设备1000使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RAID系统、磁带驱动器以及数据备份存储系统等。
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,根据本申请实施例的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中或网络上,包括若干指令以使得一台计算设备(可以是个人计算机、服务器、或者网络设备等)执行根据本申请实施例的上述方法。
图11示意性示出本申请示例性实施例中一种计算机可读存储介质示意图。
参考图11所示,描述了根据本申请的实施例的用于实现上述方法的程序产品1100,其可以采用便携式紧凑盘只读存储器(CD-ROM)并包括程序代码,并可以在终端设备,例如个人电脑上运行。然而,本申请实施例的程序产品不限于此,在本文件中,可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个计算设备执行时,使得该计算设备实现如下功能:从用户的输入信息中提取关键词;根据所述关键词确定候选文章;获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;以及基于评分结果从所述多个句子中提取部分句子生成返回信息。
本领域技术人员可以理解上述各模块可以按照实施例的描述分布于装置中,也可以进行相应变化唯一不同于本实施例的一个或多个装置中。上述实施例的模块可以合并为一个模块,也可以进一步拆分成多个子模块。
以上具体地示出和描述了本申请的示例性实施例。应可理解的是,本申请不限于这里描述的详细结构、设置方式或实现方法;相反,本申请意图涵盖包含在所附权利要求的精神和范围内的各种修改和等效设置。

Claims (15)

  1. 一种人机对话方法,由电子设备执行,包括:
    从用户的输入信息中提取关键词;
    根据所述关键词确定候选文章;
    获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;以及
    基于评分结果从所述多个句子中提取部分句子生成返回信息。
  2. 如权利要求1所述的方法,所述从用户的输入信息中提取关键词,包括:
    从用户的语音输入信息中提取关键词;或
    从用户的文字输入信息中提取关键词。
  3. 如权利要求1所述的方法,所述从用户的输入信息中提取关键词,包括:
    将所述输入信息进行分词处理,以获取多个词汇;
    确定多个词汇的词汇向量;
    通过余弦相似度与词汇向量确定多个词汇之间的相似度;
    根据所述相似度确定多个词汇的重要度;以及
    依据所述重要度的排序确定所述关键词。
  4. 如权利要求1所述的方法,所述根据所述关键词确定候选文章,包括:
    根据所述关键词在预定平台中进行检索以确定所述候选文章。
  5. 如权利要求1所述的方法,所述确定所述多个句子中每一个句子的评分,包括:
    根据所述多个句子中每一个句子在所述文章中的重要度确定第一评分;
    根据所述多个句子中每一个句子与所述输入信息的相似性确定第二评分;
    根据所述第一评分与所述第二评分确定所述每一个句子的评分。
  6. 如权利要求5所述的方法,所述根据所述多个句子中每一个句 子在所述文章中的重要度确定第一评分,包括:
    确定所述多个句子中每一个句子的句子向量;
    确定所述多个句子的句子向量之间的相似度;以及
    基于所述相似度获取每一个句子在所述文章中的重要度以确定所述第一评分。
  7. 如权利要求6所述的方法,所述确定所述多个句子中每一个句子的句子向量,包括:
    将一句子进行分词处理获取多个词汇;
    确定所述多个词汇的词汇向量;
    确定所述多个词汇的词频逆文档频率;以及
    根据所述词频逆文档频率与所述词汇向量确定该句子的句子向量。
  8. 如权利要求6所述的方法,所述基于所述相似度获取每一个句子在所述文章中的重要度以确定第一评分,包括:
    基于所述相似度构建相似度矩阵;
    将句子作为节点,将相似度作为边的权重,基于所述相似度矩阵构建图模型;
    基于所述图模型通过迭代获取每一个句子在所述文章中的重要度;
    通过所述多个句子中每一个句子的重要度确定所述第一评分。
  9. 如权利要求5所述的方法,所述根据所述多个句子中每一个句子与所述输入信息的相似性确定第二评分,包括:
    确定用户输入信息的信息向量;
    确定所述多个句子中每一个句子的句子向量;
    通过余弦相似度确定所述信息向量与每一个句子的句子向量之间的相似性;以及
    通过所述相似性确定所述第二评分。
  10. 如权利要求1所述的方法,所述基于评分结果从所述多个句子中提取部分句子生成返回信息,包括:
    将所述多个句子按照评分结果进行排序;以及
    根据排序结果从所述多个句子中提取部分句子生成所述返回信息。
  11. 如权利要求10所述的方法,所述根据排序结果从所述多个句子中提取部分句子生成所述返回信息,包括:
    对所述部分句子进行自然语言处理以生成所述返回信息。
  12. 如权利要求3或7所述的方法,还包括:
    通过词向量训练算法训练文字数据获取所述词汇向量。
  13. 一种人机对话装置,包括:
    关键词模块,用于从用户的输入信息中提取关键词;
    文章模块,用于根据所述关键词确定候选文章;
    评分模块,用于获取所述候选文章中的多个句子,并确定所述多个句子中每一个句子的评分;以及
    返回信息模块,用于基于评分结果从所述多个句子中提取部分句子生成返回信息。
  14. 一种电子设备,包括:
    一个或多个处理器;
    存储装置,用于存储一个或多个程序;
    当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现如权利要求1-12中任一所述的方法。
  15. 一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现如权利要求1-12中任一所述的方法。
PCT/CN2019/101038 2018-08-29 2019-08-16 人机对话方法、装置、电子设备及计算机可读介质 WO2020042925A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/013,705 US11775760B2 (en) 2018-08-29 2020-09-07 Man-machine conversation method, electronic device, and computer-readable medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810995868.8A CN109284357B (zh) 2018-08-29 2018-08-29 人机对话方法、装置、电子设备及计算机可读介质
CN201810995868.8 2018-08-29

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/013,705 Continuation US11775760B2 (en) 2018-08-29 2020-09-07 Man-machine conversation method, electronic device, and computer-readable medium

Publications (1)

Publication Number Publication Date
WO2020042925A1 true WO2020042925A1 (zh) 2020-03-05

Family

ID=65184174

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/101038 WO2020042925A1 (zh) 2018-08-29 2019-08-16 人机对话方法、装置、电子设备及计算机可读介质

Country Status (4)

Country Link
US (1) US11775760B2 (zh)
CN (1) CN109284357B (zh)
TW (1) TWI732271B (zh)
WO (1) WO2020042925A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111881270A (zh) * 2020-07-01 2020-11-03 北京嘀嘀无限科技发展有限公司 一种智能对话方法和系统
CN113033196A (zh) * 2021-03-19 2021-06-25 北京百度网讯科技有限公司 分词方法、装置、设备及存储介质
CN113869033A (zh) * 2021-09-24 2021-12-31 厦门大学 融入迭代式句对关系预测的图神经网络句子排序方法

Families Citing this family (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109284357B (zh) * 2018-08-29 2022-07-19 腾讯科技(深圳)有限公司 人机对话方法、装置、电子设备及计算机可读介质
CN110188190B (zh) * 2019-04-03 2023-07-14 创新先进技术有限公司 对话解析方法、装置、服务器及可读存储介质
CN110334199A (zh) * 2019-07-09 2019-10-15 北京百度网讯科技有限公司 获得问题答案的方法和装置、电子设备、计算机可读介质
CN110334356B (zh) * 2019-07-15 2023-08-04 腾讯科技(深圳)有限公司 文章质量的确定方法、文章筛选方法、以及相应的装置
CN110414004B (zh) * 2019-07-31 2022-11-18 创新先进技术有限公司 一种核心信息提取的方法和系统
CN110674271B (zh) * 2019-08-27 2023-01-06 腾讯科技(深圳)有限公司 一种问答处理方法及装置
CN110910283A (zh) * 2019-10-18 2020-03-24 平安科技(深圳)有限公司 生成法律文书的方法、装置、设备和存储介质
US11610588B1 (en) * 2019-10-28 2023-03-21 Meta Platforms, Inc. Generating contextually relevant text transcripts of voice recordings within a message thread
CN111144546B (zh) * 2019-10-31 2024-01-02 平安创科科技(北京)有限公司 评分方法、装置、电子设备及存储介质
CN111177355B (zh) * 2019-12-30 2021-05-28 北京百度网讯科技有限公司 基于搜索数据的人机对话交互方法、装置和电子设备
CN111241242B (zh) * 2020-01-09 2023-05-30 北京百度网讯科技有限公司 目标内容的确定方法、装置、设备及计算机可读存储介质
CN111400450B (zh) * 2020-03-16 2023-02-03 腾讯科技(深圳)有限公司 人机对话方法、装置、设备及计算机可读存储介质
CN111476021B (zh) * 2020-04-07 2023-08-15 抖音视界有限公司 输出信息的方法、装置、电子设备和计算机可读介质
CN111832305B (zh) * 2020-07-03 2023-08-25 北京小鹏汽车有限公司 一种用户意图识别方法、装置、服务器和介质
CN111898375B (zh) * 2020-07-30 2023-12-29 混沌时代(北京)教育科技有限公司 一种基于词向量句子链的文章论点论据自动检测划分方法
CN111931494B (zh) * 2020-08-10 2022-06-28 北京字节跳动网络技术有限公司 用于生成预测信息的方法、装置、电子设备和介质
TWI778404B (zh) * 2020-08-20 2022-09-21 國立高雄大學 程式自動生成系統
US11704497B2 (en) * 2020-09-09 2023-07-18 International Business Machines Corporation Generating and using a sentence model for answer generation
CN112017660B (zh) * 2020-10-30 2021-01-12 北京淇瑀信息科技有限公司 一种智能语音机器人的对话策略构建方法、装置及系统
CN112329422A (zh) * 2020-11-03 2021-02-05 中国平安人寿保险股份有限公司 基于TextRank的摘要获取方法、装置、计算机设备及存储介质
CN112380328B (zh) * 2020-11-11 2024-02-06 广州知图科技有限公司 一种安全应急响应机器人交互方法及系统
CN112559868A (zh) * 2020-12-17 2021-03-26 广州博冠信息科技有限公司 信息召回方法、装置、存储介质及电子设备
TWI806000B (zh) * 2021-02-03 2023-06-21 國立成功大學 基於複雜任務分析的對話方法及系統
CN112905765A (zh) * 2021-02-09 2021-06-04 联想(北京)有限公司 一种信息处理方法及装置
US11677692B2 (en) 2021-09-15 2023-06-13 International Business Machines Corporation Conversational systems content related to external events
CN114090747A (zh) * 2021-10-14 2022-02-25 特斯联科技集团有限公司 基于多重语义匹配的自动问答方法、装置、设备及介质
CN114462384B (zh) * 2022-04-12 2022-07-12 北京大学 一种面向数字对象建模的元数据自动生成装置
TWI802459B (zh) * 2022-07-01 2023-05-11 中華電信股份有限公司 基於資料增強推薦問答的系統及方法
CN116628142B (zh) * 2023-07-26 2023-12-01 科大讯飞股份有限公司 知识检索方法、装置、设备及可读存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760128A (zh) * 2011-04-26 2012-10-31 华东师范大学 一种基于智能客服机器人交互的电信领域套餐推荐方法
US20150331851A1 (en) * 2014-02-10 2015-11-19 Commissariat A L'energie Atomique Et Aux Energies Alternatives Assisted input of rules into a knowledge base
CN107562774A (zh) * 2017-07-13 2018-01-09 同济大学 小语种词嵌入模型的生成方法、系统及问答方法和系统
CN107862004A (zh) * 2017-10-24 2018-03-30 科大讯飞股份有限公司 智能排序方法及装置、存储介质、电子设备
CN109284357A (zh) * 2018-08-29 2019-01-29 腾讯科技(深圳)有限公司 人机对话方法、装置、电子设备及计算机可读介质

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW420778B (en) * 1998-05-18 2001-02-01 Inst Information Industry An information retrieval system realized by fuzzy neutral network model
CN101719129A (zh) * 2009-12-31 2010-06-02 浙江大学 一种采用人工智能技术自动提取关键字的方法
US9317498B2 (en) * 2014-05-23 2016-04-19 Codeq Llc Systems and methods for generating summaries of documents
WO2016121048A1 (ja) * 2015-01-29 2016-08-04 株式会社日立製作所 文章生成装置及び方法
CN105159996B (zh) * 2015-09-07 2018-09-07 百度在线网络技术(北京)有限公司 基于人工智能的深度问答服务提供方法和装置
CN105243152B (zh) * 2015-10-26 2018-08-24 同济大学 一种基于图模型的自动文摘方法
CN105653704B (zh) * 2015-12-31 2018-10-12 南京财经大学 自动摘要生成方法及装置
CN105653738B (zh) 2016-03-01 2020-05-22 北京百度网讯科技有限公司 基于人工智能的搜索结果播报方法和装置
US10360265B1 (en) * 2016-08-29 2019-07-23 A9.Com, Inc. Using a voice communications device to answer unstructured questions
CN106446109A (zh) * 2016-09-14 2017-02-22 科大讯飞股份有限公司 语音文件摘要的获取方法和装置
CN107066633A (zh) * 2017-06-15 2017-08-18 厦门创材健康科技有限公司 基于人机互动的深度学习方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760128A (zh) * 2011-04-26 2012-10-31 华东师范大学 一种基于智能客服机器人交互的电信领域套餐推荐方法
US20150331851A1 (en) * 2014-02-10 2015-11-19 Commissariat A L'energie Atomique Et Aux Energies Alternatives Assisted input of rules into a knowledge base
CN107562774A (zh) * 2017-07-13 2018-01-09 同济大学 小语种词嵌入模型的生成方法、系统及问答方法和系统
CN107862004A (zh) * 2017-10-24 2018-03-30 科大讯飞股份有限公司 智能排序方法及装置、存储介质、电子设备
CN109284357A (zh) * 2018-08-29 2019-01-29 腾讯科技(深圳)有限公司 人机对话方法、装置、电子设备及计算机可读介质

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111881270A (zh) * 2020-07-01 2020-11-03 北京嘀嘀无限科技发展有限公司 一种智能对话方法和系统
CN113033196A (zh) * 2021-03-19 2021-06-25 北京百度网讯科技有限公司 分词方法、装置、设备及存储介质
CN113033196B (zh) * 2021-03-19 2023-08-15 北京百度网讯科技有限公司 分词方法、装置、设备及存储介质
CN113869033A (zh) * 2021-09-24 2021-12-31 厦门大学 融入迭代式句对关系预测的图神经网络句子排序方法

Also Published As

Publication number Publication date
US20200401765A1 (en) 2020-12-24
TWI732271B (zh) 2021-07-01
CN109284357B (zh) 2022-07-19
CN109284357A (zh) 2019-01-29
TW202009749A (zh) 2020-03-01
US11775760B2 (en) 2023-10-03

Similar Documents

Publication Publication Date Title
WO2020042925A1 (zh) 人机对话方法、装置、电子设备及计算机可读介质
US11693894B2 (en) Conversation oriented machine-user interaction
CN109829104B (zh) 基于语义相似度的伪相关反馈模型信息检索方法及系统
CN107122413B (zh) 一种基于图模型的关键词提取方法及装置
US9373086B1 (en) Crowdsource reasoning process to facilitate question answering
WO2021017721A1 (zh) 智能问答方法、装置、介质及电子设备
WO2019153737A1 (zh) 用于对评论进行评估的方法、装置、设备和存储介质
US8073877B2 (en) Scalable semi-structured named entity detection
WO2018157789A1 (zh) 一种语音识别的方法、计算机、存储介质以及电子装置
EP3729231A1 (en) Domain-specific natural language understanding of customer intent in self-help
CN111143576A (zh) 一种面向事件的动态知识图谱构建方法和装置
US20130060769A1 (en) System and method for identifying social media interactions
EP3958145A1 (en) Method and apparatus for semantic retrieval, device and storage medium
CN110162771B (zh) 事件触发词的识别方法、装置、电子设备
Lavanya et al. Twitter sentiment analysis using multi-class SVM
CN112989208B (zh) 一种信息推荐方法、装置、电子设备及存储介质
CN110083837B (zh) 一种关键词生成方法及装置
Lommatzsch et al. An Information Retrieval-based Approach for Building Intuitive Chatbots for Large Knowledge Bases.
US20230306205A1 (en) System and method for personalized conversational agents travelling through space and time
CN112182145A (zh) 文本相似度确定方法、装置、设备和存储介质
CN112860865A (zh) 一种智能问答的实现方法、装置、设备及存储介质
CN111813993A (zh) 视频内容的拓展方法、装置、终端设备及存储介质
Alshammari et al. TAQS: an Arabic question similarity system using transfer learning of BERT with BILSTM
Juan An effective similarity measurement for FAQ question answering system
CN116226320A (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: 19856210

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: 19856210

Country of ref document: EP

Kind code of ref document: A1