Coal industry-oriented text classification model training method and text classification method
By constructing a text classification model for the coal industry and enhancing the sample set with industry synonym sets and generative models, the problem of low recognition accuracy in text classification of the coal industry by traditional methods is solved, and more efficient text classification is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA COAL RES INST
- Filing Date
- 2025-12-04
- Publication Date
- 2026-04-24
AI Technical Summary
Traditional text classification methods face challenges when dealing with complex and specialized text data from the coal industry, struggling to effectively identify and distinguish between information relevant to the coal industry across multiple dimensions and irrelevant information.
A text classification model for the coal industry is constructed by acquiring sample sets related to and unrelated to the coal industry, defining a custom set of industry synonyms, performing data augmentation on the relevant sample sets, and using a generative model to augment the unrelated sample sets, and finally constructing a comprehensive sample set for model training.
The text classification model has improved its recognition accuracy for coal industry texts, better understanding synonyms and variants, distinguishing between coal-related and irrelevant content, enhancing the refinement and differentiation of labels, and improving classification accuracy.
Smart Images

Figure CN121919352A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of data processing and coal industry technology, and in particular to a training method and a text classification method for a text classification model for the coal industry. Background Technology
[0002] With the continuous advancement of information technology construction in the coal industry, the scale of text data in the coal industry is growing rapidly, covering multiple fields such as safety, production, management, and technology. This text data includes, but is not limited to, technical reports, production logs, safety procedures, laws and regulations, and industry standards, and has significant informational value. However, due to the specialized and complex nature of coal industry texts, traditional text classification methods face many challenges in processing this data. Summary of the Invention
[0003] This application aims to at least partially address one of the technical problems in the related art.
[0004] Therefore, one objective of this application is to propose a training method for a text classification model for the coal industry. This method involves obtaining N first sample sets and one second sample set. Each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with N relevant tags. Each second sample in the second sample set is unrelated to the coal industry. Based on professional knowledge of the coal industry, a set of industry synonyms related to the coal industry is defined for each of the N relevant tags. For any first sample set, a target industry synonym set is determined from the set of industry synonyms based on the relevant tags corresponding to the first sample set, and then... The first sample set is augmented with a set of industry synonyms to obtain a first target sample set, where each first target sample carries a relevant label corresponding to the first sample set. The second sample set is augmented with a generative model to obtain a second target sample set, where each second target sample carries an irrelevant label indicating that the second target sample is unrelated to the coal industry. A comprehensive sample set is constructed based on the first and second target sample sets, and the initial text classification model is trained using the labels carried by each sample in the comprehensive sample set to obtain the target text classification model generated after training.
[0005] The second objective of this application is to propose a text classification method.
[0006] The third objective of this application is to propose a training device for a text classification model for the coal industry.
[0007] The fourth objective of this application is to propose a text classification device.
[0008] The fifth objective of this application is to provide an electronic device.
[0009] The sixth objective of this application is to provide a non-transitory computer-readable storage medium.
[0010] The seventh objective of this application is to provide a computer program product.
[0011] To achieve the above objectives, the first aspect of this application proposes a training method for a text classification model targeting the coal industry. This method involves acquiring N first sample sets and one second sample set, where each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with N related tags. Each second sample in the second sample set is unrelated to the coal industry. Based on professional knowledge of the coal industry, a set of industry synonyms related to the coal industry is defined for each of the N related tags. For any first sample set, a target industry synonym set is determined from the set of industry synonyms based on the related tags corresponding to the first sample set. The first sample set is augmented with data based on the target industry synonym set to obtain the first target sample set, wherein each first target sample in the first target sample set carries the relevant label corresponding to the first sample set; the second sample set is augmented with data based on the generative model to obtain the second target sample set, wherein each second target sample in the second target sample set carries the irrelevant label indicating that the second target sample is not related to the coal industry; a comprehensive sample set is constructed based on the first target sample set and the second target sample set, and the initial text classification model is trained by combining the labels carried by each sample in the comprehensive sample set to obtain the target text classification model generated after training.
[0012] Considering the highly specialized nature of information related to the coal industry, this application constructs a professional set of industry synonyms. The construction and application of this set of industry synonyms makes the resulting coal-related samples more professional, enabling the model to better understand synonyms or variations within the industry. This application also enhances the refinement and discriminativeness of the labels, including relevant labels across multiple dimensions related to coal, as well as irrelevant labels indicating that the samples are unrelated to the coal industry. This effectively helps the text classification model identify subtle differences in the text, improving classification accuracy, and allowing the model to learn to distinguish content unrelated to the coal industry.
[0013] According to one embodiment of this application, obtaining N first sample sets and 1 second sample set includes: constructing a tag library containing N relevant tags and 1 irrelevant tag; obtaining the original text content to be extracted, and extracting sample content from the original text content to obtain an original sample set, wherein the original sample set includes multiple original samples; for each original sample, determining the target tag corresponding to the original sample from the tag library, and labeling the original sample based on the target tag; after all original samples have been labeled, dividing the original samples according to the target tag corresponding to each original sample to obtain N first sample sets and 1 second sample set.
[0014] According to one embodiment of this application, the N related labels include security labels, production labels, and basic information labels.
[0015] According to one embodiment of this application, data augmentation is performed on a first sample set based on a target industry synonym set to obtain a first target sample set, including: for any first sample in the first sample set, determining whether any industry synonym in the target industry synonym set appears in any first sample; in response to the appearance of any industry synonym in the target industry synonym set in any first sample, taking any industry synonym as a first target industry synonym; calculating the weight of the first target industry synonym in any first sample; in response to the weight being greater than a preset weight threshold, selecting a second target industry synonym from the remaining industry synonyms in the target industry synonym set other than the first target industry synonym; replacing the first target industry synonym in any first sample based on the second target industry synonym to obtain a first augmented sample; merging all the obtained first augmented samples into the first sample set to obtain the first target sample set.
[0016] According to one embodiment of this application, data augmentation of a second sample set based on a generative model is performed to obtain a second target sample set, including: determining the number of augmented samples corresponding to the second sample set; performing data augmentation on the second samples in the second sample set based on the number of augmented samples using a generative model to obtain multiple second augmented samples; and merging the multiple second augmented samples into the second sample set to obtain the second target sample set.
[0017] According to one embodiment of this application, determining the number of augmented samples corresponding to the second sample set includes: calculating the total number of first target samples in all first target sample sets; obtaining the total number of related tags; obtaining the total number of second samples in the second sample set; and determining the number of augmented samples corresponding to the second sample set based on the total number of first target samples, the total number of related tags, and the total number of second samples.
[0018] According to one embodiment of this application, before training the initial text classification model by combining the labels carried by each sample in the comprehensive sample set, the method further includes: obtaining the cosine similarity between every two samples in the comprehensive sample set; and deduplicating the comprehensive sample set based on the cosine similarity.
[0019] To achieve the above objectives, a second aspect of this application proposes a text classification method, comprising: acquiring target text to be classified; inputting the target text into a trained target text classification model for the coal industry, and obtaining the text classification result output by the target text classification model.
[0020] To achieve the above objectives, a third aspect of this application proposes a training device for a text classification model targeting the coal industry, comprising: an acquisition module for acquiring N first sample sets and one second sample set, wherein each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with N related labels, and each second sample in the second sample set is unrelated to the coal industry; a customization module for customizing a set of industry synonyms related to the coal industry corresponding to each of the N related labels based on professional knowledge of the coal industry; and a first enhancement module for determining a target industry synonym set from the set of industry synonyms based on the related labels corresponding to any first sample set. The system employs a first target sample set, which is augmented based on a set of synonyms for the target industry. Each target sample in the first target sample set carries a relevant label corresponding to the first sample set. A second augmentation module augments the second sample set based on a generative model, resulting in a second target sample set. Each target sample in the second target sample set carries an irrelevant label indicating that the second target sample is unrelated to the coal industry. A model training module constructs a comprehensive sample set based on the first and second target sample sets and trains the initial text classification model using the labels carried by each sample in the comprehensive sample set, resulting in a target text classification model generated after training.
[0021] According to one embodiment of this application, the acquisition module is further configured to: construct a tag library containing N relevant tags and 1 irrelevant tag; acquire the original text content to be extracted, and extract sample content from the original text content to obtain an original sample set, wherein the original sample set includes multiple original samples; for each original sample, determine the target tag corresponding to the original sample from the tag library, and label the original sample based on the target tag; after all original samples have been labeled, divide the original samples according to the target tag corresponding to each original sample to obtain N first sample sets and 1 second sample set.
[0022] According to one embodiment of this application, the N related labels include security labels, production labels, and basic information labels.
[0023] According to one embodiment of this application, the first enhancement module is further configured to: for any first sample in the first sample set, determine whether any industry synonym in the target industry synonym set appears in any first sample; in response to the appearance of any industry synonym in the target industry synonym set in any first sample, use any industry synonym as the first target industry synonym; calculate the weight of the first target industry synonym in any first sample; in response to the weight being greater than a preset weight threshold, select a second target industry synonym from the remaining industry synonyms in the target industry synonym set other than the first target industry synonym; replace the first target industry synonym in any first sample based on the second target industry synonym to obtain a first enhanced sample; and merge all the obtained first enhanced samples into the first sample set to obtain a first target sample set.
[0024] According to one embodiment of this application, the second enhancement module is further configured to: determine the number of enhanced samples corresponding to the second sample set; perform data enhancement on the second samples in the second sample set based on a generative model according to the number of enhanced samples to obtain multiple second enhanced samples; and merge the multiple second enhanced samples into the second sample set to obtain the second target sample set.
[0025] According to one embodiment of this application, the second enhancement module is further configured to: calculate the total number of first target samples in all first target sample sets; obtain the total number of related tags of related tags; obtain the total number of second samples in the second sample set; and determine the number of enhanced samples corresponding to the second sample set based on the total number of first target samples, the total number of related tags, and the total number of second samples.
[0026] According to one embodiment of this application, the model training module is further configured to: obtain the cosine similarity between every two samples in the comprehensive sample set; and deduplicate the comprehensive sample set based on the cosine similarity.
[0027] To achieve the above objectives, a fourth aspect of this application proposes a text classification device, comprising: an acquisition module for acquiring target text to be classified; and a classification module for inputting the target text into a trained target text classification model for the coal industry to obtain the text classification result output by the target text classification model.
[0028] To achieve the above objectives, a fifth aspect of this application provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to implement the training method for a text classification model for the coal industry as described in the first aspect of this application or the text classification method as described in the second aspect of this application.
[0029] To achieve the above objectives, a sixth aspect of this application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to implement the training method for a text classification model for the coal industry as described in the first aspect of this application or the text classification method as described in the second aspect of this application.
[0030] To achieve the above objectives, a seventh aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements a training method for a text classification model for the coal industry as described in the first aspect of this application or a text classification method as described in the second aspect of this application. Attached Figure Description
[0031] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a schematic diagram illustrating an exemplary implementation of a training method for a text classification model for the coal industry, as shown in one embodiment of this application.
[0032] Figure 2 This is a schematic diagram illustrating an exemplary implementation of a training method for a text classification model for the coal industry, as shown in one embodiment of this application.
[0033] Figure 3 This is a schematic diagram illustrating an exemplary implementation of a training method for a text classification model for the coal industry, as shown in one embodiment of this application.
[0034] Figure 4 This is an exemplary schematic diagram illustrating a text classification method according to one embodiment of this application.
[0035] Figure 5 This is an exemplary schematic diagram of a training apparatus for a text classification model for the coal industry, as shown in one embodiment of this application.
[0036] Figure 6 This is a schematic diagram illustrating an exemplary implementation of a text classification device according to one embodiment of this application.
[0037] Figure 7 This is a schematic diagram of an electronic device according to one embodiment of this application. Detailed Implementation
[0038] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0039] Figure 1 This is a schematic diagram illustrating an exemplary implementation of a training method for a text classification model for the coal industry, as shown in this application. Figure 1 As shown, the training method for this text classification model for the coal industry includes the following steps: S101, obtain N first sample sets and 1 second sample set, wherein each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with the N related labels, and each second sample in the second sample set is unrelated to the coal industry.
[0040] Among them, the relevant tags refer to tags related to the coal industry in multiple dimensions, such as "production" tags, "safety" tags, and "basic information" tags.
[0041] There are N first sample sets and N related labels. Taking N as 3 as an example, there are 3 first sample sets. Each first sample set can include multiple first samples. All first samples in each first sample set carry the related labels corresponding to that first sample set.
[0042] For example, assuming there are three relevant tags: "Production," "Safety," and "Basic Information," three first sample sets can be obtained. In the first sample set, all samples carry the "Production" tag (meaning all samples in the first sample set are related to production information in the coal industry); in the second sample set, all samples carry the "Safety" tag (meaning all samples in the second sample set are related to safety information in the coal industry); and in the third sample set, all samples carry the "Basic Information" tag (meaning all samples in the third sample set are related to basic information in the coal industry).
[0043] In addition to the N first sample sets, this application also obtains one second sample set, which includes multiple second samples. Each second sample is unrelated to the coal industry, and each second sample carries an "unrelated" label. This "unrelated" label, which can also be written as "unrelated label" below, indicates that the second sample carrying it is not related to the coal industry. It should be understood that the "unrelated label" means that the second sample carries the label, but this label indicates that the information expressed by the second sample is unrelated to the coal industry, not that the second sample does not carry the label.
[0044] S102, based on professional knowledge of the coal industry, define a set of industry synonyms related to the coal industry for each of the N related tags.
[0045] In this application, in order to improve the accuracy of the enhanced samples, a set of industry synonyms related to the coal industry is customized for each relevant label.
[0046] For example, assuming the relevant tag is "production", the set of industry synonyms corresponding to this tag can be manually set as ["underground mining", "coalbed methane mining", "power supply and distribution", "hoisting", "belt", "belt conveyor", "auxiliary transportation", "ventilation", "compressed air", "drainage", "blasting", "tunneling", "well construction technology", "water supply", "washing and beneficiation", "coal chemical industry", "production planning", "trackless rubber-tired vehicle", "mining processing", "coal pillarless", "industrial square", "grouting"].
[0047] For example, assuming the relevant label is the "safety" label, the set of industry synonyms corresponding to this label can be manually set as ["surrounding rock control", "rock burst prevention", "water hazard prevention", "fire prevention", "water pressure fracturing", "gas prevention", "accident management", "safety training", "occupational health", "environmental protection", "heat hazard control", "risk classification and management", "accident hazard investigation and management", "safety inspection", "hidden disaster", "surface subsidence", "coal and gas outburst", "gas extraction"].
[0048] For example, assuming the relevant tag is the "basic information" tag, the set of industry synonyms corresponding to this tag can be manually set to ["license information", "organization", "geological and hydrological conditions", "mining conditions", "disaster conditions", "comprehensive columnar chart", "exploration", "coal seam group", "geological structure"].
[0049] It should be understood that the industry synonym sets corresponding to the above-mentioned relevant tags are merely examples and do not constitute a limitation on this application.
[0050] S103, for any first sample set, determine the target industry synonym set from the industry synonym set based on the relevant tags corresponding to the first sample set, and perform data augmentation on the first sample set based on the target industry synonym set to obtain the first target sample set, wherein each first target sample in the first target sample set carries the relevant tags corresponding to the first sample set.
[0051] For example, suppose a certain first sample set corresponds to the "production category" label, meaning that all first samples in this first sample set carry the "production category" label. In some implementations, data augmentation is performed sequentially for each first sample in this first sample set. Specifically, when performing data augmentation on any first sample, it is possible to first traverse and query whether a certain industry synonym from the industry synonym set corresponding to the "production category" label appears in the first sample. If it appears, then data augmentation is performed on the first sample based on other industry synonyms from the industry synonym set corresponding to that relevant label (here, the relevant label is the "production category" label) besides the industry synonyms appearing in the first sample.
[0052] As one feasible approach, the aforementioned data augmentation of the first sample is performed using industry synonyms from the industry synonym set corresponding to the relevant tag, excluding those appearing in the first sample. This includes: sequentially replacing the first sample with other industry synonyms from the industry synonym set corresponding to the relevant tag, resulting in multiple initial augmented samples. Each initial augmented sample is then sequentially input into a trained text logic scoring model to obtain a logic score for each initial augmented sample. If the logic score of an initial augmented sample is lower than a preset logic score threshold, that initial augmented sample is deleted, thus ensuring sample quality while increasing the number of samples. Based on this approach, the final initial augmented sample remaining after filtering is used as the augmented sample corresponding to the first sample. The logic score is used to determine whether the initial augmented sample conforms to common sense or technical logic, as forcibly replacing some words can lead to illogical initial augmented samples.
[0053] This process involves data augmentation of a first sample set based on a set of synonyms for the target industry, resulting in a first target sample set. This first target sample set includes both all the original first samples and the augmented samples generated after data augmentation. Both the original first samples and the augmented samples in the first target sample set are then referred to as first target samples, and each first target sample carries the relevant label corresponding to that first sample set. For example, suppose a first sample set corresponds to the label "production category" and contains 100 first samples. After data augmentation, the resulting first target sample set contains 1000 first target samples, all of which carry the "production category" label.
[0054] Based on the above example, N first target sample sets can be obtained in this step.
[0055] S104. Data augmentation is performed on the second sample set based on the generative model to obtain the second target sample set. Each second target sample in the second target sample set carries an irrelevant label to indicate that the second target sample is irrelevant to the coal industry.
[0056] In this application, for the second sample set, the second samples in the second sample set can be used as seeds, and data augmentation can be performed on each second sample based on a generative model to obtain the second target sample set. This second target sample set includes both all the original second samples in the second sample set and the augmented samples generated after data augmentation based on the second samples. In this case, all the original second samples and the augmented samples generated after data augmentation in the second target sample set are referred to as second target samples, and each second target sample carries an irrelevant label.
[0057] S105, construct a comprehensive sample set based on the first target sample set and the second target sample set, and train the initial text classification model by combining the label carried by each sample in the comprehensive sample set, so as to obtain the target text classification model generated after training.
[0058] After obtaining N first target sample sets and 1 second target sample set, all samples from the N first target sample sets and 1 second target sample set are merged to form a comprehensive sample set. This comprehensive sample set is then divided into a first sample set for model training and a second sample set for model testing. Model training is performed based on the first sample set, and the classification accuracy and other metrics of the model are evaluated based on the second sample set, resulting in the final trained target text classification model.
[0059] In the process of training a text classification model, when it comes to extracting semantic features of samples, the BGE-3 pre-trained model can be used to extract the semantic features of samples.
[0060] During the training of the text classification model, if necessary, the label of each sample can be converted into a numerical value, according to the following format: {"Production Class": 0, "Security Class": 1, "Basic Class": 2, "Irrelevant Class": 3}.
[0061] In the process of training the text classification model, RBF is used as the kernel function, the coefficient gamma of the RBF kernel is set to 'scale', the regularization parameter C is 1.0, and the data is passed in by calling the fit method to train the support vector machine (SVM) model.
[0062] This application proposes a training method for a text classification model targeting the coal industry. It involves acquiring N first sample sets and one second sample set. Each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with N related tags. Each second sample in the second sample set is unrelated to the coal industry. Based on professional knowledge of the coal industry, a set of industry synonyms related to the coal industry is defined for each of the N related tags. For any first sample set, a target industry synonym set is determined from the set of industry synonyms based on the related tags corresponding to the first sample set, and then based on the target industry... A first target sample set is obtained by augmenting the first sample set with a set of synonyms, where each first target sample carries a relevant label corresponding to the first sample set. A second target sample set is obtained by augmenting the second sample set with a generative model, where each second target sample carries an irrelevant label indicating that the second target sample is unrelated to the coal industry. A comprehensive sample set is constructed based on the first and second target sample sets, and the initial text classification model is trained using the labels carried by each sample in the comprehensive sample set, resulting in a trained target text classification model. Considering the specialized nature of information related to the coal industry, this application constructs a professional industry synonym set. The construction and application of this industry synonym set make the resulting coal-related samples more professional, enabling the model to better understand synonyms or variations within the industry domain. This application enhances the refinement and discriminativeness of the labels, including relevant labels across multiple dimensions related to coal, as well as irrelevant labels indicating that the sample is unrelated to the coal industry. This effectively helps the text classification model identify subtle differences in the text, improving classification accuracy, and enabling the model to learn to distinguish content unrelated to the coal industry.
[0063] Figure 2 This is a schematic diagram illustrating an exemplary implementation of a training method for a text classification model for the coal industry, as shown in this application. Figure 2 As shown, the training method for this text classification model for the coal industry includes the following steps: S201, construct a tag library containing N related tags and 1 irrelevant tag.
[0064] Among them, the N related tags include safety tags, production tags, and basic information tags, all of which are related to the coal industry and are used to represent information from different dimensions of the coal industry.
[0065] The "irrelevant" label indicates that it is not related to the coal industry.
[0066] S202, obtain the original text content to be extracted, and extract the sample content from the original text content to obtain the original sample set, which includes multiple original samples.
[0067] For example, textual content such as publicly published papers, standard documents, and relevant laws and regulations related to the coal industry, as well as textual content unrelated to the coal industry, are obtained together as the original textual content to be used for sample extraction.
[0068] In this application, sample content can be extracted from the original text content based on formatted text extraction technology, such as extraction by sentence, by paragraph, or by hierarchical headings, to obtain an original sample set composed of multiple original samples.
[0069] S203. For each original sample, determine the target label corresponding to the original sample from the label library, and label the original sample based on the target label.
[0070] As an feasible approach, considering the specialized nature of coal-related industry texts, each original sample can be manually annotated by professionals. The label corresponding to each original sample can be selected from the above N relevant labels and 1 irrelevant label for manual annotation.
[0071] As another feasible approach, based on a pre-trained annotation model, after semantic understanding of each original text, the label corresponding to each original sample can be selected from the above N relevant labels and 1 irrelevant label for automatic annotation.
[0072] S204. After all the original samples have been labeled, the original samples are divided according to the target label corresponding to each original sample to obtain N first sample sets and 1 second sample set.
[0073] Among them, the N first sample sets correspond one-to-one with the N related labels.
[0074] In this first sample set, each first sample is related to the coal industry. For example, assuming there are three relevant tags: "Production," "Safety," and "Basic Information," three first sample sets can be obtained. In the first sample set, all first samples carry the "Production" tag (meaning all first samples in the first sample set are related to production information in the coal industry); in the second sample set, all first samples carry the "Safety" tag (meaning all first samples in the second sample set are related to safety information in the coal industry); and in the third sample set, all first samples carry the "Basic Information" tag (meaning all first samples in the third sample set are related to basic information in the coal industry).
[0075] In this second sample set, each second sample is unrelated to the coal industry, and each second sample carries the label "unrelated".
[0076] S205, based on professional knowledge of the coal industry, define a set of industry synonyms related to the coal industry for each of the N related tags.
[0077] S206, for any first sample set, determine the target industry synonym set from the industry synonym set based on the relevant tags corresponding to the first sample set, and perform data augmentation on the first sample set based on the target industry synonym set to obtain the first target sample set, wherein each first target sample in the first target sample set carries the relevant tags corresponding to the first sample set.
[0078] In some implementations, for any first sample set, a target industry synonym set is determined from the industry synonym set based on the relevant tags corresponding to the first sample set. For any first sample in the first sample set, it is determined whether any industry synonym from the target industry synonym set appears in the first sample. If any industry synonym from the target industry synonym set appears in the first sample, that industry synonym is taken as the first target industry synonym. The weight of the first target industry synonym in the first sample is calculated. If the weight is greater than a preset weight threshold, a second target industry synonym is selected from the remaining industry synonyms in the target industry synonym set other than the first target industry synonym (for example, selecting an industry synonym with a similar meaning to the first target industry synonym from the remaining industry synonyms in the target industry synonym set other than the first target industry synonym as the second target industry synonym). The first target industry synonym in the first sample is replaced based on the second target industry synonym to obtain a first enhanced sample. All the obtained first enhanced samples are merged into the first sample set to obtain the first target sample set.
[0079] For example, if a certain first sample set corresponds to the "production category" label, then the industry synonym set corresponding to the "production category" label is taken as the target industry synonym set corresponding to the first sample set. Suppose a first sample in this first sample set is: "Underground mining is an important part of coal mine production, involving mine excavation and ventilation." Since this first sample contains "underground mining" from the industry synonym set corresponding to the "production category" label, the weight of the word "underground mining" in this first sample is obtained. If the weight of "underground mining" in this first sample is greater than a preset weight threshold, then it is determined that the first sample needs to undergo synonym replacement for the word "underground mining" to achieve data augmentation. Considering that "coalbed methane mining" in the industry synonym set corresponding to the "production category" label is similar to "underground mining," the first sample can be replaced with a synonym based on "coalbed methane mining," resulting in the augmented sample: "Coalbed methane mining is an important part of coal mine production, involving mine excavation and ventilation."
[0080] The weight of the aforementioned first target industry synonym in any first sample can be understood as the importance of the first target industry synonym in any first sample.
[0081] In some implementations, the weight of a first target industry synonym in any first sample can be calculated using a term frequency-inverse document frequency (TNF) approach. In this scheme, the ratio of the frequency of occurrence of the first target industry synonym to the total number of words in any first sample is used as the term frequency of the first target industry synonym. Then, based on the total number of first samples included in the first sample set containing the first target industry synonym, and the total number of first samples containing the first target industry synonym within the first sample set containing the first target industry synonym, the inverse document frequency of the first target industry synonym is calculated. The product of the term frequency and the inverse document frequency of the first target industry synonym is then used as the weight of the first target industry synonym in any first sample.
[0082] S207, Data augmentation is performed on the second sample set based on the generative model to obtain the second target sample set, wherein each second target sample in the second target sample set carries an irrelevant label to indicate that the second target sample is irrelevant to the coal industry.
[0083] In some implementations, it is first necessary to determine the number of augmented samples corresponding to the second sample set, and then perform data augmentation on the second samples in the second sample set based on the number of augmented samples using a generative model to obtain multiple second augmented samples; the multiple second augmented samples are then merged into the second sample set to obtain the second target sample set.
[0084] Preferably, when performing data augmentation based on any second sample combined with a generative model, the word count difference between any second augmented sample corresponding to the second sample and the second sample should not be too large, and the word count should preferably be the same.
[0085] The determination of the augmented sample number corresponding to the second sample set includes: calculating the total number of first target samples in all first target sample sets (i.e., the total number of first target samples in the N first target sample sets obtained after data augmentation); obtaining the total number of related labels (i.e., as mentioned above, the total number of related labels is N); obtaining the total number of original second samples in the second sample set; and finally, determining the augmented sample number corresponding to the second sample set based on the total number of first target samples, the total number of related labels, and the total number of second samples. The specific calculation formula is as follows:
[0086] In the above formula, This represents the result after data augmentation. The total number of first target samples in the first target sample set. This represents the total number of related tags. It represents The ratio of the total number of first target samples in the first target sample set to the total number of related labels. This represents the total number of original second samples in the second sample set. This represents the minimum number of augmented samples corresponding to the second sample set.
[0087] Preferably, there are N first target sample sets and 1 second target sample set, with the number of samples in each sample set being equal.
[0088] S208. Based on the first target sample set and the second target sample set, a comprehensive sample set is constructed, and the initial text classification model is trained by combining the label carried by each sample in the comprehensive sample set, so as to obtain the target text classification model generated after training.
[0089] After obtaining N first target sample sets and 1 second target sample set, all samples from the N first target sample sets and 1 second target sample set are merged to form a comprehensive sample set. This comprehensive sample set is then divided into a first sample set for model training and a second sample set for model testing. Model training is performed based on the first sample set, and the classification accuracy and other metrics of the model are evaluated based on the second sample set, resulting in the final trained target text classification model.
[0090] Before training the initial text classification model using the labels carried by each sample in the comprehensive sample set, the process includes: obtaining the cosine similarity between every two samples in the comprehensive sample set; and removing duplicates from the comprehensive sample set based on the cosine similarity. For example, if the cosine similarity between two samples is greater than a preset similarity threshold, one of those two samples is randomly removed.
[0091] In the process of training a text classification model, when it comes to extracting semantic features of samples, the BGE-3 pre-trained model can be used to extract the semantic features of samples.
[0092] During the training of the text classification model, if necessary, the label of each sample can be converted into a numerical value, according to the following format: {"Production Class": 0, "Security Class": 1, "Basic Class": 2, "Irrelevant Class": 3}.
[0093] In the process of training the text classification model, RBF is used as the kernel function, the coefficient gamma of the RBF kernel is set to 'scale', the regularization parameter C is 1.0, and the data is passed in by calling the fit method to train the support vector machine (SVM) model.
[0094] This application takes into account the highly specialized nature of information related to the coal industry, and therefore constructs a professional set of industry synonyms. The construction and application of this set of industry synonyms makes the resulting coal-related samples more professional, enabling the model to better understand synonyms or variations within the industry. This application enhances the refinement and discriminativeness of the labels, including relevant labels across multiple dimensions related to coal, as well as irrelevant labels indicating that the samples are unrelated to the coal industry. This effectively helps the text classification model identify subtle differences in the text, improving classification accuracy, and allowing the model to learn to distinguish content unrelated to the coal industry. This application strives to ensure dataset balance, avoiding model bias caused by uneven sample distribution.
[0095] Figure 3 This is a schematic diagram illustrating an exemplary implementation of a training method for a text classification model for the coal industry, as shown in this application. Figure 3 As shown, the training method for this text classification model for the coal industry includes the following steps: S301, construct a tag library containing N related tags and 1 unrelated tag. The N related tags include security tags, production tags, and basic information tags.
[0096] S302, obtain the original text content to be extracted, and extract sample content from the original text content to obtain the original sample set, wherein the original sample set includes multiple original samples.
[0097] S303, for each original sample, determine the target label corresponding to the original sample from the label library, and label the original sample based on the target label.
[0098] S304. After all the original samples have been labeled, the original samples are divided according to the target label corresponding to each original sample to obtain N first sample sets and 1 second sample set.
[0099] For details on the specific implementation of steps S301 to S304, please refer to the relevant parts of the above embodiments, which will not be repeated here.
[0100] S305, Based on professional knowledge in the coal industry, customize the set of industry synonyms related to the coal industry for each of the N related tags.
[0101] S306, for any first sample set, determine the target industry synonym set from the industry synonym set based on the relevant tags corresponding to the first sample set, and for any first sample in the first sample set, determine whether any industry synonym in the target industry synonym set appears in any first sample.
[0102] S307, in response to the occurrence of any industry synonym in the target industry synonym set in any first sample, take any industry synonym as the first target industry synonym, and calculate the weight of the first target industry synonym in any first sample.
[0103] S308, in response to the weight being greater than the preset weight threshold, select the second target industry synonym from the remaining industry synonyms in the target industry synonym set excluding the first target industry synonym.
[0104] S309, based on the second target industry synonyms, replace the first target industry synonyms in any first sample to obtain the first enhanced sample.
[0105] S310, all the obtained first enhanced samples are merged into the first sample set to obtain the first target sample set. Each first target sample in the first target sample set carries a relevant label corresponding to the first sample set.
[0106] For details on the specific implementation of steps S305 to S310, please refer to the relevant parts of the above embodiments, which will not be repeated here.
[0107] S311, determine the number of augmented samples corresponding to the second sample set, and perform data augmentation on the second samples in the second sample set based on the generative model based on the number of augmented samples to obtain multiple second augmented samples.
[0108] S312, multiple second-enhanced samples are merged into a second sample set to obtain a second target sample set. Each second target sample in the second target sample set carries an irrelevant label indicating that the second target sample is unrelated to the coal industry.
[0109] S313, construct a comprehensive sample set based on the first target sample set and the second target sample set, obtain the cosine similarity between every two samples in the comprehensive sample set, and remove duplicates from the comprehensive sample set based on the cosine similarity.
[0110] S314, combine the labels carried by each sample in the deduplicated comprehensive sample set to train the initial text classification model, and obtain the target text classification model generated after training.
[0111] For details on the specific implementation of steps S311 to S314, please refer to the relevant parts of the above embodiments, which will not be repeated here.
[0112] This application takes into account the highly specialized nature of information related to the coal industry, and therefore constructs a professional set of industry synonyms. The construction and application of this set of industry synonyms makes the resulting coal-related samples more professional, enabling the model to better understand synonyms or variations within the industry. This application enhances the refinement and discriminativeness of the labels, including relevant labels across multiple dimensions related to coal, as well as irrelevant labels indicating that the samples are unrelated to the coal industry. This effectively helps the text classification model identify subtle differences in the text, improving classification accuracy, and allowing the model to learn to distinguish content unrelated to the coal industry. This application strives to ensure dataset balance, avoiding model bias caused by uneven sample distribution.
[0113] Figure 4 This is an exemplary schematic diagram of a text classification method shown in this application, such as... Figure 4 As shown, this text classification method includes the following steps: S401, Obtain the target text to be classified.
[0114] S402, input the target text into the trained target text classification model for the coal industry, and obtain the text classification result output by the target text classification model.
[0115] The target text classification model for the coal industry described above is trained and generated using the training method for the text classification model for the coal industry introduced in the above embodiments.
[0116] This application embodiment can obtain more accurate text classification results by inputting the target text to be classified into a pre-trained target text classification model for the coal industry.
[0117] Figure 5 This application illustrates an exemplary schematic diagram of a training device for a text classification model aimed at the coal industry. Figure 5 As shown, the training device 500 for the text classification model in the coal industry includes an acquisition module 501, a custom module 502, a first enhancement module 503, a second enhancement module 504, and a model training module 505, wherein: The acquisition module 501 is used to acquire N first sample sets and 1 second sample set. Each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with N related labels. Each second sample in the second sample set is unrelated to the coal industry.
[0118] Custom module 502 is used to customize a set of industry synonyms related to the coal industry for each of N related tags based on professional knowledge of the coal industry.
[0119] The first enhancement module 503 is used to determine a target industry synonym set from the industry synonym set based on the relevant tags corresponding to the first sample set for any first sample set, and to perform data enhancement on the first sample set based on the target industry synonym set to obtain a first target sample set, wherein each first target sample in the first target sample set carries the relevant tags corresponding to the first sample set.
[0120] The second enhancement module 504 is used to perform data augmentation on the second sample set based on the generative model to obtain the second target sample set, wherein each second target sample in the second target sample set carries an irrelevant label to indicate that the second target sample is irrelevant to the coal industry.
[0121] The model training module 505 is used to construct a comprehensive sample set based on the first target sample set and the second target sample set, and to train the initial text classification model by combining the label carried by each sample in the comprehensive sample set, so as to obtain the target text classification model generated after training.
[0122] Considering the highly specialized nature of information related to the coal industry, this device constructs a professional set of industry synonyms. The construction and application of this set make the resulting coal-related samples more specialized, enabling the model to better understand synonyms or variations within the industry. This application enhances the refinement and discriminativeness of the labels, including relevant labels across multiple dimensions related to coal, as well as irrelevant labels indicating that the sample is unrelated to the coal industry. This effectively helps the text classification model identify subtle differences in the text, improving classification accuracy, and allowing the model to learn to distinguish content unrelated to the coal industry.
[0123] Furthermore, the acquisition module 501 is also used for: constructing a tag library containing N relevant tags and 1 irrelevant tag; acquiring the original text content to be extracted, and extracting sample content from the original text content to obtain an original sample set, wherein the original sample set includes multiple original samples; for each original sample, determining the target tag corresponding to the original sample from the tag library, and labeling the original sample based on the target tag; after all original samples have been labeled, dividing the original samples according to the target tag corresponding to each original sample to obtain N first sample sets and 1 second sample set.
[0124] Furthermore, the N related tags include safety tags, production tags, and basic information tags.
[0125] Furthermore, the first enhancement module 503 is also configured to: for any first sample in the first sample set, determine whether any industry synonym in the target industry synonym set appears in any first sample; in response to the appearance of any industry synonym in the target industry synonym set in any first sample, use any industry synonym as the first target industry synonym; calculate the weight of the first target industry synonym in any first sample; in response to the weight being greater than a preset weight threshold, select a second target industry synonym from the remaining industry synonyms in the target industry synonym set other than the first target industry synonym; replace the first target industry synonym in any first sample based on the second target industry synonym to obtain a first enhanced sample; and merge all the obtained first enhanced samples into the first sample set to obtain the first target sample set.
[0126] Furthermore, the second enhancement module 504 is also used to: determine the number of enhanced samples corresponding to the second sample set; perform data enhancement on the second samples in the second sample set based on the number of enhanced samples using a generative model to obtain multiple second enhanced samples; and merge the multiple second enhanced samples into the second sample set to obtain the second target sample set.
[0127] Furthermore, the second enhancement module 504 is also used to: calculate the total number of first target samples in all first target sample sets; obtain the total number of related labels; obtain the total number of second samples in the second sample set; and determine the number of enhanced samples corresponding to the second sample set based on the total number of first target samples, the total number of related labels, and the total number of second samples.
[0128] Furthermore, the model training module 505 is also used to: obtain the cosine similarity between every two samples in the comprehensive sample set; and to deduplicate the comprehensive sample set based on the cosine similarity.
[0129] Figure 6 This is a schematic diagram illustrating an exemplary embodiment of a text classification device shown in this application, such as... Figure 6 As shown, the text classification device 600 includes an acquisition module 601 and a classification module 602, wherein: The acquisition module 601 is used to acquire the target text to be classified.
[0130] The classification module 602 is used to input the target text into a pre-trained target text classification model for the coal industry and obtain the text classification result output by the target text classification model.
[0131] This embodiment of the device can obtain more accurate text classification results by inputting the target text to be classified into a pre-trained target text classification model for the coal industry.
[0132] To implement the above embodiments, this application also proposes an electronic device 700, such as... Figure 7 As shown, the electronic device 700 includes a processor 701 and a memory 702 communicatively connected to the processor. The memory 702 stores instructions that can be executed by at least one processor. The instructions are executed by at least one processor 701 to implement the training method or text classification method for the text classification model for the coal industry as shown in the above embodiments.
[0133] To implement the above embodiments, this application also proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to implement the training method or text classification method for a text classification model for the coal industry as shown in the above embodiments.
[0134] To implement the above embodiments, this application also proposes a computer program product, including a computer program that, when executed by a processor, implements a training method or a text classification method for a text classification model for the coal industry as shown in the above embodiments.
[0135] In the description of this application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc., indicating the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application.
[0136] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0137] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0138] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A training method for a text classification model for the coal industry, characterized in that, include: Obtain N first sample sets and 1 second sample set, wherein each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with N related labels, and each second sample in the second sample set is unrelated to the coal industry; Based on professional knowledge of the coal industry, we define a set of industry synonyms related to the coal industry for each of the N related tags; For any of the first sample sets, a target industry synonym set is determined from the industry synonym set based on the relevant tags corresponding to the first sample set, and the first sample set is augmented based on the target industry synonym set to obtain a first target sample set, wherein each first target sample in the first target sample set carries the relevant tags corresponding to the first sample set; The second sample set is augmented based on a generative model to obtain a second target sample set, wherein each second target sample in the second target sample set carries an irrelevant label to indicate that the second target sample is irrelevant to the coal industry. A comprehensive sample set is constructed based on the first target sample set and the second target sample set. The initial text classification model is then trained using the labels carried by each sample in the comprehensive sample set to obtain the target text classification model generated after training.
2. The method according to claim 1, characterized in that, The process of obtaining N first sample sets and 1 second sample set includes: Construct a tag library containing N related tags and 1 irrelevant tag; Obtain the original text content to be sampled, and extract sample content from the original text content to obtain an original sample set, wherein the original sample set includes multiple original samples. For each original sample, a target label corresponding to the original sample is determined from the label library, and the original sample is labeled based on the target label; After all the original samples have been labeled, the original samples are divided according to the target label corresponding to each original sample to obtain N first sample sets and 1 second sample set.
3. The method according to claim 2, characterized in that, The N related tags include safety tags, production tags, and basic information tags.
4. The method according to any one of claims 1-3, characterized in that, The process of augmenting the first sample set based on the target industry synonym set to obtain the first target sample set includes: For any first sample in the first sample set, determine whether any industry synonym in the target industry synonym set appears in any first sample; In response to the occurrence of any industry synonym in the target industry synonym set in any of the first samples, the any industry synonym is taken as the first target industry synonym; The weight of the first target industry synonym in any of the first samples is calculated; In response to the weight being greater than a preset weight threshold, a second target industry synonym is selected from the remaining industry synonyms in the target industry synonym set excluding the first target industry synonym; Based on the second target industry synonyms, the first target industry synonyms in any of the first samples are replaced to obtain the first enhanced sample; All the first enhanced samples obtained are merged into the first sample set to obtain the first target sample set.
5. The method according to claim 4, characterized in that, The process of augmenting the second sample set based on a generative model to obtain a second target sample set includes: Determine the number of augmented samples corresponding to the second sample set; Based on the number of augmented samples, the second samples in the second sample set are augmented using a generative model to obtain multiple second augmented samples; The multiple second enhanced samples are merged into the second sample set to obtain the second target sample set.
6. The method according to claim 5, characterized in that, Determining the number of augmented samples corresponding to the second sample set includes: Calculate the total number of first target samples in all the first target sample sets; Obtain the total number of related tags for the aforementioned related tags; Obtain the total number of second samples in the second sample set; The number of augmented samples corresponding to the second sample set is determined based on the total number of the first target samples, the total number of related labels, and the total number of the second samples.
7. The method according to claim 6, characterized in that, Before training the initial text classification model by combining the labels carried by each sample in the comprehensive sample set, the method further includes: Obtain the cosine similarity between every two samples in the comprehensive sample set; The comprehensive sample set is deduplicated based on the cosine similarity.
8. A text classification method, characterized in that, include: Obtain the target text to be classified; The target text is input into a target text classification model for the coal industry trained using the method described in any one of claims 1-7, and the text classification result output by the target text classification model is obtained.
9. A training device for a text classification model for the coal industry, characterized in that, include: The acquisition module is used to acquire N first sample sets and 1 second sample set, wherein each first sample in the first sample set is related to the coal industry, and the N first sample sets correspond one-to-one with N related labels, and each second sample in the second sample set is unrelated to the coal industry. A custom module is used to customize the set of industry synonyms related to the coal industry for each of the N related tags, based on professional knowledge of the coal industry. The first enhancement module is configured to, for any first sample set, determine a target industry synonym set from the industry synonym set based on the relevant tags corresponding to the first sample set, and perform data enhancement on the first sample set based on the target industry synonym set to obtain a first target sample set, wherein each first target sample in the first target sample set carries the relevant tags corresponding to the first sample set; The second enhancement module is used to perform data enhancement on the second sample set based on a generative model to obtain a second target sample set, wherein each second target sample in the second target sample set carries an irrelevant label to indicate that the second target sample is irrelevant to the coal industry; The model training module is used to construct a comprehensive sample set based on the first target sample set and the second target sample set, and to train the initial text classification model by combining the labels carried by each sample in the comprehensive sample set, so as to obtain the target text classification model generated after training.
10. A text classification device, characterized in that, include: The acquisition module is used to acquire the target text to be classified. The classification module is used to input the target text into a target text classification model for the coal industry trained using the method described in any one of claims 1-7, and obtain the text classification result output by the target text classification model.