CN112395398A - Question and answer processing method, device and equipment - Google Patents
Question and answer processing method, device and equipment Download PDFInfo
- Publication number
- CN112395398A CN112395398A CN201910760258.4A CN201910760258A CN112395398A CN 112395398 A CN112395398 A CN 112395398A CN 201910760258 A CN201910760258 A CN 201910760258A CN 112395398 A CN112395398 A CN 112395398A
- Authority
- CN
- China
- Prior art keywords
- sentence
- question
- answer
- attribute
- reply
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 19
- 238000012549 training Methods 0.000 claims abstract description 43
- 238000002372 labelling Methods 0.000 claims abstract description 27
- 230000004044 response Effects 0.000 claims abstract description 18
- 239000013598 vector Substances 0.000 claims description 59
- 238000000034 method Methods 0.000 claims description 43
- 230000006870 function Effects 0.000 claims description 26
- 238000012545 processing Methods 0.000 claims description 18
- 239000013604 expression vector Substances 0.000 claims description 12
- 230000015654 memory Effects 0.000 claims description 6
- 238000012216 screening Methods 0.000 claims description 4
- 230000008569 process Effects 0.000 description 21
- 238000010586 diagram Methods 0.000 description 8
- 230000006403 short-term memory Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 238000010276 construction Methods 0.000 description 3
- 238000003062 neural network model Methods 0.000 description 3
- 230000011218 segmentation Effects 0.000 description 3
- 238000001514 detection method Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 238000009411 base construction Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000003780 insertion Methods 0.000 description 1
- 230000037431 insertion Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000306 recurrent effect Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
- G06F16/3329—Natural language query formulation or dialogue systems
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Theoretical Computer Science (AREA)
- Artificial Intelligence (AREA)
- Human Computer Interaction (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Machine Translation (AREA)
Abstract
The embodiment of the invention provides a question and answer processing method, a device and equipment, wherein the question and answer processing method comprises the following steps: receiving a first question sentence aiming at a target article at a first time, and inputting the first question sentence into a model to acquire an attribute corresponding to the first question sentence through the model, wherein the attribute and an attribute value are acquired by the model from a question-answer sentence pair associated with the target article; and acquiring a first reply sentence corresponding to the attribute of the target object, wherein the first reply sentence comprises the attribute value, and outputting the first reply sentence, so that automatic response to the question posed by the user is realized. In addition, through the joint training of the question and answer sentences, the model can learn the semantic features among the question and answer sentences, so that the attribute prediction result of the question sentences in the question and answer sentences and the attribute value labeling result of the answer sentences are more accurate.
Description
Technical Field
The invention relates to the technical field of internet, in particular to a question and answer processing method, device and equipment.
Background
With the development of internet technology, people can acquire various articles and information needed by themselves from a network without going out of home. For example, with the advent of many online shopping platforms (commonly referred to as e-commerce platforms), people can access a server of the shopping platform by using a corresponding shopping APP or in a Web access manner, and perform operations such as searching, selecting, placing orders and the like on commodities, so as to obtain the commodities required by the people.
The interactive communication between the buyer and the seller is a key factor for the commodity transaction. In some practical applications, the seller often replies untimely to the question posed by the buyer, which may result in the buyer possibly losing the will of further interaction, even considering the seller's goods no longer.
Disclosure of Invention
The embodiment of the invention provides a question and answer processing method, device and equipment, which are used for realizing automatic response of consultation questions provided by users.
In a first aspect, an embodiment of the present invention provides a question and answer processing method, where the method includes:
receiving a first question statement for a target item at a first time;
inputting the first question statement into a model so as to acquire an attribute corresponding to the first question statement through the model; wherein the model has obtained the attributes and attribute values from a question-and-answer statement pair associated with the target item;
acquiring a first answer sentence corresponding to the attribute of the target item, wherein the first answer sentence comprises the attribute value;
outputting the first reply sentence.
In a second aspect, an embodiment of the present invention provides a question and answer processing apparatus, including:
the question receiving module is used for receiving a first question statement aiming at the target object at a first time;
the attribute prediction module is used for inputting the first question statement into a model so as to obtain an attribute corresponding to the first question statement through the model; wherein the model has obtained the attributes and attribute values from a question-and-answer statement pair associated with the target item;
a reply obtaining module, configured to obtain a first reply statement corresponding to the attribute of the target item, where the first reply statement includes the attribute value;
and the reply output module is used for outputting the first reply sentence.
In a third aspect, an embodiment of the present invention provides an electronic device, which includes a processor and a memory, where the memory stores executable codes, and when the executable codes are executed by the processor, the processor is enabled to implement at least the question-answering processing method in the first aspect.
An embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable code is stored, and when the executable code is executed by a processor of an electronic device, the processor is enabled to implement at least the question answering processing method in the first aspect.
In a fourth aspect, an embodiment of the present invention provides a model training method, where the model includes a first input layer, a second input layer, a statement representation layer, a first output layer, and a second output layer; the first input layer and the second input layer are respectively connected with the statement representation layer; the first output layer and the second output layer are respectively connected with the statement representation layer; the training method of the model comprises the following steps:
obtaining question sentences and answer sentences serving as training samples, wherein the question sentences and the answer sentences are question-answer sentences;
performing word vector coding on the question sentence through the first input layer to obtain a plurality of first word vectors, and performing word vector coding on the answer sentence through the second input layer to obtain a plurality of second word vectors;
extracting, by the sentence representation layer, first semantic representation vectors corresponding to the plurality of first word vectors, and extracting, by the sentence representation layer, second semantic representation vectors corresponding to the plurality of second word vectors;
classifying the first semantic expression vector through the first output layer to obtain an attribute classification result corresponding to the question sentence, and performing sequence labeling processing on the second semantic expression vector through the second output layer to obtain an attribute value labeling result corresponding to the answer sentence;
determining a first loss function according to the attribute classification result, and determining a second loss function according to the attribute value labeling result;
and adjusting the parameters of the model according to the superposition result of the first loss function and the second loss function.
The model used in the embodiment of the present invention is obtained by jointly training a pair of generated question-answer sentences, that is, one training sample of the model consists of a pair of generated question-answer sentences. Semantic information among the question sentences can be learned by the model through joint training of the question sentences, attribute information learned from the question sentences can be helpful for labeling attribute values in answer sentences, and attribute value information learned from the answer sentences is helpful for identifying attributes in the question sentences, so that attribute prediction results of the question sentences in the question sentences and attribute value labeling results of the answer sentences are more accurate. For a certain target item, a question-answer sentence pair that has been generated under the target item may be input into the model, so that the model learns the attribute and the attribute value corresponding to the question-answer sentence pair, and a reply sentence corresponding to the attribute is generated based on the attribute value.
Based on the above, when a first question sentence proposed by the user for the target article is received, the first question sentence is input into the model, so that the attribute corresponding to the first question sentence is obtained through the model, a first answer sentence corresponding to the attribute of the target article is further obtained, and the first answer sentence is output, so that the automatic answer to the question proposed by the user is realized.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
FIG. 1 is a schematic diagram of a model structure according to an embodiment of the present invention;
FIG. 2 is a flowchart of a model training method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a model training process according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the composition of an article knowledge base according to an embodiment of the present invention;
FIG. 5 is a flow chart of a process for building an item knowledge base according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a process for building an article knowledge base according to an embodiment of the present invention;
fig. 7 is a flowchart of a question answering processing method according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a question-answer processing method according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a question answering processing device according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of an electronic device corresponding to the question answering processing apparatus provided in the embodiment shown in fig. 9.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "a plurality" typically includes at least two.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
It is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a good or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such good or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a commodity or system that includes the element.
In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited.
In the embodiment of the present invention, in order to implement automatic response to a question posed by a user, a model is required, and the model may be a neural network model. The structure of the model is schematically described below with reference to fig. 1, and as shown in fig. 1, the model includes a first input layer, a second input layer, a sentence expression layer, a first output layer, and a second output layer. The first input layer and the second input layer are respectively connected with the statement representation layer, and the first output layer and the second output layer are respectively connected with the statement representation layer. The first input layer corresponds to the first output layer, and the second input layer corresponds to the second output layer. It can be seen that the statement representation layer is shared by both input layers and both output layers.
In the embodiment of the present invention, the above model is actually used for executing two tasks, namely, a classification task and a sequence labeling task. As shown in fig. 1, the first input layer, the statement representation layer, and the first output layer constitute an execution unit of the classification task, and the second input layer, the statement representation layer, and the second output layer constitute an execution unit of the sequence labeling task.
Based on this, the first output layer may be considered to be formed by a classifier, such as a softmax classifier, and the second output model may be implemented, for example, as a Conditional Random Field (CRF) model.
The first input layer and the second input layer may both be implemented as word vector models to accomplish word vector encoding of respective input sentences, such as word2vec models.
The statement representation layer can be implemented by using various neural network models, such as: a Bi-directional Long Short Term Memory Network model (Bi-directional Long Short Term Memory, abbreviated as Bi-LSTM), a Long Short Term Memory Network model (Long Short Term Memory, abbreviated as LSTM), a Recurrent Neural Network model (RNN), etc.
The question and answer processing method provided by the embodiment of the invention can be applied to the scene of online shopping, taking the scene of online shopping as an example, the model which is trained to be converged can be provided for a plurality of merchants to use, and based on the model, the model can be downloaded to the client sides of the merchants corresponding to the plurality of merchants respectively, namely the terminal equipment of the merchants, so that the question and answer processing method provided by the embodiment of the invention can be executed by the terminal equipment of the merchants. Of course, the model may also be deployed in a server or a server cluster corresponding to the e-commerce platform, and the server may be located in a cloud, so that the question-answering processing method provided in the embodiment of the present invention may also be executed by the server.
The training process of the model is described first, and then the using process of the model is described.
Fig. 2 is a flowchart of a model training method according to an embodiment of the present invention, and as shown in fig. 2, the model training method includes the following steps:
201. a second question sentence and a second answer sentence, which are a question-answer sentence, are obtained as training samples.
202. Word vector encoding is performed on the second question sentence through the first input layer to obtain a plurality of first word vectors, and word vector encoding is performed on the second answer sentence through the second input layer to obtain a plurality of second word vectors.
203. And extracting a first semantic representation vector corresponding to a plurality of first word vectors through the sentence representation layer, and extracting a second semantic representation vector corresponding to a plurality of second word vectors through the sentence representation layer.
204. And performing sequence labeling processing on the second semantic expression vector through a second output layer to obtain an attribute value labeling result corresponding to the second answer sentence.
205. And determining a first loss function according to the attribute classification result corresponding to the second question statement, determining a second loss function according to the attribute value labeling result corresponding to the second answer statement, and adjusting the parameters of the model according to the superposition result of the first loss function and the second loss function.
Taking an online shopping scenario as an example, when model training is performed, training samples used for training the model come from historical question-answer records of one or more merchants. Specifically, one training sample of the model is composed of a pair of question-answer sentences (i.e., a pair of question-answer sentences) that have been generated, the pair of question-answer sentences being a pair of question sentences and answer sentences having a question-answer relationship. For example, once a user has asked a question sentence X, and a reply sentence to the question sentence X by a merchant is a reply sentence Y, the question sentence X and the reply sentence Y serve as a training sample. For example, assume that a user has asked a merchant who sells clothes: what color is there for the garment? The merchant answers: there are blue and white. Then, question statement X: "what color this piece of clothing has" and a reply sentence Y: the question-answer sentence "with blue and white" is used as a training sample.
The question sentence X and the answer sentence Y exemplified here can be the second question sentence and the second answer sentence in the above step 201.
It should be noted that the question sentence X and the answer sentence Y are used as a training sample, and it is not limited that the question sentence X and the answer sentence Y need to be combined into a sentence, and the two sentences also exist independently and are used as the input of the first input layer and the second input layer of the model respectively. In addition, the model can be trained in a supervised training mode, so that the question sentence X is labeled with a corresponding attribute label, and the answer sentence Y is also labeled with an attribute value of the attribute.
In addition, in practical applications, there may be two cases:
first, a user issues a question sentence, and a merchant replies a plurality of reply sentences, that is, the merchant replies a plurality of sentences (each reply sentence can be distinguished by a sentence number or a line feed character), at this time, the concatenation result of the plurality of sentences replied by the merchant can be used as the reply sentence corresponding to the question sentence. For example, a question and sentence asked by a user is: q, the merchant replies with two reply sentences a1 and a2, so that the reply sentences a1 and a2 can be spliced together to form a reply sentence a ═ a1, a2, so that Q and a are regarded as a question-answer sentence pair as a training sample.
Second, a plurality of questions and sentences are proposed by a plurality of users or the same user, and the merchant only replies one answer sentence, in this case, one question and answer sentence can be selected from the plurality of question and sentences, and the answer sentence and the question and answer sentence constitute a pair of question and answer sentences as a training sample. Of course, assuming that there are 3 question sentences corresponding to the same answer sentence, 3 training samples may be constructed, corresponding to the 3 question sentences, respectively. For example, if a plurality of question sentences are Q1 and Q2, respectively, and correspond to the same answer sentence a, then Q1 and a may be finally regarded as a question-answer sentence pair as a training sample, and Q2 and a may also be regarded as a question-answer sentence pair as another training sample.
The process of model training is schematically illustrated below in conjunction with fig. 3.
Taking the current training sample as the question sentence X and the answer sentence Y, the two sentences may be segmented first. As shown in fig. 3, question statement X: the word segmentation result of "what color is still left in the piece of clothing" is: this/piece/garment/also/what/color. Reply sentence Y: the word segmentation result of "having blue and white" is: with/blue/and/white.
Further, inputting all words contained in the question statement X into a first input layer, and carrying out word vector coding on the words through the first input layer to obtain a plurality of first word vectors; and inputting all the words contained in the reply sentence Y into the second input layer so as to carry out word vector coding on the words through the second input layer to obtain a plurality of second word vectors. In fig. 3, it is assumed that the plurality of first word vectors are w1, w2, w3, w4, w5, w6, w7, respectively, and the plurality of second word vectors are w8, w9, w10, w11, respectively.
In fig. 3, after a plurality of first word vectors are sequentially input to the word expression layer, a first semantic expression vector obtained by sequentially encoding the first word vectors by the word expression layer is assumed to be represented as C1. After the plurality of second word vectors are sequentially input to the term representation layer, it is assumed that a second semantic representation vector obtained by sequentially encoding the second word vectors by the term representation layer is represented as C2. The context semantic information of question sentence X included in C1 and the context semantic information of question sentence Y included in C2. In addition, the sharing of the sentence representation layer in the two input layers is embodied in that the sentence representation layer processes the plurality of first word vectors and the plurality of second word vectors based on the same parameter.
Inputting the first semantic expression vector C1 into the first output layer, and performing classification processing on the first output layer to predict the attribute corresponding to the question statement X, such as the attribute illustrated in fig. 3: and (4) color. Inputting the second semantic expression vector C2 to the second output layer, and labeling the attribute value corresponding to the reply sentence Y through the sequence labeling processing of the second output layer, for example, as illustrated in fig. 3: there are (O) blue (B) color (I) and (O) white (B) color (I), i.e. the attribute values are: blue and white.
Then, based on the above-described attributes and attribute values actually output by the model and the marking information (supervision information) corresponding to the question sentence X and the answer sentence Y, a first loss function corresponding to the question sentence X and a second loss function corresponding to the answer sentence Y can be calculated, and the parameters of the model are adjusted according to the superposition result of the first loss function and the second loss function. The result of the superposition of the first loss function and the second loss function is, for example, the sum or the average of the two, and so on.
The attribute corresponding to the question statement X reflects the consultation intention of the question statement X, and a plurality of attribute categories can be set in advance according to the actual application requirements, so that the problem about which attribute the user specifically wants to consult is predicted. And the attribute value in the answer sentence Y reflects the keyword of the question sentence X of the answer user. Therefore, the attribute in the question sentence X and the attribute value in the answer sentence Y actually form a key-value relationship pair, and a pair of question-answer sentences with question-answer relationship is taken as a training sample in the model training process, so that the core purpose is to learn the corresponding relationship between the attributes and the attribute values. Based on the above, when the model is used for predicting the attribute corresponding to the question statement, the semantic information of the attribute value can be used for assisting in predicting the attribute, so that the attribute prediction result is more accurate, and relatively, the attribute information can also help to improve the accuracy of the attribute value labeling result.
The training process of the model is described above, and the using process of the model is described below. In summary, the use process of the model is divided into two stages, the first stage is a stage of building and updating an article knowledge base by using the model, and the second stage is a stage of automatically answering a question posed by a user based on the latest article knowledge base. The automatic response refers to that the robot automatically responds to a problem posed by a user, and the automatic response of the robot is understood to refer to a non-manual response mode in a broad sense, and does not limit the existence of the physical equipment of the robot.
The article knowledge base is an article knowledge base corresponding to a certain article, and one or more attributes of the article and a reply sentence corresponding to each attribute are specifically stored in the article knowledge base. For example, in connection with fig. 4, it is assumed that for a certain model of a certain brand of mobile phone, the corresponding multiple attribute categories may include: new and old, color, shipping location, whether package is mailed, etc. Assume that the reply sentence corresponding to the new or old sentence is: jiuchenxin. Assume that the reply sentence corresponding to the color is: it has a black color. Assume that the reply sentence corresponding to the destination is: shipping from Hangzhou. Assume that the reply sentence corresponding to whether to wrap or not to mail is: the parent can be covered by mail. It has been cost effective to leave a single bar clean!
The structure of the article knowledge base is realized based on the model, specifically, the attributes of the articles contained in the article knowledge base are identified by the model, and the response sentence corresponding to the attribute is obtained based on the attribute value labeling result of the model object. That is, the reply sentence actually contains the attribute values marked out by the model. The reply sentence can be understood as being obtained by the phonetics template and the attribute value, namely, the reply sentence is formed by filling the attribute value in the corresponding empty slot position in the phonetics template.
The following describes the building process of the knowledge base of items with reference to the embodiment shown in fig. 5, and the building process is summarized as follows: collecting question-answer sentence pairs generated under a certain article, inputting the question-answer sentence pairs into a trained model, outputting corresponding attributes and attribute values by the model, generating answer sentences based on the attribute values, and adding the attributes and the corresponding answer sentences in an article knowledge base corresponding to the article.
Fig. 5 is a flowchart of a process for building an article knowledge base according to an embodiment of the present invention, and as shown in fig. 5, the process may include the following steps:
501. a third question sentence and a third reply sentence corresponding to the target item are received, the third question sentence and the third reply sentence being a one-to-one question and answer sentence.
To distinguish from the first time when the user-triggered first question sentence is received, it is assumed here that the time when the third question sentence and the third reply sentence are acquired is the second time, and it can be considered that the third question sentence and the third reply sentence can be acquired when the third reply sentence is generated, and therefore, the second time can also be considered as the generation time of the third reply sentence.
Since users consult with a specific item in an actual online shopping scenario, the model is ultimately used for each item. The target item can be any item of any seller in the e-commerce platform.
502. An attribute corresponding to the third question sentence and an attribute value corresponding to the third answer sentence are acquired by the model.
At this time, the model is a model that has been trained to converge through the training process described above. And inputting the third question sentence into the first input layer of the model, and predicting the attribute corresponding to the third question sentence through the first output layer. And inputting the third reply sentence into a second input layer of the model, and marking the attribute value corresponding to the third reply sentence through a second output layer.
503. And generating a reply sentence corresponding to the attribute according to the attribute value corresponding to the third reply sentence.
Assuming that the attribute corresponding to the third question sentence is S, and the attribute value corresponding to the attribute S in the third answer sentence is T, as described above, the answer sentence corresponding to the attribute S can be obtained from the dialogue template (hereinafter referred to as the answer template) corresponding to the attribute S and the attribute value T, that is, the answer sentence corresponding to the attribute S can be formed by filling the attribute value T in the corresponding empty slot in the answer template.
The following describes the process of obtaining the reply template corresponding to the attribute S:
acquiring a plurality of historical reply sentences corresponding to the attribute S;
screening out at least one historical reply sentence with different expression modes from the plurality of historical reply sentences;
and generating at least one corresponding reply template according to the screened at least one historical reply sentence, wherein the attribute value corresponding to the attribute S in the at least one reply template is set as a null slot position.
The plurality of history reply sentences corresponding to the attribute S may correspond to the target item, and may include history reply sentences corresponding to the attribute S, which correspond to other items, in addition to the target item.
For example, assume that items corresponding to the same merchant or different merchants in the e-commerce platform include: if the target item is item 1 and the attribute S is color, item 1, item 2, and item 3 may collect respective reply sentences that the merchant corresponding to item 1 has replied to the buyer with respect to the color attribute, which is assumed to include reply sentence 1 and reply sentence 2. The respective reply sentences of the buyer that the merchant corresponding to the item 2 and the item 3 has replied to with regard to the color attribute may also be collected, and are assumed to include the reply sentence 3, the reply sentence 4, the reply sentence 5 and the reply sentence 6. Then, the plurality of history reply sentences corresponding to the color attribute may include: reply sentence 1, reply sentence 2, reply sentence 3, reply sentence 4, reply sentence 5, reply sentence 6.
The step of screening out at least one historical reply sentence with different expression modes from the plurality of historical reply sentences means that each historical reply sentence reflects the customary expression modes of the corresponding seller, the expression modes of some sellers are likely to be relatively close, and the difference of some sellers is likely to be larger.
In practical applications, by calculating the similarity distance between different reply sentences, if the similarity distance between two reply sentences is smaller than a set threshold, one of the two reply sentences can be filtered, so that the last remaining historical reply sentence in the plurality of historical reply sentences serves as the at least one historical reply sentence. The similarity distance may be calculated by using a Levenshtein algorithm, for example, and therefore may also be referred to as a Levenshtein distance or an edit distance.
The Levenshtein distance describes the minimum number of operations that can be performed to translate from one string to another, including insertions, deletions, substitutions, and the like. For example, turning eeba into abac, the first e may be deleted first, thereby becoming eba, then the remaining e may be replaced with a, thereby becoming aba, and then c may be inserted at the end, thereby becoming abac, so the Levenshtein distance between eeba and abac is 3.
Assuming that the attribute S is a color, the at least one history reply sentence is a reply sentence having two different expression modes as follows: the product is also blue and white. It is red and black, and the red is better sold. Where blue and white, red and black, and red are the positions of the attribute values, these positions are set as empty slots, and thus, the following two reply templates can be obtained:
this product is also () of.
Leave () that is better for selling.
Based on this, generating the reply sentence according to the attribute value T corresponding to the attribute S may be implemented as: and filling the attribute value T in the empty slot position of the reply template to obtain a reply sentence corresponding to the attribute S.
In the above example, the two answer sentences corresponding to the attribute S are: the product is also (attribute value T); the (attribute value T) selling is better, which remains (attribute value T).
Through the above process, the construction of each attribute of the target object and the corresponding reply sentence thereof can be realized for the target object, that is, the construction of the object knowledge base of the target object is completed.
However, it should be noted that in practical applications, as the seller's item is sold, the inventory is dynamically updated, for example, some item may be left with blue and white before, and may be left with white after the blue is sold out. Assuming that at this point there has been a user asking what color remains for the item, the seller answers that white remains. Then if there is a further user asking what color this item still has, then based on the reply statement stored in the previous knowledge base of the item: "parent, this commodity also has blue and white" automatic answer, the display is not correct, therefore, the answer sentence corresponding to each attribute in the commodity knowledge base should be dynamically updated, the updated basis is the answer sentence input by the seller under the corresponding attribute.
Specifically, assuming that after the second time of acquiring the third question sentence and the third answer sentence, for any attribute S, a fourth question sentence corresponding to the attribute S and a fourth answer sentence corresponding to the fourth question sentence exist under the target item, updating the answer sentence corresponding to the attribute S according to the attribute value H corresponding to the fourth answer sentence is as follows: the product is also (attribute value H); and, what remains (attribute value H) is better sold (attribute value H).
It can be understood that the attribute corresponding to the fourth question sentence and the attribute value corresponding to the fourth answer sentence are obtained through the model.
In order to more intuitively understand the item knowledge base construction process provided in the present embodiment, an example will be schematically described with reference to fig. 6.
In fig. 6, it is assumed that a question-and-answer sentence "where the destination was" is generated "at time T1 for an item Z, and the answer sentence" shipment from the state of hangzhou "is generated. After the question and answer sentences are input into the model, the model outputs the attributes corresponding to the question sentences as follows: the model outputs the attribute values corresponding to the reply sentence as: hangzhou is a Chinese character of Hangzhou. Assume that the reply template is: shipment from (). Thus, the following information is added to the item knowledge base of item Z: the attribute is shipped, and the reply statement is shipped from Hangzhou.
Thereafter, it is assumed that a pair of question-and-answer sentences are generated again at time T2, the question sentence being "where the ship is" and the answer sentence being "ship from shanghai". After the question and answer sentences are input into the model, the model outputs the attributes corresponding to the question sentences as follows: the model outputs the attribute values corresponding to the reply sentence as: shanghai. At this time, the above information in the article knowledge base of the article Z is updated to: the attribute is ship, and the answer sentence is ship from shanghai.
The above describes the process of building and updating the knowledge base of the article, and the following describes the process of using the knowledge base of the article, as shown in fig. 7.
Fig. 7 is a flowchart of a question answering processing method according to an embodiment of the present invention, and as shown in fig. 7, the method includes the following steps:
701. a first question statement is received for a target item at a first time.
702. Inputting the first question sentence into a model to obtain the attribute corresponding to the first question sentence through the model, wherein one training sample of the model consists of a pair of question-answer sentences which are generated, and the model can output the attribute corresponding to the training sample and the attribute value labeling result.
703. And acquiring a first reply sentence corresponding to the attribute of the target item, wherein the first reply sentence comprises an attribute value corresponding to the attribute of the target item.
704. The first reply sentence is output.
It should be noted that, in the present embodiment, the first time is compared with the second time in the foregoing embodiment, and the first time is assumed to be later than the second time, that is, it is assumed that the latest object knowledge base of the target object is already formed at a time before the first time, such as the second time. Based on this, the present embodiment describes how to automatically respond to the first question sentence currently posed by the user based on the knowledge base of the article and the aforementioned model that has been trained.
After receiving a first question sentence issued by a user for a target item, as shown in fig. 8, assume that the first question sentence is: asking what color this cup is. The first question statement may be input into the model, specifically, into a first input layer of the model, so as to output an attribute corresponding to the first question statement through a first output layer of the model: and (4) color.
Wherein, the processing procedure of the first question statement is summarized as follows: performing word segmentation processing on a first problem statement, performing word vector coding on each obtained word through a first input layer, sequentially inputting a plurality of obtained word vectors into a Bi-LSTM (Bi-LSTM) serving as a statement representation layer to perform semantic extraction so as to obtain a semantic representation vector corresponding to the first problem statement, and classifying and identifying the semantic representation vector through a softmax classifier so as to obtain an attribute corresponding to the first problem statement.
Further, it may be queried in the article knowledge base corresponding to the target article whether a response sentence corresponding to the color attribute, referred to as a first response sentence, exists, and if so, the first response sentence is output to the user, for example, the first response sentence is output in a voice or text manner, thereby implementing an automatic response to the first question sentence proposed by the user.
Wherein, it is assumed that the answer sentence corresponding to the color attribute in the article knowledge base includes two sentences, which are respectively:
the product is also red in color.
The red color remains, and the red color sells better.
One of the two answer sentences may be randomly selected to automatically answer to the user, such as "parent, the product is also red".
In practical applications, optionally, before outputting the first reply sentence to the user, i.e., the buyer, prompt information corresponding to the first reply sentence may be further output to an owner, i.e., the seller, corresponding to the target item, so that the owner may determine whether to adopt the first reply sentence, or, when there are multiple first reply sentences, the owner may be allowed to select whether to adopt one of the first reply sentences. The first reply sentence is then output to the buyer in response to the determination of the owner feedback to employ the indication of the first reply sentence.
In conclusion, the question-answer sentence pairs with question-answer relations are used as training samples to perform joint training on the model, so that the attribute classification result of the question sentences and the attribute value labeling result of the answer sentences by the model can be more accurate. Based on the attribute prediction and attribute value labeling of the question-answer sentence pair for a certain item, a reply sentence corresponding to each attribute of the item can be generated for the user-oriented automatic reply.
The question-answer processing apparatus of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that the question and answer processing devices may each be configured using commercially available hardware components through the steps taught in the present scheme.
Fig. 9 is a schematic structural diagram of a question-answering processing device according to an embodiment of the present invention, and as shown in fig. 9, the question-answering processing device includes: a question receiving module 11, an attribute predicting module 12, a reply acquiring module 13 and a reply output module 14.
The question receiving module 11 is configured to receive a first question statement for the target item at a first time.
The attribute prediction module 12 is configured to input the first question statement into a model, so as to obtain an attribute corresponding to the first question statement through the model; wherein the model has obtained the attributes and attribute values from a question-and-answer sentence pair associated with the target item.
A reply obtaining module 13, configured to obtain a first reply statement corresponding to the attribute of the target item, where the first reply statement includes the attribute value.
A reply output module 14, configured to output the first reply sentence.
Wherein the model comprises a first input layer, a second input layer, a statement representation layer, a first output layer and a second output layer; the first input layer and the second input layer are respectively connected with the statement representation layer; the first output layer and the second output layer are respectively connected with the statement representation layer.
The apparatus method further comprises: and a training module.
The training module is used for acquiring a second question sentence and a second answer sentence serving as training samples, wherein the second question sentence and the second answer sentence are a question-answer sentence; performing word vector coding on the second question sentence through the first input layer to obtain a plurality of first word vectors, and performing word vector coding on the second answer sentence through the second input layer to obtain a plurality of second word vectors; extracting, by the sentence representation layer, first semantic representation vectors corresponding to the plurality of first word vectors, and extracting, by the sentence representation layer, second semantic representation vectors corresponding to the plurality of second word vectors; classifying the first semantic expression vector through the first output layer to obtain an attribute classification result corresponding to the second question statement, and performing sequence labeling processing on the second semantic expression vector through the second output layer to obtain an attribute value labeling result corresponding to the second answer statement; determining a first loss function according to the attribute classification result, and determining a second loss function according to the attribute value labeling result; and adjusting the parameters of the model according to the superposition result of the first loss function and the second loss function.
Alternatively, if there are a plurality of question sentences corresponding to the second reply sentence, the second question sentence is any one of the plurality of question sentences.
Optionally, if there are multiple answer sentences corresponding to the second question sentence, the second answer sentence is a concatenation result of the multiple answer sentences.
Optionally, the apparatus further comprises: a generating module, configured to obtain a third question sentence and a third answer sentence corresponding to the target item at a second time, where the third question sentence and the third answer sentence are a question-answer sentence, and the second time is earlier than the first time; acquiring the attribute corresponding to the third question sentence and an attribute value corresponding to the third answer sentence through the model; and generating the first reply sentence corresponding to the attribute according to the attribute value.
Optionally, the generating module is further configured to: if a fourth question sentence corresponding to the attribute and a fourth answer sentence corresponding to the fourth question sentence exist between the second time and the first time, updating the first answer sentence according to an attribute value corresponding to the fourth answer sentence, wherein the attribute corresponding to the fourth question sentence and the attribute value corresponding to the fourth answer sentence are obtained through the model.
Optionally, the apparatus further comprises: the template construction module is used for acquiring a plurality of historical reply sentences corresponding to the attributes; screening out at least one historical reply sentence with different expression modes from the plurality of historical reply sentences; and generating at least one corresponding reply template according to the at least one historical reply sentence, wherein the attribute value corresponding to the attribute in the at least one reply template is set as an empty slot.
Thus, the generating module is specifically configured to: filling the attribute value at the empty slot to obtain the first reply statement.
The question answering device shown in fig. 9 can execute the method provided in the embodiments shown in fig. 1 to fig. 7, and the parts of this embodiment that are not described in detail can refer to the related descriptions of the embodiments, which are not described herein again.
In one possible design, the structure of the question answering processing apparatus shown in fig. 9 can be implemented as an electronic device. As shown in fig. 10, the electronic device may include: a processor 21 and a memory 22. Wherein the memory 22 has stored thereon executable code, which when executed by the processor 21, at least makes the processor 21 capable of implementing the question-answering processing method as provided in the aforementioned embodiments shown in fig. 1 to 7.
The electronic device may further include a communication interface 23 for communicating with other devices or a communication network.
In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, on which executable codes are stored, and when the executable codes are executed by a processor of an electronic device, the processor is caused to execute the question answering processing method provided in the embodiments shown in fig. 1 to 7.
The above-described apparatus embodiments are merely illustrative, wherein the various modules illustrated as separate components may or may not be physically separate. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. With this understanding in mind, the above-described aspects and portions of the present technology which contribute substantially or in part to the prior art may be embodied in the form of a computer program product, which may be embodied on one or more computer-usable storage media having computer-usable program code embodied therein, including without limitation disk storage, CD-ROM, optical storage, and the like.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (13)
1. A question-answer processing method, characterized by comprising:
receiving a first question statement for a target item at a first time;
inputting the first question statement into a model so as to acquire an attribute corresponding to the first question statement through the model; wherein the model has obtained the attributes and attribute values from a question-and-answer statement pair associated with the target item;
acquiring a first answer sentence corresponding to the attribute of the target item, wherein the first answer sentence comprises the attribute value;
outputting the first reply sentence.
2. The method of claim 1, wherein the model comprises a first input layer, a second input layer, a statement representation layer, a first output layer, and a second output layer;
the first input layer and the second input layer are respectively connected with the statement representation layer;
the first output layer and the second output layer are respectively connected with the statement representation layer.
3. The method of claim 2, further comprising:
acquiring a second question sentence and a second answer sentence serving as training samples, wherein the second question sentence and the second answer sentence are question-answer sentences;
performing word vector coding on the second question sentence through the first input layer to obtain a plurality of first word vectors, and performing word vector coding on the second answer sentence through the second input layer to obtain a plurality of second word vectors;
extracting, by the sentence representation layer, first semantic representation vectors corresponding to the plurality of first word vectors, and extracting, by the sentence representation layer, second semantic representation vectors corresponding to the plurality of second word vectors;
classifying the first semantic expression vector through the first output layer to obtain an attribute classification result corresponding to the second question statement, and performing sequence labeling processing on the second semantic expression vector through the second output layer to obtain an attribute value labeling result corresponding to the second answer statement;
determining a first loss function according to the attribute classification result, and determining a second loss function according to the attribute value labeling result;
and adjusting the parameters of the model according to the superposition result of the first loss function and the second loss function.
4. The method according to claim 3, wherein if there are a plurality of question sentences corresponding to the second reply sentence, the second question sentence is any one of the plurality of question sentences.
5. The method according to claim 3, wherein if there are a plurality of answer sentences corresponding to the second question sentence, the second answer sentence is a concatenation result of the plurality of answer sentences.
6. The method of claim 3, further comprising:
acquiring a third question sentence and a third answer sentence corresponding to the target item at a second time, wherein the third question sentence and the third answer sentence are a question-answer sentence, and the second time is earlier than the first time;
acquiring the attribute corresponding to the third question sentence and an attribute value corresponding to the third answer sentence through the model;
and generating the first reply sentence corresponding to the attribute according to the attribute value.
7. The method of claim 6, further comprising:
if a fourth question sentence corresponding to the attribute and a fourth answer sentence corresponding to the fourth question sentence exist between the second time and the first time, updating the first answer sentence according to an attribute value corresponding to the fourth answer sentence, wherein the attribute corresponding to the fourth question sentence and the attribute value corresponding to the fourth answer sentence are obtained through the model.
8. The method of claim 6, further comprising:
acquiring a plurality of historical reply sentences corresponding to the attributes;
screening out at least one historical reply sentence with different expression modes from the plurality of historical reply sentences;
and generating at least one corresponding reply template according to the at least one historical reply sentence, wherein the attribute value corresponding to the attribute in the at least one reply template is set as an empty slot.
9. The method according to claim 8, wherein said generating the first reply sentence corresponding to the attribute from the attribute value comprises:
filling the attribute value at the empty slot to obtain the first reply statement.
10. The method according to any one of claims 1 to 9, wherein said outputting the first reply sentence includes:
outputting prompt information corresponding to the first reply sentence to an owner corresponding to the target item, so that the owner can determine whether to adopt the first reply sentence;
outputting the first reply sentence in response to the determination of the owner feedback taking the indication of the first reply sentence.
11. A question-answering processing apparatus characterized by comprising:
the question receiving module is used for receiving a first question statement aiming at the target object at a first time;
the attribute prediction module is used for inputting the first question statement into a model so as to obtain an attribute corresponding to the first question statement through the model; wherein the model has obtained the attributes and attribute values from a question-and-answer statement pair associated with the target item;
a reply obtaining module, configured to obtain a first reply statement corresponding to the attribute of the target item, where the first reply statement includes the attribute value;
and the reply output module is used for outputting the first reply sentence.
12. An electronic device, comprising: a memory, a processor; wherein the memory has stored thereon executable code which, when executed by the processor, causes the processor to perform the question-answer processing method according to any one of claims 1 to 10.
13. A model training method is characterized in that the model comprises a first input layer, a second input layer, a statement representation layer, a first output layer and a second output layer; the first input layer and the second input layer are respectively connected with the statement representation layer; the first output layer and the second output layer are respectively connected with the statement representation layer;
the training method of the model comprises the following steps:
obtaining question sentences and answer sentences serving as training samples, wherein the question sentences and the answer sentences are question-answer sentences;
performing word vector coding on the question sentence through the first input layer to obtain a plurality of first word vectors, and performing word vector coding on the answer sentence through the second input layer to obtain a plurality of second word vectors;
extracting, by the sentence representation layer, first semantic representation vectors corresponding to the plurality of first word vectors, and extracting, by the sentence representation layer, second semantic representation vectors corresponding to the plurality of second word vectors;
classifying the first semantic expression vector through the first output layer to obtain an attribute classification result corresponding to the question sentence, and performing sequence labeling processing on the second semantic expression vector through the second output layer to obtain an attribute value labeling result corresponding to the answer sentence;
determining a first loss function according to the attribute classification result, and determining a second loss function according to the attribute value labeling result;
and adjusting the parameters of the model according to the superposition result of the first loss function and the second loss function.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910760258.4A CN112395398A (en) | 2019-08-16 | 2019-08-16 | Question and answer processing method, device and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910760258.4A CN112395398A (en) | 2019-08-16 | 2019-08-16 | Question and answer processing method, device and equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112395398A true CN112395398A (en) | 2021-02-23 |
Family
ID=74602878
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910760258.4A Pending CN112395398A (en) | 2019-08-16 | 2019-08-16 | Question and answer processing method, device and equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112395398A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112948565A (en) * | 2021-04-16 | 2021-06-11 | 北京小米移动软件有限公司 | Man-machine conversation method, device, electronic equipment and storage medium |
CN113420542A (en) * | 2021-06-23 | 2021-09-21 | 平安科技(深圳)有限公司 | Dialog generation method and device, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108536818A (en) * | 2018-04-08 | 2018-09-14 | 中国联合网络通信集团有限公司 | The generation method and device of question and answer sentence |
CN108897867A (en) * | 2018-06-29 | 2018-11-27 | 北京百度网讯科技有限公司 | For the data processing method of knowledge question, device, server and medium |
CN109408627A (en) * | 2018-11-15 | 2019-03-01 | 众安信息技术服务有限公司 | A kind of answering method and system merging convolutional neural networks and Recognition with Recurrent Neural Network |
CN109492077A (en) * | 2018-09-29 | 2019-03-19 | 北明智通(北京)科技有限公司 | The petrochemical field answering method and system of knowledge based map |
-
2019
- 2019-08-16 CN CN201910760258.4A patent/CN112395398A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108536818A (en) * | 2018-04-08 | 2018-09-14 | 中国联合网络通信集团有限公司 | The generation method and device of question and answer sentence |
CN108897867A (en) * | 2018-06-29 | 2018-11-27 | 北京百度网讯科技有限公司 | For the data processing method of knowledge question, device, server and medium |
CN109492077A (en) * | 2018-09-29 | 2019-03-19 | 北明智通(北京)科技有限公司 | The petrochemical field answering method and system of knowledge based map |
CN109408627A (en) * | 2018-11-15 | 2019-03-01 | 众安信息技术服务有限公司 | A kind of answering method and system merging convolutional neural networks and Recognition with Recurrent Neural Network |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112948565A (en) * | 2021-04-16 | 2021-06-11 | 北京小米移动软件有限公司 | Man-machine conversation method, device, electronic equipment and storage medium |
CN113420542A (en) * | 2021-06-23 | 2021-09-21 | 平安科技(深圳)有限公司 | Dialog generation method and device, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108345692B (en) | Automatic question answering method and system | |
CN107798571A (en) | Identifying system, the method and device of malice address/malice order | |
US20020102526A1 (en) | Apparatus and method accumulating cases to be learned | |
CN108920665B (en) | Recommendation scoring method and device based on network structure and comment text | |
US11875241B2 (en) | Aspect pre-selection using machine learning | |
CN110516033B (en) | Method and device for calculating user preference | |
CN114491077A (en) | Text generation method, device, equipment and medium | |
CN111291158B (en) | Information query method and device, electronic equipment and storage medium | |
CN112527972A (en) | Intelligent customer service chat robot implementation method and system based on deep learning | |
CN113761219A (en) | Knowledge graph-based retrieval method and device, electronic equipment and storage medium | |
KR102444498B1 (en) | System and method for providing image-based service to sell and buy product | |
CN111680165A (en) | Information matching method and device, readable storage medium and electronic equipment | |
US20160267425A1 (en) | Data processing techniques | |
CN110135769B (en) | Goods attribute filling method and device, storage medium and electronic terminal | |
CN112395398A (en) | Question and answer processing method, device and equipment | |
CN108984777B (en) | Customer service method, apparatus and computer-readable storage medium | |
CN112241490A (en) | Classification processing and data searching method and device, electronic equipment and intelligent sound box | |
KR20210054021A (en) | Probabilistic item matching and search | |
CN115859121A (en) | Text processing model training method and device | |
CN116185812A (en) | Automatic testing method, device and medium for software system functions | |
CN114610863A (en) | Dialogue text pushing method and device, storage medium and terminal | |
CN113742559A (en) | Keyword detection method and device, electronic equipment and storage medium | |
CN110019700B (en) | Data processing method and device | |
CN116684480B (en) | Method and device for determining information push model and method and device for information push | |
CN115222486B (en) | Article recommendation model training method, article recommendation method, device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |