Semantic recognition method and apparatus

Obtaining character vectors and determining word vectors through the text processing model solves the problem of low accuracy of semantic recognition in the existing technology, improves the accuracy of semantic recognition, and reduces the impact of contextual information.

WO2024179519A1PCT designated stage expired Publication Date: 2024-09-06VIVO MOBILE COMM CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/079034
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-01
Filing Date
2024-02-28
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

In the existing technology, the accuracy of semantic recognition is low, mainly because the word vector is not accurate enough and is greatly affected by contextual information, resulting in inaccurate semantic recognition results.

Method used

The text is processed through the preset text processing model to obtain character vectors, and word vectors are determined based on these character vectors. Context information is fully considered to avoid word vectors being affected by context, thereby improving the accuracy of semantic recognition.

Benefits of technology

It improves the accuracy of semantic recognition, ensures that word vectors reduce the impact of contextual information while retaining the semantics of keywords, and improves the accuracy of semantic recognition results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024079034_06092024_PF_FP
    Figure CN2024079034_06092024_PF_FP
Patent Text Reader

Abstract

Provided in the present application are a semantic recognition method and apparatus. The semantic recognition method comprises: acquiring N pieces of first text, and second text, wherein each piece of first text comprises a first keyword in a preset word list, and N is a positive integer greater than 1; performing first text processing on each piece of first text by means of a preset text processing model, so as to obtain M character vectors corresponding to the first keyword in each piece of first text, wherein M is a positive integer greater than 1; according to the M character vectors, determining a first word vector corresponding to each piece of first text; and performing semantic recognition on the second text according to the first word vector corresponding to each piece of first text.
Need to check novelty before this filing date? Find Prior Art

Description

Semantic recognition method and device

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on March 1, 2023, with application number 202310181906.7 and invention name “Semantic Recognition Method and Device Thereof”. The entire contents of the Chinese patent application are incorporated herein by reference. Technical Field

[0003] The present application belongs to the field of data processing technology, and specifically relates to a semantic recognition method and device thereof. Background Art

[0004] Currently, related technologies usually perform semantic recognition on text based on a pre-set vocabulary to obtain the text category corresponding to the text. The above vocabulary includes keywords and text categories. It is easy to understand that the above vocabulary can represent the mapping relationship between keywords and text categories, and the above keywords can be represented by the word vectors included in the vocabulary. However, the word vectors representing the keywords in the above vocabulary may not be accurate enough, which affects the recognition results of semantic recognition and thus reduces the accuracy of semantic recognition.

[0005] Summary of the Invention

[0006] The purpose of the embodiments of the present application is to provide a semantic recognition method and device thereof, which can solve the problem of low accuracy of semantic recognition.

[0007] In a first aspect, an embodiment of the present application provides a semantic recognition method, which includes: obtaining N first texts and second texts; each first text includes a first keyword in a preset vocabulary, where N is a positive integer greater than 1; performing first text processing on each first text through a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text, where M is a positive integer greater than 1; determining a first word vector corresponding to each first text based on the M character vectors; and performing semantic recognition on the second text based on the first word vector corresponding to each first text.

[0008] In second aspect, an embodiment of the present application provides a semantic recognition device, which includes: an acquisition module for acquiring N first texts and second texts; each first text includes a first keyword in a preset vocabulary, where N is a positive integer greater than 1; a first processing module for performing first text processing on each first text through a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text, where M is a positive integer greater than 1; a first determination module for determining the first word vector corresponding to each first text based on the M character vectors; and a first recognition module for performing semantic recognition on the second text based on the first word vector corresponding to each first text.

[0009] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.

[0010] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0011] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the method described in the first aspect.

[0012] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the method described in the first aspect.

[0013] The embodiment of the present application performs first text processing on each first text through a preset text processing model, obtains M character vectors corresponding to the first keyword in each first text, and then determines the first word vector based on the M character vectors. The above-mentioned first word vector is determined based on the M character vectors, which fully takes into account the context information in the first text, and is not as in the related art that the text feature vector corresponding to the first text is directly determined as the word vector; the above-mentioned M character vectors are obtained by performing first text processing on each first text through the text processing model, thereby taking into account the semantics of the first keyword in the first text. The above-mentioned method ensures that the first word vector will not be affected by the context information while retaining the semantics of the keyword, and thus improves the accuracy of semantic recognition in the subsequent process of semantic recognition of the second text based on the first word vector corresponding to each first text. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] FIG1 is a flow chart of a semantic recognition method provided by an embodiment of the present application;

[0015] FIG2 is an application flow chart of updating a vocabulary table according to an embodiment of the present application;

[0016] FIG3 is a structural diagram of a semantic recognition device provided in an embodiment of the present application;

[0017] FIG4 is a structural diagram of an electronic device provided in an embodiment of the present application;

[0018] FIG5 is a hardware structure diagram of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the accompanying drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the embodiments described are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field are within the scope of protection of this application.

