Text data enhancement method, system, computer device and storage medium

By obtaining the word vectors of entities for clustering and substitution, the problem of noise introduction in the text data augmentation process is solved, the generalization ability of the model is improved, and the dependence on high-quality synonyms dictionaries is avoided.

CN113869057BActive Publication Date: 2025-03-25BEIJING MININGLAMP SOFTWARE SYST CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111201161.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-15
Publication Date
2025-03-25
Estimated Expiration
2041-10-15

AI Technical Summary

Technical Problem

The prior art is prone to introducing noise in the process of text data enhancement, which affects the generalization ability of the model and makes it difficult to establish and improve high-quality synonyms dictionaries.

Method used

By obtaining the word vector of an entity, performing cluster division, constructing an entity class cluster dictionary, and selecting replacement entities based on the class cluster to generate an enhanced sample data set.

Benefits of technology

It effectively reduces the introduction of noise, improves the generalization ability of the model, and avoids dependence on high-quality synonyms dictionaries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113869057B_ABST
    Figure CN113869057B_ABST
Patent Text Reader

Abstract

The present application relates to a text data enhancement method, system and computer-readable storage medium, wherein the method comprises: extracting entities from a text training data set, and using a pre-trained model to obtain the corresponding word vector from each entity; dividing the entities corresponding to the word vector into corresponding clusters by clustering, and constructing an entity cluster dictionary; selecting a target text and determining the entity to be replaced corresponding to the target text, selecting a replacement entity according to the entity cluster dictionary to complete the replacement, and generating an enhanced sample data set. When the present application uses a pre-trained model to obtain the word vector of an entity, the entity is treated as a whole, and the pre-trained model is trained twice, thereby directly obtaining the entity word vector, and using the word vector to perform more detailed clustering of the entity to achieve text data enhancement, and avoid introducing unnecessary noise in the process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a text data enhancement method, system and computer-readable storage medium. Background Art

[0002] In recent years, with the development of deep learning technology, various neural network models have been widely used in named entity recognition tasks and have achieved good results. Deep learning technology uses neural network models to automatically mine features from data, and often requires a large amount of high-quality data as training sample support to have a high data generalization ability. Obviously, in current practical engineering applications, there are generally small amounts of data and unbalanced data, which makes it very easy for the model to overfit on the training data, affecting the generalization ability of the model. In addition, manually annotating new data will bring high manpower and time costs. In order to solve this problem, text data enhancement is a very effective data expansion method.

[0003] As an important means to expand the training set, data augmentation technology is often used to generate more new data to supplement the text training data set, thereby improving the generalization ability of the model. The core of data augmentation technology is to use another form of data as a new sample to supplement the training data without changing the meaning expressed by the data itself. The most commonly used data augmentation methods in the text field are vocabulary replacement and back translation. Vocabulary replacement refers to randomly selecting one or more words from the text, randomly selecting synonyms using a synonym dictionary for vocabulary replacement, and obtaining new sample data. Back translation refers to using machine translation technology to translate the target text into another language representation, and then translating the other language representation back to obtain the same semantic representation of the target text. In entity recognition tasks, vocabulary replacement is usually used as the main method of data augmentation. The specific words to be replaced are entities in the text, and the replacement words can be synonyms or other entities of the same entity category. For example: to identify the institution in the text, "Xiao Ming graduated from Tsinghua University", the word to be replaced is "Tsinghua University", and the replacement word is a synonym "Tsinghua", or it can be other entities of the same entity category "Peking University". However, it is very difficult to build and improve a high-quality synonym dictionary, which requires time accumulation and the assistance of experts. Moreover, choosing other entities of the same entity category as replacement words may generate unreasonable new samples, which will introduce unnecessary noise. For example, "*** Company" is also the name of an organization, but after replacement, it becomes "He graduated from *** Company". Obviously, this is not a usable new sample.

[0004] Currently, no effective solution has been proposed for the problem of introducing noise in the data enhancement process in related technologies. Summary of the invention

[0005] The embodiments of the present application provide a text data enhancement method, system, and computer-readable storage medium to at least solve the problem of introducing noise in the data enhancement process in the related art.

[0006] In a first aspect, an embodiment of the present application provides a text data enhancement method, comprising the following steps:

[0007] The word vector acquisition step extracts entities from a text training data set and uses a pre-trained model to obtain the corresponding word vector from each entity;

[0008] Entity clustering step: divide the entities corresponding to the word vectors into corresponding clusters through clustering, and build an entity cluster dictionary;

[0009] In the entity replacement step, the target text is selected and the entity to be replaced corresponding to the target text is determined. The replacement entity is selected according to the entity cluster dictionary to complete the replacement and generate an enhanced sample data set.

[0010] In some embodiments, the word vector acquisition step further includes:

[0011] The model is trained once, using common corpus to train the preset network structure and obtain the pre-trained model;

[0012] The vocabulary reconstruction step obtains all entities in the text training data set, encodes all entities to obtain entity codes, and adds the entity codes to the vocabulary of the pre-trained model to reconstruct the vocabulary;

[0013] The model secondary training step is to obtain unlabeled text corpus according to the text training data set, replace the corresponding entities in the unlabeled text with entity encoding based on the reconstructed vocabulary, train the pre-trained model according to the replaced unlabeled text, and save the pre-trained model after secondary training;

[0014] The entity word vector acquisition step obtains the entity code ID based on the vocabulary and inputs it into the pre-trained model to obtain the vector corresponding to the entity code, that is, to obtain the word vector of the corresponding entity.

[0015] The above method can directly obtain the word vector representation of the entire entity to prevent information loss. In addition, the pre-trained model can be used to continue training to obtain the context information of the entity, enhance the sensitivity of the pre-trained model to the data in the field, and make the word vector output more accurate.

[0016] In some embodiments, the entity clustering step specifically includes:

[0017] The word vector cluster acquisition step uses a clustering algorithm to cluster the word vectors and divide them into different clusters;

[0018] The entity cluster dictionary construction step obtains the entities contained in each cluster based on the correspondence between the entity and the word vector, and constructs the entity cluster dictionary.

[0019] The purpose of the clustering module is to divide entities into different clusters, which is a more detailed classification based on the original entity category. Compared with random entity category replacement, clustering helps to reduce the generation of unreasonable text and alleviate the problem of noise introduction.

[0020] In some of the embodiments, the clustering algorithm is set to one of a K-Means clustering algorithm, a DBSCAN clustering algorithm, and a hierarchical clustering algorithm, or a combination thereof.

[0021] In some embodiments, the entity replacement step further comprises:

[0022] A cluster determination step, determining the entity to be replaced according to the target text, and determining the cluster to which the entity to be replaced belongs according to the entity cluster dictionary;

[0023] New sample data generation step: According to the entity cluster dictionary, other entities in the cluster are selected as replacement words, and the replacement words are used to replace the entities to be replaced to generate new sample data;

[0024] In the step of obtaining an enhanced sample data set, new sample data is added to the text training data set to obtain an enhanced sample data set.

[0025] In a second aspect, an embodiment of the present application provides an entity recognition method, including the text data enhancement method and entity recognition step of the first aspect, wherein the entity recognition step specifically includes:

[0026] The enhanced sample dataset is used to train the entity recognition neural network model, and the trained entity recognition neural network model is used for entity recognition extraction.

[0027] In a third aspect, an embodiment of the present application provides a text data enhancement system, including:

[0028] The word vector acquisition module extracts entities from a text training data set and uses a pre-trained model to obtain the corresponding word vector from each entity;

[0029] The entity clustering module divides the entities corresponding to the word vectors into corresponding clusters through clustering, and constructs an entity cluster dictionary;

[0030] The entity replacement module selects the target text and determines the entity to be replaced corresponding to the target text, selects the replacement entity according to the entity cluster dictionary to complete the replacement, and generates an enhanced sample data set.

[0031] In some embodiments, the word vector acquisition module further includes:

[0032] The model is trained once, using common corpus to train the preset network structure and obtain the pre-trained model;

[0033] The vocabulary reconstruction unit obtains all entities in the text training data set, encodes all entities to obtain entity codes, and adds the entity codes to the vocabulary of the pre-trained model to reconstruct the vocabulary;

[0034] The model secondary training unit obtains unlabeled text corpus according to the text training data set, replaces the corresponding entities in the unlabeled text with entity encoding based on the reconstructed vocabulary, trains the pre-trained model according to the replaced unlabeled text, and saves the pre-trained model after the secondary training;

[0035] The entity word vector acquisition unit obtains the ID of the entity code based on the vocabulary and inputs it into the pre-trained model to obtain the vector corresponding to the entity code, that is, to obtain the word vector of the corresponding entity.

[0036] In a fourth aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the text data enhancement method as described in the first aspect above is implemented.

[0037] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the text data enhancement method as described in the first aspect above.

[0038] Compared with the related art, the text data enhancement method, system and computer-readable storage medium provided in the embodiments of the present application can be applied to the field of deep learning technology and the field of natural language processing technology. When using a pre-trained model to obtain the word vector of an entity, the entity is treated as a whole and the pre-trained model is further trained, thereby directly obtaining the entity word vector and using the word vector to perform more detailed clustering of the entity to achieve text data enhancement and avoid introducing unnecessary noise in the process.

[0039] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0041] Figure 1 is a flowchart of a text data enhancement method according to an embodiment of the present application;

[0042] Figure 2 is a flow chart of an entity recognition method according to an embodiment of the present application;

[0043] Figure 3 is a flowchart of a text data enhancement method based on entity recognition according to a preferred embodiment of the present application;

[0044] Figure 4 is a structural block diagram of a text data enhancement system according to an embodiment of the present application;

[0045] Figure 5 is a preferred structural block diagram of a text data enhancement system according to an embodiment of the present application;

[0046] Figure 6 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present application. Description of the drawings:

[0048] Word vector acquisition module 1; entity clustering module 2; entity replacement module 3;

[0049] Model primary training unit 11; model secondary training unit 12; model reading unit 13;

[0050] Word vector cluster acquisition unit 21; entity cluster dictionary construction unit 22; cluster determination unit 31;

[0051] New sample data generation unit 32; Enhanced sample data set acquisition unit 33;

[0052] Processor 81; memory 82; communication interface 83; bus 80. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated 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 intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0054] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.

[0055] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0056] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0057] This embodiment provides a text data enhancement method. Figure 1 is a flowchart of a text data enhancement method according to an embodiment of the present application. Figure 1 As shown, the process includes the following steps:

[0058] The word vector acquisition step S1 extracts entities from a text training data set, and uses a pre-trained model to obtain the corresponding word vector from each entity;

[0059] In the prior art, a pre-trained model is usually used to obtain entity word vectors. First, the vector of each character in the entity is obtained, and then the vectors of all characters are averaged to indirectly obtain the word vector representation of the entity. This method ignores the fact that the entity is a whole, which may cause information loss. In the embodiment of the present application, a new pre-trained model is used to obtain the entity word vector. The entity is regarded as a whole, and the word vector of the entity is directly obtained using the pre-trained model.

[0060] Entity clustering step S2, dividing the entities corresponding to the word vectors into corresponding clusters through clustering, and constructing an entity cluster dictionary;

[0061] Exemplarily, different clusters may include government agencies, school names, social groups, etc.

[0062] In the entity replacement step S3, a target text is selected and the entity to be replaced corresponding to the target text is determined. A replacement entity is selected according to the entity cluster dictionary to complete the replacement and generate an enhanced sample data set.

[0063] In the above steps, the corresponding word vector is obtained by treating the entity as a whole, and the pre-trained model can be used to better represent the characteristics of the entity, so that the clusters can be accurately divided according to the entity characteristics, thereby achieving data enhancement and obtaining an enhanced sample data set.

[0064] It should be noted that the entities are obtained from the text training data set, and the above-mentioned extraction of entities based on the training data can be directly obtained based on the pre-annotation. A large number of training data constitute the text training data set, which is the training sample data in a certain field.

[0065] In some embodiments, the word vector acquisition step S1 further includes:

[0066] A model training step S11, using common corpus to train a preset network structure and obtain a pre-trained model;

[0067] The vocabulary reconstruction step S12, obtaining all entities in the text training data set, encoding all entities to obtain entity codes, and adding the entity codes to the vocabulary of the pre-trained model to reconstruct the vocabulary;

[0068] For example, the word Tsinghua is replaced by a symbol code that does not exist in the vocabulary and added to the vocabulary. At this time, the symbol code corresponding to "Tsinghua" and "Qing" and "Hua" exist in the vocabulary.

