Semantic recognition method and apparatus therefor

CN116187341BActive Publication Date: 2026-08-28VIVO MOBILE COMM CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310181906.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-01
Publication Date
2026-08-28
Estimated Expiration
2043-03-01

AI Technical Summary

Technical Problem

[0003]本申请实施例的目的是一种语义识别方法及其装置,能够解决语义识别的准确性较低的问题

Benefits of technology

[0018] This application embodiment processes each first text using a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text. Then, based on these M character vectors, a first word vector is determined. The first word vector is determined based on the M character vectors, fully considering the contextual information in the first text, unlike related technologies where the text feature vectors corresponding to the first text are directly determined as word vectors. The M character vectors are obtained by processing each first text using the text processing model, thus taking into account the semantics of the first keyword in the first text. This method ensures that the first word vector retains the semantics of the keyword without being affected by contextual information, thereby improving the accuracy of semantic recognition in subsequent semantic recognition of the second text based on the first word vectors corresponding to each first text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116187341B_ABST
    Figure CN116187341B_ABST
Patent Text Reader

Abstract

The application provides a semantic recognition method and device, the semantic recognition method comprises: obtaining N first texts and a second text; each first text comprises a first keyword in a preset word table, and 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, and M is a positive integer greater than 1; determining a first word vector corresponding to each first text according to the M character vectors; and performing semantic recognition on the second text according to the first word vector corresponding to each first text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of data processing technology, and specifically relates to a semantic recognition method and apparatus. Background Technology

[0002] Currently, relevant technologies typically perform semantic recognition on text based on a pre-set vocabulary to obtain the text category. This vocabulary includes keywords and text categories, which is easy to understand; the vocabulary represents the mapping relationship between keywords and text categories, and the keywords can be represented by word vectors included in the vocabulary. However, the word vectors representing keywords in the vocabulary may not be accurate enough, which affects the recognition results and thus reduces the accuracy of semantic recognition. Summary of the Invention

[0003] The purpose of this application is to provide a semantic recognition method and apparatus that can solve the problem of low accuracy in semantic recognition.

[0004] In a first aspect, embodiments of this application provide a semantic recognition method, the method comprising:

[0005] Obtain N first texts and second texts; each first text includes a first keyword from a preset vocabulary, where N is a positive integer greater than 1;

[0006] Each of the first texts is processed by 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;

[0007] Based on the M character vectors, determine the first word vector corresponding to each of the first texts;

[0008] Based on the first word vector corresponding to each of the first texts, semantic recognition is performed on the second text.

[0009] Secondly, embodiments of this application provide a semantic recognition device, the device comprising:

[0010] The acquisition module is used to acquire N first texts and second texts; each first text includes a first keyword from a preset vocabulary, where N is a positive integer greater than 1;

[0011] The first processing module is used to perform 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;

[0012] The first determining module is used to determine the first word vector corresponding to each of the first texts based on the M character vectors;

[0013] The first recognition module is used to perform semantic recognition on the second text based on the first word vector corresponding to each of the first texts.

[0014] Thirdly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0015] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0016] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.

[0017] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.

[0018] This application embodiment processes each first text using a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text. Then, based on these M character vectors, a first word vector is determined. The first word vector is determined based on the M character vectors, fully considering the contextual information in the first text, unlike related technologies where the text feature vectors corresponding to the first text are directly determined as word vectors. The M character vectors are obtained by processing each first text using the text processing model, thus taking into account the semantics of the first keyword in the first text. This method ensures that the first word vector retains the semantics of the keyword without being affected by contextual information, thereby improving the accuracy of semantic recognition in subsequent semantic recognition of the second text based on the first word vectors corresponding to each first text. Attached Figure Description

[0019] Figure 1 This is a flowchart of the semantic recognition method provided in the embodiments of this application;

[0020] Figure 2 This is an application flowchart of the updated vocabulary provided in the embodiments of this application;

[0021] Figure 3 This is a structural diagram of the semantic recognition device provided in the embodiments of this application;