[0020] The terms "first," "second," and the like in the specification and claims of this application are used to distinguish similar objects, and are not used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this application can be implemented in an order other than that illustrated or described herein, and that the objects distinguished by "first," "second," and the like are generally of the same type, and do not limit the number of objects; for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims refers to at least one of the connected objects, and the character " / " generally indicates that the objects connected are in an "or" relationship.

[0021] In related technologies, text is typically categorized using a pre-set vocabulary. This vocabulary can represent the mapping between keywords and text categories, and these keywords can be represented by word vectors included in the vocabulary. Specifically, after acquiring the text, the text keywords are extracted from the text, and the similarity between the word vectors representing the keywords in the vocabulary is calculated. Based on this similarity value, the text category corresponding to the text is determined, thereby achieving semantic recognition of the text.

[0022] The word vectors of keywords are usually obtained in the following two ways to build a vocabulary:

[0023] Method 1:

[0024] Input the keyword into a preset text processing model to obtain the word vector corresponding to the keyword. The above text processing model includes a Bert model, a Markov model, or other types of text processing models.

[0025] Method 2:

[0026] The text containing the keyword is input into a preset text processing model to obtain a text feature vector corresponding to the text, and then the text feature vector is determined as the word vector corresponding to the keyword. Optionally, if the text is a sentence, the text feature vector is a sentence vector.

[0027] However, the word vector obtained by the above method 1 cannot fully express the semantics of the keyword, which in turn affects the accuracy of the vocabulary. In the process of classifying texts through the vocabulary, the accuracy of the semantic recognition results is also reduced.

[0028] The word vectors obtained by the above method 2 are easily affected by the contextual information in the text, that is, the word vectors obtained by the above method 2 are not sufficiently prepared, which in turn affects the accuracy of the vocabulary. In the process of classifying the text through the vocabulary, the accuracy of the semantic recognition results is also reduced.

[0029] Based on the above-mentioned technical problems, an embodiment of the present application provides a semantic recognition method. The semantic recognition method provided by the embodiment of the present application is described in detail below through specific embodiments and application scenarios in combination with the accompanying drawings.

[0030] The present invention provides a semantic recognition method. Please refer to Figure 1, which is a flow chart of the semantic recognition method provided by the present invention. The semantic recognition method provided by the present invention includes the following steps:

[0031] S101: Obtain N first texts and second texts.

[0032] In this step, N first texts are obtained, and each first text includes a first keyword, where N is a positive integer greater than 1.

[0033] Optionally, the N first texts may be obtained from a preset database, or downloaded from the Internet. The specific method for obtaining the N first texts is not limited here.

[0034] Optionally, the first text mentioned above is a public opinion text used in a public opinion analysis project.

[0035] Optionally, the first text may be a sentence.

[0036] In this step, a second text is obtained, which can be understood as the text to be classified. The second text includes a second keyword, which can be a manually annotated opinion word or an object word representing an opinion.

[0037] S102: Perform first text processing on each of the first texts using a preset text processing model to obtain M character vectors corresponding to the first keyword in each of the first texts.

[0038] In this embodiment, a text processing model is pre-set. As mentioned above, the text processing model includes a Bert model, a Markov model, or other types of text processing models.

[0039] In this step, N first texts are input into the text processing model, and each first text is processed by the text processing model to obtain M character vectors corresponding to the first keyword in each first text. M is a positive integer greater than 1.

[0040] The above character vector is also called a token vector, and is a vector corresponding to each character in the first keyword.

[0041] Among them, the text processing model processes the input text to obtain a processing method of the vector corresponding to each character in the input text, which is called the first text processing method.

[0042] S103: Determine a first word vector corresponding to each first text based on the M character vectors.

[0043] In this step, after obtaining M character vectors corresponding to the first keyword in each first text, these M character vectors can be used to determine the first word vector corresponding to each first text, wherein the first word vector corresponding to the above-mentioned first text is used to represent the first keyword in the first text.

[0044] S104: Perform semantic recognition on the second text according to the first word vector corresponding to each first text.

[0045] In this step, after obtaining the first word vector corresponding to each first text, that is, N first word vectors, semantic recognition can be performed on the second text based on the N first word vectors. For the specific method of performing semantic recognition on the second text, please refer to the subsequent embodiments.

[0046] The embodiment of the present application performs first text processing on each first text through a preset text processing model, obtains M character vectors corresponding to the first keyword in each first text, and then determines the first word vector based on the M character vectors. The above-mentioned first word vector is determined based on the M character vectors, which fully takes into account the context information in the first text, and is not as in the related art that the text feature vector corresponding to the first text is directly determined as the word vector; the above-mentioned M character vectors are obtained by performing first text processing on each first text through the text processing model, thereby taking into account the semantics of the first keyword in the first text. The above-mentioned method ensures that the first word vector will not be affected by the context information while retaining the semantics of the keyword, and thus improves the accuracy of semantic recognition in the subsequent process of semantic recognition of the second text based on the first word vector corresponding to each first text.

