Model training data processing method, device and electronic device

Through word segmentation preprocessing and keyword extraction, word vectors and text vectors are generated, and text deduplication processing of large language models is performed, which solves the problem of long text duplication and memory in large language models in massive training data, and improves training efficiency and accuracy. , avoiding the risk of privacy leakage.

CN118378723BActive Publication Date: 2024-09-13CHINA TELECOM CORP LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410813561.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-13
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

When large language models use massive unlabeled training data, they are prone to long text duplication and memory problems, leading to low model training efficiency and the risk of privacy leaks.

Method used

Through word segmentation preprocessing, keyword extraction, word vectors and text vectors are generated, the distance between keywords and words is used to determine weights, text is deduplicated, and similar texts are processed in groups to reduce the amount of calculation and misjudgment rate.

Benefits of technology

It improves the efficiency of model training, reduces the amount of text similarity calculations, enhances the accuracy of deduplication, avoids the problem of the model's memory of training data, and improves the model's perplexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118378723B
    Figure CN118378723B
Patent Text Reader

Abstract

The present disclosure provides a model training data processing method, device and electronic device, which relate to the field of data processing technology. The model training data processing method includes: obtaining model training data to be processed including multiple training texts, performing word segmentation preprocessing on each of the training texts to obtain a vocabulary set corresponding to each training text; extracting K keywords of each training text according to the vocabulary set, and dividing the multiple training texts into multiple groups according to the K keywords, K≥1; generating a word vector for each vocabulary in each vocabulary set; for each training text, determining the weight of the vocabulary according to the distance between the vocabulary and the keyword, and determining the text vector of the training text according to the word vectors of the multiple vocabulary corresponding to the training text and the weight; deduplicating the training texts whose text vector similarity is greater than a preset threshold in the same group. The embodiments of the present disclosure can improve the efficiency of model training.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] A large model (LM) refers to a machine learning model with large-scale parameters and complex computing structure. It has a huge number of parameters, can process massive amounts of data, and complete a variety of complex tasks. When a large model is mainly used to process language tasks, it is also called a large language model (LLM).

[0003] Large language models usually require massive amounts of training texts to train, and these training texts are all unlabeled. Therefore, there are a large number of long texts in the existing training datasets, and there are many nearly repeated examples and long repeated substrings between these long texts. Using such training datasets to train large language models is difficult to improve the perplexity of the model, and it is easy to cause the trained model to exhibit memory (generated content is copied from the training data), resulting in privacy issues caused by the model memorizing its training data.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0005] The purpose of the present disclosure is to provide a model training data processing method, device and electronic device for deduplicating long texts in a training data set of a large language model to solve the problem of model memorizing training data and showing memory, while improving model training efficiency.

[0006] According to a first aspect of an embodiment of the present disclosure, a model training data processing method is provided, comprising: obtaining model training data to be processed including a plurality of training texts, performing word segmentation preprocessing on each of the training texts to obtain a vocabulary set corresponding to each training text; extracting K keywords of each of the training texts according to the vocabulary set, and dividing the plurality of training texts into a plurality of groups according to the K keywords, K≥1; generating a word vector for each vocabulary in each of the vocabulary sets; for each training text, determining a weight of the vocabulary according to a distance between the vocabulary and the keyword, and determining a text vector of the training text according to the word vectors of the plurality of vocabulary corresponding to the training text and the weight; and deduplicating training texts in the same group whose text vector similarity is greater than a preset threshold.

[0007] In an exemplary embodiment of the present disclosure, extracting K keywords from each of the training texts according to the vocabulary set includes:

[0008] The K keywords with the highest TF-IDF values ​​in each of the vocabulary sets are determined by the term frequency-inverse document frequency method.

[0009] In an exemplary embodiment of the present disclosure, determining the weight of a word according to the distance between the word and the keyword includes:

[0010] According to the word order of the training text, determine the keywords closest to the left and right sides of a word, and the distance between the word and the keyword;

[0011] When the word is located on the left side of the keyword, the weight of the word is set to a negative number, and when the word is located on the right side of the keyword, the weight of the word is set to a positive number;

[0012] The absolute value of the weight of the vocabulary is set according to the distance, and the greater the distance, the smaller the weight.

[0013] In an exemplary embodiment of the present disclosure, setting the absolute value of the weight of the vocabulary according to the distance includes:

[0014] The denominator of the absolute value of the weight is set according to the distance, and the numerator of the absolute value of the weight is 1.

[0015] In an exemplary embodiment of the present disclosure, the weight of the keyword is 1, and the weights of other words are all smaller than the weight of the keyword.

[0016] In an exemplary embodiment of the present disclosure, dividing the plurality of training texts into a plurality of groups according to the K keywords comprises:

[0017] The training texts with the K completely identical keywords are divided into the same group, and the training texts with the K non-completely identical keywords are divided into different groups;

[0018] Determine the number of words corresponding to the training texts in the same group;