[0022] Figure 4 This is a structural diagram of the electronic device provided in the embodiments of this application;

[0023] Figure 5 This is a hardware structure diagram of the electronic device provided in the embodiments of this application. Detailed Implementation

[0024] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0025] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0026] In related technologies, text is typically classified using a pre-set vocabulary. This vocabulary represents the mapping relationship between keywords and text categories, and the keywords can be represented by word vectors included in the vocabulary. Specifically, after acquiring the text, text keywords are extracted, and the similarity between the word vectors of these keywords and 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, thus achieving semantic recognition of the text.

[0027] Keyword vectors are typically obtained in the following two ways to construct a vocabulary:

[0028] Method 1:

[0029] Keywords are input into a pre-defined text processing model to obtain word vectors corresponding to those keywords. This text processing model includes BERT models, Markov models, or other types of text processing models.

[0030] Method 2:

[0031] Text containing keywords is input into a pre-defined text processing model to obtain the text feature vector corresponding to the text. This text feature vector is then used to determine the word vector corresponding to the keyword. Optionally, if the text is a sentence, the text feature vector is then a sentence vector.

[0032] However, the word vectors obtained through the above method cannot fully express the semantics of the keywords, which affects the accuracy of the vocabulary and reduces the accuracy of semantic recognition results during the process of classifying text using the vocabulary.

[0033] The word vectors obtained by the second method are easily affected by the contextual information in the text. That is, the word vectors obtained by the second method are not accurate enough, which affects the accuracy of the vocabulary and reduces the accuracy of semantic recognition results when classifying text through the vocabulary.

[0034] Based on the aforementioned technical problems, this application provides a semantic recognition method. The semantic recognition method provided by this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.

[0035] This application provides a semantic recognition method. Please refer to [link to relevant documentation]. Figure 1 , Figure 1 This is a flowchart of the semantic recognition method provided in this application embodiment. The semantic recognition method provided in this application embodiment includes the following steps:

[0036] S101, obtain N first texts and second texts.

[0037] 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.

[0038] Optionally, N first texts can be obtained from a pre-set database, or N first texts can be downloaded from the Internet. The specific method of obtaining the N first texts is not limited here.

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

[0040] Optionally, the first text mentioned above can be a sentence.

[0041] In this step, a second text is obtained, which can be understood as the text to be classified. This second text includes second keywords, which can optionally be manually annotated opinion terms or object terms representing opinion points.

[0042] 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.

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

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

[0045] The aforementioned character vector is also called the token vector, which is the vector corresponding to each character in the first keyword.

[0046] The text processing model processes the input text to obtain the vector corresponding to each character in the input text, which is called the first text processing method.

[0047] S103, based on the M character vectors, determine the first word vector corresponding to each of the first texts.

[0048] In this step, after obtaining the M character vectors corresponding to the first keyword in each first text, the first word vector corresponding to each first text can be determined using these M character vectors. The first word vector corresponding to the first text is used to represent the first keyword in the first text.

[0049] S104, based on the first word vector corresponding to each of the first texts, perform semantic recognition on the second text.

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

[0051] This application embodiment processes each first text using a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text. Then, based on these M character vectors, a first word vector is determined. The first word vector is determined based on the M character vectors, fully considering the contextual information in the first text, unlike related technologies where the text feature vectors corresponding to the first text are directly determined as word vectors. The M character vectors are obtained by processing each first text using the text processing model, thus taking into account the semantics of the first keyword in the first text. This method ensures that the first word vector retains the semantics of the keyword without being affected by contextual information, thereby improving the accuracy of semantic recognition in subsequent semantic recognition of the second text based on the first word vectors corresponding to each first text.

[0052] Optionally, the step of processing 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:

[0053] For each of the first texts, the first text is processed by the text processing model to obtain at least two character vectors corresponding to each character in the first text.

[0054] Based on the position of the first keyword in the first text, M target characters are determined; the M target characters are used to represent the first keyword;

[0055] The 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.

[0056] In this embodiment, after processing the first text using a 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 used to represent the first keyword are determined from the multiple characters included in the first text; the average value of at least some character vectors corresponding to each target character is determined as the character vector corresponding to that 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.

[0057] For example, the text processing model is a BERT model with 25 network layers. The first text representation is a sentence with 10 characters: "Can't charge, charging is too slow". The first keyword is "too slow".

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

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

[0060] As described above, each character corresponds to 25 character vectors, that is, 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 may be determined as the character vector corresponding to the first keyword.

[0061] Illustratively, the character "太" in the first keyword corresponds to 25 character vectors, and these 25 character vectors are respectively character vectors output by the 1st network layer to the 25th network layer of the Bert model; calculating the average value of the character vectors output by the 10th network layer to the 25th network layer of the Bert model, and determining the average value as a character vector corresponding to the character "太" in the first keyword.

[0062] By adopting the same method as described above, determining a character vector corresponding to the character "慢" in the first keyword and a character vector corresponding to the character "了" in the first keyword, and then determining the above three character vectors as the 3 character vectors corresponding to the first keyword.

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

[0064] In this embodiment, each first text is subjected to first text processing through a preset text processing model, so as to obtain M character vectors corresponding to the first keyword in each first text, thereby performing text processing on the first text including the first keyword and partial context information, which takes into account the semantics of the first keyword in the first text and avoids semantic missing of the first keyword.

[0065] Optionally, the step of determining the first word vector corresponding to each first text according to the M character vectors comprises:

[0066] For each of the first texts, the 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.

[0067] 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, the M character vectors corresponding to the first keyword can be weighted and summed, and the weighted sum result can be determined as the first word vector corresponding to the first text.

[0068] In this embodiment, the first word vector corresponding to each first text is determined based on M character vectors, instead of directly determining the text feature vector corresponding to the first text as in related technologies. This avoids the representation of the first word vector being affected by the context information in the first text.

[0069] Optionally, the step of performing semantic recognition on the second text based on the first word vector corresponding to each of the first texts includes:

[0070] Update the preset vocabulary based on the first word vector corresponding to each of the first texts;

[0071] The updated vocabulary is used to determine the text category corresponding to the second text.

[0072] 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. This vocabulary can be used to classify text. As described in the background art, text keywords are extracted from the text to be classified, the similarity between the word vectors of the text keywords and the word vectors representing the first keywords in the vocabulary is calculated, and the text category corresponding to the text to be classified is determined based on the similarity value.

[0073] In this embodiment, after determining N first word vectors, the 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.

[0074] In other embodiments, word vectors 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. Then, the text type corresponding to the first word vector can be determined as the text type corresponding to the second text, thereby realizing semantic recognition of the second text.

[0075] If the first keyword includes multiple semantic meanings, and the vocabulary can represent the mapping relationship between the first keyword with multiple semantic meanings and text categories, then the vocabulary can be updated using the technical solutions described in the following embodiments:

[0076] Optionally, updating the preset vocabulary based on the first word vector corresponding to each of the first texts includes:

[0077] Semantic clustering is performed on the N first word vectors to obtain K clusters;

[0078] 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.

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

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

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

[0082]

[0083] in, This represents the second word vector. This indicates the number of second word vectors included in the cluster. This represents the vector of the i-th second word. This represents the I-th first text.

[0084] After obtaining K clusters and the corresponding second word vectors for each cluster, the vocabulary is updated. The updated vocabulary includes K second word vectors representing the first keyword; that is, the first keyword can be represented by K second word vectors, and each second word vector represents one semantic meaning of the first keyword. For example, if the updated vocabulary includes 3 second word vectors representing the first keyword, it means that the updated vocabulary includes 3 semantic meanings of the first keyword.

[0085] Optionally, the vocabulary is used to represent the 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:

[0086] If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model.

[0087] If 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 and the text category represented by the updated vocabulary.

[0088] 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.