[0047] Optionally, performing text processing on each of the first texts using a preset text processing model to obtain M character vectors corresponding to the first keyword in each of the first texts includes:

[0048] For each of the first texts, performing first text processing on the first text by using the text processing model to obtain at least two character vectors corresponding to each character in the first text;

[0049] Determining M target characters according to the position of the first keyword in the first text; the M target characters are used to represent the first keyword;

[0050] An average value of at least a portion of the character vectors corresponding to each target character is determined as the M character vectors corresponding to the first keyword in the first text.

[0051] In this embodiment, after the first text is processed by the text processing model, multiple character vectors corresponding to each character in the first text are obtained; then, based on the position of the character corresponding to the first keyword in the first text, M target characters for representing the first keyword from the multiple characters included in the first text are determined; the average value of at least part of the character vector corresponding to each target character is determined as the character vector corresponding to the target character, and then the M character vectors corresponding to the M target characters are determined as the M character vectors corresponding to the first keyword.

[0052] For example, the text processing model is a Bert model including 25 network layers, the first text is represented as a sentence including 10 characters "The battery cannot be charged, the charging is too slow", and the first keyword is "too slow".

[0053] In this case, the first text is input into the Bert model. Each network layer of the Bert model outputs 10 character vectors, that is, the Bert model outputs a total of 250 character vectors, and each character in the first text corresponds to 25 character vectors. Exemplarily, the output result of the i-th layer of the Bert model can be expressed as [vec_i1, vec_i2,..., vec_i10].

[0054] The position of the first keyword in the first text is the last three characters, and then the last three characters in the first text are determined as 3 target characters. Exemplarily, in the i-th layer of the Bert model, the target characters can be expressed as [vec_i8, vec_i9, vec_i10].

[0055] As described above, each character corresponds to 25 character vectors, that is to say, each target character also corresponds to 25 character vectors. Optionally, the average value of the 10th to 25th character vectors corresponding to each target character can be determined as the character vector corresponding to the first keyword.

[0056] Exemplarily, the character 'too' in the first keyword corresponds to 25 character vectors, and these 25 character vectors are respectively the character vectors output by the 1st network layer to the 25th network layer of the Bert model; calculate the average value of the character vectors output by the 10th network layer to the 25th network layer of the Bert model, and determine this average value as a character vector corresponding to the character 'too' in the first keyword.

[0057] Sampling in the same way as above, determine a character vector corresponding to the character'slow' in the first keyword, and determine a character vector corresponding to the character 'le' in the first keyword, and then determine the above three character vectors as 3 character vectors corresponding to the first keyword.

[0058] Optionally, the average value of all the character vectors corresponding to each target character can also be determined as the character vector corresponding to the first keyword.

[0059] In this embodiment, each first text is processed by a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text, so as to process the first text including the first keyword and part of the context information, taking into account the semantics of the first keyword in the first text and avoiding the semantic loss of the first keyword.

[0060] Optionally, determining the first word vector corresponding to each first text according to the M character vectors includes:

[0061] For each of the first texts, an average value of the M character vectors corresponding to the first keyword in the first text is determined as the first word vector corresponding to the first text.

[0062] In this embodiment, the average value of the M character vectors corresponding to the first keyword can be determined as the first word vector corresponding to the first text. It should be understood that in other embodiments, a weighted summation can be performed on the M character vectors corresponding to the first keyword, and the weighted summation result can be determined as the first word vector corresponding to the first text.

[0063] In this embodiment, the first word vector corresponding to each first text is determined based on M character vectors, rather than directly determining the text feature vector corresponding to the first text as the word vector as in the related art, so as to avoid the representation of the first word vector being affected by the context information in the first text.

[0064] Optionally, performing semantic recognition on the second text according to the first word vector corresponding to each first text includes:

[0065] Updating a preset vocabulary according to the first word vector corresponding to each of the first texts;

[0066] The text category corresponding to the second text is determined using the updated vocabulary.

[0067] In this embodiment, a vocabulary is pre-set, comprising a plurality of first keywords and a plurality of text categories, and is used to represent the mapping relationship between the first keywords and the text categories. This vocabulary can be used to classify texts. As described in the background art, text keywords are extracted from the text to be classified, and the similarity between the word vectors of the text keywords and the word vectors representing the first keywords in the vocabulary is calculated. Based on this similarity, the text category corresponding to the text to be classified is determined.

[0068] In this embodiment, after determining N first word vectors, the above-mentioned preset vocabulary can be updated according to the first word vector corresponding to each first text, and then the text category corresponding to the second text can be determined through the updated vocabulary, thereby realizing semantic recognition of the second text.

[0069] In other embodiments, the word vector of the second text can also be extracted, and at least one first word vector can be determined based on the similarity between each first word vector and the word vector of the second text, and then the text type corresponding to the first word vector can be determined as the text type corresponding to the second text, thereby achieving semantic recognition of the second text.

[0070] If the first keyword includes multiple semantics, and the vocabulary can represent the mapping relationship between the first keyword including multiple semantics and the text category, in this case, the technical solution involved in the following embodiment can be used to update the vocabulary:

