CN111274823A - Text semantic understanding method and related device - Google Patents
Text semantic understanding method and related device Download PDFInfo
- Publication number
- CN111274823A CN111274823A CN202010010698.0A CN202010010698A CN111274823A CN 111274823 A CN111274823 A CN 111274823A CN 202010010698 A CN202010010698 A CN 202010010698A CN 111274823 A CN111274823 A CN 111274823A
- Authority
- CN
- China
- Prior art keywords
- target text
- slot value
- type
- text
- semantic
- 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.)
- Granted
Links
Images
Landscapes
- Machine Translation (AREA)
Abstract
The application discloses a text semantic understanding method and a related device, wherein the method comprises the following steps: firstly, acquiring a target text to be semantically understood; then, extracting semantic information of the target text, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; and finally, performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text. Therefore, by extracting semantic information of the target text, the relation between the field type and the slot value type and the corresponding slot value is fully mined, the slot value type and the corresponding slot value are fully utilized for predicting the auxiliary field type, so that the field type, the slot value type and the corresponding slot value of the target text can be obtained at the same time, the text semantic understanding effect of the target text to be subjected to semantic understanding can be greatly improved, and the user experience is improved.
Description
Technical Field
The present application relates to the field of natural language processing technologies, and in particular, to a text semantic understanding method and a related apparatus.
Background
Semantic understanding is the most important link in the technical field of natural language processing and is widely applied to intelligent dialogue systems, intelligent question-answering systems and the like. Specifically, aiming at the text input by the user, the semantic understanding module can accurately judge the field to which the text belongs and the keyword slot thereof so as to facilitate the system to reply the text corresponding to the text; for example, the field to which the text "i want to go to XX square" belongs is "navigation", and the keyword slot thereof is the destination "XX square".
At present, a sequence marking method is adopted for text semantic understanding, namely, a sequence marking model is trained aiming at a slot value type and a corresponding slot value under a field type, and the sequence marking model is divided into two independent sub-modules of 'field type prediction' and 'slot value type and corresponding slot value prediction'; wherein the 'domain type prediction' is used for predicting the domain to which the text belongs, and the 'slot value type and corresponding slot value prediction' is used for predicting the keyword slot of the text.
The inventor finds that, through research, the sequence labeling method can predict both the field type and the slot value type and the corresponding slot value, but the prediction field type, the prediction slot value type and the corresponding slot value are independent, that is, prediction of the field type is not assisted by prediction of the slot value type and the corresponding slot value, so that the text semantic understanding effect is not satisfactory, and the user experience is poor.
Disclosure of Invention
In view of this, embodiments of the present application provide a text semantic understanding method and a related device, which can greatly improve a text semantic understanding effect of a target text to be semantically understood, thereby improving user experience.
In a first aspect, an embodiment of the present application provides a text semantic understanding method, where the method includes:
acquiring a target text to be semantically understood;
extracting semantic information of the target text, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information;
and performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text.
Optionally, the extracting semantic information of the target text, and obtaining the field type, the slot value type, and the corresponding slot value of the target text based on the semantic information includes:
extracting semantic information of the target text by using a semantic understanding model, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; the semantic understanding model is obtained by training the multi-task generating model based on training texts in different fields, field types of the training texts, slot value types and corresponding slot values.
Optionally, the semantic understanding model includes an input end and an output end; the input end comprises a word vector layer and an encoding layer, and the output end comprises a decoding layer.
Optionally, the extracting semantic information of the target text by using a semantic understanding model, and obtaining a field type, a slot value type, and a corresponding slot value of the target text based on the semantic information at the same time includes:
obtaining a word vector of the target text based on the target text and the word vector layer;
extracting semantic information of the target text to obtain a semantic vector of the target text based on the word vector of the target text and the coding layer;
and obtaining the field type, the slot value type and the corresponding slot value of the target text based on the semantic vector of the target text and the corresponding decoding layer.
Optionally, the extracting semantic information of the target text based on the word vector of the target text and the coding layer to obtain the semantic vector of the target text includes:
inputting the word vector of the target text into the coding layer to obtain a hidden layer vector of the target text;
obtaining a first intermediate context vector based on the word vector of the target text and the corresponding first weight; obtaining a second intermediate context vector based on the hidden layer vector of the target text and a corresponding second weight;
and extracting semantic information of the target text to obtain a semantic vector of the target text based on the first intermediate context vector and the second intermediate context vector.
Optionally, the decoding layer includes a first decoding layer and a second decoding layer; when the field type of the target text is non-chatting, the output of the second decoding layer is null, and when the field type of the target text is chatting, the output of the first decoding layer is null.
Optionally, the method further includes:
judging whether the domain type of the slot value type of the target text is the same as the domain type of the target text;
if yes, responding to the target text based on the field type, the slot value type and the corresponding slot value of the target text;
if not, refusing to respond to the target text or inquiring the target text.
In a second aspect, an embodiment of the present application provides an apparatus for semantic understanding of text, where the apparatus includes:
the acquisition unit is used for acquiring a target text to be semantically understood;
the obtaining unit is used for extracting semantic information of the target text and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information;
and the semantic understanding unit is used for performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text.
Optionally, the obtaining unit is specifically configured to:
extracting semantic information of the target text by using a semantic understanding model, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; the semantic understanding model is obtained by training the multi-task generating model based on training texts in different fields, field types of the training texts, slot value types and corresponding slot values.
Optionally, the semantic understanding model includes an input end and an output end; the input end comprises a word vector layer and an encoding layer, and the output end comprises a decoding layer.
Optionally, the obtaining unit includes:
a first obtaining subunit, configured to obtain a word vector of the target text based on the target text and the word vector layer;
the second obtaining subunit is configured to extract semantic information of the target text to obtain a semantic vector of the target text based on the word vector of the target text and the coding layer;
and the third obtaining subunit is configured to obtain a domain type, a slot value type, and a corresponding slot value of the target text based on the semantic vector of the target text and the corresponding decoding layer.
Optionally, the second obtaining subunit includes:
a first obtaining module, configured to input the word vector of the target text into the coding layer, and obtain a hidden layer vector of the target text;
a second obtaining module, configured to obtain a first intermediate context vector based on the word vector of the target text and the corresponding first weight; obtaining a second intermediate context vector based on the hidden layer vector of the target text and a corresponding second weight;
and a third obtaining module, configured to extract semantic information of the target text based on the first intermediate context vector and the second intermediate context vector to obtain a semantic vector of the target text.
Optionally, the decoding layer includes a first decoding layer and a second decoding layer; when the field type of the target text is non-chatting, the output of the second decoding layer is null, and when the field type of the target text is chatting, the output of the first decoding layer is null.
Optionally, the method further includes:
the judging unit is used for judging whether the domain type of the slot value type of the target text is the same as the domain type of the target text or not;
the first response unit is used for responding the target text based on the field type, the slot value type and the corresponding slot value of the target text if the target text is in the first response unit;
and the second response unit is used for refusing to respond to the target text or inquiring about the target text if the answer is not positive.
In a third aspect, an embodiment of the present application provides a terminal device, where the terminal device includes a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to perform the method for semantic understanding of text according to any one of the first aspect described above according to instructions in the program code.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium for storing program code for performing the method for semantic understanding of text according to any one of the first aspect.
Compared with the prior art, the method has the advantages that:
by adopting the technical scheme of the embodiment of the application, firstly, a target text to be semantically understood is obtained; then, extracting semantic information of the target text, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; and finally, performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text. Therefore, by extracting semantic information of the target text, the relation between the field type and the slot value type and the corresponding slot value is fully mined, the slot value type and the corresponding slot value are fully utilized for predicting the auxiliary field type, so that the field type, the slot value type and the corresponding slot value of the target text can be obtained at the same time, the text semantic understanding effect of the target text to be subjected to semantic understanding can be greatly improved, and the user experience is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a system framework related to an application scenario in an embodiment of the present application;
fig. 2 is a schematic flowchart of a text semantic understanding method according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a semantic understanding model provided in an embodiment of the present application;
FIG. 4 is a schematic structural diagram of another semantic understanding model provided in an embodiment of the present application;
fig. 5 is a schematic structural diagram of an apparatus for semantic understanding of text according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. 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 application.
The text semantic understanding means that the domain to which the text belongs and the keyword slot thereof can be accurately judged according to the text input by the user. The existing text semantic understanding adopts a sequence labeling method, and a sequence labeling model is trained aiming at a slot value type and a corresponding slot value under a field type and is divided into two independent sub-modules of 'field type prediction' and 'slot value type and corresponding slot value prediction'. However, the inventor finds that the prediction domain type, the prediction slot value type and the corresponding slot value are independent, that is, prediction of the prediction auxiliary domain type without using the slot value type and the corresponding slot value makes the semantic understanding effect of the text unsatisfactory, resulting in poor user experience.
In order to solve the problem, in the embodiment of the application, firstly, a target text to be semantically understood is obtained; then, extracting semantic information of the target text, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; and finally, performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text. Therefore, by extracting semantic information of the target text, the relation between the field type and the slot value type and the corresponding slot value is fully mined, the slot value type and the corresponding slot value are fully utilized for predicting the auxiliary field type, so that the field type, the slot value type and the corresponding slot value of the target text can be obtained at the same time, the text semantic understanding effect of the target text to be subjected to semantic understanding can be greatly improved, and the user experience is improved.
For example, one of the scenarios in the embodiment of the present application may be applied to the scenario shown in fig. 1, where the scenario includes the intelligent dialog system 100, and the intelligent dialog system 100 includes the semantic understanding module 101. After a user inputs a dialog text through the intelligent dialog system 100, the dialog text is used as a target text to be semantically understood, the semantic understanding module 101 obtains the target text to be semantically understood, and the text semantic understanding is performed on the target text to be semantically understood by using the implementation manner of the embodiment of the present application.
It is to be understood that, in the above application scenario, although the action of the embodiment of the present application is described as being performed by the semantic understanding module 101, the present application is not limited in terms of the execution subject as long as the action disclosed in the embodiment of the present application is performed.
It is to be understood that the above scenario is only one example of a scenario provided in the embodiment of the present application, and the embodiment of the present application is not limited to this scenario.
The following describes in detail a specific implementation manner of a text semantic understanding method and a related apparatus in the embodiments of the present application by way of embodiments with reference to the accompanying drawings.
Exemplary method
Referring to fig. 2, a flowchart of a text semantic understanding method in an embodiment of the present application is shown. In this embodiment, the method may include, for example, the steps of:
step 201: and acquiring a target text to be semantically understood.
It can be understood that performing semantic understanding of text first requires acquiring a target text to be semantically understood. Specifically, for example, in an intelligent dialog system scenario, after a user inputs a dialog text through an intelligent dialog system, the dialog text may be used as a target text to be semantically understood, a semantic understanding module of the intelligent dialog system obtains the target text to be semantically understood, and then text semantic understanding needs to be performed on the target text to be semantically understood.
Step 202: and extracting semantic information of the target text, and simultaneously obtaining the field type, the slot value type and the corresponding slot value of the target text based on the semantic information.
It should be noted that, if the text semantic understanding is performed on the target text by using the sequence tagging method, although the field type of the target text can be predicted, and the slot value type and the corresponding slot value of the target text can be predicted, the field type of the predicted target text, the slot value type of the predicted target text, and the corresponding slot value are independent of each other, that is, the prediction of the field type is not assisted by the prediction of the slot value type and the corresponding slot value, so that the text semantic understanding effect of the target text is not satisfactory, and the user experience is poor. Therefore, in the embodiment of the present application, the semantic information of the target text to be semantically understood in the extracting step 201 is considered, the relationship between the domain type and the slot value type and the corresponding slot value is sufficiently mined, and the prediction of the domain type is sufficiently assisted by the prediction of the slot value type and the corresponding slot value, so that the domain type, the slot value type and the corresponding slot value of the target text are simultaneously obtained based on the semantic information.
It should be further noted that the slot value types in different domain types have differences, that is, the slot value type in each domain type has particularity, if the different domain types are distinguished, and the model is trained separately for each domain type, the internal relation among the multiple domain types cannot be considered, and the word vectors trained separately for each domain type cannot be shared, so that the semantic understanding effect of the text is unsatisfactory, and the user experience is poor. Therefore, in the embodiment of the present application, a multitask generating model is adopted for training with respect to the field type, the slot value type, and the corresponding slot value of each training text in different fields, on the basis of fully mining the relationship between the field type, the slot value type, and the corresponding slot value and fully utilizing the prediction of the slot value type and the prediction of the prediction-assisted field type of the corresponding slot value, the internal relation between the training texts in different fields can be fully mined, word vectors of the training texts are fully shared, and the trained multitask generating model can be used as a semantic understanding model. The semantic understanding model is utilized to process the target text to be semantically understood, and the text semantic understanding effect of the target text to be semantically understood can be greatly improved. Therefore, in an optional implementation manner of this embodiment of the present application, the step 202 may specifically be, for example: extracting semantic information of the target text by using a semantic understanding model, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; the semantic understanding model is obtained by training the multi-task generating model based on training texts in different fields, field types of the training texts, slot value types and corresponding slot values.
It should be noted that, based on the training texts in different fields, the field types, the slot value types, and the corresponding slot values of the training texts, the multi-task generating model is trained to obtain the semantic understanding model, which actually means that the multi-task generating model is firstly used to obtain the predicted field types, the predicted slot value types, and the corresponding predicted slot values of the training texts, and then parameters of the multi-task generating model are iteratively updated by using the loss functions and the like through the predicted field types, the predicted slot value types, and the corresponding predicted slot values of the training texts, and the field types, the slot value types, and the corresponding slot values of the training texts, and finally the training of the multi-task generating model is completed to obtain the semantic understanding model.
The field type, the slot value type and the corresponding slot value of the training text are labeled based on preset field types and slot value types under each field type; the respective domain types and the respective slot value types under each domain type may be uniformly set based on an industry application, for example, from the viewpoint of practical application. The respective domain types may include, for example, music, car, television, navigation, weather, stock, music, flight, movie, ticket booking, smart home, chatting, and the like, and the respective domain types are not limited thereto in the embodiment of the present application. When the domain type is "music", the respective slot value types under the domain type "music" may include, for example, songs, singers, versions, genres, languages, sources, and the like, and the respective slot value types under the domain type "music" in the embodiment of the present application are not limited thereto; the respective slot value types in other field types are not illustrated here.
After the field type, the slot value type, and the corresponding slot value of the training text are labeled, the training text, the field type, the slot value type, and the corresponding slot value of the training text may be formed into a training example as shown in table 1 below, where the training example is only a training example of the training text, the field type, the slot value type, and the corresponding slot value in an individual field, and the training example is not limited thereto, and is used for training the multitask generation model to obtain each training text, the field type, the slot value type, and the corresponding slot value in different fields of the semantic understanding model.
TABLE 1 training examples
On the basis of the above description, with respect to step 202, the semantic understanding model in practical application may include, for example, two parts, i.e., an input end and an output end; the input end may include, for example, a word vector layer and an encoding layer, where the word vector layer is used to obtain a word vector corresponding to each word in the target text, and the encoding layer is used to encode each word vector to extract semantic information of the target text to obtain a semantic vector of the target text; correspondingly, the output may for example comprise a decoding layer for decoding the semantic vector in order to predict the domain type, the slot value type and the corresponding slot value of the obtained target text. Therefore, in an alternative implementation manner of this embodiment of the present application, the semantic understanding model includes an input end and an output end; the input end comprises a word vector layer and an encoding layer, and the output end comprises a decoding layer. For example, a structural diagram of a semantic understanding model is shown in fig. 3. Correspondingly, the step 202 may comprise, for example, the steps of:
step A: and obtaining a word vector of the target text based on the target text and the word vector layer.
Specifically, assuming that the target text is "i want to listen to the distinguished of a schoolmate", inputting the target text "i want to listen to the distinguished of a schoolmate" into a word vector layer, word vectors corresponding to respective words "i", "want", "listen", "open", "learn", "friend", "kiss", and "distinguished" in the target text "i want to listen to the distinguished of a schoolmate" may be obtained, and the dimension of the word vector may be, for example, 300 dimensions.
And B: and extracting semantic information of the target text to obtain a semantic vector of the target text based on the word vector of the target text and the coding layer.
Specifically, the encoding layer may be, for example, a bidirectional encoding layer, such as a bidirectional long-short term memory model, and a word vector corresponding to each word in the target text "i want to listen to the distinguished of a scholaree" is input into the bidirectional long-short term memory model, so that a forward hidden layer representation and a backward hidden layer representation may be obtained to extract semantic information of the target text "i want to listen to the distinguished of a scholaree" and obtain a semantic vector of the target text "i want to listen to the distinguished of a scholaree".
It should be further noted that, considering that when the target text is longer, the number of word vectors of the target text obtained by executing step a is large, if step B is executed, the semantic vector of the target text obtained only by the coding layer is likely to lose more detailed information in the target text; that is, when the target text is long, the semantic information of the target text is extracted only through the coding layer in the step B, which is not accurate enough, so that the semantic vector of the target text cannot accurately represent the semantic information of the target text. For example, the target text is "i have a good mood today, and give me the version of the concert in a sunny bar", if step B is executed, the semantic vector of the target text "i have a good mood today, give me the version of the concert in a sunny bar" is obtained only by the coding layer, and the detail information of the "version of the concert" in the target text is likely to be lost. Therefore, in the embodiment of the present application, an attention layer, especially a hierarchical attention layer, needs to be introduced at an input end of the semantic understanding model, and the degree of importance of each word in the target text to the semantic information of the target text is measured by using an attention mechanism based on different granularities, so that information in the target text that is important to the semantic information of the target text is automatically captured. Therefore, in an optional implementation manner of this embodiment of the present application, the input end further includes an attention layer, where the attention layer is a hierarchical attention layer; for example, fig. 4 shows a schematic structure diagram of another semantic understanding model.
Because the semantics of the information in the target text may be different in different contexts, in order to better distinguish the semantic differences of the information due to different information contexts, an attention mechanism based on different granularities needs to be adopted. Specifically, for step B, firstly, inputting a word vector of the target text into an encoding layer, for example, the above bidirectional long-and-short term memory model, and adding the forward hidden layer representation and the backward hidden layer representation to obtain a hidden layer vector; then, a first intermediate context vector is obtained through the word vector and the corresponding first weight, and a second intermediate context vector is obtained through the hidden layer vector and the corresponding second weight; and finally, the introduced level attention layer is used for extracting semantic information of the target text more accurately through the first intermediate context vector and the second intermediate context vector to obtain the semantic vector which represents the semantic information of the target text more accurately. Therefore, in an optional implementation manner of the embodiment of the present application, the step B may include, for example, the following steps:
step B1: and inputting the word vector of the target text into the coding layer to obtain a hidden layer vector of the target text.
Step B2: obtaining a first intermediate context vector based on the word vector of the target text and the corresponding first weight; and obtaining a second intermediate context vector based on the hidden layer vector of the target text and the corresponding second weight.
Specifically, step B2 may employ the following formula, for example:
eij=(st-1,hj);
eij=(st-1,wj);
tx represents the total word count, w, of the target textjWord vector, h, representing the jth word in the target textjA word vector representing the jth word in the target text is input into the hidden layer vector of the encoded layer output, βijDenotes wjCorresponding first weight value, αijRepresents hjCorresponding second weight, cLiRepresenting a first intermediate context vector, cHiRepresenting a second intermediate context vector.
Step B3: and extracting semantic information of the target text to obtain a semantic vector of the target text based on the first intermediate context vector and the second intermediate context vector.
Specifically, step B3 may employ the following formula, for example:
ci=[cHi;cLi;cHi+cLi]。
and C: and obtaining the field type, the slot value type and the corresponding slot value of the target text based on the semantic vector of the target text and the corresponding decoding layer.
It can be understood that, after the semantic vector of the target text "i want to listen to the distinguished of a scholarly friend" is input into the corresponding decoding layer, the field type of the target text "i want to listen to the distinguished of a scholarly friend" can be predicted to be "music", and the slot value type and the corresponding slot value are "singer: zhang schoolfriends and songs: and (4) performing differentiation.
It should be noted that, when the domain type is "chatting", the context of the domain type "chatting" does not have a slot value type and a corresponding slot value, and thus, for each domain type, according to whether the domain type is chatting, the domain type can be divided into two main domain types, "non-chatting" and "chatting"; correspondingly, based on whether the context of the two major domain types of "non-chatty" and "chatty" has a slot value type and a corresponding slot value, for example, the decoding layers may be set as a first decoding layer and a second decoding layer, the first decoding layer is used for processing semantic vectors of the text in the "non-chatty" major domain type, and the second decoding layer is used for processing semantic vectors of the training text in the "chatty" major domain type, so that the distinction is obviously not confused. Therefore, in an optional implementation manner of the embodiment of the present application, the decoding layer includes a first decoding layer and a second decoding layer; when the field type of the target text is non-chatting, the output of the second decoding layer is null, and when the field type of the target text is chatting, the output of the first decoding layer is null.
As can be seen from the above description, after the semantic vector of the target text "i want to listen to the classification of a schoolmate" is input into the decoding layer, the first decoding layer actually outputs the field type, the slot value type and the corresponding slot value of the target text "i want to listen to the classification of a schoolmate", and the second decoding layer outputs the null. If the target text is 'today's true heat ', and the semantic vector of the target text' today's true heat' is input into the decoding layer, it is actually the second decoding layer that outputs the field type of obtaining the target text 'i want to hear the thoughts of a schoolmate' is 'chatting', there is no slot value type and corresponding slot value, and the output of the first decoding layer is null.
Step 203: and performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text.
It can be understood that after the field type, the slot value type, and the corresponding slot value of the target text are obtained in step 201, the field to which the target text belongs and the keyword slot thereof are represented, that is, the text semantic understanding can be performed based on the field type, the slot value type, and the corresponding slot value of the target text, so that the text semantic understanding of the target text to be subjected to semantic understanding is realized, and the text semantic understanding effect of the target text to be subjected to semantic understanding is greatly improved, so that the user experience is improved.
It should be further noted that, regarding the domain type, the slot value type, and the corresponding slot value of the target text obtained in step 202, the domain type to which the slot value type of the obtained target text belongs may be the same as or different from the domain type of the obtained target text, and different ways need to be adopted to respond to the target text in the same or different cases, which is specifically described as follows:
when the obtained field type of the slot value of the target text belongs to is the same as the obtained field type of the target text, the method indicates that the field type, the slot value type and the corresponding slot value of the target text obtained in the step 202 are high in prediction accuracy, semantic information of the target text can be accurately expressed, and the target text can be responded based on the field type, the slot value type and the corresponding slot value of the target text; when the field type to which the slot value type of the obtained target text belongs is different from the field type of the obtained target text, the field type, the slot value type and the corresponding slot value prediction accuracy of the target text obtained in the step 202 are low, semantic information of the target text cannot be accurately expressed, and the target text needs to be rejected to be responded or queried. Therefore, in an optional implementation manner of the embodiment of the present application, for example, the following steps may be further included:
step D: judging whether the domain type of the slot value type of the target text is the same as the domain type of the target text;
step E: if yes, responding to the target text based on the field type, the slot value type and the corresponding slot value of the target text;
step F: if not, refusing to respond to the target text or inquiring the target text.
Through various implementation manners provided by the embodiment, firstly, a target text to be semantically understood is obtained; then, extracting semantic information of the target text, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; and finally, performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text. Therefore, by extracting semantic information of the target text, the relation between the field type and the slot value type and the corresponding slot value is fully mined, the slot value type and the corresponding slot value are fully utilized for predicting the auxiliary field type, so that the field type, the slot value type and the corresponding slot value of the target text can be obtained at the same time, the text semantic understanding effect of the target text to be subjected to semantic understanding can be greatly improved, and the user experience is improved.
Exemplary devices
Referring to fig. 5, a schematic structural diagram of an apparatus for semantic understanding of text in the embodiment of the present application is shown. In this embodiment, the apparatus may specifically include:
an obtaining unit 501, configured to obtain a target text to be semantically understood;
an obtaining unit 502, configured to extract semantic information of the target text, and obtain a field type, a slot value type, and a corresponding slot value of the target text based on the semantic information;
a semantic understanding unit 503, configured to perform text semantic understanding on the target text based on the domain type, the slot value type, and the corresponding slot value of the target text.
In an optional implementation manner of the embodiment of the present application, the obtaining unit 502 is specifically configured to:
extracting semantic information of the target text by using a semantic understanding model, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; the semantic understanding model is obtained by training the multi-task generating model based on training texts in different fields, field types of the training texts, slot value types and corresponding slot values.
In an optional implementation manner of the embodiment of the present application, the semantic understanding model includes an input end and an output end; the input end comprises a word vector layer and an encoding layer, and the output end comprises a decoding layer.
In an optional implementation manner of this embodiment of this application, the obtaining unit 502 includes:
a first obtaining subunit, configured to obtain a word vector of the target text based on the target text and the word vector layer;
the second obtaining subunit is configured to extract semantic information of the target text to obtain a semantic vector of the target text based on the word vector of the target text and the coding layer;
and the third obtaining subunit is configured to obtain a domain type, a slot value type, and a corresponding slot value of the target text based on the semantic vector of the target text and the corresponding decoding layer.
In an optional implementation manner of the embodiment of the present application, the second obtaining subunit includes:
a first obtaining module, configured to input the word vector of the target text into the coding layer, and obtain a hidden layer vector of the target text;
a second obtaining module, configured to obtain a first intermediate context vector based on the word vector of the target text and the corresponding first weight; obtaining a second intermediate context vector based on the hidden layer vector of the target text and a corresponding second weight;
and a third obtaining module, configured to extract semantic information of the target text based on the first intermediate context vector and the second intermediate context vector to obtain a semantic vector of the target text.
In an optional implementation manner of the embodiment of the present application, the decoding layer includes a first decoding layer and a second decoding layer; when the field type of the target text is non-chatting, the output of the second decoding layer is null, and when the field type of the target text is chatting, the output of the first decoding layer is null.
In an optional implementation manner of the embodiment of the present application, the method further includes:
the judging unit is used for judging whether the domain type of the slot value type of the target text is the same as the domain type of the target text or not;
the first response unit is used for responding the target text based on the field type, the slot value type and the corresponding slot value of the target text if the target text is in the first response unit;
and the second response unit is used for refusing to respond to the target text or inquiring about the target text if the answer is not positive.
Through various implementation manners provided by the embodiment, firstly, a target text to be semantically understood is obtained; then, extracting semantic information of the target text, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; and finally, performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text. Therefore, by extracting semantic information of the target text, the relation between the field type and the slot value type and the corresponding slot value is fully mined, the slot value type and the corresponding slot value are fully utilized for predicting the auxiliary field type, so that the field type, the slot value type and the corresponding slot value of the target text can be obtained at the same time, the text semantic understanding effect of the target text to be subjected to semantic understanding can be greatly improved, and the user experience is improved.
In addition, an embodiment of the present application further provides a terminal device, where the terminal device includes a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is used for executing the text semantic understanding method of the above method embodiments according to the instructions in the program code.
The embodiment of the present application further provides a computer-readable storage medium, which is used for storing a program code, where the program code is used for executing the method for semantic understanding of text described in the above method embodiment.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing is merely a preferred embodiment of the present application and is not intended to limit the present application in any way. Although the present application has been described with reference to the preferred embodiments, it is not intended to limit the present application. Those skilled in the art can now make numerous possible variations and modifications to the disclosed embodiments, or modify equivalent embodiments, using the methods and techniques disclosed above, without departing from the scope of the claimed embodiments. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application still fall within the protection scope of the technical solution of the present application without departing from the content of the technical solution of the present application.
Claims (10)
1. A method for semantic understanding of text, comprising:
acquiring a target text to be semantically understood;
extracting semantic information of the target text, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information;
and performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text.
2. The method according to claim 1, wherein the extracting semantic information of the target text, and based on the semantic information, obtaining a domain type, a slot value type, and a corresponding slot value of the target text at the same time specifically comprises:
extracting semantic information of the target text by using a semantic understanding model, and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information; the semantic understanding model is obtained by training the multi-task generating model based on training texts in different fields, field types of the training texts, slot value types and corresponding slot values.
3. The method of claim 2, wherein the semantic understanding model comprises an input and an output; the input end comprises a word vector layer and an encoding layer, and the output end comprises a decoding layer.
4. The method according to claim 3, wherein the extracting semantic information of the target text by using a semantic understanding model, and simultaneously obtaining a domain type, a slot value type and a corresponding slot value of the target text based on the semantic information comprises:
obtaining a word vector of the target text based on the target text and the word vector layer;
extracting semantic information of the target text to obtain a semantic vector of the target text based on the word vector of the target text and the coding layer;
and obtaining the field type, the slot value type and the corresponding slot value of the target text based on the semantic vector of the target text and the corresponding decoding layer.
5. The method according to claim 4, wherein the extracting semantic information of the target text based on the word vector of the target text and the coding layer to obtain the semantic vector of the target text comprises:
inputting the word vector of the target text into the coding layer to obtain a hidden layer vector of the target text;
obtaining a first intermediate context vector based on the word vector of the target text and the corresponding first weight; obtaining a second intermediate context vector based on the hidden layer vector of the target text and a corresponding second weight;
and extracting semantic information of the target text to obtain a semantic vector of the target text based on the first intermediate context vector and the second intermediate context vector.
6. The method of claim 3, wherein the decoding layers comprise a first decoding layer and a second decoding layer; when the field type of the target text is non-chatting, the output of the second decoding layer is null, and when the field type of the target text is chatting, the output of the first decoding layer is null.
7. The method of claim 1, further comprising:
judging whether the domain type of the slot value type of the target text is the same as the domain type of the target text;
if yes, responding to the target text based on the field type, the slot value type and the corresponding slot value of the target text;
if not, refusing to respond to the target text or inquiring the target text.
8. An apparatus for semantic understanding of text, comprising:
the acquisition unit is used for acquiring a target text to be semantically understood;
the obtaining unit is used for extracting semantic information of the target text and simultaneously obtaining a field type, a slot value type and a corresponding slot value of the target text based on the semantic information;
and the semantic understanding unit is used for performing text semantic understanding on the target text based on the field type, the slot value type and the corresponding slot value of the target text.
9. A terminal device, comprising a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
the processor is configured to perform the method for semantic understanding of text according to any one of claims 1-7 according to instructions in the program code.
10. A computer-readable storage medium for storing program code for performing the method for semantic understanding of text according to any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010010698.0A CN111274823B (en) | 2020-01-06 | 2020-01-06 | Text semantic understanding method and related device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010010698.0A CN111274823B (en) | 2020-01-06 | 2020-01-06 | Text semantic understanding method and related device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111274823A true CN111274823A (en) | 2020-06-12 |
CN111274823B CN111274823B (en) | 2021-08-27 |
Family
ID=71001616
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010010698.0A Active CN111274823B (en) | 2020-01-06 | 2020-01-06 | Text semantic understanding method and related device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111274823B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113177415A (en) * | 2021-04-30 | 2021-07-27 | 科大讯飞股份有限公司 | Semantic understanding method and device, electronic equipment and storage medium |
CN116738298A (en) * | 2023-08-16 | 2023-09-12 | 杭州同花顺数据开发有限公司 | Text classification method, system and storage medium |
WO2024066391A1 (en) * | 2022-09-30 | 2024-04-04 | 中兴通讯股份有限公司 | Intent-based driving method and apparatus for telecommunication network management product |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180203852A1 (en) * | 2017-01-18 | 2018-07-19 | Xerox Corporation | Natural language generation through character-based recurrent neural networks with finite-state prior knowledge |
CN109918682A (en) * | 2019-03-29 | 2019-06-21 | 科大讯飞股份有限公司 | A kind of text marking method and device |
CN110209446A (en) * | 2019-04-23 | 2019-09-06 | 华为技术有限公司 | The configuration method and device of slot position are combined in a kind of interactive system |
-
2020
- 2020-01-06 CN CN202010010698.0A patent/CN111274823B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180203852A1 (en) * | 2017-01-18 | 2018-07-19 | Xerox Corporation | Natural language generation through character-based recurrent neural networks with finite-state prior knowledge |
CN109918682A (en) * | 2019-03-29 | 2019-06-21 | 科大讯飞股份有限公司 | A kind of text marking method and device |
CN110209446A (en) * | 2019-04-23 | 2019-09-06 | 华为技术有限公司 | The configuration method and device of slot position are combined in a kind of interactive system |
Non-Patent Citations (2)
Title |
---|
JIAN-GUO ZHANG ET AL.: "Find or Classify? Dual Strategy for Slot-Value Predictions on Multi-Domain Dialog State Tracking", 《ARXIV》 * |
王子岳 等: "基于S-LSTM模型利用‘槽值门’机制的说话人意图识别", 《南京信息工程大学学报(自然科学版)》 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113177415A (en) * | 2021-04-30 | 2021-07-27 | 科大讯飞股份有限公司 | Semantic understanding method and device, electronic equipment and storage medium |
CN113177415B (en) * | 2021-04-30 | 2024-06-07 | 科大讯飞股份有限公司 | Semantic understanding method and device, electronic equipment and storage medium |
WO2024066391A1 (en) * | 2022-09-30 | 2024-04-04 | 中兴通讯股份有限公司 | Intent-based driving method and apparatus for telecommunication network management product |
CN116738298A (en) * | 2023-08-16 | 2023-09-12 | 杭州同花顺数据开发有限公司 | Text classification method, system and storage medium |
CN116738298B (en) * | 2023-08-16 | 2023-11-24 | 杭州同花顺数据开发有限公司 | Text classification method, system and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN111274823B (en) | 2021-08-27 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108509619B (en) | Voice interaction method and device | |
CN109918673B (en) | Semantic arbitration method and device, electronic equipment and computer-readable storage medium | |
CN111274823B (en) | Text semantic understanding method and related device | |
CN106960030B (en) | Information pushing method and device based on artificial intelligence | |
CN110807332A (en) | Training method of semantic understanding model, semantic processing method, semantic processing device and storage medium | |
CN110704576B (en) | Text-based entity relationship extraction method and device | |
CN112214593A (en) | Question and answer processing method and device, electronic equipment and storage medium | |
CN110619051B (en) | Question sentence classification method, device, electronic equipment and storage medium | |
CN111046656A (en) | Text processing method and device, electronic equipment and readable storage medium | |
CN112988979A (en) | Entity identification method, entity identification device, computer readable medium and electronic equipment | |
CN110795945A (en) | Semantic understanding model training method, semantic understanding device and storage medium | |
CN110210035B (en) | Sequence labeling method and device and training method of sequence labeling model | |
CN104572631A (en) | Training method and system for language model | |
CN111488468A (en) | Geographic information knowledge point extraction method and device, storage medium and computer equipment | |
CN111414471B (en) | Method and device for outputting information | |
CN114003682A (en) | Text classification method, device, equipment and storage medium | |
CN112328778A (en) | Method, apparatus, device and medium for determining user characteristics and model training | |
CN112446209A (en) | Method, equipment and device for setting intention label and storage medium | |
CN113515611B (en) | Intention recognition method and recognition system for task type multi-intention conversation | |
CN117093687A (en) | Question answering method and device, electronic equipment and storage medium | |
CN114676705B (en) | Dialogue relation processing method, computer and readable storage medium | |
CN110852103A (en) | Named entity identification method and device | |
CN117520793A (en) | Method and device for generating intended slot recognition model and electronic equipment | |
CN114398903B (en) | Intention recognition method, device, electronic equipment and storage medium | |
CN114116975A (en) | Multi-intention identification method and system |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |