Model training method and device, text processing method and device, medium and equipment
Through fine-grained word segmentation processing and word segmentation combination, combined with semantic distance optimization word segmentation processing model, the problem of semantic information loss during high-frequency vocabulary screening in word cloud technology is solved, and the accuracy and performance of keyword extraction are improved.
Patent Information
- Application Number
- CN202310639434.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-31
- Publication Date
- 2024-12-03
AI Technical Summary
When existing word cloud technology filters high-frequency vocabulary through statistical word frequency, it is easy to introduce meaningless vocabulary, resulting in the screened high-frequency vocabulary being unable to effectively retain the semantic information of the text.
By fine-grained word segmentation processing on the sample data, the initial word segmentation is obtained and word segmentation is combined to generate candidate words. The candidate words are filtered and predicted based on the trained word segmentation processing model, and the model parameters are updated using semantic distance to ensure that the filtered words are in the semantic dimension Closer to the original text.
The accuracy of the word segmentation processing model in the semantic dimension can be improved, and the semantic information of the original text can be better preserved, thereby improving the performance of keyword extraction.
Smart Images

Figure CN119066412A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to data processing technology, and more particularly to a model training method, text processing method, device, medium and equipment. Background Art
[0002] Word cloud is a common technology that can intuitively display high-frequency words in a text. In different business scenarios, word cloud can be used to display key information in the scenario.
[0003] The words in the word cloud are obtained by segmenting the text and counting the word frequency to represent the importance of the words in the text, so as to filter out high-frequency words. However, since the method of counting the word frequency will introduce meaningless words, the high-frequency words filtered out cannot retain the semantics of the text information. Summary of the invention
[0004] The present disclosure provides a model training method, a text processing method, an apparatus, a medium and a device to achieve training to obtain a word segmentation processing model, through which the word segmentation processing model can obtain word segments that retain the semantics of the original text.
[0005] In a first aspect, the present disclosure provides a model training method, comprising:
[0006] Acquire sample data, and perform word segmentation processing on the sample data to obtain a plurality of initial word segmentations;
[0007] Performing word segmentation and combination on the initial word segmentation to obtain a plurality of candidate words, and screening the plurality of candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words;
[0008] Determining a semantic distance between the predicted candidate word and the sample data, and updating model parameters of the word segmentation processing model based on a loss function determined by the semantic distance;
[0009] When the word segmentation processing model after the model parameters are updated meets the training result conditions, a trained word segmentation processing model is obtained.
[0010] In a second aspect, the present disclosure also provides a text processing method, including:
[0011] Acquire text data to be processed, and perform word segmentation processing on the text data to be processed to obtain a plurality of initial word segments;
[0012] The initial segmented words are segmented and combined to obtain a plurality of candidate words, and the plurality of candidate words are screened based on a trained segmentation processing model to obtain predicted words for the text data to be processed.
[0013] In a third aspect, the present disclosure also provides a model training device, including:
[0014] A word segmentation processing module, used to obtain sample data, and perform word segmentation processing on the sample data to obtain multiple initial word segments;
[0015] A candidate word screening module is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words;
[0016] A model parameter updating module is used to determine the semantic distance between the predicted candidate word and the sample data, and to update the model parameters of the word segmentation processing model based on the loss function determined by the semantic distance; when the word segmentation processing model after the model parameter update meets the training result conditions, a trained word segmentation processing model is obtained.
[0017] In a fourth aspect, the present disclosure also provides a text processing device, including:
[0018] A basic word segmentation processing module is used to obtain text data to be processed, and perform word segmentation processing on the text data to be processed to obtain a plurality of initial word segments;
[0019] The word segmentation screening module is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the trained word segmentation processing model to obtain the predicted words for the text data to be processed.
[0020] In a fifth aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0021] one or more processors;
[0022] a storage device for storing one or more programs,
[0023] When the one or more programs are executed by the one or more processors, the one or more processors implement the model training method and / or the text processing method as provided in any embodiment of the present disclosure.
[0024] In a sixth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute a model training method as provided in any embodiment of the present disclosure, and / or a text processing method.
[0025] The embodiment provided by the embodiment of the present disclosure, in the training process of the word segmentation processing model, the initial word segmentation obtained by the fine-grained word segmentation of the sample data is combined to obtain candidate words of different granularities, thereby improving the comprehensiveness of the candidate words and avoiding single-granularity word segmentation. The word segmentation processing model is used to screen and obtain predicted candidate words from multiple candidate words, and a loss function is obtained based on the semantic distance between the word segmentation processing model and the sample data. The word segmentation processing model is trained so that the predicted candidate words screened by the word segmentation processing model can continuously tend to the sample data in the semantic dimension. Accordingly, the trained word segmentation processing model can screen and obtain predicted candidate words that can retain the original semantics of the sample data, thereby improving the keyword extraction performance of the word segmentation processing model. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0027] Figure 1 A flowchart of a model training method provided by an embodiment of the present disclosure;
[0028] Figure 2 It is a flowchart of a model training method provided by an embodiment of the present disclosure;
[0029] Figure 3 is a flow chart of a model training method provided by an embodiment of the present disclosure;
[0030] Figure 4 is a flowchart of a text processing method provided by an embodiment of the present disclosure;
[0031] Figure 5 is a structural schematic diagram of a model training device provided by an embodiment of the present disclosure;
[0032] Figure 6 is a structural schematic diagram of a text processing device provided by an embodiment of the present disclosure;
[0033] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0034] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0035] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0036] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0037] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0038] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0039] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0040] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0041] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0042] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0043] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0044] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0045] Figure 1 A flow chart of a model training method provided in an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to the situation where a word segmentation processing model is obtained by training through a semantic distance measurement method. The method can be executed by a model training device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0046] like Figure 1 As shown, the method includes:
[0047] S110: Acquire sample data, and perform word segmentation processing on the sample data to obtain a plurality of initial word segments.
[0048] S120, performing word segmentation combination on the initial word segmentation to obtain a plurality of candidate words, and screening the plurality of candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words.
[0049] S130, determining the semantic distance between the predicted candidate word and the sample data, and updating the model parameters of the word segmentation processing model based on the loss function determined by the semantic distance; when the word segmentation processing model after the model parameters are updated meets the training result conditions, a trained word segmentation processing model is obtained.
[0050] The sample data is text data. A sample data set is formed by acquiring the sample data. The word segmentation processing model to be processed is iteratively trained using the sample data set to obtain the word segmentation processing model.
[0051] Optionally, a text generator is pre-set, and the text generator is used to generate text data as sample information. Specifically, a business scenario of the text generator may be set to generate text data under the business scenario.
[0052] In any iteration of the model training process, a sample data is randomly determined in the sample data set, and the sample data is segmented to achieve the minimum granularity of the sample data segmentation, and multiple initial segmentations are obtained. Correspondingly, the initial segmentation is the minimum granularity of the sample data segmentation. Specifically, the segmentation can be performed by a pre-set segmentation algorithm, which includes but is not limited to the stammering segmentation algorithm, the TF-IDF algorithm, etc. Among them, the multiple initial segmentations of the sample data are sorted in word order to obtain the original sequence of the sample data.
[0053] In the process of word segmentation, if the word segmentation granularity is too fine, it is difficult to express the true semantics through a single initial word segmentation; if the word segmentation granularity is too coarse, the word frequency of each word is low, and it is difficult to zone by word frequency. In response to the above technical problems, the present invention divides the sample data into fine-grained initial word segmentations through word segmentation processing, combines word segmentations through the initial word segmentations, obtains coarse-grained combined words, and merges the initial word segmentations and combined words to form candidate words, that is, the candidate words include fine-grained initial word segmentations and coarse-grained combined words. By screening words in the candidate words, the problem of incompleteness of single-grained words is avoided.
[0054] Optionally, the initial participles are combined to obtain multiple candidate words, including: combining the initial participles based on multiple combination granularities to obtain candidate words of multiple combination granularities. The combination granularity may be k, and k may be a positive integer greater than or equal to zero. Combining the initial participles based on the combination granularity may be combining k+1 initial participles, and accordingly, when k=0, the initial participles are used as candidate words.
[0055] In some embodiments, the word segmentation with different combination granularities can be combined in the following manner: sorting according to the position order of the initial analysis in the sample data, and for any initial word segmentation, combining the initial word segmentation with the k sequential analyses after the initial word segmentation to obtain a candidate word. Sorting multiple candidate words based on word position can obtain a candidate sequence.
[0056] Taking the sample data "I love to eat apples" as an example, the initial segmented words obtained by segmenting the sample data are: "I", "love", "eat", "apple". Correspondingly, for the initial segmented word "I", when k = 0, the candidate word is "I", when k = 1, the candidate word is "I love", and when k = 2, the candidate word is "I love to eat". Similarly, for any initial segmented word, at least one candidate word can be obtained based on the above multiple combination granularities.
[0057] In some embodiments, the initial word segmentations are combined based on multiple combination granularities to obtain candidate words of multiple combination granularities, including: setting multiple sliding windows of different sizes; sliding each sliding window in the multiple initial word segmentations arranged in sequence to obtain the candidate words in the sliding window. The multiple initial word segmentations are sorted according to the middle word order of the sample data, and sliding windows of different sizes are sequentially slid in the initial word segmentations to extract the candidate words extracted by the sliding window at each sliding.
[0058] Assume that the number of initial segmented words is l, the size of the sliding window is k, and accordingly, the number of candidate words that can be obtained is
[0059] On the basis of the above embodiment, since the sample data may include meaningless words such as stop words, after obtaining the candidate words, the candidate words are preliminarily screened based on the stop words, and the stop words in the candidate words, and the candidate words starting with stop words and ending with stop words are removed. Through the preliminary screening of the candidate words, the interference words in the candidate words are reduced, and the waste of computing power and time caused by the invalid processing of interference words is avoided, thereby improving the processing efficiency.
[0060] On the basis of the above embodiment, the candidate words initially screened are further screened by the word segmentation processing model in this iteration to obtain predicted candidate words of the sample data, wherein the predicted candidate words are keywords screened from multiple candidate words. The candidate words initially screened are input into the word segmentation processing model in this iteration to obtain predicted candidate words.
[0061] The word segmentation processing model in this iteration can be the word segmentation processing model obtained in the previous iteration, or, in the first iteration, the word segmentation processing model is an untrained initial word segmentation processing model. Among them, the word segmentation processing model includes a word processing module and an evaluation module, and the word processing module is connected to the evaluation module. The word processing module is used to process the input candidate words to obtain the word vector of the candidate words. The evaluation module is used to evaluate the word vector of the candidate words to obtain evaluation data, which can be data between 0 and 1. The importance of the candidate words is represented by the numerical value of the evaluation data, and the predicted candidate words are determined among multiple candidate words by the evaluation data.
[0062] Accordingly, the multiple candidate words are screened based on the word segmentation processing model in the training process to obtain predicted candidate words, including: processing each candidate word through the word processing module to obtain the word vector of each candidate word; evaluating and processing the word vector of each candidate word through the evaluation module to obtain the evaluation data of each candidate word, and determining the predicted candidate word based on the evaluation data. Optionally, the candidate words can be sorted according to the evaluation data of the candidate words, and the predicted candidate words can be screened out according to the sorting, for example, the candidate words are sorted from large to small based on the evaluation data, and the top n candidate words in the sorting are screened as predicted candidate words, where n can be set according to the keyword screening requirements. For example, it can be a fixed value, such as 3 or 5; for example, n can be determined based on the initial word segmentation number l of the sample data, and exemplarily, it can be determined by a preset ratio of the initial word segmentation number l.
[0063] Optionally, the predicted candidate words are determined based on the evaluation data and the evaluation threshold of the candidate words, for example, the candidate words whose evaluation data are greater than the evaluation threshold are determined as the predicted candidate words. The predicted candidate words are screened according to the evaluation data representing the importance of the words, so that the obtained predicted candidate words are important words in the sample data. It can be understood that the evaluation module evaluates the word vectors of the candidate words, and accordingly, the result screened by the evaluation data is the word vector of the predicted candidate words.
[0064] The model structures of the word processing module and the evaluation module are not limited here. In some embodiments, the word processing module and the evaluation module can be neural network blocks. Exemplarily, the word processing module includes but is not limited to an encoder.
[0065] Optionally, the word processing module includes an encoding unit and a context processing unit. The encoding unit is used to encode each candidate word to obtain a first word vector of the candidate word itself. The context processing unit combines each candidate word with the context word vector of the candidate word to obtain a second word vector of each candidate word in the context scenario. In some embodiments, the encoding unit can be an encoder, such as a BERT encoder, and the context processing unit can be a neural network module, such as a bidirectional GRU (Gated Recurrent Unit) model.
[0066] Correspondingly, each of the candidate words is processed by the word processing module to obtain the word vector of each of the candidate words, including: encoding each of the candidate words by the encoding unit to obtain the first word vector of each of the candidate words, and performing context processing on each of the candidate words based on the first word vectors of multiple candidate words by the context processing module to obtain the second word vector of each of the candidate words.
[0067] Specifically, for each candidate word, the context candidate words of the current candidate word are determined according to the word positions of multiple candidate words, wherein the number of context candidate words can be preset, or the context candidate words are all candidate words other than the current candidate word. The context processing module weights the first word vector of the current candidate word and the first word vector of the context candidate word to obtain a second word vector, wherein the weight of the current candidate word is greater than the weight of the context candidate word, and the weight of the context candidate word is determined based on the word position of the context candidate word, wherein the weight of the context candidate word is positively correlated with the word distance between the context candidate word and the current candidate word.
[0068] Correspondingly, the evaluation module evaluates the word vector of each candidate word to obtain the evaluation data of each candidate word, including: the evaluation module evaluates the second word vector of each candidate word to obtain the evaluation data of each candidate word. By determining the second word vector of each candidate word in the context of the sample data, it is not limited to a single candidate word itself, but the context word vector of each candidate word is determined based on the context of the sample data, which can more accurately and comprehensively represent the feature information of the candidate word, further improve the accuracy of the candidate word evaluation, and the accuracy of the candidate word prediction.
[0069] The number of prediction candidate words is one or more, which can be used as keywords to be screened from the sample data. By determining the semantic distance between the prediction candidate words and the sample data, the semantic information that the prediction candidate words can retain is evaluated. The smaller the semantic distance between the prediction candidate words and the sample data, the more complete the semantic information retained by the prediction candidate words, and the more accurate the selection of the prediction candidate words. The larger the semantic distance between the prediction candidate words and the sample data, the more inaccurate the prediction candidate words are, that is, the word segmentation processing model needs to be further trained.
[0070] The semantic distance between the predicted candidate word and the sample data is obtained by calculating the distance between the candidate feature information of the predicted candidate word and the original feature information of the sample data. Optionally, determining the semantic distance between the predicted candidate word and the sample data includes: obtaining candidate feature information based on multiple word vectors of the predicted candidate words; determining word vectors of multiple initial word segmentations of the sample data, and obtaining the original feature information of the sample data based on the word vectors of the multiple initial word segmentations; and determining the semantic distance between the candidate feature information and the original feature information.
[0071] The word vector of the predicted candidate word is the word vector of the predicted candidate word output by the word processing module. In some embodiments, the word vector of the predicted candidate word is the second word vector of the predicted candidate word. When there is one predicted candidate word, the word vector of the predicted candidate word is used as the candidate feature information; when there are multiple predicted candidate words, the candidate feature information is determined based on the word vectors of multiple predicted candidate words. Optionally, the word vectors of multiple predicted candidate words are feature concatenated to obtain candidate feature information. Optionally, the word vectors of multiple predicted candidate words are weighted to obtain candidate feature information. Specifically, the weight of the predicted candidate word is determined based on the evaluation data of the predicted candidate word; the word vector of the predicted candidate word is weighted based on the weight of the predicted candidate word to obtain candidate feature information. Among them, the weight of the predicted candidate word is positively correlated with the evaluation data, which can be the evaluation data as the weight of the predicted candidate word, or the evaluation data of multiple predicted candidate words are normalized to obtain normalized data, and the normalized data is used as the weight of the predicted candidate word. Optionally, the word vectors of multiple prediction candidate words are pooled to obtain candidate feature information; specifically, the weight of the prediction candidate word is determined based on the evaluation data of the prediction candidate word; the word vectors of the prediction candidate word are pooled based on the weight of the prediction candidate word to obtain candidate feature information, and the pooling process may be an average pooling process.
[0072] For the sample data, multiple initial word segmentations in the sample data may be processed separately to obtain the word vector of each initial word segmentation. Specifically, each initial word segmentation may be processed by a word processing model in the word segmentation processing model to obtain the word vector of each initial word segmentation. The original feature information of the sample data is determined based on the word vectors of multiple initial word segmentations. Specifically, multiple word vectors may be feature concatenated to obtain the original feature information; or the word vectors of multiple initial word segmentations may be average pooled to obtain the original feature information.
[0073] The distance between the candidate feature information and the original feature information is calculated to characterize the semantic distance between the predicted candidate word and the sample data. The distance between the candidate feature information and the original feature information may be calculated by a distance calculation algorithm, and the distance calculation algorithm includes but is not limited to Euclidean distance, Hamming distance, etc. The similarity between the candidate feature information and the original feature information may be calculated, and the distance between the candidate feature information and the original feature information may be characterized by similarity data, wherein the smaller the similarity, the smaller the distance between the candidate feature information and the original feature information.
[0074] In this embodiment, the word segmentation processing model is trained based on the principle of minimizing the semantic distance. Specifically, the loss function is determined based on the semantic distance between the predicted candidate words and the sample data. The loss function can be hinge loss. The model parameters of the word segmentation processing model of the current iteration are updated through the loss function to obtain a new word segmentation processing model, and the next iteration training is performed until the training end condition is met to obtain a trained word segmentation processing model. Specifically, the model parameters of each layer in the word segmentation processing model can be updated by back-transmitting the loss function to the word segmentation processing model, and the parameter update can be implemented based on the gradient descent method.
[0075] The technical solution of the disclosed embodiment is that during the training process of the word segmentation processing model, the initial word segmentation obtained by the fine-grained word segmentation of the sample data is combined to obtain candidate words of different granularities, thereby improving the comprehensiveness of the candidate words and avoiding single-granularity word segmentation. The word segmentation processing model is used to screen and obtain predicted candidate words from multiple candidate words, and a loss function is obtained based on the semantic distance between the word segmentation processing model and the sample data. The word segmentation processing model is trained so that the predicted candidate words screened by the word segmentation processing model can continuously tend to the sample data in the semantic dimension. Accordingly, the trained word segmentation processing model can screen and obtain predicted candidate words that can retain the original semantics of the sample data, thereby improving the keyword extraction performance of the word segmentation processing model.
[0076] Figure 2 It is a flow chart of a training method of a model provided by an embodiment of the present disclosure, which is optimized on the basis of the above embodiment. Optionally, the predicted candidate words and the sample data are classified and processed respectively to obtain the category information of the predicted candidate words and the category information of the sample data; a category loss function is obtained based on the category information of the predicted candidate words and the category information of the sample data, a target loss function is obtained based on the semantic distance and the category loss function, and the model parameters of the word segmentation processing model are updated based on the target loss function. The method specifically includes:
[0077] S210: Acquire sample data, and perform word segmentation processing on the sample data to obtain a plurality of initial word segments.
[0078] S220, performing word segmentation combination on the initial word segmentation to obtain a plurality of candidate words, and screening the plurality of candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words.
[0079] S230: Determine the semantic distance between the predicted candidate word and the sample data.
[0080] S240, classify the prediction candidate words and the sample data respectively to obtain category information of the prediction candidate words and category information of the sample data; and obtain a category loss function based on the category information of the prediction candidate words and the category information of the sample data.
[0081] S250, obtaining a target loss function based on the semantic distance and the category loss function, and updating model parameters of the word segmentation processing model based on the target loss function. When the word segmentation processing model after the model parameters are updated meets the training result conditions, a trained word segmentation processing model is obtained.
[0082] In this embodiment, in order to improve the accuracy of predicted candidate words, the predicted candidate words are verified from the dimension of the category to which the predicted candidate words belong, and when the predicted candidate words and the sample data do not belong to the same category, a category loss function is generated. The semantic loss function determined by the semantic distance and the category loss function are used to jointly update the model parameters of the word segmentation processing model, thereby accelerating the training process of the word segmentation processing model and improving the training efficiency of the word processing model.
[0083] Specifically, the at least one predicted candidate word is segmented as a whole to obtain category information of the predicted candidate word. Specifically, the candidate feature information obtained from the at least one predicted candidate word is classified to obtain category information. Similarly, the original feature information obtained from the sample data is classified to obtain category information of the sample data. The classification process of the candidate feature information and the original feature information is the same.
[0084] In some embodiments, the process of classifying predicted candidate words or sample data may be: performing the following steps on the candidate feature information formed by the predicted candidate words, or the original feature information formed by the sample data: performing random feature discarding on the candidate feature information or the original feature information to obtain remaining feature information; performing semantic mapping and normalization processing on the remaining feature information to obtain normalized feature information; and performing classification processing on the normalized feature information to obtain category information.
[0085] Random feature discarding is performed on the candidate feature information or the original feature information to improve the generalization of the classification process. Specifically, the probability p may be set, and a random number may be generated in the processing of the candidate feature information or the original feature information. When the random number is greater than or equal to the probability p, the candidate feature information or the original feature information is randomly discarded. When the random number is less than the probability p, there is no need to randomly discard the candidate feature information or the original feature information. Among them, the random feature discarding of the candidate feature information or the original feature information may be to randomly determine a preset number of feature information in the candidate feature information or the original feature information and discard them to improve the generalization of the classification process.
[0086] By performing random feature discarding on the candidate feature information or the original feature information, the remaining feature information is obtained respectively, and semantic mapping is performed on the remaining feature information to obtain high-level semantic mapping feature information, so as to classify the candidate feature information or the original feature information from a semantic dimension. By performing normalization processing on the mapped feature information, a basis for classification processing is provided. Accordingly, the normalized features obtained by the normalization processing are classified to obtain the category information of the candidate feature information or the original feature information.
[0087] In some embodiments, the process of classifying the predicted candidate words or sample data may be: classifying the candidate feature information of the predicted candidate words based on the classification model to obtain the category information of the predicted candidate words; and classifying the original feature information of the sample data based on the classification model to obtain the category information of the sample data, wherein the classification model includes: a random deactivation unit, a feature mapping unit, a normalization unit and a classification unit. The random deactivation unit is used to randomly discard the input candidate feature information or original feature information to obtain the remaining feature information. For example, the random deactivation unit may include a Dropout layer to randomly discard features with probability p. The feature mapping unit is used to map the remaining feature information to a high-level semantic representation to obtain the mapped feature information. For example, the feature mapping unit may be a multi-layer perceptron. The normalization unit is used to normalize the mapped feature information. Specifically, the normalization process may be realized based on the layer normalization technology. The classification unit is used to classify the normalized features. For example, the classification unit may be a Softmax unit.
[0088] In this embodiment, the predicted candidate words or sample data are classified into domains, and the determined category information is the domain category information. A category loss function is generated by predicting the category information of the candidate words and the category information of the sample data, and the category loss function may be a minimum cross entropy function.
[0089] The target loss function is obtained by summing the category loss function and the semantic loss function determined based on the semantic distance; or, the category loss function and the semantic loss function determined based on the semantic distance are weighted to obtain the target loss function.
[0090] In some embodiments, the classification model is pre-trained, and accordingly, the model parameters of the word segmentation processing model are updated through the target loss function. In some embodiments, the classification model is a classification model in the training process, and accordingly, the model parameters of the word segmentation processing model and the classification model are synchronously updated through the target loss function.
[0091] The target loss function obtained by the category loss function and the semantic loss function is used to update the model parameters of the word segmentation processing model, which improves the accuracy and comprehensiveness of the loss function and is conducive to the rapid convergence of the word segmentation processing model.
[0092] Based on the above embodiments, the present disclosure also provides a preferred example of a model training method, see Figure 3 , Figure 3 is a flow chart of a model training method. Sample data is input into an encoder to obtain the original feature information of the sample data. Multiple candidate words of the sample data are input into the encoder to obtain the word vector of each candidate word. The encoder is the word processing module in the word segmentation processing model in the above embodiment. Through the evaluation module ( Figure 3 (not shown) evaluates the word vectors of the candidate words to obtain evaluation data of the candidate words, and screens and predicts the candidate words based on the evaluation data, and performs average pooling on the word vectors of the predicted candidate words to obtain candidate feature information. The semantic distance is determined by the candidate feature information and the original feature information, and the semantic loss function can be obtained by the semantic distance.
[0093] The classification model is used to classify the original feature information to obtain the category information of the sample data, and the classification model is used to classify the candidate feature information to obtain the category information of the predicted candidate words. The category loss function can be obtained through the category information of the sample data and the category information of the predicted candidate words. The parameters of the classification model and the word segmentation processing model can be updated through the semantic loss function and the category loss function. The above training process is iteratively executed, and a trained word segmentation processing model can be obtained when the training end conditions are met. It can be explained that in the above training process, the encoder parameters for processing the sample data and the candidate words are shared, and the classification model parameters for classifying the original feature information and the candidate feature information are shared.
[0094] Figure 4The present invention is a flowchart of a text processing method provided by an embodiment of the present invention. The present invention is applicable to the case where a trained word segmentation processing model is used to screen words in text data. The method can be executed by a text processing device, which can be implemented in the form of software and / or hardware, and optionally, by an electronic device, which can be a mobile terminal, a PC, or a server.
[0095] S310: Obtain text data to be processed, and perform word segmentation on the text data to be processed to obtain a plurality of initial word segments.
[0096] S320, performing word segmentation combination on the initial word segmentation to obtain a plurality of candidate words, and screening the plurality of candidate words based on a trained word segmentation processing model to obtain predicted words for the text data to be processed.
[0097] By performing word segmentation on the text data to be processed, a fine-grained initial word segmentation is obtained, and the initial word segmentation is combined with word segmentations of different granularities to obtain multiple candidate words of different granularities, and the predicted word is screened from the multiple candidate words of different granularities to improve the comprehensiveness of the candidate words and further improve the screening accuracy of the predicted word. The predicted word is a keyword in the text data to be processed screened from multiple candidate words, and the predicted word can be at least one, which can represent the semantic information of the text data to be processed and belongs to the same field category as the text data to be processed.
[0098] Specifically, the word segmentation processing model encodes the input candidate words to obtain word vectors, and evaluates the word vectors to obtain evaluation data of the candidate words, and selects predicted words from the candidate words through the evaluation data. For example, among the candidate words sorted based on the evaluation data, the candidate words at a preset sorting position can be selected as predicted words. The word segmentation processing model is trained by the model training method provided in any embodiment of the present disclosure.
[0099] Based on the above embodiment, since the candidate words are words of different granularities, there may be overlaps between the predicted words obtained by screening. In view of the above problem, when there is data overlap between any two predicted words, the two predicted words are screened according to the data overlap degree to reduce the duplication between the predicted words. Specifically, the data overlap degree is determined by the overlapping words between the two predicted words, and the data overlap degree can be the ratio of the number of overlapping words to the total number of words in the predicted words.
[0100] Optionally, in the case where the first prediction word includes the second prediction word, the data overlap of the second prediction word is 100%, and the second prediction word is discarded. For example, the two prediction words "love to eat apples" and "love to eat", the data overlap of "love to eat" is 100%, "love to eat" is discarded, and "love to eat apples" is retained.
[0101] Optionally, when the first predicted word and the second predicted word partially overlap, and the overlap degree between the first predicted word and the second predicted word is greater than a preset value, the predicted word with a larger reserved word length may be used.
[0102] Optionally, when the first predicted word and the second predicted word partially overlap and the degree of overlap between the first predicted word and the second predicted word is greater than a preset value, the retained predicted word is determined according to the parts of speech of non-overlapping characters in the first predicted word and the second predicted word, wherein the part-of-speech priority is pre-set and the predicted words with high part-of-speech priority of non-overlapping characters are retained.
[0103] The technical solution provided in this embodiment combines the initial segmentations obtained by the fine-grained segmentation of the text data to be processed to obtain candidate words of different granularities, thereby improving the comprehensiveness of the candidate words and avoiding single-granularity segmentations. The candidate words are screened by a pre-trained segmentation processing model to obtain predicted words that can represent the semantic information of the text data to be processed, thereby improving the screening accuracy of the predicted words.
[0104] Figure 5 A schematic diagram of a model training device provided by an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the device includes: a word segmentation processing module 410, a candidate word screening module 420 and a model parameter updating module 430.
[0105] The word segmentation processing module 410 is used to obtain sample data and perform word segmentation processing on the sample data to obtain a plurality of initial word segments;
[0106] A candidate word screening module 420 is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words;
[0107] The model parameter updating module 430 is used to determine the semantic distance between the predicted candidate word and the sample data, and to update the model parameters of the word segmentation processing model based on the loss function determined by the semantic distance; when the word segmentation processing model after the model parameters are updated meets the training result conditions, a trained word segmentation processing model is obtained.
[0108] The technical solution provided by the embodiment of the present disclosure, during the training process of the word segmentation processing model, the initial word segmentation obtained by the fine-grained word segmentation of the sample data is combined to obtain candidate words of different granularities, thereby improving the comprehensiveness of the candidate words and avoiding single-granularity word segmentation. The word segmentation processing model is used to screen and obtain predicted candidate words from multiple candidate words, and a loss function is obtained based on the semantic distance between the word segmentation processing model and the sample data. The word segmentation processing model is trained so that the predicted candidate words screened by the word segmentation processing model can continuously tend to the sample data in the semantic dimension. Accordingly, the trained word segmentation processing model can screen and obtain predicted candidate words that can retain the original semantics of the sample data, thereby improving the keyword extraction performance of the word segmentation processing model.
[0109] Based on the above embodiment, optionally, the candidate word screening module 420 is used to:
[0110] The initial word segments are respectively combined based on multiple combination granularities to obtain candidate words of multiple combination granularities.
[0111] Optionally, the candidate word screening module 420 is further used for:
[0112] Set up multiple sliding windows of different sizes;
[0113] Each sliding window is slid in the plurality of initial word segments arranged in sequence to obtain candidate words in the sliding window.
[0114] On the basis of the above embodiment, optionally, the word segmentation processing model includes a word processing module and an evaluation module;
[0115] The candidate word screening module 420 is also used for:
[0116] Processing each of the candidate words by the word processing module to obtain a word vector for each of the candidate words;
[0117] The evaluation module evaluates the word vector of each candidate word to obtain evaluation data of each candidate word, and determines the predicted candidate word based on the evaluation data.
[0118] Optionally, the word processing module includes an encoding unit and a context processing unit;
[0119] The candidate word screening module 420 is also used for:
[0120] The encoding unit encodes each of the candidate words to obtain a first word vector of each of the candidate words, and the context processing module performs context processing on each of the candidate words based on the first word vectors of the plurality of candidate words to obtain a second word vector of each of the candidate words;
[0121] The evaluation module evaluates the second word vector of each candidate word to obtain evaluation data of each candidate word.
[0122] Based on the above embodiment, optionally, the model parameter updating module 430 is used to:
[0123] Obtaining candidate feature information based on the word vectors of the plurality of predicted candidate words;
[0124] Determine word vectors of multiple initial word segmentations of the sample data, and obtain original feature information of the sample data based on the word vectors of the multiple initial word segmentations;
[0125] Determine a semantic distance between the candidate feature information and the original feature information.
[0126] Optionally, the model parameter updating module 430 is further used for:
[0127] Determining a weight of the predicted candidate word based on the evaluation data of the predicted candidate word;
[0128] The word vector of the predicted candidate word is weighted based on the weight of the predicted candidate word to obtain candidate feature information.
[0129] Based on the above embodiment, optionally, the model parameter updating module 430 is further used to:
[0130] Classifying the prediction candidate words and the sample data respectively to obtain category information of the prediction candidate words and category information of the sample data;
[0131] Obtaining a category loss function based on the category information of the predicted candidate words and the category information of the sample data;
[0132] A target loss function is obtained based on the semantic distance and the category loss function, and model parameters of the word segmentation processing model are updated based on the target loss function.
[0133] Optionally, the model parameter updating module 430 is further used for:
[0134] For the candidate feature information formed by the predicted candidate word, or the original feature information formed by the sample data, the following steps are performed:
[0135] Randomly discarding features of the candidate feature information or the original feature information to obtain remaining feature information;
[0136] The remaining feature information is semantically mapped and normalized to obtain normalized feature information, and the normalized feature information is classified to obtain category information.
[0137] Optionally, the model parameter updating module 430 is further used for:
[0138] Classifying the candidate feature information of the predicted candidate words based on the classification model to obtain category information of the predicted candidate words; and
[0139] The original feature information of the sample data is classified based on the classification model to obtain category information of the sample data, wherein the classification model includes: a random inactivation unit, a feature mapping unit, a normalization unit and a classification unit.
[0140] The model training device provided in the embodiments of the present disclosure can execute the model training method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0141] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0142] Figure 6 : is a structural diagram of a text processing device provided by an embodiment of the present disclosure. The device includes:
[0143] The basic word segmentation processing module 510 is used to obtain text data to be processed, and perform word segmentation processing on the text data to be processed to obtain a plurality of initial word segments;
[0144] The word segmentation screening module 520 is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the trained word segmentation processing model to obtain the predicted words for the text data to be processed.
[0145] Based on the above embodiment, optionally, the device further includes:
[0146] The post-processing module is used to screen the two predicted words according to the degree of data overlap when there is data overlap between any two predicted words.
[0147] The text processing device provided in the embodiments of the present disclosure can execute the text processing method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0148] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0149] Figure 7 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 7 , which shows an electronic device (eg, Figure 7 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0150] like Figure 7 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An edit / output (I / O) interface 505 is also connected to the bus 504.
[0151] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0152] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0153] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0154] The electronic device provided in the embodiment of the present disclosure and the model training method or text processing method provided in the above-mentioned embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, reference can be made to the above-mentioned embodiment, and this embodiment has the same beneficial effects as the above-mentioned embodiment.
[0155] An embodiment of the present disclosure provides a computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the model training method and / or the text processing method provided in the above-mentioned embodiment.
[0156] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0157] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0158] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0159] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0160] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains sample data, performs word segmentation processing on the sample data to obtain multiple initial word segmentations; performs word segmentation combination on the initial word segmentations to obtain multiple candidate words, and screens the multiple candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words; determines the semantic distance between the predicted candidate words and the sample data, and updates the model parameters of the word segmentation processing model based on the loss function determined by the semantic distance; and obtains a trained word segmentation processing model when the word segmentation processing model after the model parameters are updated meets the training result conditions.
[0161] Alternatively, the computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains text data to be processed, performs word segmentation processing on the text data to be processed to obtain multiple initial word segmentations; performs word segmentation combination on the initial word segmentations to obtain multiple candidate words, and screens the multiple candidate words based on a trained word segmentation processing model to obtain predicted words for the text data to be processed.
[0162] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0163] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0164] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0165] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0166] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0167] [In the detailed description section, after the full text is finished, please repeat all the contents that you want to protect in the form of claims in the following form:]
[0168] According to one or more embodiments of the present disclosure, [Example 1] provides a model training method, including:
[0169] Acquire sample data, and perform word segmentation processing on the sample data to obtain a plurality of initial word segmentations;
[0170] Performing word segmentation and combination on the initial word segmentation to obtain a plurality of candidate words, and screening the plurality of candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words;
[0171] Determining a semantic distance between the predicted candidate word and the sample data, and updating model parameters of the word segmentation processing model based on a loss function determined by the semantic distance;
[0172] When the word segmentation processing model after the model parameters are updated meets the training result conditions, a trained word segmentation processing model is obtained.
[0173] According to one or more embodiments of the present disclosure, [Example 2] provides a training method for the model of Example 1, further comprising:
[0174] The performing word segmentation combination on the initial word segmentation to obtain a plurality of candidate words includes: performing word segmentation combination on the initial word segmentation based on a plurality of combination granularities to obtain candidate words of a plurality of combination granularities.
[0175] According to one or more embodiments of the present disclosure, [Example 3] provides a training method for the model of Example 1, further comprising:
[0176] The method of combining the initial word segments based on multiple combination granularities to obtain candidate words of multiple combination granularities includes: setting multiple sliding windows of different sizes; sliding each sliding window among the multiple initial word segments arranged in sequence to obtain candidate words in the sliding window.
[0177] According to one or more embodiments of the present disclosure, [Example 4] provides a training method for the model of Example 1, further comprising:
[0178] The word segmentation processing model includes a word processing module and an evaluation module;
[0179] The word segmentation processing model based on the training process screens the multiple candidate words to obtain predicted candidate words, including: processing each of the candidate words through the word processing module to obtain the word vector of each of the candidate words; evaluating the word vector of each of the candidate words through the evaluation module to obtain evaluation data of each of the candidate words, and determining the predicted candidate words based on the evaluation data.
[0180] According to one or more embodiments of the present disclosure, [Example 5] provides a training method for the model of Example 1, further comprising:
[0181] The word processing module includes an encoding unit and a context processing unit;
[0182] The processing of each candidate word by the word processing module to obtain a word vector of each candidate word includes: encoding each candidate word by the encoding unit to obtain a first word vector of each candidate word, and performing context processing on each candidate word based on the first word vectors of multiple candidate words by the context processing module to obtain a second word vector of each candidate word;
[0183] Correspondingly, the evaluation module evaluates the word vector of each candidate word to obtain the evaluation data of each candidate word, including: the evaluation module evaluates the second word vector of each candidate word to obtain the evaluation data of each candidate word.
[0184] According to one or more embodiments of the present disclosure, [Example 6] provides a training method for the model of Example 1, further comprising:
[0185] The determining of the semantic distance between the predicted candidate word and the sample data includes: obtaining candidate feature information based on multiple word vectors of the predicted candidate words; determining the word vectors of multiple initial word segments of the sample data, and obtaining the original feature information of the sample data based on the word vectors of the multiple initial word segments; and determining the semantic distance between the candidate feature information and the original feature information.
[0186] According to one or more embodiments of the present disclosure, [Example 7] provides a training method for the model of Example 1, further comprising:
[0187] The obtaining of candidate feature information based on the word vectors of the plurality of predicted candidate words includes: determining the weight of the predicted candidate words based on the evaluation data of the predicted candidate words; and performing weighted processing on the word vectors of the predicted candidate words based on the weight of the predicted candidate words to obtain the candidate feature information.
[0188] According to one or more embodiments of the present disclosure, [Example 8] provides a training method for the model of Example 1, further comprising:
[0189] The method further includes: classifying the prediction candidate words and the sample data respectively to obtain category information of the prediction candidate words and category information of the sample data; obtaining a category loss function based on the category information of the prediction candidate words and the category information of the sample data;
[0190] Correspondingly, the loss function determined based on the semantic distance updates the model parameters of the word segmentation processing model, including: obtaining a target loss function based on the semantic distance and the category loss function, and updating the model parameters of the word segmentation processing model based on the target loss function.
[0191] According to one or more embodiments of the present disclosure, [Example 9] provides a training method for the model of Example 1, further comprising:
[0192] The prediction candidate words and the sample data are classified and processed respectively to obtain category information of the prediction candidate words and category information of the sample data, including: performing the following steps on the candidate feature information formed by the prediction candidate words, or the original feature information formed by the sample data: randomly discarding features of the candidate feature information or the original feature information to obtain remaining feature information; performing semantic mapping and normalization processing on the remaining feature information to obtain normalized feature information, and classifying the normalized feature information to obtain category information.
[0193] According to one or more embodiments of the present disclosure, [Example 10] provides a training method for the model of Example 1, further comprising:
[0194] The prediction candidate words and the sample data are classified and processed respectively to obtain category information of the prediction candidate words and category information of the sample data, including: classifying the candidate feature information of the prediction candidate words based on a classification model to obtain category information of the prediction candidate words; and classifying the original feature information of the sample data based on the classification model to obtain category information of the sample data, wherein the classification model includes: a random deactivation unit, a feature mapping unit, a normalization unit and a classification unit.
[0195] According to one or more embodiments of the present disclosure, [Example 11] provides a text processing method, including:
[0196] Acquire text data to be processed, and perform word segmentation processing on the text data to be processed to obtain a plurality of initial word segments;
[0197] The initial segmented words are segmented and combined to obtain a plurality of candidate words, and the plurality of candidate words are screened based on a trained segmentation processing model to obtain predicted words for the text data to be processed.
[0198] According to one or more embodiments of the present disclosure, [Example 12] provides the text processing method of Example 11, further comprising:
[0199] The method further includes: when there is data overlap between any two of the predicted words, screening the two predicted words according to the degree of data overlap.
[0200] According to one or more embodiments of the present disclosure, [Example 13] provides a model training device, including:
[0201] A word segmentation processing module, used to obtain sample data, and perform word segmentation processing on the sample data to obtain multiple initial word segments;
[0202] A candidate word screening module is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words;
[0203] A model parameter updating module is used to determine the semantic distance between the predicted candidate word and the sample data, and to update the model parameters of the word segmentation processing model based on the loss function determined by the semantic distance; when the word segmentation processing model after the model parameter update meets the training result conditions, a trained word segmentation processing model is obtained.
[0204] According to one or more embodiments of the present disclosure, [Example 14] provides a text processing device, including:
[0205] A basic word segmentation processing module is used to obtain text data to be processed, and perform word segmentation processing on the text data to be processed to obtain a plurality of initial word segments;
[0206] The word segmentation screening module is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the trained word segmentation processing model to obtain the predicted words for the text data to be processed.
[0207] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0208] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0209] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A model training method, characterized in that: include: Acquire sample data, and perform word segmentation processing on the sample data to obtain a plurality of initial word segmentations; Performing word segmentation combination on the initial word segmentation to obtain a plurality of candidate words, and screening the plurality of candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words; Determining a semantic distance between the predicted candidate word and the sample data, and updating model parameters of the word segmentation processing model based on a loss function determined by the semantic distance; When the word segmentation processing model after the model parameters are updated meets the training result conditions, a trained word segmentation processing model is obtained.
2. The method according to claim 1, characterized in that The step of performing word segmentation and combination on the initial word segmentation to obtain a plurality of candidate words includes: The initial word segments are respectively combined based on multiple combination granularities to obtain candidate words of multiple combination granularities.
3. The method according to claim 2, characterized in that The step of combining the initial word segments based on multiple combination granularities to obtain candidate words of multiple combination granularities includes: Set up multiple sliding windows of different sizes; Each sliding window is slid in the plurality of initial word segments arranged in sequence to obtain candidate words in the sliding window.
4. The method according to claim 1, characterized in that: The word segmentation processing model includes a word processing module and an evaluation module; The method of screening the plurality of candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words includes: Processing each of the candidate words by the word processing module to obtain a word vector for each of the candidate words; The evaluation module evaluates the word vector of each candidate word to obtain evaluation data of each candidate word, and determines the predicted candidate word based on the evaluation data.
5. The method according to claim 4, characterized in that The word processing module includes an encoding unit and a context processing unit; The step of processing each candidate word by the word processing module to obtain a word vector of each candidate word includes: The encoding unit encodes each of the candidate words to obtain a first word vector of each of the candidate words, and the context processing module performs context processing on each of the candidate words based on the first word vectors of the plurality of candidate words to obtain a second word vector of each of the candidate words; Correspondingly, the evaluation module evaluates the word vector of each candidate word to obtain evaluation data of each candidate word, including: The evaluation module evaluates the second word vector of each candidate word to obtain evaluation data of each candidate word.
6. The method according to claim 1, characterized in that The determining the semantic distance between the predicted candidate word and the sample data includes: Obtaining candidate feature information based on the word vectors of the plurality of predicted candidate words; Determine word vectors of multiple initial word segmentations of the sample data, and obtain original feature information of the sample data based on the word vectors of the multiple initial word segmentations; Determine a semantic distance between the candidate feature information and the original feature information.
7. The method according to claim 6, characterized in that The obtaining of candidate feature information based on the word vectors of the plurality of predicted candidate words includes: Determining a weight of the predicted candidate word based on the evaluation data of the predicted candidate word; The word vector of the predicted candidate word is weighted based on the weight of the predicted candidate word to obtain candidate feature information.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Classifying the prediction candidate words and the sample data respectively to obtain category information of the prediction candidate words and category information of the sample data; Obtaining a category loss function based on the category information of the predicted candidate words and the category information of the sample data; Correspondingly, the loss function determined based on the semantic distance updates the model parameters of the word segmentation processing model, including: A target loss function is obtained based on the semantic distance and the category loss function, and model parameters of the word segmentation processing model are updated based on the target loss function.
9. The method according to claim 8, characterized in that Classifying the prediction candidate words and the sample data respectively to obtain category information of the prediction candidate words and category information of the sample data includes: For the candidate feature information formed by the predicted candidate word, or the original feature information formed by the sample data, the following steps are performed: Randomly discarding features of the candidate feature information or the original feature information to obtain remaining feature information; The remaining feature information is semantically mapped and normalized to obtain normalized feature information, and the normalized feature information is classified to obtain category information.
10. The method according to claim 8, characterized in that Classifying the prediction candidate words and the sample data respectively to obtain category information of the prediction candidate words and category information of the sample data includes: Classifying the candidate feature information of the predicted candidate words based on the classification model to obtain category information of the predicted candidate words; and The original feature information of the sample data is classified based on the classification model to obtain category information of the sample data, wherein the classification model includes: a random inactivation unit, a feature mapping unit, a normalization unit and a classification unit.
11. A text processing method, characterized in that: include: Acquire text data to be processed, and perform word segmentation processing on the text data to be processed to obtain a plurality of initial word segments; The initial segmented words are segmented and combined to obtain a plurality of candidate words, and the plurality of candidate words are screened based on a trained segmentation processing model to obtain predicted words for the text data to be processed.
12. The method according to claim 11, characterized in that The method further comprises: In the case where there is data overlap between any two of the predicted words, the two predicted words are screened according to the degree of data overlap.
13. A model training device, characterized in that: include: A word segmentation processing module, used to obtain sample data, and perform word segmentation processing on the sample data to obtain multiple initial word segments; A candidate word screening module is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the word segmentation processing model in the training process to obtain predicted candidate words; A model parameter updating module is used to determine the semantic distance between the predicted candidate word and the sample data, and to update the model parameters of the word segmentation processing model based on the loss function determined by the semantic distance; when the word segmentation processing model after the model parameter update meets the training result conditions, a trained word segmentation processing model is obtained.
14. A text processing device, characterized in that: include: A basic word segmentation processing module is used to obtain text data to be processed, and perform word segmentation processing on the text data to be processed to obtain a plurality of initial word segments; The word segmentation screening module is used to perform word segmentation combination on the initial word segmentation to obtain multiple candidate words, and screen the multiple candidate words based on the trained word segmentation processing model to obtain the predicted words for the text data to be processed.
15. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the model training method as described in any one of claims 1-10, and / or the text processing method as described in claim 11 or 12.
16. A storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the model training method as described in any one of claims 1 to 10, and / or the text processing method as described in claim 11 or 12.