[0069] The model secondary training step S13 is to obtain an unlabeled text corpus according to the text training data set, replace the corresponding entities in the unlabeled text with entity encoding based on the reconstructed vocabulary, train the pre-trained model according to the replaced unlabeled text, and save the pre-trained model after the secondary training;

[0070] For example, the original training data is "He graduated from Tsinghua University", and Tsinghua University is replaced with code A and added to the vocabulary, so the unlabeled corpus becomes "He graduated from code A".

[0071] The entity word vector acquisition step obtains the entity code ID based on the vocabulary and inputs it into the pre-trained model to obtain the vector corresponding to the entity code, that is, to obtain the word vector of the corresponding entity.

[0072] The vocabulary of the pre-trained model includes all Chinese characters, some individual characters, and some English words, and the content is adjusted through reconstruction.

[0073] Through the above steps, by reconstructing the pre-trained model vocabulary, using the text training data set, that is, the data in the field to which the data enhancement text belongs, and continuing to train the pre-trained model, high-quality entity word vectors can be obtained; using this method, the word vector representation of the entire entity can be directly obtained to prevent information loss. In addition, by continuing to train the pre-trained model, the context information of the entity can be obtained, and the sensitivity of the pre-trained model to the data in the field can be enhanced, making the word vector output by it more accurate.

[0074] It should be noted that the pre-training model can be set to BERT model, ERNIE and RoBERTa, etc.

[0075] In some embodiments, the entity clustering step S2 specifically includes:

[0076] In the word vector cluster acquisition step S21, the word vectors are clustered using a clustering algorithm to divide them into different clusters.

[0077] In the entity cluster dictionary construction step S22, the entities included in each cluster are obtained according to the correspondence between the entity and the word vector, and the entity cluster dictionary is constructed.

[0078] It should be noted that the corresponding relationship between the entity and the word vector here can be a mapping relationship.

[0079] Through the above steps, a clustering process is added before entity replacement. The purpose of the clustering process is to divide entities into different clusters, which is a more detailed classification based on the original entity category. Compared with random entity category replacement, clustering helps to reduce the generation of unreasonable text and alleviate the problem of noise introduction. It can get rid of the dependence of the traditional entity replacement process on the synonym dictionary and alleviate the problem of the entity replacement process generating unreasonable text.

[0080] It should be noted that the above clustering algorithm can be set to K-Means clustering algorithm, DBSCAN, hierarchical clustering, etc.

[0081] In some of the embodiments, in the word vector cluster acquisition step S21, the parameters of the clustering algorithm may also be adjusted according to the clustering results.

[0082] In some of the embodiments, the clustering algorithm is set to one of a K-Means clustering algorithm, a DBSCAN clustering algorithm, and a hierarchical clustering algorithm, or a combination thereof.

[0083] In some embodiments, the entity replacement step S3 further comprises:

[0084] Cluster determination step S31, determining the entity to be replaced according to the target text, and determining the cluster to which the entity to be replaced belongs according to the entity cluster dictionary;

[0085] For example, "Xiao Ming graduated from Tsinghua University", the word to be replaced is "Tsinghua University", and the cluster used is the school name rather than the name of the institution in a broad sense. "Tsinghua University" can be replaced by other entities in the same cluster, such as "Peking University", "University of Science and Technology of China", etc.

[0086] New sample data generation step S32, selecting other entities in the cluster as replacement words according to the entity cluster dictionary, using the replacement words to replace the entity to be replaced, and generating new sample data;

[0087] In the enhanced sample data set acquisition step S33, the new sample data is added to the text training data set to obtain an enhanced sample data set.

[0088] It should be noted that in the step of obtaining the enhanced sample data set, the amount of training data for each original entity category can be controlled to be equivalent, so as to alleviate the problem of imbalance in original entity categories in entity recognition.

[0089] This embodiment also provides an entity recognition method. Figure 2 is a flow chart of an entity recognition method according to an embodiment of the present application, such as Figure 2 As shown, the process includes the above-mentioned text data enhancement method and entity recognition step, and the entity recognition step S201 specifically includes:

[0090] The enhanced sample dataset is used to train the entity recognition neural network model, and the trained entity recognition neural network model is used for entity recognition extraction.

[0091] Through the above steps, entity replacement is used to obtain an enhanced data set, train the entity recognition model, and effectively improve the generalization ability of the model.

[0092] The embodiments of the present application are described and illustrated below through preferred embodiments.

[0093] Figure 3 It is a flowchart of a text data enhancement method based on entity recognition according to a preferred embodiment of the present application.

[0094] S301, using the pre-trained model to obtain the word vector corresponding to the entity in the text,

[0095] In the prior art, the vector of each character in the entity is first obtained, and then the vectors of all characters are averaged to indirectly obtain the word vector representation of the entity. However, this method ignores the fact that the entity is a whole, which may cause information loss.

[0096] The embodiment of the present application adopts a new method of obtaining entity word vectors using a pre-trained model, treating the entity as a whole and using the pre-trained model to directly obtain the word vector of the entity. The specific steps include:

[0097] 1. Obtain all entities in the text training dataset, build an entity dictionary and encode the entities, add the entity encoding to the vocabulary of the pre-trained model BERT, and reconstruct the vocabulary.

[0098] 2. Obtain unlabeled text corpus based on the text training dataset, use entity encoding to replace entities in the unlabeled text corpus, continue training the pre-trained model BERT on the replaced unlabeled corpus, and save the model after training.

[0099] 3. Get the entity id according to the vocabulary, read the saved BERT model, and get the word vector of the entity.

[0100] The purpose of this is to directly obtain the word vector representation of the entire entity in this way to prevent information loss. In addition, by continuing to train with the pre-trained model, the context information of the entity can be obtained, which enhances the sensitivity of the pre-trained model to the data in the field and makes the word vector output more accurate.

[0101] S302, divide the entities into different clusters to obtain an entity cluster dictionary. The specific steps of S302 are:

[0102] 1. Use the K-Means clustering algorithm to cluster the word vectors of all entities and divide them into different clusters. The parameter k of the clustering algorithm can be adaptively adjusted according to the specific clustering results.

[0103] 2. According to the mapping relationship between entity and word vector, the entities contained in each cluster are obtained, and the cluster-entity dictionary and entity cluster dictionary are constructed.

[0104] This step is a more detailed classification based on the original entity category. Compared with random entity category replacement, clustering helps reduce the generation of unreasonable text and alleviate the problem of noise introduction.

[0105] S303, using the entity cluster dictionary obtained by clustering, replace the entities in the text, thereby obtaining an enhanced sample data set. Specifically:

[0106] 1. Select the target text, determine the entity to be replaced in the target text, and determine the cluster to which the entity to be replaced belongs based on the entity cluster dictionary.

[0107] 2. According to the entity cluster dictionary, select other entities in the cluster as replacement words, use the replacement words to replace the entities to be replaced in the text, and generate new training data.

[0108] 3. Add the new training data to the original text training data set to obtain an enhanced sample data set.

[0109] In the process of obtaining the enhanced sample data set, the amount of training data for each original entity category can be controlled to be equivalent, so as to alleviate the problem of imbalance in original entity categories in entity recognition.

[0110] S304, using the enhanced sample data set to train an entity recognition neural network model, and using the trained model to perform entity recognition extraction on the text data.

[0111] The above entity recognition neural network model can be set as a BILSTM+CRF model.

[0112] Through the above steps, the embodiment of the present application is different from the traditional method of using a pre-trained model to obtain text word vectors. When using the pre-trained model to obtain the word vector of an entity, the entity is regarded as a whole and the pre-trained model is further trained. Then, the method of directly obtaining the entity word vector can be used to perform more detailed clustering of the entity using high-quality entity word vectors, thereby providing an effective basis for entity replacement.

[0113] It should be noted that the steps shown in the above process or the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0114] This embodiment also provides a text data enhancement system, which is used to implement the above embodiments and preferred implementations, and will not be repeated here. As used below, the terms "module", "unit", "subunit", etc. can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0115] Figure 4 is a structural block diagram of a text data enhancement system according to an embodiment of the present application, such as Figure 4 As shown, the system includes:

[0116] The word vector acquisition module 1 extracts entities from a text training data set and uses a pre-trained model to obtain the corresponding word vector from each entity;

[0117] Entity clustering module 2, which divides the entities corresponding to the word vectors into corresponding clusters through clustering, and constructs an entity cluster dictionary;

[0118] The entity replacement module 3 selects the target text and determines the entity to be replaced corresponding to the target text, selects the replacement entity according to the entity cluster dictionary to complete the replacement, and generates an enhanced sample data set.

[0119] In some embodiments, the word vector acquisition module 1 further includes:

[0120] A model one-time training unit 11 uses a general corpus to train a preset network structure and obtain a pre-trained model;

[0121] The vocabulary reconstruction unit 12 obtains all entities in the text training data set, encodes all entities to obtain entity codes, and adds the entity codes to the vocabulary of the pre-trained model to reconstruct the vocabulary;

[0122] The model secondary training unit 13 obtains unlabeled text corpus according to the text training data set, replaces corresponding entities in the unlabeled text with entity encoding based on the reconstructed vocabulary, trains the pre-trained model according to the replaced unlabeled text, and saves the pre-trained model after the secondary training;

[0123] The entity word vector acquisition unit 14 acquires the ID of the entity code based on the vocabulary and inputs it into the pre-trained model to acquire the vector corresponding to the entity code, that is, to obtain the word vector of the corresponding entity.

[0124] Through the above settings, by reconstructing the pre-trained model vocabulary, and using the training model to continue training the pre-trained model, high-quality entity word vectors can be obtained; this method can directly obtain the word vector representation of the entire entity to prevent information loss. In addition, by continuing to train the pre-trained model, the context information of the entity can be obtained, which enhances the sensitivity of the pre-trained model to the data in the field, making the word vector output more accurate.

[0125] Figure 5 is a preferred structural block diagram of a text data enhancement system according to an embodiment of the present application, such as Figure 5 As shown, the system includes Figure 4 Of all the modules shown, entity clustering module 2 also includes:

[0126] A word vector cluster acquisition unit 21 clusters the word vectors using a clustering algorithm and divides them into different clusters;

[0127] The entity cluster dictionary construction unit 22 obtains the entities included in each cluster according to the mapping relationship between the entity and the word vector, and constructs the entity cluster dictionary.

[0128] The word vector cluster acquisition unit 21 can also adjust the parameters of the clustering algorithm according to the clustering results.

[0129] The entity replacement module 3 further comprises:

[0130] A cluster determination unit 31 determines an entity to be replaced according to a target text, and determines a cluster to which the entity to be replaced belongs according to an entity cluster dictionary;

[0131] A new sample data generating unit 32 selects other entities in the cluster as replacement words according to the entity cluster dictionary, and uses the replacement words to replace the entity to be replaced to generate new sample data;

[0132] The enhanced sample data set acquisition unit 33 adds the new sample data to the text training data set to obtain an enhanced sample data set.

[0133] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0134] In addition, combined Figure 1 The text data enhancement method described in the embodiment of the present application can be implemented by a computer device. Figure 6 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present application.

[0135] The computer device may include a processor 81 and a memory 82 storing computer program instructions.

[0136] Specifically, the processor 81 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0137] Among them, the memory 82 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 82 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 82 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 82 may be inside or outside the data processing device. In a specific embodiment, the memory 82 is a non-volatile memory. In a specific embodiment, the memory 82 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable ProgrammableRead-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable ProgrammableRead-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.

[0138] The memory 82 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 81 .

[0139] The processor 81 implements any one of the text data enhancement methods in the above embodiments by reading and executing computer program instructions stored in the memory 82 .

[0140] In some of these embodiments, the computer device may further include a communication interface 83 and a bus 80. Figure 6 As shown, the processor 81, the memory 82, and the communication interface 83 are connected via a bus 80 and communicate with each other.

[0141] The communication interface 83 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication port 83 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.

[0142] The bus 80 includes hardware, software or both, and couples the components of the computer device to each other. The bus 80 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 80 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 80 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.

[0143] The computer device can execute the text data enhancement method in the embodiment of the present application based on the acquired entity, thereby realizing the combination Figure 1 Describes the text data augmentation method.

[0144] In addition, in combination with the text data enhancement method in the above embodiment, the embodiment of the present application can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the text data enhancement methods in the above embodiment is implemented.

[0145] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described 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.