[0071] Optionally, updating a preset vocabulary according to the first word vector corresponding to each first text includes:

[0072] Perform semantic clustering on the N first word vectors to obtain K clusters;

[0073] Determining an average value of at least one first word vector included in each cluster as a second word vector corresponding to the cluster;

[0074] The vocabulary is updated according to the K second word vectors corresponding to the K clusters; the updated vocabulary includes K second word vectors for representing the first keyword, and each second word vector is used to represent a semantic meaning corresponding to the first keyword.

[0075] In this embodiment, N first word vectors are clustered, and first word vectors with similar semantics are clustered in one cluster to obtain K clusters; each cluster includes at least one first word vector, and K is a positive integer less than or equal to N.

[0076] The average value of at least one first word vector included in each cluster is determined as the second word vector corresponding to the cluster. Specifically, the second word vector corresponding to the cluster can be determined by the following formula:

[0077] in, Represents the second word vector, N I Represents the number of second word vectors included in the cluster, Vec_i represents the i-th second word vector, and N_I represents the I-th first text.

[0078] After obtaining K clusters and the second word vector corresponding to each cluster, the vocabulary is updated. The updated vocabulary includes K second word vectors for representing the first keyword, that is, the first keyword can be represented by K second word vectors, and each second word vector is used to represent a semantic meaning corresponding to the first keyword. For example, the updated vocabulary includes 3 second word vectors for representing the first keyword, indicating that the updated vocabulary includes 3 semantic meanings of the first keyword.

[0079] Optionally, the vocabulary is used to represent a mapping relationship between the first keyword and the text category, and determining the text category corresponding to the second text using the updated vocabulary includes:

[0080] If the second keyword included in the second text is not the same as the first keyword, determining a text category corresponding to the second text based on a similarity between a text feature vector corresponding to the second text and each second word vector; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text using the text processing model;

[0081] In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

[0082] It should be understood that the vocabulary is used to represent the mapping relationship between the first keyword and the text category. In this embodiment, the text can be classified according to the updated vocabulary.

[0083] The second keyword is searched in the updated vocabulary. If the updated vocabulary includes the second keyword, that is, the second keyword is the same as the first keyword, the text category corresponding to the second text can be directly determined based on the mapping relationship represented by the updated vocabulary.

[0084] If the updated vocabulary does not include the second keyword, that is, the second keyword is not the same as the first keyword, in this case, the second text can be processed using a preset text processing model to obtain a text feature vector corresponding to the second text. The method by which the text processing model processes the input text to obtain a text feature vector corresponding to the input text is called the second text processing method. Optionally, the second text is a sentence including the second keyword, and the text feature vector corresponding to the second text is a sentence vector.

[0085] Calculate the similarity between the text feature vector and each second word vector in the vocabulary. If there is a second word vector whose similarity value with the text feature vector is higher than a preset threshold, the text category that has a mapping relationship with the second word vector is determined as the text category corresponding to the second text.

[0086] If there are multiple second word vectors whose similarity values ​​with the text feature vector are higher than the first preset threshold, the second word vector with the highest similarity value among the multiple second word vectors is determined, and the text category that has a mapping relationship with the second word vector is determined as the text category corresponding to the second text.

[0087] It should be understood that the above-mentioned method of determining the similarity between the text feature vector and the second word vector includes, but is not limited to, based on the cosine similarity between vectors, based on the Euclidean distance between vectors, or other calculation methods.

[0088] In this embodiment, text classification is performed using the updated vocabulary to achieve semantic recognition of the text. Because the second word vectors included in the updated vocabulary can accurately represent keywords, this does not affect the similarity calculation results between the word vectors of the text keywords and the word vectors representing the keywords in the vocabulary, thereby improving the accuracy of the semantic recognition results.

[0089] If the first keyword includes multiple semantics, but the vocabulary representation includes a mapping relationship between the first keyword and the text category, in this case, the technical solution involved in the following embodiment can be used to update the vocabulary:

[0090] Optionally, after obtaining N first texts and N second texts, the method further includes:

[0091] Performing second text processing on the N first texts using the text processing model to obtain N text feature vectors corresponding to the N first texts;

[0092] Filtering the N first texts based on similarities between the N text feature vectors and the benchmark word vectors to obtain L first texts; the benchmark word vectors are obtained by performing first text processing on preset benchmark texts using the text processing model;

[0093] Determine third word vectors corresponding to L first texts; the third word vector is an average of L fourth word vectors, and the L fourth word vectors are obtained by performing first text processing on the L first texts based on the text processing model;

[0094] Perform semantic recognition on the second text based on the L third word vectors corresponding to the first texts.

[0095] In this embodiment, a text processing model performs second text processing on N first texts to obtain N text feature vectors. The implementation of the second text processing is consistent with the implementation of the second text processing in the above embodiment and is not repeated here. Optionally, the first texts are sentences, and the text feature vectors are sentence vectors.

[0096] The text processing model performs first text processing on a preset reference text to obtain a reference word vector. The reference text includes a first keyword. The implementation of the first text processing is consistent with the implementation of the first text processing involved in the above embodiment and will not be repeated here.

[0097] The similarity between each text feature vector and the benchmark word vector is calculated, and the first texts corresponding to the text feature vectors having a similarity higher than a second preset threshold are selected to obtain L first texts.

[0098] L first texts are processed by a text processing model to obtain L fourth word vectors; an average value of the L fourth word vectors is determined as a third word vector, and semantic recognition of the second text is performed based on the third word vector. Optionally, a preset vocabulary can be updated based on the third word vector, wherein the updated vocabulary includes a third word vector for representing the first keyword, that is, the first keyword can be represented by one third word vector, and the third word vector is used to represent a semantic meaning corresponding to the first keyword.

[0099] To facilitate understanding of the technical solutions of some embodiments provided herein, please refer to FIG. As shown in FIG. 2 , in some embodiments of the present application, a vocabulary is pre-set, and the pre-set vocabulary can be updated to further perform semantic recognition on a second text using the updated vocabulary. The application process for updating the vocabulary provided herein is as follows: Obtain N first texts that include a first keyword.

[0100] When the first keyword includes multiple semantics and the vocabulary can represent the mapping relationship between the first keyword including multiple semantics and the text category, the vocabulary is updated in the following manner: determine N first word vectors corresponding to N first texts, perform semantic clustering on the N first word vectors, and obtain K clusters; determine the second word vector corresponding to each cluster; and update the vocabulary according to the K second word vectors corresponding to the K clusters.

[0101] In the case where the first keyword includes multiple semantics and the vocabulary representation includes a mapping relationship between the first keyword of one semantic and the text category, the vocabulary is updated in the following manner: second text processing is performed on N first texts through a text processing model to obtain N text feature vectors; L first texts are screened based on the similarity between the N text feature vectors and the benchmark word vectors; the third word vectors corresponding to the L first texts are determined; and the vocabulary is updated based on the third word vectors.

[0102] Optionally, performing semantic recognition on the second text according to the L third word vectors corresponding to the first texts includes:

[0103] Updating a preset vocabulary based on the L third word vectors corresponding to the first texts; the updated vocabulary includes the third word vector for representing the first keyword, and the updated vocabulary is used to represent the mapping relationship between the first keyword and the text category;

[0104] If the second keyword included in the second text is not the same as the first keyword, determining a text category corresponding to the second text based on a similarity between a text feature vector corresponding to the second text and the third word vector; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text using the text processing model;

[0105] In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

[0106] In this embodiment, a vocabulary is pre-set, which includes multiple first keywords and multiple text categories. The vocabulary is used to represent the mapping relationship between the first keywords and the text categories. The vocabulary can be used to classify texts.

[0107] In this embodiment, a preset vocabulary can be updated based on the third word vector. The specific updating method is consistent with the above-mentioned method of updating the vocabulary based on the first word vector, and will not be repeated here. The updated vocabulary includes a third word vector for representing the first keyword, that is, the first keyword can be represented by one third word vector, and the third word vector is used to represent a semantic meaning corresponding to the first keyword.

[0108] In this embodiment, the text can be classified according to the updated vocabulary, thereby achieving semantic recognition of the text.

[0109] The second keyword included in the second text is queried in the updated vocabulary. If the updated vocabulary includes the second keyword, that is, the second keyword is the same keyword as the first keyword, the text category corresponding to the second text can be directly determined based on the mapping relationship represented by the updated vocabulary.

[0110] If the updated vocabulary does not include the second keyword, that is, the second keyword is not the same keyword as the first keyword, in this case, the second text can be processed by a preset text processing model to obtain a text feature vector corresponding to the second text; and then the similarity between the text feature vector and the third word vector in the vocabulary is calculated. If the similarity value between the text feature vector and the third word vector is higher than a third preset threshold, the text category that has a mapping relationship with the third word vector is determined as the text category corresponding to the second text.

[0111] In this embodiment, text classification is performed using the updated vocabulary to achieve semantic recognition of the text. Because the third word vector included in the updated vocabulary can accurately represent the keywords, it does not affect the similarity calculation results between the word vectors of the text keywords and the word vectors representing the keywords in the vocabulary, thereby improving the accuracy of the semantic recognition results.

[0112] The semantic recognition device provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0113] As shown in FIG3 , the semantic recognition device 300 includes:

[0114] An acquisition module 301 is configured to acquire N first texts and second texts; each of the first texts includes a first keyword in a preset vocabulary, and N is a positive integer greater than 1;

[0115] A first processing module 302 is configured to perform first text processing on each first text using a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text, where M is a positive integer greater than 1;

[0116] A first determining module 303 is configured to determine a first word vector corresponding to each of the first texts based on the M character vectors;

[0117] The first recognition module 304 is configured to perform semantic recognition on the second text according to the first word vector corresponding to each first text.