[0019] The training texts in the same group are divided into different groups again according to the number of words, so that the difference in the number of words of the training texts in the same group is not greater than a preset number, and the K keywords of the training texts in the same group are the same.

[0020] In an exemplary embodiment of the present disclosure, the word segmentation preprocessing of each training text includes:

[0021] Performing word segmentation processing on the training text to obtain a word segmentation result;

[0022] Punctuation characters and stop words in the word segmentation result are removed.

[0023] According to a second aspect of an embodiment of the present disclosure, a model training data processing device is provided, including:

[0024] A word segmentation processing module, configured to obtain model training data to be processed including a plurality of training texts, and perform word segmentation preprocessing on each of the training texts to obtain a vocabulary set corresponding to each training text;

[0025] A text grouping module, configured to extract K keywords from each of the training texts according to the vocabulary set, and to divide the plurality of training texts into a plurality of groups according to the K keywords, K≥1;

[0026] A word vector calculation module, configured to generate a word vector for each word in each of the vocabulary sets;

[0027] A text vector calculation module is configured to determine, for each training text, a weight of a word according to a distance between the word and the keyword, and determine a text vector of the training text according to word vectors of multiple words corresponding to the training text and the weights;

[0028] The text deduplication module is configured to dedupe training texts whose text vector similarity is greater than a preset threshold within the same group.

[0029] According to a third aspect of the present disclosure, there is provided an electronic device, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute any one of the methods described above based on instructions stored in the memory.

[0030] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a program is stored, and when the program is executed by a processor, the model training data processing method as described in any one of the above items is implemented.

[0031] The disclosed embodiment extracts keywords from multiple training texts and groups them according to the keywords, thereby roughly classifying massive training texts, deduplicating training texts within the group, reducing the amount of computation for text similarity comparison, and improving data processing efficiency. By determining the weight of each word according to the distance between the word and the keyword in a training text, and then determining the text vector of the training text according to the word vector and weight of each word, the text vector can express the word order and semantics of the training text, avoid similarity misjudgment due to similar vocabulary but different semantics, and improve the accuracy of deduplicating training texts. Finally, by deduplicating training texts with a similarity greater than a preset threshold within the same group, the model training efficiency can be improved, the trained model can have a better perplexity, and the model can be prevented from showing memory of the training data.

[0032] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0034] Figure 1 Detailed description of the invention The figure is a flowchart of a method for processing model training data in an exemplary embodiment of the present invention.

[0035] Figure 2 It is a sub-flow chart of step S4 in the embodiment of the present disclosure.

[0036] Figure 3A~3C It is a schematic diagram of vocabulary weight setting in an embodiment of the present disclosure.

[0037] Figure 4 It is an overall schematic diagram of the data processing process in one embodiment of the present disclosure.

[0038] Figure 5 It is a block diagram of a model training data processing device in an exemplary embodiment of the present disclosure.

[0039] Figure 6 is a block diagram of an electronic device in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0040] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.

[0041] In addition, the accompanying drawings are only schematic diagrams of the present disclosure, and the same reference numerals in the drawings represent the same or similar parts, so their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities, which do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0042] The exemplary embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.

[0043] Figure 1 Detailed description of the invention The figure is a flowchart of a method for processing model training data in an exemplary embodiment of the present invention.

[0044] refer to Figure 1 , the model training data processing method 100 may include:

[0045] Step S1, obtaining model training data to be processed including a plurality of training texts, and performing word segmentation preprocessing on each of the training texts to obtain a vocabulary set corresponding to each training text;

[0046] Step S2, extracting K keywords from each of the training texts according to the vocabulary set, and dividing the plurality of training texts into a plurality of groups according to the K keywords, K≥1;

[0047] Step S3, generating a word vector for each word in each of the vocabulary sets;

[0048] Step S4, for each training text, determining a weight of a word according to the distance between the word and the keyword, and determining a text vector of the training text according to word vectors of multiple words corresponding to the training text and the weight;

[0049] Step S5, removing duplicates from the training texts in the same group whose text vector similarity is greater than a preset threshold.

[0050] The disclosed embodiment extracts keywords from multiple training texts and groups them according to the keywords, thereby roughly classifying massive training texts, deduplicating training texts within the group, reducing the amount of computation for text similarity comparison, and improving data processing efficiency. By determining the weight of each word according to the distance between the word and the keyword in a training text, and then determining the text vector of the training text according to the word vector and weight of each word, the text vector can express the word order and semantics of the training text, avoid similarity misjudgment due to similar vocabulary but different semantics, and improve the accuracy of deduplicating training texts. Finally, by deduplicating training texts with a similarity greater than a preset threshold within the same group, the model training efficiency can be improved, the trained model can have a better perplexity, and the model can be prevented from showing memory of the training data.

[0051] Next, each step of the model training data processing method 100 is described in detail.

[0052] In step S1, model training data to be processed including a plurality of training texts is obtained, and word segmentation preprocessing is performed on each of the training texts to obtain a vocabulary set corresponding to each training text.

[0053] The method of the disclosed embodiment can be applied to a large language model, and the model training data to be processed is the training data of the large language model, including text data collected for training the large language model, and these text data include long texts. After being processed by the method 100, the model training data to be processed can be used to train the large language model, which not only has a higher training efficiency, but also can overcome the problem of memory exhibited by the large language model.

[0054] In an exemplary embodiment, the model training data to be processed may include, but is not limited to, web page data, social media texts, news articles, academic papers, conversation records, comments, novels, etc. In some application scenarios, some models may focus on learning knowledge in a specific field, and the model training data to be processed may include, for example, professional texts in the fields of science and technology, law, or medicine. In addition, the model training data to be processed may also include a large number of general corpora for the model to learn the basic laws and patterns of language through training.

[0055] In the process of obtaining the training data of the model to be processed in step S1, the file format and character style of data of different types and sources can be adjusted, and finally a plurality of training texts with fixed file formats that can be used as qualified data processing objects are formed. It should be noted that in order to ensure the effective deduplication of the training texts, the text length of the training texts obtained in step S1 can be limited to training texts with a length greater than a preset length, that is, they are all long texts, containing multiple sentences or paragraphs, rather than phrases and words.

[0056] Next, each training text is preprocessed by word segmentation.

[0057] In an exemplary embodiment, word segmentation preprocessing for each training text includes: word segmentation of the training text to obtain a word segmentation result including multiple words, and then, removing punctuation characters and stop words in the word segmentation result to obtain a vocabulary set corresponding to each training text, wherein the punctuation characters and stop words can be determined according to a preset punctuation character data table and a stop word table.

[0058] It is understandable that the vocabulary set may include multiple repeated words. Each word is arranged in the vocabulary set according to the original word order in the training text.

[0059] In step S2, K keywords of each of the training texts are extracted according to the vocabulary set, and the plurality of training texts are divided into a plurality of groups according to the K keywords, where K≥1.

[0060] In an exemplary embodiment, the K keywords with the highest TF-IDF values ​​in each training text may be determined by a TF-IDF method, where K is a preset value.

[0061] TF-IDF is a statistical method used in information retrieval and text mining to evaluate the importance of a word to a document or an entire document set. Among them, term frequency (TF) refers to the frequency of a specific word in a document, and inverse document frequency (IDF) measures the rarity of a word in multiple documents. The calculation of the TF-IDF value multiplies these two indicators to get a value. The larger the value, the stronger the discriminative ability and importance of the word to the document.

[0062] In addition to using the TF-IDF method to extract keywords, other methods can also be used to extract K keywords that can express the semantics of the training text, as long as the combination of the K keywords can express the semantics and theme of the training text.

[0063] In an exemplary embodiment, the K value can be set according to the text length of the training text (eg, the average length of the training text processed in this batch). The longer the text length, the larger the K value. It can also be set according to the needs of subsequent grouping.

[0064] After extracting the keywords, the training texts can be grouped according to the K keywords.

[0065] In related technologies, the traditional algorithm used for deduplication of text is to calculate the similarity of different texts - matching the text similarity of each text with other texts. When the number of texts is large, it takes a huge amount of time and space resources to calculate the training texts in the entire database. In addition, this calculation method stays at the text level of text matching and cannot consider the semantic level. It will identify texts with similar words but different semantics as duplicate texts.

[0066] In order to solve these problems, the embodiment of the present disclosure extracts K keywords from each training text, and then groups the training texts according to the K keywords, so as to quickly classify the training texts with similar semantics, so as to further deduplicate the texts within the group by comparing the text vectors that express the semantics, thereby reducing the amount of calculation and computing resources required for comparing the texts.

[0067] In an exemplary embodiment, the training texts grouped into the same group have the same K keywords. In some embodiments, the K value can be adjusted to limit the accuracy of the grouping of the training texts. The larger the K value, the more accurate the grouping, the fewer the number of training texts in the same group, and the greater the semantic similarity of the training texts in the same group; the smaller the K value, the fewer the number of groups, and the faster the grouping speed.

[0068] The above-mentioned “K keywords are the same” does not limit the order of the K keywords to be the same. The following example illustrates this. Suppose training texts T1, T2, and T3 are:

[0069] T1: The development of science and technology has profoundly changed our lives. From smartphones to artificial intelligence, the continuous innovation of technology has created a more convenient and intelligent lifestyle for us. The rise of social media has made it easier for people to share their lives and insights, and the exchange of information around the world has become more seamless. In the future, we can expect more exciting technological advances to bring more convenience and opportunities to the global community.

[0070] T2: With the rapid development of science and technology, our lives have become more intelligent. From smartphones to artificial intelligence, the continuous innovation of technology has provided us with a more convenient and efficient lifestyle. The prevalence of social media has made it easier for us to share our lives and insights, and the exchange of information around the world has become more seamless. In the future, we are full of expectations for technological progress and believe that it will bring more convenience and opportunities to the global society.

