Text processing model construction method and text processing method
By performing word segmentation and encoding processing on text training samples and introducing threshold function processing word vectors, the problem of low accuracy in word weight tasks in traditional classification models is solved, and high-precision classification of words in text and high efficiency of text processing models is achieved. analyze.
Patent Information
- Application Number
- CN202010784088.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-06
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-08-06
AI Technical Summary
The traditional classification model has low classification accuracy in word weight tasks, making it difficult to effectively distinguish between core words and non-core words in sentences, affecting the interpretation of text semantic information.
By obtaining text training samples for word segmentation processing, and calling preset classification model for encoding processing, introducing a threshold function to process word vectors, balancing the dimensional differences between text vectors and word vectors, strengthening the interaction between text and target word segmentation, and suppressing Unrelated vector feature dimensions to improve classification accuracy.
It realizes high-precision classification of words in text, improves the accuracy and efficiency of the classification model, and supports high-precision analysis during text processing.
Smart Images

Figure CN112749557B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computer equipment and storage medium for constructing a text processing model, and a method, apparatus, computer equipment and storage medium for text processing. Background Art
[0002] With the development and application of computer technology, text analysis and processing technology has been widely used. In application scenarios such as title understanding and paragraph sentence understanding, it is necessary to distinguish the weights of different words and determine the core words of the text. Taking video as an example, video title is an important part of video content. It is one of the core tasks of the entire video search system to complete text parsing by combining title text with natural language processing technology and strengthen the understanding of video semantic information.
[0003] The word weight task is to understand the semantics of a sentence and assign a corresponding weight value to each word in the sentence, so as to distinguish the primary and secondary components of the sentence. The word weight task is of great significance for the interpretation of text semantic information, so it is necessary to process the word weight task. The word weight task can be modeled through a classification model, but the traditional classification model has the problem of low classification accuracy. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for constructing a text processing model that can improve classification accuracy, as well as a text processing method, device, computer equipment and storage medium in response to the above-mentioned technical problems.
[0005] A method for constructing a text processing model, the method comprising:
[0006] Acquire a text training sample, perform word segmentation processing on the text training sample, and obtain a plurality of target word segments and classification results of each target word segmentation;
[0007] Calling a preset classification model to encode the text training sample to obtain a text vector, and encoding the target word segmentation to obtain a first word vector of the target word segmentation;
[0008] Calling the threshold function cached in the classification model to process the first word vector to obtain a second word vector;
[0009] The classification model is trained through the classification results of the second word vector, the first word vector, the text vector and the target word segmentation to obtain a text processing model.
[0010] A device for constructing a text processing model, the device comprising:
[0011] The sample data acquisition module is used to acquire text training samples, perform word segmentation processing on the text training samples, and obtain multiple target word segments and classification results of each target word segmentation;
[0012] An encoding processing module, used to call a preset classification model to perform encoding processing on the text training sample to obtain a text vector, and to perform encoding processing on the target word segmentation to obtain a first word vector of the target word segmentation;
[0013] A threshold processing module, used for calling the threshold function cached in the classification model to process the first word vector to obtain a second word vector;
[0014] A model determination module is used to train the classification model through the second word vector, the first word vector, the text vector and the classification result of the target word segmentation to obtain a text processing model.
[0015] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0016] Acquire a text training sample, perform word segmentation processing on the text training sample, and obtain a plurality of target word segments and classification results of each target word segmentation;
[0017] Calling a first encoding unit of a preset classification model to encode the text training sample to obtain a text vector, and encoding the target word segmentation to obtain a first word vector of the target word segmentation;
[0018] Calling the threshold function unit cached in the classification model to process the first word vector to obtain a second word vector;
[0019] The classification model is trained through the classification results of the second word vector, the first word vector, the text vector and the target word segmentation to obtain a text processing model.
[0020] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0021] Acquire a text training sample, perform word segmentation processing on the text training sample, and obtain a plurality of target word segments and classification results of each target word segmentation;
[0022] Calling a preset classification model to encode the text training sample to obtain a text vector, and encoding the target word segmentation to obtain a first word vector of the target word segmentation;
[0023] Calling the threshold function cached in the classification model to process the first word vector to obtain a second word vector;
[0024] The classification model is trained through the classification results of the second word vector, the first word vector, the text vector and the target word segmentation to obtain a text processing model.
[0025] The method, device, computer equipment and storage medium for constructing the above-mentioned text processing model obtain text training samples, perform word segmentation processing on the text training samples, and obtain multiple target word segments and classification results of each target word segmentation; then encode the text training samples through a preset classification model to obtain a text vector, and encode the target word segmentation to obtain a first word vector of the target word segmentation; then process the first word vector through a threshold function of the classification model to obtain a second word vector; train the classification model through the second word vector, the first word vector, the text vector and the classification result of the target word segmentation to obtain a text processing model. In the training process of the classification model, the second word vector obtained by threshold processing of the first word vector is introduced, which not only strengthens the interaction between the text and the target word segmentation, but also suppresses the feature dimensions of the vector that are not related to the word through the word vector. The difference in dimension between the text vector and the first word vector is balanced, and when the text is subsequently processed through the text processing model, high-precision classification of words in the text can be supported.
[0026] A text processing method, the method comprising:
[0027] Acquire a text to be processed, perform word segmentation on the text to be processed, and obtain a plurality of target words;
[0028] Calling a text processing model to encode the text to be processed to obtain a target text vector, and encoding the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data;
[0029] Calling the threshold function cached in the text processing model to process the first word vector to obtain the second word vector of the target word;
[0030] Based on the second word vector of the target word, the first word vector of the target word and the target text vector, a classification result of the target word in the text to be processed is obtained.
[0031] A text processing device, comprising:
[0032] A text segmentation module is used to obtain a text to be processed, perform word segmentation on the text to be processed, and obtain multiple target words;
[0033] A vector acquisition module, used to call a text processing model to encode the text to be processed to obtain a target text vector, and to encode the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data;
[0034] A word vector processing module, used to process the first word vector by using a threshold function cached in the text processing model to obtain a second word vector of the target word;
[0035] The classification result determination module is used to obtain the classification result of the target word in the text to be processed based on the second word vector of the target word, the first word vector of the target word and the target text vector.
[0036] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0037] Acquire a text to be processed, perform word segmentation on the text to be processed, and obtain a plurality of target words;
[0038] Calling a text processing model to encode the text to be processed to obtain a target text vector, and encoding the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data;
[0039] Calling the threshold function cached in the text processing model to process the first word vector to obtain the second word vector of the target word;
[0040] Based on the second word vector of the target word, the first word vector of the target word and the target text vector, a classification result of the target word in the text to be processed is obtained.
[0041] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0042] Acquire a text to be processed, perform word segmentation on the text to be processed, and obtain a plurality of target words;
[0043] Calling a text processing model to encode the text to be processed to obtain a target text vector, and encoding the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data;
[0044] Calling the threshold function cached in the text processing model to process the first word vector to obtain the second word vector of the target word;
[0045] Based on the second word vector of the target word, the first word vector of the target word and the target text vector, a classification result of the target word in the text to be processed is obtained.
[0046] The above-mentioned text processing method, device, computer equipment and storage medium obtain a text to be processed, perform word segmentation processing on the text to be processed, and obtain multiple target words; encode the text to be processed through a text processing model to obtain a target text vector, and encode the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data; call the threshold function cached in the text processing model to process the first word vector to obtain a second word vector of the target word; based on the second word vector of the target word, the first word vector of the target word and the target text vector, obtain the classification result of the target word in the text to be processed, process the first word vector through the threshold function of the text processing model, and obtain the second word vector of the target word. The introduction of the second word vector not only strengthens the interaction between the text to be processed and the target word, but also performs threshold control on the text vector through the word vector, which can suppress the feature dimension of the vector that is not related to the word, thereby balancing the dimensional difference between the target text vector and the first word vector of the target word, thereby achieving high-precision classification of the target word in the text to be processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 An application environment diagram of a method for constructing a text processing model in one embodiment;
[0048] Figure 2 A flowchart of a method for constructing a text processing model in an embodiment;
[0049] Figure 3 A schematic diagram of a flow chart of title word weight in one embodiment;
[0050] Figure 4 A flowchart of a text processing method in one embodiment;
[0051] Figure 5 A schematic diagram of text processing in which a threshold function is introduced in one embodiment;
[0052] Figure 6 is a structural block diagram of a device for constructing a text processing model in one embodiment;
[0053] Figure 7is a structural block diagram of a text processing device in one embodiment;
[0054] Figure 8 FIG. 4 is a structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0056] In order to help those skilled in the art to better understand the text processing model construction method / text processing method provided in the embodiments of the present application, the relevant contents of natural language processing are first explained.
[0057] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0058] The method for constructing a text processing model provided in this application belongs to the category of semantic understanding in natural language processing and can be applied to Figure 1In the application environment shown. The application scenario includes a mobile terminal 102 and a server 104, and the mobile terminal 102 is connected to the server 104 through a network. The user can upload a text training sample to the server 104 through the mobile terminal 102, and the server 104 obtains the text training sample, performs word segmentation processing on the text training sample, and obtains multiple target word segments and classification results of each target word segmentation; calls a preset classification model to encode the text training sample to obtain a text vector, and encodes the target word segmentation to obtain the first word vector of the target word segmentation; calls the threshold function cached in the classification model to process the first word vector to obtain a second word vector; trains the classification model through the second word vector, the first word vector, the text vector and the classification results of the target word segmentation to obtain a text processing model. Among them, the mobile terminal 102 can be a mobile phone, a tablet computer, a notebook, a desktop computer, etc., and the server 104 can be implemented with an independent server or a server cluster composed of multiple servers. The above application scenario is illustrated by applying the method for constructing a text processing model to a system including a mobile terminal and a server, and is implemented through the interaction between the mobile terminal and the server. It can be understood that the method for constructing a text processing model can also be applied to mobile terminals and servers.
[0059] In one embodiment, Figure 2 As shown, a method for constructing a text processing model is provided. This embodiment applies this method to Figure 1 The server in the example is used to illustrate. Figure 2 , the method specifically comprises the following steps:
[0060] Step 202: obtain text training samples, perform word segmentation processing on the text training samples, and obtain multiple target word segments and classification results of each target word segmentation.
[0061] Text training samples refer to text data used for model training. The word segmentation of text training samples can be achieved through word segmentation methods. Specific word segmentation methods include rule-based word segmentation, statistical-based word segmentation, etc., such as forward maximum matching method, reverse maximum matching method, bidirectional maximum matching method, etc. Figure 3As shown, taking "Lu Ban is hopeless, the economy is suppressed, and he can't get up at all, you can play with the phone" as an example of a text in the text training sample, the text is segmented, and the target segmented words obtained include "this", "Lu Ban", "hopeless", "economy", "suppressed", "can't get up", "phone", etc. The classification result of the target segmented word refers to whether the target segmented word is the core word of the text. For example, the classification result can be marked with 0 and 1, with core words marked as 1 and non-core words marked as 0. Specifically, the encoding vector of a word and the corresponding text encoding vector can be feature fused, the fused vector is mapped through a fully connected layer, and then through an activation function to obtain the probability that the word is a core word. For example, Figure 3 The corresponding probabilities of “this”, “Lu Ban”, “no hope”, “economy”, “suppression”, “can’t get up”, and “mobile phone” are 0.1, 0.91, 0.2, 0.81, 0.7, 0.2, and 0.3 respectively. Assuming that the probability is greater than 0.6, it is judged as a core word. Then, the classification results of the target word “this”, “Lu Ban”, “no hope”, “economy”, “suppression”, “can’t get up”, and “mobile phone” are 0, 1, 0, 1, 1, 0, and 0 respectively.
[0062] Step 204, calling a preset classification model to encode the text training sample to obtain a text vector, and encode the target word segmentation to obtain a first word vector of the target word segmentation.
[0063] The text may be encoded by the first encoding unit, specifically by using BERT (Bidirectional Encoder Representations from Transformers) encoding, neural network model encoding, etc. The sentence text is encoded by the first encoding unit to obtain a text vector corresponding to the sentence.
[0064] The word can be encoded by the second encoding unit, and specifically, DNN (Deep Neural Networks) encoding, one-hot encoding, etc. The word is encoded by the second encoding unit to obtain a word vector corresponding to the word.
[0065] Step 206: Call the threshold function cached in the classification model to process the first word vector to obtain the second word vector.
[0066] The threshold vector output by the threshold function has a corresponding vector value in the range of [0,1]. The threshold vector controls the state of the corresponding neuron in the classification model. The closer the threshold vector value is to 0, the more severely the corresponding neuron is suppressed and the weaker the influence will be. In the classification model, the first word vector of a word is used as the input of the threshold function unit, indicating that the word determines the relevance between the sentence text and the word. Specifically, the threshold function can be expressed as σ(w T x+b), where x is the first word vector after word encoding, σ uses an activation function, which can be a sigmoid activation function, a tanh activation function or other activation functions, w is a vector mapping matrix, and b is a bias constant. The first word vector is mapped by the activation function to obtain a second word vector with the same dimension as the text vector.
[0067] Step 208, training the classification model through the second word vector, the first word vector, the text vector and the classification result of the target word segmentation to obtain a text processing model.
[0068] According to the second word vector and the first word vector corresponding to a certain word, and the text vector corresponding to the sentence, the binary classification result of the word can be obtained, that is, whether the word is the core word or the non-core word of the sentence, and then according to the binary classification result of the word and its true classification result, the parameters of the classification model are adjusted to train the classification model, and finally a text processing model is obtained. Specifically, the classification model is trained by the second word vector, the first word vector, the text vector and the classification result of the target word segmentation to obtain the text processing model, including: based on the second word vector, the first word vector and the text vector, the classification prediction result of the target word segmentation is obtained; when the classification prediction result is inconsistent with the classification result, the parameters of the classification model are adjusted until the classification prediction result is consistent with the classification result, and the text processing model is obtained. When the model is trained, the classification prediction result is inconsistent with the true classification result, and the parameters of the first coding unit, the second coding unit and the threshold function in the classification model can be adjusted to make the classification prediction result consistent with the classification true result. At this time, the classification model obtained is the text processing model.
[0069] In one embodiment, based on the second word vector, the first word vector and the text vector, the classification prediction result of the target word segmentation is obtained, including: performing vector operation based on the second word vector and the text vector to obtain the transformed text vector; performing feature fusion processing based on the transformed text vector and the first word vector to obtain the classification prediction result of the target word segmentation. Among them, performing vector operation based on the second word vector and the text vector to obtain the transformed text vector includes: performing vector calculation on the second word vector and the text vector by dot multiplication to obtain the transformed text vector. Performing feature fusion processing based on the transformed text vector and the first word vector to obtain the classification prediction result of the target word segmentation includes: performing fusion processing on the second text vector and the first word vector to obtain the fused vector; determining the probability distribution data of the target word segmentation based on the fused vector, and obtaining the classification prediction result of the target word segmentation according to the probability distribution data. The fusion processing can be cascaded, or other fusion methods such as dot multiplication and introduction of tensors. For example, the dimension corresponding to the second text vector is 768 dimensions, and the dimension corresponding to the first word vector is 50 dimensions, then the dimension corresponding to the vector obtained by connecting the two is 818 dimensions.
[0070] The method for constructing the above-mentioned text processing model obtains text training samples, performs word segmentation processing on the text training samples, obtains multiple target word segments and classification results of each target word segmentation; then encodes the text training samples through a preset classification model to obtain a text vector, and encodes the target word segmentation to obtain a first word vector of the target word segmentation; then processes the first word vector through a threshold function of the classification model to obtain a second word vector; trains the classification model through the second word vector, the first word vector, the text vector and the classification results of the target word segmentation to obtain a text processing model. In the training process of the classification model, the second word vector obtained by threshold processing of the first word vector is introduced, which not only strengthens the interaction between the text and the target word segmentation, but also performs threshold control on the text vector through the word vector, which can suppress the feature dimensions of the vector that are not related to the word, thereby balancing the dimensional difference between the text vector and the first word vector. When the text is subsequently processed through the text processing model, high-precision classification of words in the text can be supported.
[0071] like Figure 4 As shown, in one embodiment, a text processing method is provided, and the method specifically includes the following steps:
[0072] Step 402, obtaining a text to be processed, performing word segmentation processing on the text to be processed, and obtaining a plurality of target words.
[0073] Step 404, calling the first encoding unit of the text processing model to encode the text to be processed to obtain the target text vector, and encode the target word to obtain the first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data.
[0074] Step 406: Call the threshold function cached in the text processing model to process the first word vector to obtain a second word vector of the target word.
[0075] Step 408, based on the second word vector of the target word, the first word vector of the target word and the target text vector, obtain the classification result of the target word in the text to be processed.
[0076] The above-mentioned text processing method obtains a text to be processed, performs word segmentation processing on the text to be processed, and obtains multiple target words; encodes the text to be processed through a text processing model to obtain a target text vector, and encodes the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data; the first word vector is processed through a threshold function of the text processing model to obtain a second word vector of the target word; based on the second word vector of the target word, the first word vector of the target word and the target text vector, a classification result of the target word in the text to be processed is obtained, and the first word vector is processed through the threshold function of the text processing model to obtain the second word vector of the target word. The introduction of the second word vector not only strengthens the interaction between the text to be processed and the target word, but also performs threshold control on the text vector through the word vector, which can suppress the feature dimension of the vector that is not related to the word, thereby balancing the dimensional difference between the target text vector and the first word vector of the target word, thereby achieving high-precision classification of the target word in the text to be processed.
[0077] The present application also provides an application scenario, which applies the above-mentioned method for constructing a text processing model and a text processing method. Specifically, the method for constructing a text processing model and the application of the text processing method in the application scenario are as follows: first, the model is trained by the method for constructing a text processing model to obtain a text processing model for realizing the binary classification of each word in the text. Among them, the method for constructing a text processing model includes: obtaining a text training sample, performing word segmentation processing on the text training sample, obtaining multiple target word segments and the classification results of each target word segmentation; encoding the text training sample through the classification model to obtain a text vector, and encoding the target word segmentation to obtain the first word vector of the target word segmentation; processing the first word vector through the threshold function of the classification model to obtain a second word vector; training the classification model through the second word vector, the first word vector, the text vector and the classification results of the target word segmentation to obtain a text processing model. Then, the text processing model is applied to perform binary classification on the words in the text to be processed. The text processing method includes: obtaining the text to be processed, performing word segmentation processing on the text to be processed, and obtaining multiple target words; encoding the text to be processed through the text processing model to obtain a target text vector, and encoding the target word to obtain a first word vector of the target word; processing the first word vector through the threshold function of the text processing model to obtain a second word vector of the target word; based on the second word vector of the target word, the first word vector of the target word and the target text vector, obtaining the classification result of the target word in the text to be processed.
[0078] Reference Figure 5 , use BERT encoder to encode the sentence, use DNN encoding to encode the current word, use the encoding vector of the current word as the input of the threshold function, use point multiplication to calculate the output vector of the threshold function and the sentence encoding vector, get the final sentence encoding vector, and then connect the final sentence encoding vector and the encoding vector of the current word. For example, the vector after the final sentence encoding vector and the encoding vector of the current word are connected has a total of 818 dimensions. Map it to 1 dimension through a fully connected layer, and then connect a sigmoid activation function to obtain the probability that the current word is the core word, thereby determining the model classification result of the current word.
[0079] It should be understood that although Figure 2-5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-5At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0080] Based on the same idea as the above method, Figure 6 A schematic diagram of the structure of a device for constructing a text processing model according to an embodiment is shown. This embodiment is described by taking the device being set on the server 104 as an example.
[0081] like Figure 6 As shown, the device for constructing the text processing model in this embodiment includes: a sample data acquisition module 602, which is used to obtain text training samples, perform word segmentation processing on the text training samples, and obtain multiple target word segments and classification results of each target word segmentation. An encoding processing module 604 is used to call a preset classification model to encode the text training samples to obtain a text vector, and encode the target word segmentation to obtain a first word vector of the target word segmentation. A threshold processing module 606 is used to call the threshold function cached in the classification model to process the first word vector to obtain a second word vector. A model determination module 608 is used to train the classification model through the second word vector, the first word vector, the text vector and the classification results of the target word segmentation to obtain a text processing model.
[0082] In one embodiment, the model determination module is also used to obtain a classification prediction result of the target word segmentation based on the second word vector, the first word vector and the text vector; when the classification prediction result is inconsistent with the classification result, the parameters of the classification model are adjusted until the classification prediction result is consistent with the classification result, thereby obtaining a text processing model.
[0083] In one embodiment, the model determination module is also used to perform vector operations based on the second word vector and the text vector to obtain a transformed text vector; perform feature fusion processing based on the transformed text vector and the first word vector to obtain a classification prediction result of the target word segmentation.
[0084] In one embodiment, the model determination module is also used to fuse the transformed text vector and the first word vector to obtain a fused vector; determine the probability distribution data of the target word segmentation based on the fused vector, and obtain the classification prediction result of the target word segmentation according to the probability distribution data.
[0085] In one embodiment, the model determination module is further used to perform vector calculation on the second word vector and the text vector by dot multiplication to obtain a transformed text vector.
[0086] Figure 7A structural schematic diagram of a text processing device of an embodiment is shown, and the text processing device in this embodiment includes: a text segmentation module 702, which is used to obtain a text to be processed, perform word segmentation processing on the text to be processed, and obtain multiple target words. A vector acquisition module 704, which is used to call a text processing model to encode the text to be processed to obtain a target text vector, and encode the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data. A word vector processing module 706, which is used to call a threshold function of the text processing model to process the first word vector to obtain a second word vector of the target word. A classification result determination module 708, which is used to obtain a classification result of the target word in the text to be processed based on the second word vector of the target word, the first word vector of the target word, and the target text vector.
[0087] For the specific definition of the device for constructing a text processing model / text processing device, please refer to the definition of the method for constructing a text processing model / text processing method mentioned above, which will not be repeated here. Each module in the device for constructing a text processing model / text processing device mentioned above can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0088] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for constructing a text processing model / text processing method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0089] Those skilled in the art will understand that Figure 8The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0090] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0091] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0092] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.
[0093] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0094] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0095] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for constructing a text processing model, characterized in that: The method comprises: Acquire a text training sample, perform word segmentation processing on the text training sample, obtain multiple target word segments, and perform feature fusion on the encoding vector of each target word segment and the corresponding text encoding vector, map the fused vector through a fully connected layer, and then obtain the probability of each target word segment being a core word through an activation function, and obtain the classification result of each target word segment based on the probability of each target word segment being a core word, wherein the classification result of the target word segment refers to the result that the target word segment is the core word of the text training sample; Calling a preset classification model to encode the text training sample to obtain a text vector of the text training sample, and encoding the target word segmentation to obtain a first word vector of the target word segmentation; Calling the activation function in the threshold function cached in the classification model to map the first word vector to obtain a second word vector with the same dimension as the text vector to strengthen the interaction between the text training sample and the target word segmentation, wherein the first word vector determines the relevance between the text training sample and the target word segmentation; Performing vector operation based on the second word vector and the text vector to obtain a transformed text vector, so as to suppress feature dimensions of the vector that are not related to the target word segmentation, and balance the dimensional difference between the transformed text vector and the first word vector; The transformed text vector and the first word vector are fused to obtain a fused vector; wherein the fusion processing method includes any one of the following: a cascade method, a dot product method, and an introduction of a tensor method; Determining probability distribution data of the target word segmentation based on the fused vector, and obtaining a classification prediction result of the target word segmentation according to the probability distribution data; When the classification prediction result is inconsistent with the classification result, the parameters of the classification model are adjusted until the classification prediction result is consistent with the classification result, thereby obtaining a text processing model.
2. The method according to claim 1, characterized in that The performing vector operation based on the second word vector and the text vector to obtain a transformed text vector includes: Vector calculation is performed on the second word vector and the text vector by dot multiplication to obtain a transformed text vector.
3. The method according to claim 1, characterized in that The fusing the transformed text vector and the first word vector to obtain a fused vector includes: The transformed text vector and the first word vector are fused in a cascade manner to obtain a fused vector.
4. The method according to claim 1, characterized in that: The fusing the transformed text vector and the first word vector to obtain a fused vector includes: The transformed text vector and the first word vector are fused by dot multiplication to obtain a fused vector.
5. The method according to claim 1, characterized in that The step of fusing the transformed text vector and the first word vector to obtain a fused vector includes: The transformed text vector and the first word vector are fused by introducing a tensor to obtain a fused vector.
6. A text processing method, characterized in that: The method comprises: Acquire a text to be processed, perform word segmentation on the text to be processed, and obtain a plurality of target words; Calling a text processing model to encode the text to be processed to obtain a target text vector of the text to be processed, and encoding the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data; Calling the activation function in the threshold function cached in the text processing model to map the first word vector to obtain a second word vector of the target word with the same dimension as the target text vector, so as to strengthen the interaction between the text to be processed and the target word, wherein the first word vector determines the relevance between the text to be processed and the target word; The first word vector of the target word is used as the input of the threshold function, and the output vector of the threshold function and the target text vector are calculated by dot multiplication to obtain a final sentence encoding vector, so as to suppress the feature dimension of the vector irrelevant to the target word and balance the dimensional difference between the final sentence encoding vector and the first word vector; the final sentence encoding vector and the first word vector are fused to obtain a fused vector; wherein the fusion processing method includes any one of the following: a cascade method, a dot multiplication method, and an introduction of a tensor method; based on the fused vector, the probability that the target word in the text to be processed is a core word is obtained, and the classification result of the target word is determined by the probability that the target word in the text to be processed is a core word.
7. A device for constructing a text processing model, characterized in that: The device comprises: A sample data acquisition module is used to acquire text training samples, perform word segmentation processing on the text training samples, obtain multiple target word segments, and perform feature fusion on the encoding vector of each target word segment and the corresponding text encoding vector, map the fused vector through a fully connected layer, and then obtain the probability of each target word segment being a core word through an activation function, and obtain the classification result of each target word segment based on the probability of each target word segment being a core word, wherein the classification result of the target word segment refers to the result that the target word segment is the core word of the text training sample; An encoding processing module, used to call a preset classification model to perform encoding processing on the text training sample to obtain a text vector of the text training sample, and to perform encoding processing on the target word segmentation to obtain a first word vector of the target word segmentation; A threshold processing module, used for calling the activation function in the threshold function cached in the classification model to map the first word vector to obtain a second word vector with the same dimension as the text vector, so as to strengthen the interaction between the text training sample and the target word segmentation, and the first word vector determines the correlation between the text training sample and the target word segmentation; A model determination module is used to perform vector operations based on the second word vector and the text vector to obtain a transformed text vector, so as to suppress the feature dimensions of the vector that are not related to the target word segmentation, and balance the dimensional difference between the transformed text vector and the first word vector; fuse the transformed text vector and the first word vector to obtain a fused vector; wherein the fusion processing method includes any one of the following: a cascade method, a dot product method, and an introduction of a tensor method; determine the probability distribution data of the target word segmentation based on the fused vector, and obtain the classification prediction result of the target word segmentation according to the probability distribution data; when the classification prediction result is inconsistent with the classification result, adjust the parameters of the classification model until the classification prediction result is consistent with the classification result, so as to obtain a text processing model.
8. The device according to claim 7, characterized in that The model determination module is also used to perform vector calculation on the second word vector and the text vector by dot multiplication to obtain a transformed text vector.
9. A text processing device, characterized in that: The device comprises: A text segmentation module is used to obtain a text to be processed, perform word segmentation on the text to be processed, and obtain multiple target words; A vector acquisition module, used to call a text processing model to encode the text to be processed, obtain a target text vector of the text to be processed, and encode the target word to obtain a first word vector of the target word, wherein the text processing model is obtained by training a preset classification model through historical text sample data; A word vector processing module, used for calling the activation function in the threshold function cached in the text processing model to map the first word vector, to obtain a second word vector of the target word with the same dimension as the target text vector, so as to strengthen the interaction between the text to be processed and the target word, and the first word vector determines the relevance between the text to be processed and the target word; A classification result determination module is used to use the first word vector of the target word as the input of the threshold function, and to calculate the final sentence encoding vector by the dot multiplication method on the output vector of the threshold function and the target text vector, so as to suppress the feature dimension of the vector irrelevant to the target word, and balance the dimensional difference between the final sentence encoding vector and the first word vector; to fuse the final sentence encoding vector and the first word vector to obtain a fused vector; wherein the fusion processing method includes any one of the following: a cascade method, a dot multiplication method, and an introduction of a tensor method; based on the fused vector, obtain the probability that the target word in the text to be processed is a core word, and determine the classification result of the target word by the probability that the target word in the text to be processed is a core word.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
11. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