[0089] If the updated thesaurus contains the second keyword, meaning the second keyword is the same as the first keyword, then the text category corresponding to the second text can be directly determined based on the mapping relationship represented by the updated thesaurus.

[0090] If the updated vocabulary does not include the second keyword, meaning the second keyword is not the same as the first keyword, then a pre-defined text processing model can be used to process the second text and obtain its corresponding text feature vector. This process of processing the input text to obtain its corresponding text feature vector is called the second text processing method. Optionally, the second text is a sentence containing the second keyword, and the corresponding text feature vector is a sentence vector.

[0091] 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, then the text category that has a mapping relationship with the second word vector is determined as the text category corresponding to the second text.

[0092] If there are multiple second word vectors with similarity values ​​higher than the first preset threshold to the text feature vector, then 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.

[0093] It should be understood that the methods for determining the similarity between the text feature vector and the second word vector include, but are not limited to, cosine similarity between vectors, Euclidean distance between vectors, or other calculation methods.

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

[0095] If the first keyword includes multiple semantics, but the vocabulary representation includes a mapping relationship between the first keyword and the text category for only one semantic meaning, then the vocabulary can be updated using the technical solutions described in the following embodiments:

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

[0097] The text processing model is used to process N first texts using the second text processing method to obtain N text feature vectors corresponding to each of the N first texts.

[0098] Based on the similarity between the N text feature vectors and the benchmark word vectors, the N first texts are filtered to obtain L first texts; the benchmark word vectors are obtained by processing the preset benchmark texts through the text processing model.

[0099] Determine L third word vectors corresponding to the first texts; the third word vectors are the 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;

[0100] Based on the L third word vectors corresponding to the first text, semantic recognition is performed on the second text.

[0101] In this embodiment, a text processing model is used to perform second text processing on N first texts to obtain N text feature vectors. The implementation method of the second text processing is the same as that described in the above embodiments, and will not be repeated here. Optionally, the first texts are sentences, and the text feature vectors are sentence vectors.

[0102] The preset benchmark text is processed by a text processing model to obtain benchmark word vectors. The benchmark text includes a first keyword. The implementation method of the first text processing is the same as that described in the above embodiments, and will not be repeated here.

[0103] Calculate the similarity between each text feature vector and the baseline word vector, and select the first text corresponding to the text feature vector with a similarity higher than the second preset threshold, thereby obtaining L first texts.

[0104] The text processing model processes L first texts to obtain L fourth word vectors. The average value of these L fourth word vectors is determined as the third word vector, and then semantic recognition is performed on the second text based on the third word vector. Optionally, a preset vocabulary can be updated based on the third word vector. The updated vocabulary includes a third word vector used to represent 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.

[0105] For a better understanding of the technical solutions of some embodiments provided in this application, please refer to [link / reference]. Figure 2 ,like Figure 2 As shown, in some embodiments of this application, a pre-set vocabulary is provided, which can be updated to perform semantic recognition on the second text. The application process for updating the vocabulary provided in this application is as follows: obtain N first texts including the first keyword.

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

[0107] When the first keyword includes multiple semantics and the vocabulary represents the mapping relationship between the first keyword and the text category, the vocabulary is updated in the following way: N first texts are processed by the text processing model to obtain N text feature vectors; L first texts are selected 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.

[0108] Optionally, the step of performing semantic recognition on the second text based on the L third word vectors corresponding to the first text includes:

[0109] The preset vocabulary is updated based on the L third word vectors corresponding to the first text; the updated vocabulary includes third word vectors used to represent the first keyword, and the updated vocabulary is used to represent the mapping relationship between the first keyword and the text category.

[0110] If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model;

[0111] If 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 and the text category represented by the updated vocabulary.

[0112] 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, and can be used to classify text.

[0113] In this embodiment, a preset vocabulary can be updated based on a third word vector. The specific update method is the same as the method described above for updating the vocabulary based on a first word vector, and will not be repeated here. The updated vocabulary includes a third word vector used to represent the first keyword; that is, the first keyword can be represented by one third word vector, and this third word vector is used to represent a semantic meaning corresponding to the first keyword.

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