[0071] T3: Green energy is the key to sustainable development in today's society. By utilizing renewable energy sources such as solar and wind power, we can reduce our dependence on limited resources and reduce environmental pollution. However, to achieve sustainable energy transformation, we need interdisciplinary cooperation to promote technological innovation and policy support. The development of green energy will create a healthier and more sustainable future for us.

[0072] After the word segmentation preprocessing in step S1, the vocabulary sets H1, H2, and H3 corresponding to the training texts T1, T2, and T3 can be obtained respectively:

[0073] H1=[Technological development has profoundly changed our lives. Smartphones and artificial intelligence technology are constantly innovating. We are creating a more convenient and intelligent lifestyle. The rise of social media makes it easy to share life insights. Global information exchange has become more seamless. We look forward to exciting technological progress and global social convenience opportunities];

[0074] H2=[Technology is developing rapidly. Today, our lives are becoming more intelligent. Smartphones and artificial intelligence technologies are constantly innovating. We are providing a more convenient and efficient lifestyle. Social media is popular. We can easily share our life insights. Information exchange around the world has become more seamless. We are full of expectations for technological progress and believe that it will bring convenient opportunities to the global society];

[0075] H3=[Green energy is the key to sustainable development of today's society. By utilizing solar energy, wind energy and renewable energy, we can reduce our dependence on limited resources and reduce environmental pollution. However, to achieve sustainable energy transformation, we need interdisciplinary cooperation to promote technological innovation and support green energy development. We can create healthy and sustainable development].

[0076] Assume K=4, and calculate the four keywords with the highest TD-IDF of each training text T1, T2, T3 and the TD-IDF values ​​corresponding to these four keywords based on H1, H2, and H3, and obtain the keyword information sets W1, W2, and W3 corresponding to the training texts T1, T2, and T3 respectively:

[0077] W1=[Life: 0.3980542160186187, Us: 0.3091246081113119, Global: 0.2653694773457458, More: 0.2653694773457458];

[0078] W2=[We: 0.3571057055177209, Life: 0.34487896122406064, More: 0.34487896122406064, Global: 0.2299193074827071];

[0079] W3=[Sustained: 0.41589942149704145,Energy: 0.41589942149704145,Green: 0.27726628099802764,We: 0.24563689812216927].

[0080] According to the keyword information set corresponding to each training text, it is determined that the four keywords of training texts T1 and T2 are exactly the same, and training texts T1 and T2 are grouped into one group, and training text T3 is grouped into another group. The above values ​​are only examples.

[0081] In an exemplary embodiment, considering that two or more texts with a large length difference may have exactly the same K keywords, but the possibility that two or more texts with a large length difference are duplicate texts is not high, after the training texts with exactly the same K keywords are divided into the same group and the training texts with not exactly the same K keywords are divided into different groups, the number of words corresponding to the training texts in the same group can also be determined, and the training texts in the same group can be divided into different groups again according to the number of words, so that the difference in the number of words of the training texts in the same group is not greater than a preset number, and the K keywords of the training texts in the same group are the same.

[0082] By grouping the training texts according to the two limiting conditions of the number of words and K keywords, it is possible to most efficiently screen out training texts that may have semantic duplication and content duplication, making it easier to remove duplicates within the group, thereby increasing the success rate of removing duplicates within the group and improving computing efficiency.

[0083] In step S3, a word vector for each word in each of the vocabulary sets is generated.

[0084] A word vector refers to a numerical vector converted from a word in a text. There are many methods for generating word vectors, including traditional methods based on matrix decomposition and learning methods based on neural networks. In the disclosed embodiment, word vectors can be generated by Word2vec. Word2vec is a word vector generation model based on a neural network. Through training, each word is mapped to a continuous vector space, so that words with similar semantics are also adjacent in the vector space.

[0085] A word vector usually uses values ​​of multiple dimensions to express a word. The higher the dimension, the higher the expression accuracy. To facilitate subsequent calculations, the number of dimensions of the word vectors of each word generated in step S3 is set to be the same.

[0086] In step S4, for each training text, the weight of a word is determined according to the distance between the word and the keyword, and the text vector of the training text is determined according to the word vectors of multiple words corresponding to the training text and the weights.

[0087] Step S4 is used to obtain a text vector that can represent the semantics and text information of the entire training text, so that training texts with repeated semantics and text information (same words, same semantics) can be identified by calculating the similarity between different text vectors.

[0088] Different from the related art that only performs text and vocabulary comparison to achieve duplicate text detection, the embodiment of the present disclosure takes into account the word order and semantics, and adjusts the weights of other words that are not keywords according to the word order, so as to distinguish the situations where the same word appears in different word order positions, and expresses them in the final text vector through the weight of the word, so that the generated text vector can express the word order of the words and the semantics of the training text.

[0089] In an exemplary embodiment, during the generation of a text vector, the word vector features of each word are enlarged or reduced by weights, the lexical weights are semantically reduced in connection with the meaning of the context, and the weights of different words in the sentence are adjusted according to keywords and word order to obtain a text vector containing word order and contextual information.

[0090] Figure 2 It is a sub-flow chart of step S4 in the embodiment of the present disclosure.

[0091] refer to Figure 2 In an exemplary embodiment, step S4 may include:

[0092] Step S41, determining the keywords closest to a word on both sides of the word and the distance between the word and the keyword according to the word order of the training text;

[0093] Step S42, when the word is located on the left side of the keyword, the weight of the word is set to a negative number, and when the word is located on the right side of the keyword, the weight of the word is set to a positive number;

[0094] Step S43, setting the absolute value of the weight of the vocabulary according to the distance, the greater the distance, the smaller the weight.

[0095] Figure 2 The illustrated embodiment can express the word order of words in a training text through weights. In a training text, if two words are the same but have different relative position relationships with keywords, the weights of the two words are different, which have different effects on the calculation results. Similarly, for two training texts, if the same words exist but the relative position relationships between the words and the same keywords are different, the text vectors of the two training texts will eventually be different. Thus, the differences in semantics and word order can be expressed in the weights of each word, and ultimately in the text vector corresponding to the training text, so that two or more training texts with small vocabulary differences but large semantic differences have significantly different text vectors.

[0096] In an exemplary embodiment, the weight of a word is ωj, where j is the sequence number of the word in the training text, and the weight of the word on the left side of the keyword is negative, and the weight of the word on the right side of the keyword is negative. The denominator of the absolute value of the weight can be set according to the distance, and the numerator of the absolute value of the weight is 1.

[0097] For example, in one case, there are words only on the left side of the keyword. Let the set of word weights be ω, then the weights of each word from left to right are: ω=[-1 / R, ..., -1 / 3, -1 / 2, -1 / 1], where R represents the distance between the word and the keyword. In another case, there are words only on the right side of the keyword, then the weights of each word from left to right are: ω=[1 / 1, 1 / 2, 1 / 3, ...1 / R].

[0098] If there are an odd number of words between two keywords, the weights of the words between the two keywords are ω=[1 / 1, 1 / 2, 1 / 3, …1 / R, …, -1 / 3, -1 / 2, -1 / 1] from left to right; if there are an even number of words between two keywords, the weights of the words between the two keywords are ω=[1 / 1, 1 / 2, 1 / 3, …1 / R, -1 / R, …, -1 / 3, -1 / 2, -1 / 1] from left to right.

[0099] Taking the above training text T1 as an example, if its corresponding vocabulary set contains the following continuous participles: [life, way, social, media, rise, can, easy, share, life], and there are an odd number of words between the two keywords "life", then the weight of each word (excluding keywords) is ω = [1 / 1, 1 / 2, 1 / 3, 1 / 4, -1 / 3, -1 / 2, -1 / 1], as shown in Table 1.

[0100] Table 1:

[0101]

[0102] After weighting, the word vector of each vocabulary word is represented as the word vector set V = [method, social / 2, media / 3, rise / 4, - able / 3, - easy / 2, - share], where each word in the word vector set V represents the value of its word vector.

[0103] In the above example, different keywords are considered as the same anchor point to measure the word order of each word and the keyword. At this time, the distance R of the word closest to the keyword is considered to be 1, and the keyword itself is not given a weight. The value of the keyword's word vector can be considered or not when calculating the text vector. This method can quickly determine the weight of each word and has high calculation efficiency.

[0104] In an exemplary embodiment, different keywords can also be regarded as different positioning points. When determining the weight of a certain word, first find the keyword A closest to the word, and determine the distance R between the word and the keyword A and whether the relative position of the word and the keyword A is on the left or right, so as to determine the weight of the word based on the keyword A.

[0105] Figure 3A~3C It is a schematic diagram of vocabulary weight setting in an embodiment of the present disclosure.

[0106] refer to Figure 3A to Figure 3C , each word 31 is arranged in the vocabulary set according to the original word order, including keyword A and keyword B.

[0107] exist Figure 3A In the illustrated embodiment, the keyword closest to the target word C whose weight is to be determined is keyword A. At this time, it can be determined that the distance between the target word C and keyword A is 2, and the target word is on the right side of keyword A. The weight of the target word C can be set to 1 / 2.

[0108] In an exemplary embodiment, in order to indicate that the weight of the vocabulary is formed based on keyword A and is distinguished from the weight formed based on keyword B, the weight may be adjusted according to the parameters corresponding to keyword A. For example, if the weight is generated based on keyword A, the weight is increased by x, and if the weight is generated based on keyword B, the weight is increased by y or decreased by y. The above x and y are only examples, and in actual applications, they can be adjusted according to the number of K and the setting logic of the weight, as long as the weights generated based on different keywords can be expressed.

[0109] exist Figure 3B In the illustrated embodiment, the keyword closest to the target vocabulary C whose weight is to be determined is keyword B. At this time, it can be determined that the distance between the target vocabulary C and keyword B is 1, and the target vocabulary is on the left side of keyword B. The weight of the target vocabulary C can be set to -1 / 1.

[0110] Similarly, in order to indicate that the weight is calculated based on keyword B, the weight of target vocabulary C can be numerically adjusted to reflect the relationship between target vocabulary C and keyword B.

[0111] exist Figure 3C In the illustrated embodiment, the keywords closest to the target vocabulary C whose weight is to be determined are keyword A and keyword B, that is, the distances between the target vocabulary C and keyword A and keyword B are the same, which are both 3.

[0112] In an exemplary embodiment, if a word has the same distance from two different keywords, the weight can be calculated based on the keyword on the left side of the word first, or the weight can be calculated based on the keyword on the right side of the word first, and those skilled in the art can choose to set it. In addition, if a word has the same distance from two identical keywords, the weight of the word is set to be positive, and the absolute value of the weight is set according to the distance.

[0113] right Figure 3C In the embodiment shown, the weight of the target vocabulary C can be set to 1 / 3, and the weight of the target vocabulary C can be adjusted based on keyword A or keyword B to reflect the relationship between the target vocabulary C and keyword A or keyword B; the weight of the target vocabulary C can also be adjusted based on keyword A and keyword B at the same time to reflect the relationship between the target vocabulary C and keyword A and keyword B at the same time.

[0114] In an exemplary embodiment, considering that even if K keywords are exactly the same in multiple training texts in the same group, the importance of each keyword may not be the same and the number of keywords may also vary greatly, the word vector of the keyword can also be taken into account when calculating the text vector.

[0115] In some embodiments, the weight of the keyword can be set to 1, and the weights of other words are all smaller than the weight of the keyword. For example, in one case, there are words only on the left side of the keyword, and the weights of each word (including the keyword) are respectively: ω=[-1 / L, ..., -1 / 3, -1 / 2, 1] in order from left to right, where L represents the distance length between the word and the keyword plus one (for example, the word closest to the keyword has a distance of 1, and L=2); in another case, there are words only on the right side of the keyword, and the weights of each word (including the keyword) are respectively: ω=[1, 1 / 2, 1 / 3, ...1 / L] in order from left to right.

[0116] If there is an odd number of words between two keywords, the weights of the two keywords and the words between them are ω=[1, 1 / 2, 1 / 3, …1 / L, …, -1 / 3, -1 / 2, 1] in order from left to right; if there is an even number of words between two keywords, the weights of the two keywords and the words between them are ω=[1, 1 / 2, 1 / 3, …1 / L, -1 / L, …, -1 / 3, -1 / 2, 1] in order from left to right.

[0117] After determining the weight of each vocabulary and obtaining the word vector of each vocabulary, the text vector is calculated for each training text. In an exemplary embodiment, the text vector can be calculated by the following formula:

[0118]

[0119] Among them, i is the ordinal number of the text vector, Si is the i-th text vector, n is the number of words in the vocabulary set corresponding to the i-th text vector, j is the ordinal number of the word in the vocabulary set corresponding to the i-th text vector, vj is the word vector of the j-th word, and ωj is the weight of the j-th word.

[0120] The "vocabulary" in the above formula may include keywords or not. When keywords are included, different weights may be set for different keywords according to the TF-IDF value, or the weights of all keywords may be set to 1, and the present disclosure does not impose any special restrictions on this.

[0121] In an exemplary embodiment, the text vector of the training text is determined by calculating the average of the product of the word vector of each vocabulary corresponding to the training text and the weight. In other embodiments of the present disclosure, the text vector can also be determined by the sum of the product of the word vector of each vocabulary corresponding to the training text and the weight.

[0122] By calculating the text vector for each training text in a group of training texts, a text vector set S=[S1, S2, S3, S4,…, Si,…SN] corresponding to the group of training texts can be obtained, where N is the number of training texts in the group.

[0123] In step S5, the training texts whose text vector similarity is greater than a preset threshold are deduplicated within the same group.

[0124] Next, we can use cosine similarity to calculate the similarity between each text vector and other text vectors in the same group. The calculation process can be expressed as follows:

[0125]

[0126] Where α and β are the serial numbers of the two text vectors being compared, Sα and Sβ represent the two text vectors being compared in the same group. The value range of formula (2) is [-1, 1], where -1 means completely dissimilar and 1 means completely similar. Set a preset threshold T. When Similarity(Sα, Sβ)>T, the training text corresponding to Sβ can be removed from the group. Repeat the above process and continue to use Sα to calculate the similarity with the remaining text vectors in the same group. After Sα calculates the similarity with each text vector, use other text vectors to compare the similarity with each remaining text vector until the similarity between the remaining text vectors in the group is less than or equal to T.

[0127] In an exemplary embodiment, in addition to the pairwise comparison, multiple text vectors can also be directly compared for similarity. For example, the text vectors are applied to a hierarchical clustering algorithm, and the text vectors are gradually grouped according to the similarity to generate a hierarchical structure to show the similarity relationship between different text vectors; or, the k-nearest neighbor algorithm is used to calculate the distance or similarity between a text vector and all other text vectors, and the closest k text vectors are selected as the measure of similarity to find the k text vectors that are most similar to the text vector.

[0128] There are many methods for calculating the similarity between text vectors, such as Euclidean distance, Manhattan distance, etc., which are not limited to the above formula, and those skilled in the art can set it according to actual conditions.

[0129] Figure 4 It is an overall schematic diagram of the data processing process in one embodiment of the present disclosure.

[0130] refer to Figure 4 , in step S01, the training text is segmented to remove stop words and punctuation characters.

[0131] In step S02, TF-IDF is used to extract the top K keywords with the largest TF-IDF values ​​of each training text.

[0132] In step S03, the first K keywords extracted from all training texts are grouped to obtain a training text group grouped by keywords. The K keywords of the training texts in the same group are the same.

[0133] In step S04, a training text group is selected, and a vocabulary set corresponding to each training text in the training text group is obtained.

[0134] In step S05, the weight of each word in each vocabulary set is determined according to the position of the keyword in each vocabulary set.

[0135] In step S06, Word2Vec word vector encoding is performed on each word in each vocabulary set to obtain a word vector.

[0136] In step S07, the word vector obtained in step S06 is weighted based on the weight obtained in step S05 to obtain a text vector corresponding to each training text.

[0137] In step S08, the cosine similarity is used to calculate the similarity of all text vectors in the same group, a preset threshold T is set, and the training texts in the same group are deleted according to the condition that the similarity is greater than the preset threshold T.

[0138] Step S09: if all training text groups have not been traversed, return to step S04 until all training text groups have been traversed.

[0139] The disclosed embodiment groups the training texts according to their keywords and determines vocabulary weights based on the keywords, which not only improves the performance of the algorithm when classifying long texts, effectively reduces the complexity of computing time and space, and reduces the resources consumed by the system, but also fully considers the word order relationship of the long text to obtain a text vector that can characterize the semantics of the entire text, effectively represents the semantic information of the training text, reduces misjudgment in the process of deleting duplicate texts, and improves the accuracy of deduplication.

[0140] The model is trained using the training text after deduplication by method 100, and the training speed is faster. After experiments, the model has significantly better perplexity than the model trained using the training data without deduplication, and the model can avoid showing memory.

[0141] In addition to providing good data preprocessing for the training of general large models or domain large models and implementing semantic-based long text deduplication, the method of the embodiments of the present invention can also meet the data processing requirements for deleting duplicate texts in all other large model training corpora, and has high universality.

[0142] Corresponding to the above method embodiments, the present disclosure also provides a model training data processing device, which can be used to execute the above method embodiments.

[0143] Figure 5 It is a block diagram of a model training data processing device in an exemplary embodiment of the present disclosure.

[0144] refer to Figure 5 , the model training data processing device 500 may include:

[0145] The word segmentation processing module 51 is configured to obtain model training data to be processed including a plurality of training texts, and perform word segmentation preprocessing on each of the training texts to obtain a vocabulary set corresponding to each training text;

[0146] A text grouping module 52, configured to extract K keywords from each of the training texts according to the vocabulary set, and to divide the plurality of training texts into a plurality of groups according to the K keywords, K≥1;

[0147] A word vector calculation module 53, configured to generate a word vector for each word in each of the vocabulary sets;

[0148] A text vector calculation module 54 is configured to determine, for each training text, a weight of a word according to a distance between the word and the keyword, and determine a text vector of the training text according to word vectors of a plurality of words corresponding to the training text and the weights;

[0149] The text deduplication module 55 is configured to dedupe the training texts whose text vector similarity is greater than a preset threshold within the same group.

[0150] In an exemplary embodiment of the present disclosure, the text grouping module 52 is configured to determine the K keywords with the highest TF-IDF values ​​in each training text by using a term frequency-inverse document frequency method.

[0151] In an exemplary embodiment of the present disclosure, the text vector calculation module 54 is configured to: determine the keywords closest to the left and right sides of a word and the distance between the word and the keyword according to the word order of the training text; when the word is located on the left side of the keyword, the weight of the word is set to a negative number, and when the word is located on the right side of the keyword, the weight of the word is set to a positive number; and the absolute value of the weight of the word is set according to the distance, the greater the distance, the smaller the weight.

[0152] In an exemplary embodiment of the present disclosure, the text vector calculation module 54 is configured to: set the denominator of the absolute value of the weight according to the distance, and the numerator of the absolute value of the weight is 1.

[0153] In an exemplary embodiment of the present disclosure, the weight of the keyword is 1, and the weights of other words are all smaller than the weight of the keyword.

[0154] In an exemplary embodiment of the present disclosure, the text grouping module 52 is also configured to: after dividing the multiple training texts into multiple groups according to the keywords, determine the number of vocabularies corresponding to the training texts in the same group; and divide the training texts in the same group into different groups again according to the number of vocabularies, so that the difference in the number of vocabularies of the training texts in the same group is not greater than a preset number, and the K keywords of the training texts in the same group are the same.

[0155] In an exemplary embodiment of the present disclosure, the word segmentation processing module 51 is configured to: perform word segmentation processing on the training text to obtain a word segmentation result; and remove punctuation characters and stop words in the word segmentation result.

[0156] Since the functions of the device 500 have been described in detail in the corresponding method embodiments, the present disclosure will not elaborate on them here.

[0157] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0158] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.

[0159] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".

[0160] Refer to the following Figure 6 The electronic device 600 according to this embodiment of the present invention is described. Figure 6 The electronic device 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0161] like Figure 6 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include but are not limited to: at least one processing unit 610, at least one storage unit 620, and a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610).

[0162] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 610 can perform the method shown in the embodiment of the present disclosure.

[0163] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .

[0164] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0165] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0166] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). This communication may be performed through an input / output (I / O) interface 650. In addition, the electronic device 600 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter 660. As shown, the network adapter 660 communicates with other modules of the electronic device 600 through a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0167] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0168] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0169] The program product for implementing the above method according to an embodiment of the present invention can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.

[0170] The program product may be any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0171] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0172] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0173] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0174] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0175] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are to be considered exemplary only, and the true scope and concept of the present disclosure are indicated by the claims.

Claims

1. A model training data processing method, It is characterized in that include: Acquire model training data to be processed including a plurality of training texts, and perform word segmentation preprocessing on each of the training texts to obtain a vocabulary set corresponding to each training text; Extracting K keywords from each of the training texts according to the vocabulary set, and dividing the plurality of training texts into a plurality of groups according to the K keywords, K≥1; Generate a word vector for each word in each of the vocabulary sets; For each training text, determine the weight of a word according to the distance between the word and the keyword, and determine the text vector of the training text according to the word vectors of multiple words corresponding to the training text and the weights; Within the same group, the training texts whose text vector similarity is greater than a preset threshold are deduplicated.