[0146] 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 text data enhancement method, characterized in that: The following steps are involved: A word vector acquisition step, extracting entities from a text training data set, and using a pre-trained model to acquire a corresponding word vector from each of the entities; The word vector acquisition step further includes: a model primary training step, using a general corpus to train a preset network structure and obtain a pre-trained model; a vocabulary reconstruction step, obtaining all entities in a text training data set, encoding all the entities to obtain entity codes, and adding the entity codes to the vocabulary of the pre-trained model to reconstruct the vocabulary; a model secondary training step, obtaining unlabeled text corpus according to the text training data set, replacing the corresponding entities in the unlabeled text with the entity codes based on the reconstructed vocabulary, training the pre-trained model based on the replaced unlabeled text, and saving the pre-trained model after secondary training; an entity word vector acquisition step, obtaining the ID of the entity code based on the vocabulary and inputting it into the pre-trained model, obtaining the vector corresponding to the entity code, that is, obtaining the word vector corresponding to the entity; An entity clustering step, dividing the entities corresponding to the word vectors into corresponding clusters by clustering, and constructing an entity cluster dictionary; In the entity replacement step, a target text is selected and an entity to be replaced corresponding to the target text is determined, and a replacement entity is selected according to the entity cluster dictionary to complete the replacement and generate an enhanced sample data set.

2. The text data enhancement method according to claim 1, characterized in that The entity clustering step specifically includes: A word vector cluster acquisition step, clustering the word vectors using a clustering algorithm to divide them into different clusters; The entity cluster dictionary construction step obtains the entities included in each cluster according to the corresponding relationship between the entities and the word vectors, and constructs the entity cluster dictionary.

3. The text data enhancement method according to claim 2, characterized in that: The clustering algorithm is set to be one of a K-Means clustering algorithm, a DBSCAN clustering algorithm and a hierarchical clustering algorithm or a combination thereof.

4. The text data enhancement method according to any one of claims 1 to 3, characterized in that: The entity replacement step further comprises: A cluster determination step, determining the entity to be replaced according to the target text, and determining the cluster to which the entity to be replaced belongs according to the entity cluster dictionary; A new sample data generating step, selecting other entities in the cluster as replacement words according to the entity cluster dictionary, and using the replacement words to replace the entity to be replaced to generate new sample data; The enhanced sample data set acquisition step adds the new sample data to the text training data set to obtain the enhanced sample data set.

5. An entity recognition method, characterized in that: The method comprises the text data enhancement method and entity recognition step as described in claim 4, wherein the entity recognition step specifically comprises: The enhanced sample data set is used to train an entity recognition neural network model, and the trained entity recognition neural network model is used to perform entity recognition extraction.

6. A text data enhancement system, characterized in that: include: A word vector acquisition module extracts entities from a text training data set and uses a pre-trained model to obtain the corresponding word vector from each of the entities; The word vector acquisition module further includes: a model primary training unit, which uses a general corpus to train a preset network structure and obtain a pre-trained model; a vocabulary reconstruction unit, which obtains all entities in a text training data set, encodes all the entities to obtain entity codes, and adds the entity codes to the vocabulary of the pre-trained model to reconstruct the vocabulary; a model secondary training unit, which obtains unlabeled text corpus according to the text training data set, replaces the corresponding entity in the unlabeled text with the entity code based on the reconstructed vocabulary, trains the pre-trained model based on the replaced unlabeled text, and saves the pre-trained model after secondary training; an entity word vector acquisition unit, which obtains the ID of the entity code based on the vocabulary and inputs it into the pre-trained model to obtain the vector corresponding to the entity code, that is, obtains the word vector corresponding to the entity; An entity clustering module, which divides the entities corresponding to the word vectors into corresponding clusters through clustering, and constructs an entity cluster dictionary; The entity replacement module selects a target text and determines the entity to be replaced corresponding to the target text, selects a replacement entity according to the entity cluster dictionary to complete the replacement, and generates an enhanced sample data set.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the text data enhancement method according to any one of claims 1 to 4 or the entity recognition method according to claim 5 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the text data enhancement method as described in any one of claims 1 to 4 or the entity recognition method as described in claim 5 is implemented.

Citation Information

Patent Citations

  • Method and device for replacing entity name, storage medium and electronic device

    CN110263338A