Question and answer system response method and device, equipment, medium and product
By acquiring and selecting sequential dialogue sequences from users in a question-and-answer system, and performing sequence labeling and intent recognition, the problem of redundant information affecting recognition results in existing technologies is solved, achieving efficient and accurate user intent recognition and reducing operation and maintenance costs.
Patent Information
- Application Number
- CN202210806707.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-08
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2042-07-08
AI Technical Summary
Existing question-answering systems suffer from redundant information that affects the recognition results when identifying users' true intentions, and require frequent model updates. They lack flexibility and efficiency, resulting in high operation and maintenance costs.
By acquiring the sequential dialogue statement sequence submitted by the user, performing sequence labeling and selection, constructing a selected statement sequence, using an intent recognition model to determine the target question intent, and outputting the answer text, the number of dialogue statements is dynamically adjusted to remove noise information.
It achieves accurate identification of users' true intentions, reduces the operation and maintenance costs of the intention recognition model, and improves the intelligence level and user experience of the question-and-answer system.
Smart Images

Figure CN115146124B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of e-commerce information technology, and in particular to a question-and-answer system response method and its corresponding apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology
[0002] In question-and-answer systems, a one-question-one-answer dialogue format is sufficient to solve many problems. However, in many cases, the user's current input may not be enough to reflect their intention. For example, there may be some casual remarks or interjections. In such cases, it is necessary to combine the preceding text to understand the user's true intention. Therefore, multiple rounds of question-and-answer are needed to identify the user's intention. Furthermore, it is possible to guide the user to express complete information and then determine the user's deeper intention.
[0003] The current conventional solution for addressing these requirements is to concatenate the user's current input with the previous N rounds of input before feeding it into the intent recognition model. In this approach, the setting of N relies on human experience, which is unreliable (too small a value may miss information, while too large a value introduces excessive noise) and lacks flexibility. Furthermore, the user's previous N rounds of input may contain redundant and noisy information that doesn't contribute to understanding their intent, ultimately affecting the performance of the intent recognition model. Additionally, this method requires retraining the intent recognition model, and when the model uses similarity matching, it also requires updating all similar vectors in the vector index, resulting in high update and iteration costs.
[0004] Therefore, the ability to efficiently identify a user's true intent in a question-and-answer system is directly related to the level of intelligence of the system, and there is still room for exploration regarding solutions for identifying a user's true intent. Summary of the Invention
[0005] The purpose of this application is to solve the above-mentioned problems by providing a question-and-answer system response method and corresponding apparatus, computer equipment, computer-readable storage medium, and computer program product.
[0006] To suit the various purposes of this application, the following technical solution is adopted:
[0007] In one aspect, a question-answering system response method is provided to suit one of the purposes of this application, comprising:
[0008] Obtain the user statement sequence in the chat history of the current session, wherein the user statement sequence contains multiple consecutive dialogue statements submitted by the user first;
[0009] Based on the sequence labeling information of the user statement sequence, several dialogue statements in the user statement sequence are determined to constitute a selected statement sequence;
[0010] According to the selected sentence sequence, question intention recognition is performed, and a target question intention corresponding to the selected sentence sequence is determined;
[0011] The answer text corresponding to the target question intention is output to the current session.
[0012] Optionally, a user sentence sequence in a chat record of the current session is obtained, the user sentence sequence including sequentially continuous multiple dialogue sentences submitted by the user in advance, including:
[0013] A last dialogue sentence submitted by the user in the current session is received and added to the chat record of the current session;
[0014] Based on the last dialogue sentence, the chat record of the current session is traced back, and the multiple dialogue sentences of the user are obtained in reverse order;
[0015] After text format preprocessing of the sequentially continuous multiple dialogue sentences, the sequentially continuous multiple dialogue sentences are constructed into the user sentence sequence.
[0016] Optionally, according to sequence labeling information of the user sentence sequence, it is determined that a plurality of dialogue sentences in the user sentence sequence constitute a selected sentence sequence, including:
[0017] An encoding vector sequence corresponding to the user sentence sequence is constructed;
[0018] A preset sequence labeling model is used to perform sequence labeling on the encoding vector sequence, to obtain sequence labeling information, the sequence labeling information including a binary classification result of each dialogue sentence in the user sentence sequence;
[0019] According to the sequence labeling information, the user sentence sequence is queried, and dialogue sentences of which the binary classification result represents a positive type are extracted to construct a selected sentence sequence.
[0020] Optionally, before the step of using the preset sequence labeling model, including:
[0021] A single training sample in a data set is called, the training sample being a sample sentence sequence, including a first sample sentence and a second sample sentence that are semantically irrelevant, wherein the multiple first sample sentences are semantically continuous, and the data set is associated with the training sample and is provided with a label sequence, the label sequence including a binary label that distinguishes the first sample sentence and the second sample sentence corresponding to the sample sentence sequence;
[0022] An encoding vector sequence of the single training sample is constructed, the encoding vector sequence including a separator that distinguishes vectors corresponding to each sample sentence;
[0023] Input the sequence of the encoding vectors into a sequence labeling model to realize sequence labeling by decoding, to obtain sequence labeling information, the sequence labeling information including a binary classification result of each sample sentence in the sequence of sample sentences;
[0024] Calculate a loss value of the sequence labeling information according to the label sequence of the single training sample, perform gradient update on the sequence labeling model according to the loss value, and train the sequence labeling model to a convergent state by calling a next training sample from the data set when the sequence labeling model does not converge.
[0025] Optionally, before the step of calling the single training sample in the data set, the method comprises:
[0026] Extract a training sample from pre-collected dialogue data to obtain a corresponding sequence of sample sentences, wherein the sequence of sample sentences includes a plurality of first sample sentences that are semantically coherent;
[0027] Select a plurality of second sample sentences from a text that is semantically irrelevant to the dialogue data, and the number of the second sample sentences is a random integer value in a value interval corresponding to the total number of the first sample sentences;
[0028] Determine an insertion order of each of the second sample sentences in the sequence of sample sentences according to a probability distribution from large to small, and insert the second sample sentences into corresponding positions in the sequence of sample sentences to construct the training sample in the data set.
[0029] Optionally, the question intention recognition is performed according to the selected sequence of sentences to determine a corresponding target question intention, comprising:
[0030] Construct an embedding vector sequence of the selected sequence of sentences;
[0031] Perform feature extraction on the embedding vector sequence by using a preset intention recognition model, and then perform classification mapping to obtain classification probabilities of each question intention in a preset knowledge base;
[0032] The question intention with the largest classification probability is determined as the target question intention.
[0033] Optionally, the question intention recognition is performed according to the selected sequence of sentences to determine a corresponding target question intention, comprising:
[0034] Construct an embedding vector sequence of the selected sequence of sentences;
[0035] Perform feature extraction on the embedding vector sequence by using a preset intention recognition model to obtain a deep semantic vector;
[0036] Calculate vector similarities between the deep semantic vector and deep semantic vectors of each question intention in a preset knowledge base, and determine the question intention with the largest similarity as the target question intention.
[0037] Optionally, the answer text corresponding to the target question intention is output to the current session, including:
[0038] querying an answer set in a preset knowledge base that is mapped to the target question intention, and randomly extracting an answer text in the answer set;
[0039] pushing the answer text to a terminal device of the user to display in a session interface;
[0040] adding the answer text to a chat record of the current session after the terminal device replies to the confirmation information.
[0041] In another aspect, a question and answer system response device is provided to achieve one of the purposes of the present application, and includes a statement calling module, a statement selection module, an intention recognition module, and an automatic response module. The statement calling module is configured to obtain a user statement sequence in a chat record of a current session, and the user statement sequence includes a plurality of sequential and continuous dialogue statements submitted by a user in sequence. The statement selection module is configured to determine a selected statement sequence from the user statement sequence based on sequence labeling information of the user statement sequence. The intention recognition module is configured to recognize a question intention from the selected statement sequence, and determine a target question intention corresponding to the selected statement sequence. The automatic response module is configured to output an answer text corresponding to the target question intention to the current session.
[0042] In yet another aspect, a computer device is provided to achieve one of the purposes of the present application, and includes a central processing unit and a memory. The central processing unit is configured to call and run a computer program stored in the memory to perform the steps of the question and answer system response method described in the present application.
[0043] In yet another aspect, a computer readable storage medium is provided to achieve another purpose of the present application, and stores a computer program implemented according to the question and answer system response method in the form of computer readable instructions. When the computer program is called and run by a computer, the steps included in the method are performed.
[0044] In yet another aspect, a computer program product is provided to achieve another purpose of the present application, and includes a computer program / instruction. When the computer program / instruction is executed by a processor, the steps of the question and answer system response method described in any one of the embodiments of the present application are implemented.
[0045] Compared with the prior art, the present application has many advantages, including but not limited to:
[0046] Firstly, in the judgment of the target question intention of the current session in the question and answer system, the user sentence sequence composed of multiple continuous dialogue sentences submitted by the user in sequence is taken as input, the sequence labeling information of the user sentence sequence is used to select part of the dialogue sentences to form a selected sentence sequence, the question intention recognition is performed according to the selected sentence sequence, the target question intention representing the real intention of the user is determined, and then the answer is given according to the target question intention. Through the above process, the number of dialogue sentences required for identifying the target question sentence can be intelligently determined, the noise information in the chat record of the current session can be removed, and the real intention of the user can be effectively and accurately determined. On the basis of the real intention, the answer text is provided, and the normal conversation interaction of the question and answer system can be ensured.
[0047] Secondly, since the application has the ability to dynamically determine the number of dialogue sentences in the selected sentence sequence, in the scene of using the intention recognition model to recognize the real intention, the selected sentence sequence can be encoded together to form the input, which is provided to the intention recognition model to identify the target question intention. Therefore, without retraining or other modification of the intention recognition model to adapt to the number of dialogue sentences in the selected sentence sequence, the intention recognition model can be used to realize the intention recognition by using the original ability of the intention recognition model. Therefore, it is not necessary to update the semantic vector of the prior knowledge such as the question intention in the knowledge base, and the operation and maintenance cost of the question and answer system can be greatly reduced.
[0048] In addition, the technical solution of the application applied to the e-commerce platform based on independent stations can further improve the intelligent degree of the customer service system, improve the background service capability of the e-commerce platform, improve the use experience of the terminal consumer user, and reduce the cost of artificial customer service. BRIEF DESCRIPTION OF DRAWINGS
[0049] The above and / or additional aspects and advantages of the present application will become apparent and more readily appreciated from the following description, taken in conjunction with the accompanying drawings, in which:
[0050] Figure 1 The flowchart of a typical embodiment of the question and answer system response method of the present application.
[0051] Figure 2 The flowchart of calculating the total similarity score in the embodiment of the present application.
[0052] Figure 3 The flowchart of training the sequence labeling model in the embodiment of the present application.
[0053] Figure 4 The flowchart of constructing the training sample in the embodiment of the present application.
[0054] Figure 5A flowchart of a process for determining a target question intention by using an intention recognition model for classification mapping in an embodiment of the present application.
[0055] Figure 6 A flowchart of a process for determining a target question intention by using another intention recognition model to extract a deep semantic vector and performing similar matching in an embodiment of the present application.
[0056] Figure 7 A principle block diagram of a question and answer system response device of the present application;
[0057] Figure 8 A structural schematic diagram of a computer device used in the present application. DETAILED DESCRIPTION
[0058] Embodiments of the present application are described in detail below with reference to the accompanying drawings, examples of which are shown in the drawings, in which the same or similar notations represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and cannot be interpreted as a limitation on the present application.
[0059] The neural network model referred to or possibly referred to in the present application can be deployed on a remote server and remotely called by a client, or directly called by a client with sufficient device capability, and in some embodiments, when it runs on a client, its corresponding intelligence can be obtained through transfer learning, so as to reduce the requirement for client hardware running resources and avoid excessive occupation of client hardware running resources.
[0060] Unless it is explicitly stated that the various embodiments disclosed in the present application are mutually exclusive, the related technical features involved in each embodiment can be cross combined to flexibly construct new embodiments, as long as such combination does not deviate from the creative spirit of the present application and can meet the needs of the prior art or solve some aspects of the deficiencies in the prior art. For this variation, those skilled in the art should know.
[0061] The question and answer system response method of the present application can be programmed as a computer program product and deployed in a client or a server for running and implementation, for example, in an exemplary application scenario of the present application, it can be deployed and implemented in a server of an e-commerce platform, thereby the interface opened after the computer program product runs can be accessed, the process of the computer program product can be interacted with through a graphical user interface to execute the method.
[0062] Please refer to Figure 1 The question and answer system response method of the present application includes the following steps in a typical embodiment thereof:
[0063] In step S1100, a sequence of user statements in a chat record of a current session is obtained, the sequence of user statements including a plurality of sequentially continuous dialogue statements submitted by the user in advance.
[0064] The question and answer system can be embodied in various forms, such as a customer service system, a chat robot, etc. An e-commerce platform generally configures a corresponding customer service system to provide corresponding question and answer services for platform users. Cross-border e-commerce platforms based on independent stations widely use such customer service systems.
[0065] A user can call a session interface of the question and answer system on a terminal device of the user to start a session between a human and a machine, i.e., a current session. After the user inputs a dialogue statement into the session interface and submits the dialogue statement to a server, the question and answer system performs user intent recognition based on the dialogue statement, determines a corresponding answer text based on a target question intent recognized, answers the dialogue statement with the answer text, and outputs and displays the answer text to the session interface to complete a round of question and answer. A session generally includes multiple rounds of question and answer.
[0066] Meanwhile, the dialogue statement submitted by the user is also stored in a chat record corresponding to the current session and maintained by the server. Naturally, the chat record is associated with the user. The user can start multiple sessions at different times, and chat records corresponding to the sessions can be stored in a related database for calling. Since the user generally performs dialogue based on one or more independent intents each time, the information content included in the chat record corresponding to each session is relatively independent. Of course, in some cases, since the same problem cannot be solved in a single session, the user can solve the problem through multiple sessions, and thus multiple dialogues can be developed around the same intent. In this case, a previous session can be considered as part of a current session, and a historical chat record corresponding to the previous session can be considered as part of a chat record of the current session.
[0067] It is not difficult to understand that in the chat record of the current session, there are dialogue statements corresponding to multiple rounds of question and answer, in which dialogue statements generated by the user are generally question statements corresponding to user needs, intents, and opinions, and dialogue statements generated by the question and answer system are answer texts answering the question statements. Multiple dialogue statements generated by the user can more comprehensively express the real intent of the user, and thus in an embodiment, all dialogue statements submitted by the user in advance in the chat record of the current session can be constructed as a sequence of user statements to identify the user intent based on the sequence of user statements.
[0068] In another embodiment, the sequence of user statements can be obtained according to the following process, which includes the following steps:
[0069] Step S1110, receiving the last dialogue sentence submitted by the user in the current session, adding it to the chat record of the current session;
[0070] The response logic of the question and answer system takes the user-submitted dialogue sentence as the trigger condition, and thus, the response logic of the present application is started in response to each dialogue sentence submitted by the user in the current session, specifically, in response to the submission event of each last dialogue sentence in the human-computer chat process. For archiving needs, the question and answer system adds each dialogue sentence submitted by the user to the chat record corresponding to the current session.
[0071] Step S1120, based on the last dialogue sentence, backtracking the chat record of the current session, and obtaining multiple dialogue sentences of the user in reverse order;
[0072] In the chat record generated in a session, the last dialogue sentence may not fully reflect the real intention of the user, and thus, the multiple dialogue sentences of the user can be obtained in reverse order along the time axis from the last dialogue sentence of the user in the chat record of the current session to comprehensively represent the user's intention. The multiple dialogue sentences can be dialogue sentences submitted by the user in multiple rounds of question and answer that are consecutive in time, and these dialogue sentences can also be regarded as multiple dialogue sentences that are continuous in sequence. The upper limit of the number of dialogue sentences of the user obtained can be the total number of dialogue sentences submitted by the user in the current session, or a predetermined number of multiple dialogue sentences can be obtained by backtracking, which can be flexibly set.
[0073] Step S1130, performing text formatting preprocessing on the multiple dialogue sentences that are continuous in sequence to construct a user sentence sequence.
[0074] The multiple dialogue sentences submitted by the user and obtained from the chat record can be preprocessed in format, including but not limited to removing stop words, removing punctuation marks, removing emoticons, correcting misspelled words, and the like, or any one or a combination of multiple items, to realize data cleaning, so that the sentences are more easily recognized by the computer. The multiple dialogue sentences that have been cleaned above can be organized and constructed into a user sentence sequence in chronological order, i.e., the order of multiple rounds of question and answer, so as to identify the user's intention based on the user sentence sequence.
[0075] According to the above various embodiments, it is not difficult to understand that for the present application to identify the user's intention, multiple dialogue sentences submitted by the user in sequence can be obtained from the chat record of the current session to construct a user sentence sequence as the basic material for mining the user's real intention.
[0076] Step S1200, determining, according to the sequence labeling information of the user sentence sequence, that a plurality of dialogue sentences in the user sentence sequence constitute a selected sentence sequence;
[0077] The dialogue sentences in the user sentence sequence are inconsistent in the amount of information expressing the user's intent. Some dialogue sentences may be completely irrelevant to the user's questioning intent, such as pure exclamation words or pure emoticons without specific meaning. Some dialogue sentences may need to be combined together to express a complete questioning intent, such as the following three sentences collectively representing the real intent corresponding to the purchase of a specific model of mobile phone: "I want to buy that new mobile phone", "that black 6.1 inch screen", "don't buy that old model". Some dialogue sentences may contain irrelevant information to the real intent, such as "you can send it to me early so that I can go out and play early". In summary, different dialogue sentences in the user sentence sequence carry different amounts of information about the user's questioning intent, and therefore need to be identified.
[0078] In an embodiment, the present application can label whether each dialogue sentence in the user sentence sequence is suitable for serving as a selected dialogue sentence required for intent recognition by means of a sequence labeling task, thereby obtaining a predicted label sequence corresponding to whether each dialogue sentence in the user sentence sequence belongs to a selected dialogue sentence as sequence labeling information. By each label in the sequence labeling information, the selected dialogue sentences are extracted from the user sentence sequence and reconstructed into a selected sentence sequence in the order of dialogue, which can constitute an effective basic material for discriminating the user's intent and further identifying the user's questioning intent.
[0079] In an embodiment, a pre-trained sequence labeling model to a convergent state can be used to perform a sequence labeling task on each dialogue sentence in the selected sentence sequence, obtain sequence labeling information through the sequence labeling task, and identify and extract the selected sentence sequence in the user sentence sequence according to the sequence labeling information. The sequence labeling model can be pre-trained to a convergent state with sufficient training samples, and the training samples can be a sample sentence sequence including a plurality of sample sentences, each sample sentence being labeled according to a predetermined label structure to determine whether it belongs to a selected dialogue sentence to form a corresponding label. In the training process, the corresponding label sequence is used to supervise the prediction result of the training sample, and the model is updated by gradient to reach a convergent state through iterative training.
[0080] In an embodiment, the chat records corresponding to the valid conversation can be collected from the historical conversations of the question-answering system, the time-continuous user-submitted dialogue sentences in the chat records can be extracted to construct sample sentence sequences, and noise dialogue sentences can be randomly inserted into the sample sentence sequences. Then, labels are added according to whether the dialogue sentences belong to the noise dialogue sentences, so as to complete the construction and labeling of the training samples, which can be used to train the sequence labeling model.
[0081] In an embodiment, the neural network architecture used by the sequence labeling model can be LSTM+CRF, where LSTM is a long short-term memory network, and CRF is a conditional random field network. The LSTM performs sequence feature extraction and encoding on the input text to obtain a sequence vector representation, and the CRF performs a corresponding labeling task according to the sequence vector representation to obtain the sequence labeling information. It is not difficult to understand that the LSTM can also be other basic models based on recurrent neural networks (RNN) suitable for processing sequence information, such as Bert and Transformer encoders.
[0082] After completing the sequence labeling of the user sentence sequence and obtaining the corresponding sequence labeling information, the sequence labeling information contains corresponding labels for whether each dialogue sentence in the user sentence sequence is a selected dialogue sentence. Therefore, the selected dialogue sentences can be extracted from the user sentence sequence and sequentially organized according to the time sequence of each dialogue sentence to construct a selected sentence sequence.
[0083] It is not difficult to understand that, with the help of the prior knowledge of identifying selected sentences learned by the sequence labeling model, the dialogue sentences in the user sentence sequence can be filtered to remove dialogue sentences that are not helpful for identifying the intent and retain selected dialogue sentences that are helpful for identifying the intent, so as to ensure that the basic materials relied on by the application for identifying the user question intent can effectively provide refined key information, so as to obtain a more accurate intent recognition result.
[0084] Step S1300, question intent recognition is performed according to the selected sentence sequence to determine the corresponding target question intent;
[0085] After obtaining the selected sentence sequence, the intent recognition can be performed according to the selected sentence sequence, and the purpose is to identify the question intent that matches the semantic information provided by each dialogue sentence in the selected sentence sequence, i.e., the target question intent.
[0086] The question-answering system is equipped with a knowledge base containing a large number of question intentions and corresponding answer sets. Each question intention is usually provided with a standard question and multiple similar questions, and each answer set contains multiple answer texts. The correspondence between the question intention and the answer set is the relationship between the question and the answer.
[0087] In an embodiment, a double-tower model architecture built by a text feature extraction model pre-trained to a convergent state can be used to extract feature vectors of the selected sentence sequence and the standard question or similar question of each question intention in the knowledge base through two towers, and then calculate the similarity between the two feature vectors, thereby obtaining the similarity between the selected sentence sequence and each standard question or similar question, and determining the question intention corresponding to the standard question or similar question with the highest similarity as the target question intention.
[0088] In another embodiment, a single text feature extraction model pre-trained to a convergent state is used to extract feature vectors of the standard questions and similar questions in each question intention, and when the intention needs to be identified, the feature vector of the selected sentence sequence is extracted using the text feature extraction model, and the similarity between each feature vector in the question intention and the feature vector of the selected sentence sequence is calculated to determine the question intention corresponding to the standard question or similar question with the highest similarity as the target question intention.
[0089] In another embodiment, an intention classification model is built by using a text feature extraction model followed by a classifier, and the intention classification model is trained to a convergent state in advance using corresponding training samples, so that it learns to obtain a classification result from a given sentence sequence composed of multiple dialogue sentences. The classification result represents the classification probability corresponding to each question intention in the knowledge base, and the question intention with the highest classification probability is determined as the target question intention.
[0090] The text feature extraction model can be a neural network base model based on CNN and RNN and its evolved versions, such as Bert, FastCNN, LSTM, Transformer, BART, etc., which are suitable for encoding embedding vectors for text input, and then extracting deep semantic information of the text based on the embedding vectors to obtain corresponding feature vectors.
[0091] According to the above different embodiments, the deep semantic information of multiple selected dialogue sentences can be extracted from the selected sentence sequence, the information semantics corresponding to the intention can be mined, and the target question intention pointed to by the selected sentence sequence can be accurately obtained.
[0092] Step S1400: Output the answer text corresponding to the target question intention to the current session.
[0093] When the target question intention is determined, the corresponding answer set of the target question intention can be obtained by using the mapping relationship between the question intention and the answer set in the knowledge base, and then one answer text is selected from the answer set and output to the current session to complete the reply to the last dialogue sentence of the user.
[0094] In one embodiment, the step can be implemented according to the following process, including:
[0095] In step S1410, the answer set in the preset knowledge base that is mapped with the target question intention is queried and obtained, and one answer text in the answer set is randomly extracted;
[0096] After the target question intention is determined, the corresponding answer set of the target question intention can be determined from the knowledge base of the question and answer system according to the mapping relationship between the question intention and the answer set. As described above, the answer set includes one or more answer texts, and the multiple answer texts in the same answer set usually express the same meaning with the same expression, and therefore one answer text can be randomly selected for reply to the user.
[0097] In step S1420, the answer text is pushed to the terminal device of the user to be displayed in the session interface;
[0098] For the selected answer text, it can be pushed to the terminal device of the user, so that it is parsed and displayed in the session interface of the current session by the terminal device, so that the user can read the answer text from the session interface and complete a round of human-computer dialogue.
[0099] In step S1430, after the terminal device replies to the confirmation information, the answer text is added to the chat record of the current session.
[0100] When the terminal device receives the answer text, it replies to the server through the background to confirm the identification, and according to the confirmation identification, it can be known that the terminal device has successfully received the answer text, and the answer text has constituted a basic unit in the valid chat record, and therefore the answer text can be added to the chat record corresponding to the current session for later use.
[0101] As known from the above embodiment, since the answer text is selected by comprehensively considering the dialogue sentences submitted by the user in the recent multiple rounds of question and answer, the meaning of the answer text can better match the real question intention of the user, so that the user obtains a satisfactory reply result.
[0102] As known from the above embodiment, the present application has many advantages, including but not limited to:
[0103] Firstly, in the judgment of the target question intention of the current session in the question and answer system, the user sentence sequence composed of multiple continuous dialogue sentences submitted by the user in sequence is taken as input, the part of dialogue sentences in the user sentence sequence is selected according to the sequence labeling information of the user sentence sequence to form a selected sentence sequence, and then the question intention recognition is performed according to the selected sentence sequence to determine the target question intention that can represent the real intention of the user, and then the answer is given according to the target question intention. Through the above process, the number of dialogue sentences required for identifying the target question sentence can be intelligently determined, the noise information in the chat record of the current session can be removed, and the real intention of the user can be effectively and accurately determined. On the basis of the real intention, the answer text is provided, which can ensure the normal progress of the dialogue interaction of the question and answer system.
[0104] Secondly, since the application has the ability to dynamically determine the number of dialogue sentences in the selected sentence sequence, in the scene of using the intention recognition model to recognize the real intention, the selected sentence sequence can be encoded together to form the input, which is provided to the intention recognition model to identify the target question intention. Therefore, without retraining or other modification of the intention recognition model to adapt to the number of dialogue sentences in the selected sentence sequence, the intention recognition model can be used to realize the intention recognition by using the original ability of the intention recognition model. Therefore, it is not necessary to update the semantic vector of the prior knowledge such as the question intention in the knowledge base, which can greatly reduce the operation and maintenance cost of the question and answer system.
[0105] In addition, the technical scheme of the application applied to the e-commerce platform based on independent stations can further improve the intelligent degree of the customer service system, improve the backstage service capability of the e-commerce platform, improve the use experience of the terminal consumer user, and reduce the cost of artificial customer service.
[0106] On the basis of any embodiment of the application, please refer to Figure 2 According to the sequence labeling information of the user sentence sequence, the number of dialogue sentences in the user sentence sequence is determined to form a selected sentence sequence, comprising:
[0107] Step S1210, constructing an encoding vector sequence corresponding to the user sentence sequence;
[0108] For the user sentence sequence S=[A, B, C, D, …], each dialogue sentence A, B, C, D, … in it can be word embedded using a preset word table, and a sentence vector corresponding to each dialogue sentence can be encoded, for example, the sentence vector obtained for the dialogue sentence A is in the form of A=[a1, a2, …].
[0109] Then, according to the requirements of the input parameters of the sequence labeling model, the sentence vectors of the dialogue sentences are used to construct an encoding vector sequence. In the above example, the encoding vector sequence in the form of is obtained.
[0110] [a1,a2,… <sep>b1, b2,... <sep>c1, c2, … <sep>[d1, d2,...]
[0111] In the above example, the separator <sep>is provided to adapt to the input format requirements of the sequence labeling model, and is used to separate different dialogue sentences. For a basic model that requires alignment format for individual inputs, such as a Bert model, the padding identifier required by the basic model, such as the padding identifier in the Bert model, can be inserted into the front part of the encoding vector sequence in the above example. For some basic models, such as LSTM models, the padding identifier does not need to be provided.
[0112] Step S1220, using a preset sequence labeling model, performing sequence labeling on the encoding vector sequence to obtain sequence labeling information, the sequence labeling information including a binary classification result of each dialogue sentence in the user sentence sequence;
[0113] As described above, the sequence labeling model of the present application is trained to a convergent state in advance, and thus learns the ability to perform sequence labeling on the encoding vector sequence. In the sequence labeling model, a text feature extraction model such as Bert or LSTM is usually used to extract features of the encoding vector sequence to obtain feature representations corresponding to deep semantic information of the encoding vector sequence. Then, through a conditional random field model such as CRF, the feature representations are mapped to a binary classification space corresponding to each dialogue sentence to obtain a binary classification result corresponding to each dialogue sentence. All binary classification results constitute the sequence labeling information corresponding to the user sentence sequence obtained by the sequence labeling model. The sequence labeling information provides a binary classification result for each dialogue sentence in the user sentence sequence one by one through the position mapping relationship. Through this position mapping relationship, it can be determined from the sequence labeling information that each dialogue sentence in the user sentence sequence belongs to which category of label. Specifically, the binary classification result corresponding to each dialogue sentence includes classification probabilities of the corresponding dialogue sentence mapped to a positive category and a negative category. The category with the largest classification probability is the category corresponding to the dialogue sentence, wherein the positive category indicates that the corresponding dialogue sentence is predicted to be a selected dialogue sentence, which can be used as a basic material required for intent recognition. The negative category indicates that the corresponding dialogue sentence is predicted to be a redundant or noise sentence, which cannot be used as a basic material required for intent recognition.
[0114] Step S1230, querying the user sentence sequence according to the sequence labeling information to extract dialogue sentences whose binary classification results represent the positive type to construct a selected sentence sequence.
[0115] Since the binary classification result in the sequence labeling information has a one-to-one mapping relationship with the dialogue sentences in the user sentence sequence, it is not difficult to understand that according to the category pointed by the binary classification result in the sequence labeling information, the category label corresponding to each dialogue sentence can be determined, and accordingly, the dialogue sentences belonging to the positive category in the user sentence sequence can be determined as the selected dialogue sentences, and the dialogue sentences belonging to the negative category can be discarded. The selected dialogue sentences are sequentially organized according to the original dialogue order, and a selected sentence sequence can be constructed.
[0116] According to the above embodiments, by constructing the corresponding encoding vector sequence of the user sentence sequence, using the ability of the pre-trained sequence labeling model to identify selected dialogue sentences, the selected dialogue sentences in the user sentence sequence can be quickly and efficiently identified. These selected dialogue sentences are strongly associated with the user's real question intention, and the redundant or noise sentences in the original user sentence sequence have been discarded, so as to ensure that the selected dialogue sentences highly condense the expression content corresponding to the user's real question intention. According to the selected sentence sequence, the intention recognition can make the identification of the user's question intention more accurate.
[0117] Similarly, it can be known that by means of the sequence labeling model for selecting dialogue sentences of the user sentence sequence, the number of dialogue sentences required to be selected does not need to be manually set, the intention recognition model does not need to be modified, the intention recognition model can obtain standardized input, and the original question and answer system does not need to be modified, which can greatly reduce the maintenance and upgrading cost of the question and answer system.
[0118] On the basis of any embodiment of the present application, please refer to Figure 3 Before the step of adopting the preset sequence labeling model, the step includes:
[0119] In step S2100, a single training sample in the data set is called, the training sample is a sample sentence sequence, includes a first sample sentence and a second sample sentence which are semantically irrelevant, the plurality of first sample sentences are semantically coherent, and the data set is provided with a label sequence associated with the training sample. The label sequence corresponding to the sample sentence sequence contains a binary label distinguishing the first sample sentence and the second sample sentence.
[0120] In order to train the sequence labeling model of the present application, a data set can be prepared, and then each training sample in the data set is input into the sequence labeling model for training, and the provided label sequence corresponding to the training sample is used as a supervision label to calculate the loss value of the current iteration training, and the sequence labeling model is updated according to the loss value.
[0121] The training sample in the data set is constructed as a sample sentence sequence, and the sample sentence sequence is composed of multiple dialogue sentences, wherein the multiple dialogue sentences can include first sample sentences and second sample sentences that are semantically irrelevant to each other, for example, "I want to buy a phone case" and "I want to go drinking". The first sample sentence can be regarded as a dialogue sentence used to express a user's intent, and the second sample sentence can be regarded as a redundant or noise sentence that plays a disturbing role. In this way, the sample sentences are selected. A training sample usually includes multiple first sample sentences and a small number of second sample sentences, so as to highlight the role of the first sample sentences in expressing the intent. It is not difficult to understand that, in the same training sample, the multiple first sample sentences are semantically coherent dialogue sentences, which are more helpful to shape the nature of expressing the user's intent. However, the multiple second sample sentences can be any content that is semantically completely incoherent to each other.
[0122] In one embodiment, the first sample sentences and the second sample sentences can be selected from the chat records of any question and answer system, for example, an e-commerce customer service system. All dialogue sentences submitted by the corresponding user in the same session are arranged in order as the first sample sentences, and dialogue sentences are randomly extracted from other users or other content irrelevant sessions of the same user as the second sample sentences. Each second sample sentence is randomly distributed and inserted into multiple first sample sentences to form a new arrangement set, that is, a sample sentence sequence of a training sample is obtained.
[0123] The label sequence provided corresponding to the training sample is used as a supervision label. In the sequence label, a binary label is included for whether each sample sentence in the sample sentence sequence of the training sample should belong to the selected dialogue sentence, for example, for the sample sentence sequence S' = [x1, A, B, x2, C, D,...], wherein x1 and x2 represent the second sample sentences, and A, B, C, D,... represent the first sample sentences. The corresponding label sequence can be represented as L = [0, 1, 1, 0, 1, 1,...]. Wherein 1 represents that the corresponding dialogue sentence is the first sample sentence, which is the preferred sentence and can be used as the selected dialogue sentence, belonging to the positive category; 0 represents that the corresponding dialogue sentence is the second sample sentence, which is the interfering sentence and cannot be used as the selected dialogue sentence, belonging to the negative category.
[0124] In step S2200, an encoding vector sequence of the single training sample is constructed, and the encoding vector sequence includes a separator that distinguishes vectors corresponding to each sample sentence.
[0125] Corresponding to the stage in which the sequence labeling model is used for online inference in the present application, in the training stage, the sample sentence sequence of each training sample used for training also needs to be encoded according to the corresponding rules to obtain the corresponding encoding vector sequence thereof. For example, for the exemplary sample sentence sequence S' = [x1, A, B, x2, C, D,...], an example of the corresponding encoding vector sequence thereof is:
[0126] [x11, x12... <sep>a1, a2,... <sep>b1, b2,... <sep>x21, x22... <sep>c1, c2,... <sep>, d1, d2,...
[0127] wherein the vector [x11, x12,...] and the vector [x21, x22,...] correspond to the second sample sentences x1 and x2, and the vectors [a1, a2,...], [b1, b2,...], [b1, b2,...], [b1, b2,...] correspond to the first sample sentences A, B, C, D respectively.
[0128] As the foregoing, in the encoding vector sequence of the above example, the separator <sep>is provided to adapt to the input format requirements of the sequence labeling model, and is used to separate different dialogue sentences. For a basic model that requires alignment format for individual inputs, such as a Bert model, the padding identifier required by the basic model, such as the padding identifier in the Bert model, can be inserted into the front part of the encoding vector sequence of the above example. For some basic models such as LSTM models, the padding identifier does not need to be provided.
[0129] Step S2300, inputting the encoding vector sequence into the sequence labeling model for decoding to realize sequence labeling and obtain sequence labeling information, the sequence labeling information including the binary classification results of each sample sentence in the sample sentence sequence;
[0130] Similarly, after the encoding vector sequence is input into the sequence labeling model, the feature extraction model is used for feature extraction and decoding to obtain a feature vector corresponding to the deep semantic, and then the corresponding sequence labeling information is obtained under the action of the conditional random field. The sequence labeling information includes labels corresponding to each dialogue sentence in the sample sentence sequence. The label can be expressed in the form of binary classification probability distribution input into the conditional random field, or can be converted into a binary result represented by 1 or 0, which can be flexibly processed.
[0131] Step S2400, calculating a loss value of the sequence labeling information according to the label sequence of the single training sample, performing gradient update on the sequence labeling model according to the loss value, and calling the next training sample from the data set to train the sequence labeling model to a convergent state when the sequence labeling model does not converge.
[0132] After obtaining the sequence labeling information corresponding to the single training sample, the label sequence corresponding to the training sample is used as a supervision label, and the cross-entropy loss corresponding to the sequence labeling information can be calculated to obtain a corresponding loss value. Then, a preset threshold for judging whether the sequence labeling model reaches a convergent state is used to judge whether the loss value reaches the preset threshold. When the loss value reaches the preset threshold, it indicates that the sequence labeling model has reached a convergent state, and the training task can be terminated. Otherwise, it indicates that the sequence labeling model has not converged. At this time, the gradient update can be performed on the sequence labeling model according to the loss value to correct the weight parameters, so as to further approach the convergence. Then, the next training sample is called from the data set to continue the iterative training of the sequence labeling model. In this way, the sequence labeling model is trained to a convergent state, and the sequence labeling model can be used for online inference application in the present application.
[0133] According to the above embodiments, the sequence labeling model can convert the recognition of multiple dialogue sentences into a sequence task, so as to be not limited by the number of dialogue sentences in the input sample sentence sequence, but can recognize the selected sentence sequence from the entire sample sentence sequence, and can be further used to implement the intent recognition. In the training process of the sequence labeling model, the training samples can be selected from the historical dialogue data, the first sample sentences are organized according to the time sequence relationship of the dialogue data, and the second sample sentences required to be combined according to different conversations and different users are organized, so as to construct the training samples, and the label sequence can be automatically generated according to the source of different sample sentences, without manual intervention, the construction efficiency of the data set is very high, the implementation cost of the sequence labeling model can be greatly reduced, and the sequence labeling model can also ensure the ability of accurately recognizing the selected dialogue sentences with the help of the historical chat record of the question and answer system, so that the selected sentence sequence has more expression of the real question intention of the user, thereby guiding the intent recognition model to accurately recognize the real intention of the user.
[0134] On the basis of any embodiment of the present application, please refer to Figure 4 Before the step of calling a single training sample in the data set, comprising:
[0135] Step S3100, extracting a training sample from the pre-acquired dialogue data to obtain a corresponding sample sentence sequence, which includes a plurality of first sample sentences with semantic coherence;
[0136] The dialogue data can be extracted from the historical chat record of the question and answer system, for example, from the historical chat record of the customer service system of the independent station of the served e-commerce platform, so that after the corresponding sequence labeling model is trained by using these training samples, the semantic concentration of the commodity information of the corresponding independent station can be used to ensure that the selected sentence sequence recognized by the sequence labeling model can be used to more accurately recognize the real intention of the user.
[0137] The principle of extracting the training sample from the historical chat record of the independent station can be referred to in the previous embodiment, that is, using the time sequence coherent multiple dialogue sentences or even the full amount of dialogue sentences in the same conversation of the same user as the first sample sentence, and each training sample can be based on each corresponding conversation to prepare the first sample sentence.
[0138] Step S3200, obtaining a plurality of second sample sentences in the text irrelevant to the semantics of the dialogue data, and the number of second sample sentences is randomly rounded to an integer value in a value interval corresponding to the total amount of first sample sentences;
[0139] Further, the dialogue sentence generated in the conversation of other users or other conversations of the same user can be used as the second sample sentence, or the first sample sentence is randomly obtained from other training samples different from the current training sample as the second sample sentence of the current training sample. Generally, it is understood that the second sample sentence is not semantically related to the first sample sentence of the current training sample, that is, the intents pointed to by the two are different, or the second sample sentence cannot fully express a certain user intent, while the first sample sentence can express the user intent.
[0140] In order to maintain the necessary information amount of the first sample sentence, the number of second sample sentences in the same training sample can be constrained, so that the total amount of second sample sentences in the same training sample is not higher than the total amount of first sample sentences, for example, when the total amount M of first sample sentences in the training sample is determined, the total amount N of second sample sentences in the training sample is determined according to the following formula:
[0141] N = Floor(a*M)
[0142] Wherein, a is a random number, and is subject to (0, 2) uniform distribution, and the function Floor represents the down rounding.
[0143] According to the above principle, it is not difficult to understand that the number of second sample sentences in a training sample is always constrained in the value interval (0, 2M), and is an integer value, which reasonably constrains the number relationship between the first sample sentence and the second sample sentence, avoids excessive second sample sentences from causing information interference to the limited first sample sentences, and can ensure easier convergence during model training.
[0144] Step S3300, according to the probability distribution from large to small, determine the insertion order of each second sample sentence in the sample sentence sequence and insert it into the corresponding position of the sample sentence sequence, and construct the training sample in the data set.
[0145] In order to construct the training sample by using multiple first sample sentences and multiple second sample sentences, the arrangement relationship of each first sample sentence and second sample sentence can be reconstructed. Specifically, the normalized random weight of the full amount of sample sentences in the training sample can be obtained first, so that the sum of the weights of each sample sentence is 1, for example, the Softmax() function is used to normalize to obtain the random weight, so that each sample sentence has a corresponding distribution probability. Then, according to the probability distribution principle from large to small, according to the distribution probability from large to small, the arrangement of each sample sentence is rearranged, and the corresponding training sample can be constructed.
[0146] According to the above embodiments, by constraining the number of second sample sentences relative to the first sample sentences, and constraining the arrangement relationship between the first sample sentences and the second sample sentences, the training samples can be generalized, and the sequence labeling model can be quickly trained to a convergent state by using the training samples to train the sequence labeling model, thereby reducing the training cost and achieving significant training results.
[0147] On the basis of any embodiment of the present application, refer to Figure 5 According to the question intention recognition based on the selected sentence sequence, the corresponding target question intention is determined, which includes:
[0148] Step S1311, constructing an embedding vector sequence of the selected sentence sequence;
[0149] The selected sentence sequence can be constructed into an embedding vector sequence according to the input required by the text feature extraction model in the intention recognition model selected in the embodiment, specifically, each dialogue sentence in the selected sentence sequence can be independently tokenized and sentence vectors can be prepared, and then each sentence vector can be spliced into an embedding vector sequence according to the appearance order in the chat record, which can adapt to the input required by the model, and a separator can be inserted between different sentence vectors.
[0150] Step S1312, using a preset intention recognition model to perform feature extraction on the embedding vector sequence and then perform classification mapping to obtain classification probabilities of each question intention in the preset knowledge base;
[0151] The intention recognition model of the embodiment is a classification model, which is composed of a text feature extraction model followed by a multi-classifier, wherein the text feature extraction model selects a basic model suitable for extracting deep semantic information of text such as Bert and LSTM, and after the deep semantic vector is obtained from the embedding vector sequence by the text feature model, it is input into the multi-classifier for full connection and classification mapping, which is mapped into the categories corresponding to each question intention in the knowledge base respectively, and the classification probabilities of each category are generated.
[0152] Of course, the classification model has been trained in a convergent state in advance, so that it can acquire the ability to obtain the corresponding classification result according to the input embedding vector sequence.
[0153] Step S1313, taking the question intention with the largest classification probability as the target question intention.
[0154] As can be easily understood, the question intention corresponding to the category with the largest classification probability in the classification result obtained by the intention recognition model for the embedding vector sequence is the real question intention corresponding to the selected sentence sequence, and therefore, the question intention is directly determined as the target question intention, and the corresponding answer text can be determined according to the target question intention.
[0155] According to the above embodiments, the selected sentence sequence selected by the application can be provided to the intent recognition model for classification mapping, effectively identifying the user's true intent. Since the selected sentence sequence is selected from the multiple dialogue sentences of the historical chat record of the current session of the user, the semantic representation is more concise. Therefore, the intent recognition model of the embodiment can quickly determine the target question intent by classification mapping, accurately determine the user's intent, and then determine the effective answer text, making the human-computer dialogue more effective.
[0156] On the basis of any embodiment of the application, please refer to Figure 6 According to the selected sentence sequence for question intent recognition, the corresponding target question intent is determined, which includes:
[0157] Step S1321, constructing an embedding vector sequence of the selected sentence sequence;
[0158] The selected sentence sequence can be constructed as an embedding vector sequence according to the input required by the text feature extraction model in the intent recognition model selected by the embodiment. Specifically, each dialogue sentence in the selected sentence sequence can be independently tokenized and sentence vector is prepared, and then each sentence vector is spliced into an embedding vector sequence according to the appearance order in the chat record, which can adapt to the input required by the model, and a separator can be inserted between different sentence vectors.
[0159] Step S1322, using a preset intent recognition model to extract features of the embedding vector sequence to obtain a deep semantic vector;
[0160] The intent recognition model of the embodiment can only include a text feature extraction model. The text feature extraction model is trained to a convergent state by a classifier in advance, so that it learns the ability to accurately extract the corresponding deep semantic vector of the deep semantic information from the embedding vector sequence. The text feature extraction model can be the text feature extraction model in the previous embodiment, but it does not need to carry multiple classifiers in the online inference stage.
[0161] When it is necessary to recognize the intent based on the selected sentence sequence, the intent recognition model of the embodiment is used to represent the features, and the corresponding deep semantic vector is obtained by extracting the deep semantic information. Similarly, the standard question and similar question of each question intent in the knowledge base of the question and answer system also use the intent recognition model of the embodiment to extract the corresponding deep semantic vector in advance and store it in association for calling.
[0162] Step S1323, calculating vector similarity between the deep semantic vector and the deep semantic vector of each question intention in the preset knowledge base, and determining the question intention with the largest similarity as the target question intention.
[0163] In the need of determining the target question intention corresponding to the selected sentence sequence, the data distance between the deep semantic vector of the selected sentence sequence and the deep semantic vector of each question intention in the knowledge base, specifically the deep semantic vector of the standard question and the similar question in the question intention, is calculated, the data distance is converted into similarity, and in an embodiment, the similarity of each question intention can be averaged to obtain a single similarity, so as to obtain the similarity between the selected sentence sequence and each question intention in the knowledge base. It is not difficult to understand that the question intention corresponding to the largest similarity is the target question intention corresponding to the selected sentence sequence.
[0164] In the calculation of the data distance between two deep semantic vectors, any one of cosine similarity algorithm, Euclidean distance algorithm, Pearson correlation coefficient algorithm and Jaccard coefficient algorithm can be used for calculation.
[0165] According to the above embodiment, the selected sentence sequence obtained by the application can be matched with the deep semantic vector of each question intention in the knowledge base after the deep semantic vector is extracted by the intention recognition model of the embodiment, and the question intention with the largest similarity is obtained as the target question intention of the user. Similarly, since the selected sentence sequence is selected from the multiple dialogue sentences of the historical chat record of the current session of the user, the semantic representation is more concise, and therefore, with the help of the precise feature representation of the intention recognition model of the embodiment, the target question intention can be quickly determined through similarity matching, the precise discrimination of the user's intention is realized, and the effective answer text is determined, so that the human-computer conversation is more effective.
[0166] Please refer to Figure 7 To adapt to one of the purposes of the present application, a question and answer system response device is provided, which is a functional embodiment of the question and answer system response method of the present application. The device comprises a sentence calling module 1100, a sentence selection module 1200, an intention recognition module 1300, and an automatic response module 1400. The sentence calling module 1100 is configured to obtain a user sentence sequence in a chat record of a current session, wherein the user sentence sequence comprises a plurality of sequential continuous dialogue sentences submitted by a user in sequence. The sentence selection module 1200 is configured to determine a selected sentence sequence comprising a plurality of dialogue sentences in the user sentence sequence according to sequence labeling information of the user sentence sequence. The intention recognition module 1300 is configured to perform question intention recognition according to the selected sentence sequence to determine a target question intention corresponding to the selected sentence sequence. The automatic response module 1400 is configured to output an answer text corresponding to the target question intention to the current session.
[0167] On the basis of any embodiment of the present application, the sentence calling module 1100 comprises a last receiving unit configured to receive a last dialogue sentence submitted by a user in a current session and add the last dialogue sentence to a chat record of the current session; a backtracking calling unit configured to backtrack the chat record of the current session based on the last dialogue sentence and obtain a plurality of dialogue sentences of the user in reverse order; and a format processing unit configured to construct the plurality of sequential continuous dialogue sentences into a user sentence sequence after text format preprocessing.
[0168] On the basis of any embodiment of the present application, the sentence selection module 1200 comprises an encoding processing unit configured to construct an encoding vector sequence corresponding to the user sentence sequence; a sequence labeling unit configured to perform sequence labeling on the encoding vector sequence by using a preset sequence labeling model to obtain sequence labeling information, wherein the sequence labeling information comprises a binary classification result of each dialogue sentence in the user sentence sequence; and an extraction and construction unit configured to query the user sentence sequence according to the sequence labeling information, extract dialogue sentences of a positive type represented by the binary classification result from the user sentence sequence, and construct the dialogue sentences into a selected sentence sequence.
[0169] On the basis of any embodiment of the present application, before the sequence labeling unit, comprising: a sample calling module, configured to call a single training sample in a data set, the training sample being a sample sentence sequence, comprising a first sample sentence and a second sample sentence irrelevant in semantics, wherein the plurality of first sample sentences are semantically coherent, and the data set is provided with a label sequence associated with the training sample, and the label sequence corresponding to the sample sentence sequence contains a binary label distinguishing the first sample sentence and the second sample sentence; an encoding construction module, configured to construct an encoding vector sequence of the single training sample, the encoding vector sequence containing a separator distinguishing vectors corresponding to each sample sentence; a sequence prediction module, configured to input the encoding vector sequence into a sequence labeling model for decoding to realize sequence labeling, and obtain sequence labeling information, the sequence labeling information containing a binary classification result of each sample sentence in the sample sentence sequence; and an iterative updating module, configured to calculate a loss value of the sequence labeling information according to the label sequence of the single training sample, perform gradient updating on the sequence labeling model according to the loss value, and call a next training sample from the data set to train the sequence labeling model to a convergent state when the sequence labeling model does not converge.
[0170] On the basis of any embodiment of the present application, before the sample calling module, comprising: a sample extraction module, configured to extract a training sample from pre-acquired dialogue data to obtain a corresponding sample sentence sequence, wherein the sample sentence sequence comprises a plurality of first sample sentences semantically coherent; a noise reference module, configured to select a plurality of second sample sentences in a text irrelevant in semantics to the dialogue data, and the number of the second sample sentences is randomly rounded to an integer value in a value interval corresponding to the total amount of the first sample sentences; and a noise preset module, configured to determine an insertion order of each of the second sample sentences in the sample sentence sequence according to a probability distribution from large to small, and insert the second sample sentences into corresponding positions of the sample sentence sequence, thereby constructing the training sample in the data set.
[0171] On the basis of any embodiment of the present application, the intent recognition module 1300 comprises: an encoding processing unit, configured to construct an embedding vector sequence of the selected sentence sequence; an intent classification unit, configured to perform feature extraction on the embedding vector sequence and then perform classification mapping by using a preset intent recognition model, to obtain classification probabilities of each question intent mapped to a preset knowledge base; and a target determination unit, configured to take the question intent with the largest classification probability as a target question intent.
[0172] On the basis of any embodiment of the present application, the intention recognition module 1300 comprises: an encoding processing unit configured to construct an embedding vector sequence of the selected sentence sequence; a feature extraction unit configured to extract deep semantic vectors by using a preset intention recognition model on the embedding vector sequence; and a similarity matching unit configured to calculate vector similarities between the deep semantic vectors and deep semantic vectors of each question intention in a preset knowledge base, and determine a question intention with the largest similarity as the target question intention.
[0173] On the basis of any embodiment of the present application, the automatic answering module 1400 comprises: a query extraction unit configured to query an answer set in the preset knowledge base that is mapped to the target question intention, and randomly extract an answer text in the answer set; a push display unit configured to push the answer text to a terminal device of the user to display in a conversation interface; and a data archiving unit configured to add the answer text to a chat record of the current conversation after receiving a reply confirmation information from the terminal device.
[0174] To solve the above technical problems, the embodiments of the present application further provide a computer device. As shown in the Figure 8 computer device comprises a processor, a computer readable storage medium, a memory and a network interface connected through a system bus. The computer readable storage medium of the computer device stores an operating system, a database and computer readable instructions. The database can store a control information sequence. When the computer readable instructions are executed by the processor, the processor can implement a commodity search category identification method. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The memory of the computer device can store computer readable instructions. When the computer readable instructions are executed by the processor, the processor can execute the question and answer system answering method of the present application. The network interface of the computer device is used to connect and communicate with the terminal. Those skilled in the art can understand that Figure 8 the structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0175] In the present embodiment, the processor is used to execute the specific functions of each module and its sub-modules in Figure 7 the memory stores the program codes and various data required for executing the above-mentioned modules or sub-modules. The network interface is used for data transmission between the user terminal or the server. The memory in the present embodiment stores the program codes and data required for executing all modules / sub-modules in the question and answer system answering device of the present application. The server can call the program codes and data of the server to execute the functions of all sub-modules.
[0176] The application further provides a storage medium storing computer readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the question and answer system response method of any of the embodiments of the application.
[0177] The application further provides a computer program product, comprising computer programs / instructions, which, when executed by one or more processors, implement the steps of the method described in any of the embodiments of the application.
[0178] A person of ordinary skill in the art can understand that all or part of the processes in the method of the above-mentioned embodiments of the application can be completed by a computer program instructing relevant hardware, and the computer program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments of the method. The storage medium can be a computer readable storage medium such as a magnetic disc, an optical disc, a read-only memory (ROM), or a random access memory (RAM).
[0179] In summary, the application automatically selects the prior dialogue sentence submitted by the user to avoid introducing noise information for the recognition of the real intention of the user, can improve the recognition ability of the real intention of the user in the question and answer system, accurately understand the user's intention and accurately reply, can improve the user experience of the question and answer system, reduce the operation cost of the background, and is suitable for the use of the independent station of the e-commerce platform.< / sep> < / sep> < / sep> < / sep> < / sep> < / sep> < / sep> < / sep> < / sep>
Claims
1. A question-and-answer system response method, characterized in that, include: Obtain the user statement sequence in the chat history of the current session, wherein the user statement sequence contains multiple consecutive dialogue statements submitted by the user first; Based on the sequence labeling information of the user statement sequence, several dialogue statements in the user statement sequence are identified as constituting a selected statement sequence, including: constructing an encoding vector sequence corresponding to the user statement sequence; using a preset sequence labeling model to perform sequence labeling on the encoding vector sequence to obtain sequence labeling information, the sequence labeling information containing binary classification results for each dialogue statement in the user statement sequence; querying the user statement sequence based on the sequence labeling information, extracting dialogue statements whose binary classification results represent positive types to construct a selected statement sequence; the sequence labeling model is trained to a convergent state using training samples containing sample statement sequences labeled with binary labels, and learns the ability to perform binary classification judgment on whether each dialogue statement in the user statement sequence belongs to a selected statement; Based on the selected sentence sequence, question intent is identified to determine the corresponding target question intent; Output the answer text corresponding to the target question intent to the current session.
2. The question-and-answer system response method according to claim 1, characterized in that, Retrieve the user statement sequence from the chat history of the current session, wherein the user statement sequence contains multiple sequentially submitted dialogue statements by the user, including: Receive the last dialogue statement submitted by the user in the current session and add it to the chat history of the current session; Based on the last dialogue statement, trace back the chat history of the current session and retrieve multiple dialogue statements of the user in reverse order; The multiple sequential dialogue statements are preprocessed with text formatting to construct a user statement sequence.
3. The question-and-answer system response method according to claim 1, characterized in that, Before employing a pre-defined sequence labeling model, the following steps are included: A single training sample from the dataset is called. The training sample is a sequence of sample sentences, including a first sample sentence and a second sample sentence that are semantically unrelated. Multiple first sample sentences are semantically connected. The dataset is associated with a label sequence for the training sample. The label sequence contains a binary label that distinguishes between the first sample sentence and the second sample sentence. Construct an encoding vector sequence for the single training sample, wherein the encoding vector sequence contains a delimiter that distinguishes the vectors corresponding to the statements in each sample; The encoded vector sequence is input into the sequence labeling model for decoding to achieve sequence labeling and obtain sequence labeling information, which includes the binary classification results of each sample statement in the sample statement sequence. The loss value of the sequence labeling information is calculated based on the label sequence of the single training sample. The sequence labeling model is then updated using gradients based on the loss value. If the sequence labeling model has not converged, the next training sample is retrieved from the dataset to train the sequence labeling model to a convergent state.
4. The question-and-answer system response method according to claim 3, characterized in that, Before the step of calling a single training sample from the dataset, the following steps are included: Training samples are extracted from pre-collected dialogue data to obtain their corresponding sample sentence sequences, including multiple semantically coherent first sample sentences. Multiple second sample statements are obtained from texts that are semantically unrelated to the dialogue data. The number of second sample statements is randomly selected from an integer value within a numerical range corresponding to the total number of first sample statements. The insertion order of each second sample statement in the sample statement sequence is determined according to the probability distribution from largest to smallest, and the statements are inserted into the corresponding positions in the sample statement sequence to construct the training samples in the dataset.
5. The question-and-answer system response method according to claim 1, characterized in that, Based on the selected statement sequence, question intent is identified to determine the corresponding target question intent, including: Construct the embedding vector sequence of the selected statement sequence; Using a preset intent recognition model, the embedded vector sequence is subjected to feature extraction and classification mapping to obtain the classification probability of each question intent mapped to a preset knowledge base; The question intent with the highest classification probability is taken as the target question intent.
6. The question-and-answer system response method according to any one of claims 1 to 5, characterized in that, Based on the selected statement sequence, question intent is identified to determine the corresponding target question intent, including: Construct the embedding vector sequence of the selected statement sequence; A deep semantic vector is obtained by extracting features from the embedded vector sequence using a preset intent recognition model. Calculate the vector similarity between the deep semantic vector and the deep semantic vector of each question intent in the preset knowledge base, and determine the question intent with the highest similarity as the target question intent.
7. A question-and-answer system response device, characterized in that, include: The statement invocation module is used to obtain the user statement sequence in the chat history of the current session, wherein the user statement sequence contains multiple dialogue statements submitted by the user in a sequential order. The statement selection module is used to determine a selected statement sequence from several dialogue statements in the user statement sequence based on the sequence labeling information of the user statement sequence. This includes: constructing an encoding vector sequence corresponding to the user statement sequence; using a preset sequence labeling model to perform sequence labeling on the encoding vector sequence to obtain sequence labeling information, which includes binary classification results for each dialogue statement in the user statement sequence; querying the user statement sequence based on the sequence labeling information and extracting dialogue statements whose binary classification results represent positive types to construct the selected statement sequence; the sequence labeling model is trained to a convergent state using training samples containing sample statement sequences labeled with binary tags, learning the ability to perform binary classification judgments on whether each dialogue statement in the user statement sequence belongs to the selected statements. The intent recognition module is used to identify the questioning intent based on the selected statement sequence and determine its corresponding target questioning intent; The automatic response module is used to output the answer text corresponding to the target question intent to the current session.
8. The question-and-answer system response device according to claim 7, characterized in that, The statement invocation module includes: The last receiving unit is used to receive the last dialogue statement submitted by the user in the current session and add it to the chat history of the current session. The backtracking call unit is used to backtrack the chat history of the current session based on the last dialogue statement, and retrieve multiple dialogue statements of the user in reverse order; The format processing unit is used to preprocess the multiple sequential dialogue statements into a user statement sequence after performing text formatting.
9. A computer device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 6, which, when invoked by a computer, executes the steps included in the corresponding method.
Citation Information
Patent Citations
Question-answering method and device based on human-computer interaction, equipment and medium
CN112035647A
Intelligent question and answer method, device and equipment and readable storage medium
CN112182175A