2. The model training data processing method according to claim 1, It is characterized in that The step of extracting K keywords from each of the training texts according to the vocabulary set includes: The K keywords with the highest TF-IDF values ​​in each of the vocabulary sets are determined by the term frequency-inverse document frequency method.

3. The model training data processing method according to claim 1, It is characterized in that Determining the weight of a word according to the distance between the word and the keyword includes: According to the word order of the training text, determine the keywords closest to the left and right sides of a word, and the distance between the word and the keyword; When the word is located on the left side of the keyword, the weight of the word is set to a negative number, and when the word is located on the right side of the keyword, the weight of the word is set to a positive number; The absolute value of the weight of the vocabulary is set according to the distance, and the greater the distance, the smaller the weight.

4. The model training data processing method according to claim 3, It is characterized in that Setting the absolute value of the weight of the vocabulary according to the distance includes: The denominator of the absolute value of the weight is set according to the distance, and the numerator of the absolute value of the weight is 1.

5. The model training data processing method according to claim 4, It is characterized in that The weight of the keyword is 1, and the weights of other words are all smaller than the weight of the keyword.

6. The model training data processing method according to claim 1, It is characterized in that Dividing the plurality of training texts into a plurality of groups according to the K keywords comprises: The training texts with the K completely identical keywords are divided into the same group, and the training texts with the K non-completely identical keywords are divided into different groups; Determine the number of words corresponding to the training texts in the same group; The training texts in the same group are divided into different groups again according to the number of words, so that the difference in the number of words of the training texts in the same group is not greater than a preset number, and the K keywords of the training texts in the same group are the same.