[0118] Optionally, the first processing module 302 is specifically configured to:

[0119] For each of the first texts, performing first text processing on the first text by using the text processing model to obtain at least two character vectors corresponding to each character in the first text;

[0120] Determining M target characters according to the position of the first keyword in the first text; the M target characters are used to represent the first keyword;

[0121] An average value of at least a portion of the character vectors corresponding to each target character is determined as the M character vectors corresponding to the first keyword in the first text.

[0122] Optionally, the first determining module 303 is specifically configured to:

[0123] For each of the first texts, an average value of the M character vectors corresponding to the first keyword in the first text is determined as the first word vector corresponding to the first text.

[0124] Optionally, the first identification module 304 is specifically configured to:

[0125] updating a preset vocabulary according to the first word vector corresponding to each of the first texts; the vocabulary including the first keyword in each of the first texts;

[0126] The text category corresponding to the second text is determined using the updated vocabulary.

[0127] Optionally, the first identification module 304 is further configured to:

[0128] Perform semantic clustering on the N first word vectors to obtain K clusters; each cluster includes at least one first word vector, and K is a positive integer less than or equal to N;

[0129] Determining an average value of at least one first word vector included in each cluster as a second word vector corresponding to the cluster;

[0130] The vocabulary is updated according to the K second word vectors corresponding to the K clusters; the updated vocabulary includes K second word vectors for representing the first keyword, and each second word vector is used to represent a semantic meaning corresponding to the first keyword.

[0131] Optionally, the vocabulary is used to represent a mapping relationship between the first keyword and the text category;

[0132] The first identification module 304 is further specifically configured to:

[0133] If the second keyword included in the second text is not the same as the first keyword, determining a text category corresponding to the second text based on a similarity between a text feature vector corresponding to the second text and each second word vector; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text using the text processing model;

[0134] In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

[0135] Optionally, the semantic recognition device 300 further includes:

[0136] A second processing module is configured to perform second text processing on the N first texts using the text processing model to obtain N text feature vectors corresponding one-to-one to the N first texts;

[0137] a screening module, configured to screen the N first texts based on similarities between the N text feature vectors and a benchmark word vector to obtain L first texts; the benchmark word vectors are obtained by performing first text processing on a preset benchmark text using the text processing model;

[0138] A second determination module is configured to determine third word vectors corresponding to L first texts; the third word vector is an average of L fourth word vectors, and the L fourth word vectors are obtained by performing first text processing on the L first texts based on the text processing model;

[0139] The second recognition module is used to perform semantic recognition on the second text based on the L third word vectors corresponding to the first texts.

[0140] Optionally, the second identification module is specifically configured to:

[0141] Updating a preset vocabulary based on the L third word vectors corresponding to the first texts; the updated vocabulary includes the third word vector for representing the first keyword, and the updated vocabulary is used to represent the mapping relationship between the first keyword and the text category;

[0142] If the second keyword included in the second text is not the same as the first keyword, determining a text category corresponding to the second text based on a similarity between a text feature vector corresponding to the second text and the third word vector; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text using the text processing model;

[0143] In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

[0144] The embodiment of the present application performs first text processing on each first text through a preset text processing model, obtains M character vectors corresponding to the first keyword in each first text, and then determines the first word vector based on the M character vectors. The above-mentioned first word vector is determined based on the M character vectors, which fully takes into account the context information in the first text, and is not as in the related art that the text feature vector corresponding to the first text is directly determined as the word vector; the above-mentioned M character vectors are obtained by performing first text processing on each first text through the text processing model, thereby taking into account the semantics of the first keyword in the first text. The above-mentioned method ensures that the first word vector will not be affected by the context information while retaining the semantics of the keyword, and thus improves the accuracy of semantic recognition in the subsequent process of semantic recognition of the second text based on the first word vector corresponding to each first text.

[0145] The semantic recognition device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or a device other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a car-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc. It can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application does not make specific limitations.

[0146] The semantic recognition device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0147] The embodiment of the present application provides a semantic recognition device that can implement each process implemented by the method embodiment of Figure 1. To avoid repetition, they will not be described here.

[0148] Optionally, as shown in Figure 4, an embodiment of the present application also provides an electronic device 400, including a processor 401, a memory 402, and a program or instruction stored in the memory 402 and executable on the processor 401. When the program or instruction is executed by the processor 401, each process of the above-mentioned semantic recognition method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0149] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0150] FIG5 is a schematic diagram of the hardware structure of an electronic device implementing an embodiment of the present application.

[0151] The electronic device 500 includes but is not limited to: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 505, an interface unit 508, a memory 509, and a processor 510.

[0152] Those skilled in the art will appreciate that the electronic device 500 may further include a power source (e.g., a battery) to power various components. The power source may be logically connected to the processor 510 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The electronic device structure shown in FIG5 does not limit the electronic device. The electronic device may include more or fewer components than shown, or may combine certain components or arrange the components differently, which will not be described in detail here.

[0153] The input unit 504 is further configured to obtain N first texts and N second texts;

[0154] The processor 510 is further configured to perform first text processing on each first text using a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text;

[0155] Determine, based on the M character vectors, a first word vector corresponding to each first text;

[0156] Perform semantic recognition on the second text according to the first word vector corresponding to each of the first texts.

[0157] The embodiment of the present application performs first text processing on each first text through a preset text processing model, obtains M character vectors corresponding to the first keyword in each first text, and then determines the first word vector based on the M character vectors. The above-mentioned first word vector is determined based on the M character vectors, which fully takes into account the context information in the first text, and is not as in the related art that the text feature vector corresponding to the first text is directly determined as the word vector; the above-mentioned M character vectors are obtained by performing first text processing on each first text through the text processing model, thereby taking into account the semantics of the first keyword in the first text. The above-mentioned method ensures that the first word vector will not be affected by the context information while retaining the semantics of the keyword, and thus improves the accuracy of semantic recognition in the subsequent process of semantic recognition of the second text based on the first word vector corresponding to each first text.

[0158] It should be understood that in an embodiment of the present application, the input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042, and the graphics processor 5041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 506 may include a display panel 5061, and the display panel 5061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 506 includes a touch panel 5061 and at least one of other input devices 5062. The touch panel 5061 is also called a touch screen. The touch panel 5061 may include two parts: a touch detection device and a touch controller. Other input devices 5062 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.

[0159] The memory 509 can be used to store software programs and various data. The memory 509 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 509 may include a volatile memory or a non-volatile memory, or the memory 509 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM), and a direct memory bus random access memory (DRRAM). The memory 509 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0160] Processor 510 may include one or more processing units. Optionally, processor 510 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 510.

[0161] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned semantic recognition method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0162] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer-readable storage medium, such as a computer read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.

[0163] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned semantic recognition method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0164] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0165] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned semantic recognition method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0166] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0167] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0168] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A semantic recognition method, wherein: include: Obtain N first texts and second texts; each of the first texts includes a preset first keyword, and N is a positive integer greater than 1; Performing first text processing on each of the first texts through a preset text processing model to obtain M character vectors corresponding to the first keyword in each of the first texts, where M is a positive integer greater than 1; Determine, according to the M character vectors, a first word vector corresponding to each of the first texts; Perform semantic recognition on the second text according to the first word vector corresponding to each of the first texts.

2. The method according to claim 1, wherein: The step of performing text processing on each of the first texts by using a preset text processing model to obtain M character vectors corresponding to the first keyword in each of the first texts includes: For each of the first texts, performing first text processing on the first text by using the text processing model to obtain at least two character vectors corresponding to each character in the first text; Determine M target characters according to the position of the first keyword in the first text; the M target characters are used to represent the first keyword; An average value of at least part of the character vectors corresponding to each of the target characters is determined as the M character vectors corresponding to the first keyword in the first text.

3. The method according to claim 1, wherein: The determining, based on the M character vectors, a first word vector corresponding to each of the first texts includes: For each of the first texts, an average value of the M character vectors corresponding to the first keyword in the first text is determined as the first word vector corresponding to the first text.

4. The method according to claim 1, wherein: The performing semantic recognition on the second text according to the first word vector corresponding to each of the first texts includes: According to the first word vector corresponding to each of the first texts, a preset word list is updated; the word list includes the first keyword in each of the first texts; The text category corresponding to the second text is determined through the updated vocabulary.

5. The method according to claim 4, wherein: The updating of a preset vocabulary according to the first word vector corresponding to each of the first texts includes: Perform semantic clustering on the N first word vectors to obtain K clusters; each cluster includes at least one first word vector, and K is a positive integer less than or equal to N; Determine the average value of at least one first word vector included in each of the clusters as the second word vector corresponding to the cluster; The word list is updated according to the K second word vectors corresponding to the K clusters; the updated word list includes K second word vectors for representing the first keyword, and each second word vector is used to represent a semantics corresponding to the first keyword.

6. The method according to claim 4, wherein: The vocabulary is used to represent the mapping relationship between the first keyword and the text category; The determining, by using the updated vocabulary, a text category corresponding to the second text includes: In the case where the second keyword included in the second text is not the same keyword as the first keyword, determining the text category corresponding to the second text according to the similarity between the text feature vector corresponding to the second text and each second word vector; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text by the text processing model; In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

7. The method according to claim 1, wherein: After obtaining the N first texts and the second texts, the method further includes: Performing second text processing on the N first texts by using the text processing model to obtain N text feature vectors corresponding to the N first texts one by one; According to the similarity between the N text feature vectors and the benchmark word vector, the N first texts are screened to obtain L first texts; the benchmark word vector is obtained by performing first text processing on a preset benchmark text through the text processing model; Determine the third word vectors corresponding to the L first texts; the third word vector is the L fourth an average value of word vectors, where the L fourth word vectors are obtained by performing first text processing on the L first texts based on the text processing model; Perform semantic recognition on the second text based on L third word vectors corresponding to the first texts.