[0115] If the updated thesaurus contains the second keyword, and the updated thesaurus includes the second keyword (meaning the second keyword is the same as the first keyword), then the text category corresponding to the second text can be directly determined based on the mapping relationship represented by the updated thesaurus.

[0116] If the updated vocabulary does not include the second keyword, meaning the second keyword is not the same as the first keyword, then the second text can be processed using a pre-defined text processing model to obtain the text feature vector corresponding to the second text. 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 pre-defined threshold, then the text category that has a mapping relationship with the third word vector is determined as the text category corresponding to the second text.

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

[0118] The semantic recognition device provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0119] like Figure 3 As shown, the semantic recognition device 300 includes:

[0120] The acquisition module 301 is used to acquire N first texts and second texts; each first text includes a first keyword from a preset vocabulary, where N is a positive integer greater than 1;

[0121] The first processing module 302 is used to perform 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;

[0122] The first determining module 303 is used to determine the first word vector corresponding to each of the first texts based on the M character vectors;

[0123] The first recognition module 304 is used to perform semantic recognition on the second text based on the first word vector corresponding to each of the first texts.

[0124] Optionally, the first processing module 302 is specifically used for:

[0125] For each of the first texts, the first text is processed by the text processing model to obtain at least two character vectors corresponding to each character in the first text.

[0126] Based on the position of the first keyword in the first text, M target characters are determined; the M target characters are used to represent the first keyword;

[0127] The 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.

[0128] Optionally, the first determining module 303 is specifically used for:

[0129] For each of the first texts, the 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.

[0130] Optionally, the first identification module 304 is specifically used for:

[0131] The preset vocabulary is updated based on the first word vector corresponding to each of the first texts; the vocabulary includes the first keyword in each of the first texts.

[0132] The updated vocabulary is used to determine the text category corresponding to the second text.

[0133] Optionally, the first identification module 304 is further specifically used for:

[0134] Semantic clustering is performed on 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;

[0135] 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.

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

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

[0138] The first identification module 304 is further specifically used for:

[0139] If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model.

[0140] If 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 and the text category represented by the updated vocabulary.

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

[0142] The second processing module is used to perform second text processing on the N first texts through the text processing model to obtain N text feature vectors corresponding to the N first texts.

[0143] The filtering module is used to filter N first texts based on the similarity between N text feature vectors and benchmark word vectors to obtain L first texts; the benchmark word vectors are obtained by processing the preset benchmark texts through the text processing model.

[0144] The second determining module is used to determine the third word vectors corresponding to L first texts; the third word vectors are the average of L fourth word vectors, which are obtained by performing first text processing on L first texts based on the text processing model;

[0145] 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 text.

[0146] Optionally, the second identification module is specifically used for:

[0147] The preset vocabulary is updated based on the L third word vectors corresponding to the first text; the updated vocabulary includes third word vectors used to represent the first keyword, and the updated vocabulary is used to represent the mapping relationship between the first keyword and the text category.

[0148] If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model;

[0149] If 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 and the text category represented by the updated vocabulary.

[0150] This application embodiment processes each first text using a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text. Then, based on these M character vectors, a first word vector is determined. The first word vector is determined based on the M character vectors, fully considering the contextual information in the first text, unlike related technologies where the text feature vectors corresponding to the first text are directly determined as word vectors. The M character vectors are obtained by processing each first text using the text processing model, thus taking into account the semantics of the first keyword in the first text. This method ensures that the first word vector retains the semantics of the keyword without being affected by contextual information, thereby improving the accuracy of semantic recognition in subsequent semantic recognition of the second text based on the first word vectors corresponding to each first text.

[0151] The semantic recognition device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television set (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the specific implementation.

[0152] The semantic recognition device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0153] The semantic recognition device provided in this application embodiment can achieve... Figure 1 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.