7. The model training data processing method according to claim 1, It is characterized in that The word segmentation preprocessing of each training text comprises: Performing word segmentation processing on the training text to obtain a word segmentation result; Punctuation characters and stop words in the word segmentation result are removed.

8. A model training data processing device, It is characterized in that include: A word segmentation processing module, configured to obtain model training data to be processed including a plurality of training texts, and perform word segmentation preprocessing on each of the training texts to obtain a vocabulary set corresponding to each training text; A text grouping module, configured to extract K keywords from each of the training texts according to the vocabulary set, and to divide the plurality of training texts into a plurality of groups according to the K keywords, K≥1; A word vector calculation module, configured to generate a word vector for each word in each of the vocabulary sets; A text vector calculation module is configured to determine, for each training text, a weight of a word according to a distance between the word and the keyword, and determine a text vector of the training text according to word vectors of multiple words corresponding to the training text and the weights; The text deduplication module is configured to dedupe training texts whose text vector similarity is greater than a preset threshold within the same group.

9. An electronic device, It is characterized in that include: Memory; as well as A processor coupled to the memory, the processor being configured to execute the method according to any one of claims 1 to 7 based on instructions stored in the memory.

10. A computer-readable storage medium having a program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

11. A computer program product comprising a computer program, It is 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 7 are implemented.