8. The method according to claim 7, wherein: The performing semantic recognition on the second text according to the L third word vectors corresponding to the first texts includes: According to the L third word vectors corresponding to the first texts, a preset word list is updated; the updated word list includes the third word vector used to represent the first keyword, and the updated word list is used to represent the mapping relationship between the first keyword and the text category; In the case where the second keyword included in the second text is not the same keyword as the first keyword, determining the text category corresponding to the second text according to the similarity between the text feature vector corresponding to the second text and the third word vector; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text by the text processing model; In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

9. A semantic recognition device, wherein: include: An acquisition module, used to acquire N first texts and second texts; each of the first texts includes a first keyword in a preset vocabulary, and N is a positive integer greater than 1; A first processing module, configured to perform first text processing on each of the first texts through a preset text processing model to obtain M character vectors corresponding to the first keyword in each of the first texts, where M is a positive integer greater than 1; A first determination module, configured to determine a first word vector corresponding to each of the first texts according to the M character vectors; The first recognition module is used to perform semantic recognition on the second text according to the first word vector corresponding to each of the first texts.

10. The device according to claim 9, wherein: The first processing module is specifically used for: For each of the first texts, performing first text processing on the first text by using the text processing model to obtain at least two character vectors corresponding to each character in the first text; Determine M target characters according to the position of the first keyword in the first text; the M target characters are used to represent the first keyword; An average value of at least part of the character vectors corresponding to each of the target characters is determined as the M character vectors corresponding to the first keyword in the first text.

11. The device according to claim 9, wherein: The first determining module is specifically configured to: For each of the first texts, an average value of the M character vectors corresponding to the first keyword in the first text is determined as the first word vector corresponding to the first text.

12. The device according to claim 9, wherein: The first identification module is specifically used for: According to the first word vector corresponding to each of the first texts, a preset word list is updated; the word list includes the first keyword in each of the first texts; The text category corresponding to the second text is determined through the updated vocabulary.

13. The device according to claim 12, wherein: The first identification module is further specifically used for: Perform semantic clustering on the N first word vectors to obtain K clusters; each cluster includes at least one first word vector, and K is a positive integer less than or equal to N; Determine the average value of at least one first word vector included in each of the clusters as the second word vector corresponding to the cluster; Update the vocabulary according to the K second word vectors corresponding to the K clusters; The updated vocabulary includes K second word vectors for representing the first keyword, and each second word vector is used to represent a semantic meaning corresponding to the first keyword.

14. The device according to claim 12, wherein: The vocabulary is used to represent the mapping relationship between the first keyword and the text category; The first identification module is further specifically used for: In the case where the second keyword included in the second text is not the same as the first keyword, according to the correlation between the text feature vector corresponding to the second text and each second word vector similarity, determining the text category corresponding to the second text; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text by the text processing model; In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

15. The device according to claim 9, wherein: The device also includes: A second processing module, configured to perform second text processing on the N first texts by using the text processing model to obtain N text feature vectors corresponding to the N first texts one by one; A screening module, configured to screen the N first texts according to the similarity between the N text feature vectors and the benchmark word vectors to obtain L first texts; the benchmark word vectors are obtained by performing first text processing on a preset benchmark text through the text processing model; A second determination module is used to determine third word vectors corresponding to L first texts; the third word vector is an average value of L fourth word vectors, and the L fourth word vectors are obtained by performing first text processing on the L first texts based on the text processing model; The second recognition module is used to perform semantic recognition on the second text according to the L third word vectors corresponding to the first texts.

16. The device according to claim 15, wherein: The second identification module is specifically used for: According to the L third word vectors corresponding to the first texts, a preset word list is updated; the updated word list includes the third word vector used to represent the first keyword, and the updated word list is used to represent the mapping relationship between the first keyword and the text category; In the case where the second keyword included in the second text is not the same keyword as the first keyword, determining the text category corresponding to the second text according to the similarity between the text feature vector corresponding to the second text and the third word vector; the text feature vector corresponding to the second text is obtained by performing second text processing on the second text by the text processing model; In the case that the second keyword and the first keyword are the same keyword, the text category corresponding to the second text is determined according to the mapping relationship between the first keyword represented by the updated vocabulary and the text category.

17. An electronic device, wherein: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the semantic recognition method as described in any one of claims 1 to 8.

18. A readable storage medium, wherein: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the semantic recognition method according to any one of claims 1 to 8 are implemented.

19. A chip, wherein: The chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the steps of the semantic recognition method according to any one of claims 1 to 8.

20. A computer program product, wherein: The computer program product is stored in a storage medium, and the computer program product is executed by at least one processor to implement the steps of the semantic recognition method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Keyword extracting method and device

    CN106599269A

  • Electric power text dictionary construction method based on clustering algorithm

    CN110704638A

  • Word vector generation method and device and electronic equipment

    CN111241819A

  • Keyword recognition method, device, equipment, medium and computer program product

    CN113961666A

  • Semantic recognition method and device

    CN116187341A