[0154] Optionally, such as Figure 4 As shown, this application embodiment also provides an electronic device 400, including a processor 401, a memory 402, and a program or instructions stored in the memory 402 and executable on the processor 401. When the program or instructions are executed by the processor 401, they implement the various processes of the above-described semantic recognition method embodiment and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0155] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0156] Figure 5 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.

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

[0158] Those skilled in the art will understand that the electronic device 500 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 510 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 5 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0159] The input unit 504 is also used to acquire N first texts and second texts;

[0160] 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;

[0161] Based on the M character vectors, determine the first word vector corresponding to each first text.

[0162] Based on the first word vector corresponding to each of the first texts, semantic recognition is performed on the second text.

[0163] This application embodiment processes each first text using a preset text processing model to obtain M character vectors corresponding to the first keyword in each first text. Then, based on these M character vectors, a first word vector is determined. The first word vector is determined based on the M character vectors, fully considering the contextual information in the first text, unlike related technologies where the text feature vectors corresponding to the first text are directly determined as word vectors. The M character vectors are obtained by processing each first text using the text processing model, thus taking into account the semantics of the first keyword in the first text. This method ensures that the first word vector retains the semantics of the keyword without being affected by contextual information, thereby improving the accuracy of semantic recognition in subsequent semantic recognition of the second text based on the first word vectors corresponding to each first text.

[0164] It should be understood that, in this embodiment, the input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042. The GPU 5041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 507 includes a touch panel 5071 and at least one of other input devices 5062. The touch panel 5071 is also called a touch screen. The touch panel 5071 may include a touch detection device and a touch controller. Other input devices 5062 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

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

[0166] Processor 510 may include one or more processing units; optionally, processor 510 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 510.

[0167] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the semantic recognition method embodiments described above and achieve the same technical effect. To avoid repetition, they will not be described again here.

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

[0169] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described semantic recognition method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0170] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0171] This application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the semantic recognition method embodiments described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0172] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0173] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they 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 this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0174] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A semantic recognition method, characterized in that, include: Obtain N first texts and second texts; each first text includes a preset first keyword, where N is a positive integer greater than 1; Each of the first texts is processed using a pre-defined 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; Based on the M character vectors, determine the first word vector corresponding to each of the first texts; Based on the first word vector corresponding to each of the first texts, semantic recognition is performed on the second text; The step of performing semantic recognition on the second text based on the first word vector corresponding to each of the first texts includes: A preset vocabulary is updated based on the first word vector corresponding to each first text; the vocabulary includes the first keyword in each first text; wherein, updating the preset vocabulary based on the first word vector corresponding to each first text includes: performing semantic clustering processing on N first word vectors to obtain K clusters; each cluster includes at least one first word vector, where K is a positive integer less than or equal to N; determining the average value of the at least one first word vector included in each cluster as the second word vector corresponding to the cluster; updating the vocabulary based on the K second word vectors corresponding to the K clusters; the updated vocabulary includes K second word vectors used to represent the first keyword, and each second word vector is used to represent a semantic meaning corresponding to the first keyword; the vocabulary includes the first keyword in each first text. The updated vocabulary is used to determine the text category corresponding to the second text.

2. The method according to claim 1, characterized in that, The step of processing 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: For each of the first texts, the first text is processed by the text processing model to obtain at least two character vectors corresponding to each character in the first text. Based on the position of the first keyword in the first text, M target characters are determined; the M target characters are used to represent the first keyword; The 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.

3. The method according to claim 1, characterized in that, The step of determining the first word vector corresponding to each of the first texts based on the M character vectors includes: For each of the first texts, the 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, characterized in that, The vocabulary is used to represent the mapping relationship between the first keyword and the text category; The step of determining the text category corresponding to the second text using the updated vocabulary includes: If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model. If 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 and the text category represented by the updated vocabulary.

5. The method according to claim 1, characterized in that, After obtaining N first texts and second texts, the method further includes: The text processing model is used to process N first texts using the second text processing method to obtain N text feature vectors corresponding to each of the N first texts. Based on the similarity between the N text feature vectors and the benchmark word vectors, the N first texts are filtered to obtain L first texts; the benchmark word vectors are obtained by processing the preset benchmark texts through the text processing model. Determine L third word vectors corresponding to the first texts; the third word vectors are the average of L fourth word vectors, which are obtained by performing first text processing on the L first texts based on the text processing model; Based on the L third word vectors corresponding to the first text, semantic recognition is performed on the second text.

6. The method according to claim 5, characterized in that, The step of performing semantic recognition on the second text based on the L third word vectors corresponding to the first text includes: The preset vocabulary is updated based on the L third word vectors corresponding to the first text; the updated vocabulary includes third word vectors used to represent the first keyword, and the updated vocabulary is used to represent the mapping relationship between the first keyword and the text category. If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model; If 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 and the text category represented by the updated vocabulary.

7. A semantic recognition device, characterized in that, include: The acquisition module is used to acquire N first texts and second texts; each first text includes a first keyword from a preset vocabulary, where N is a positive integer greater than 1; The first processing module is used to perform 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; The first determining module is used to determine the first word vector corresponding to each of the first texts based on the M character vectors; The first recognition module is used to perform semantic recognition on the second text based on the first word vector corresponding to each of the first texts; The first identification module is specifically used for: A preset vocabulary is updated based on the first word vector corresponding to each first text; the vocabulary includes the first keyword in each first text; wherein, updating the preset vocabulary based on the first word vector corresponding to each first text includes: performing semantic clustering processing on N first word vectors to obtain K clusters; each cluster includes at least one first word vector, where K is a positive integer less than or equal to N; determining the average value of the at least one first word vector included in each cluster as the second word vector corresponding to the cluster; updating the vocabulary based on the K second word vectors corresponding to the K clusters; the updated vocabulary includes K second word vectors used to represent the first keyword, and each second word vector is used to represent a semantic meaning corresponding to the first keyword; the vocabulary includes the first keyword in each first text. The updated vocabulary is used to determine the text category corresponding to the second text.

8. The apparatus according to claim 7, characterized in that, The first processing module is specifically used for: For each of the first texts, the first text is processed by the text processing model to obtain at least two character vectors corresponding to each character in the first text. Based on the position of the first keyword in the first text, M target characters are determined; the M target characters are used to represent the first keyword; The 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.

9. The apparatus according to claim 7, characterized in that, The first determining module is specifically used for: For each of the first texts, the 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.

10. The apparatus according to claim 7, characterized in that, 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: If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model. If 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 and the text category represented by the updated vocabulary.

11. The apparatus according to claim 7, characterized in that, The device further includes: The second processing module is used to perform second text processing on the N first texts through the text processing model to obtain N text feature vectors corresponding to the N first texts. The filtering module is used to filter N first texts based on the similarity between N text feature vectors and benchmark word vectors to obtain L first texts; the benchmark word vectors are obtained by processing the preset benchmark texts through the text processing model. The second determining module is used to determine the third word vectors corresponding to the L first texts; the third word vectors are the average of the L fourth word vectors, which 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 based on the L third word vectors corresponding to the first text.

12. The apparatus according to claim 11, characterized in that, The second identification module is specifically used for: The preset vocabulary is updated based on the L third word vectors corresponding to the first text; the updated vocabulary includes third word vectors used to represent the first keyword, and the updated vocabulary is used to represent the mapping relationship between the first keyword and the text category. If the second keyword included in the second text is not the same as the first keyword, the text category corresponding to the second text is determined based on 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 through the text processing model; If 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 and the text category represented by the updated vocabulary.

13. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the semantic recognition method as described in any one of claims 1-6.

14. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the semantic recognition method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Similarity calculation method, clustering method, device, storage medium and electronic device

    CN109101620A

  • Entity recognition method and device, electronic equipment and storage medium

    CN113408287A

  • Text vector generation model training method, text classification method and related device

    CN115033701A