Cross-domain text classification method and device based on Bayesian neural network

The cross-domain text classification method of Bayesian neural network solves the problem of distribution deviation of text classification models in different fields, achieves good classification performance and uncertainty estimation in unseen fields, and improves the model's performance. Generalization and processing abilities.

CN118733771APending Publication Date: 2024-10-01NANTONG UNIV +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410843276.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In paper retrieval systems, text classification models are prone to distribution shifts when trained in specific fields, resulting in performance degradation in unseen fields and inability to effectively generalize.

Method used

A cross-domain text classification method based on Bayesian neural network is adopted. By obtaining text data sets in multiple fields for preprocessing and initialization training, the posterior distribution of domain-invariant parameters is inferred, and Gaussian distribution is used as a variational distribution to simplify Parameter distribution ensures that the model performs consistently in different fields.

Benefits of technology

This method can capture cross-domain general features, improve the model's classification performance in unseen domains, and provide an estimate of the uncertainty of the classification results, enhancing the model's generalization ability and ability to handle fuzzy or boundary cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733771A_ABST
    Figure CN118733771A_ABST
Patent Text Reader

Abstract

The invention provides a cross-domain text classification method and device based on a Bayesian neural network. The method comprises the steps of obtaining text data sets from at least two fields; preprocessing the text data in the data set; constructing a model based on a Bayesian neural network; performing initialization training on the model; inferring posterior distribution of domain invariant parameters; simplifying the distribution form of the domain invariant parameter posteriori; and classifying new text data by utilizing the trained model. The method has the advantages that the posterior distribution of the domain invariant parameters is deduced from the parameter posterior distribution sets on different training domains, cross-domain universal features can be captured, and therefore good classification performance is shown on unseen domain data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of neural network, and in particular to a cross-domain text classification method and device based on Bayesian neural network. Background Art

[0002] The use of machine learning technology in paper retrieval systems is mainly to optimize the quality of retrieval results, improve retrieval efficiency, realize personalized retrieval, and realize automatic classification and clustering. Among them, text classification is a common machine learning application, which is mainly used to automatically classify massive academic documents into corresponding subject areas or research topics. The trained text classification model can be applied to the paper retrieval system to automatically classify newly stored papers and classify them into corresponding categories or labels. In this way, users can quickly locate the research field of interest according to subject classification when searching, which improves the convenience and accuracy of retrieval. In terms of supervised learning, naive Bayes, support vector machine, convolutional neural network, recurrent neural network, etc. are generally used to automatically classify papers, which is convenient for users to browse and search by category. However, in paper retrieval, text data may come from different fields, such as biomedicine, computer science, physics, etc. The language habits and professional terms in each field may be different, which will cause the knowledge learned by the model in the training set to be unable to be directly transferred to other fields. When a model trained in a specific field is used in another unseen field, the performance of the model often decreases, that is, the problem of distribution shift occurs. This is because the model may overfit the specific details of the training data instead of learning a broader, cross-domain pattern.

[0003] Domain invariance learning aims to learn models that can extract invariant features of various training domains, so as to better generalize to unseen target domains. Bayesian neural networks have highly competitive performance in domain invariance learning in various domain generalization benchmarks. They have common features in all domains, which can reduce the impact of domain shift and enable the model to perform well in new domains. Therefore, using Bayesian posterior distribution analysis and domain invariance learning to solve the problem of distribution shift is a practical way. Summary of the invention

[0004] In order to solve the above technical problems, the present invention provides a cross-domain text classification method and device based on Bayesian neural network, which is particularly suitable for solving the problem of distribution deviation in model training.

[0005] The technical solution adopted by the present invention is: in the first aspect, a cross-domain text classification method based on a Bayesian neural network is provided, comprising:

[0006] Obtain text datasets from at least two domains;

[0007] Preprocess the text data in the dataset;

[0008] Build models based on Bayesian neural networks;

[0009] Initialize and train the model;

[0010] Infer the posterior distribution of domain-invariant parameters;

[0011] Simplify the distribution form of the domain invariant parameter posteriors;

[0012] Use the trained model to classify new text data.

[0013] Furthermore, the text data is preprocessed, including cleaning, word segmentation, removal of stop words, stemming, and conversion of text into numerical representation.

[0014] Furthermore, the initialization training refers to initializing the Bayesian neural network on the joint data of all fields using empirical risk minimization.

[0015] Furthermore, inferring the posterior distribution of the domain-invariant parameter refers to inferring the posterior distribution of the domain-invariant parameter from an approximate set of posterior distributions of parameters on different training domains by using Gaussian distribution as variational distribution.

[0016] Furthermore, the distribution form of the simplified domain invariant parameter posteriors refers to simplifying parameter distribution by using variational inference technology.

[0017] In a second aspect, a cross-domain text classification device based on a Bayesian neural network comprises:

[0018] A data collection module is used to collect text data to be processed, and to filter out data that does not meet the requirements for completeness and accuracy in the text data after checking;

[0019] A data processing module, used for preprocessing the text data and enhancing the diversity and scale of the training set by transforming the existing data;

[0020] The text classification module is used to obtain classification results and their probabilities to classify text data.

[0021] Furthermore, the data processing includes:

[0022] A preprocessing module, for cleaning, segmenting, removing stop words, extracting stems, and converting text into numerical representations of the text data;

[0023] The data augmentation module increases the diversity and size of the training set by transforming existing data, thereby enhancing model generalization.

[0024] In a third aspect, an electronic device includes:

[0025] processor, memory, and bus;

[0026] The bus is used to connect the processor and the memory;

[0027] The memory is used to store operation instructions;

[0028] The processor is used to execute the above-mentioned text classification method by calling the operation instruction.

[0029] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium is used to store computer instructions, and when the computer-readable storage medium is run on a computer, the computer can execute the above-mentioned text classification method.

[0030] The advantages and positive effects of the present invention are as follows: due to the adoption of the above technical scheme, by inferring the posterior distribution of domain-invariant parameters from the set of posterior distributions of parameters on different training domains, it is possible to capture common features across domains, thereby also showing good classification performance on unseen domain data; by using Gaussian distribution as variational distribution, the Bayesian neural network model simplifies the distribution form of parameters, making parameter learning more efficient while maintaining the accuracy of uncertainty estimation; and not only provides classification predictions but also estimates the uncertainty of predictions, which is crucial for text classification tasks because it can help evaluate the model's confidence in different texts, especially when dealing with ambiguous or boundary cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 Schematic diagram of a text classification method according to an embodiment of the present invention

[0032] Figure 2 Schematic diagram of the structure of a text classification device according to an embodiment of the present invention

[0033] Figure 3 This is a basic structural diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0034] In the following description, those skilled in the art will recognize that the embodiments of the invention described below can be implemented in various ways (e.g., processes, devices, systems, equipment, or methods) on a tangible computer-readable medium. Throughout this discussion, components may be described as separate functional units (which may include subunits), but those skilled in the art will recognize that various components or parts thereof may be divided into separate components, or may be integrated together (including integration into a single system or component). It should be noted that the functions or operations discussed herein may be implemented as components. Components may be implemented in software, hardware, or a combination thereof.

[0035] The embodiments of the present invention are described below with reference to the accompanying drawings.

[0036] like Figure 1 As shown, the present invention provides a cross-domain text classification method based on Bayesian neural network, comprising:

[0037] Obtain text datasets from at least two domains;

[0038] Text data were collected from multiple fields, including but not limited to paper abstracts, full texts, keywords, etc., to ensure that the data covered a wide range of topics and writing styles.

[0039] Preprocess the text data in the dataset;

[0040] When dealing with natural language processing (NLP) tasks such as text classification, preprocessing is to convert raw data into a format that the model can understand and learn, while removing noise, reducing dimensions and standardizing data to improve the performance and generalization ability of the model. The methods used include but are not limited to text cleaning, word segmentation, removal of stop words, word embedding or vectorization, label encoding, data segmentation, data balancing and data expansion.

[0041] Build models based on Bayesian neural networks;

[0042] A systematic method is proposed for the construction and training of Bayesian neural networks to achieve effective management of model parameter uncertainty. First of all, starting from the selection of network architecture, the method includes fully connected layers, convolutional layers or recurrent layers as basic building blocks to adapt to different types of input data and task requirements. Unlike traditional neural networks, the weights of each layer in the Bayesian neural network are no longer limited to fixed values, but are sampled from probability distributions. This feature means that each weight is assigned a mean and variance, rather than a single value, so that the uncertainty of the weight can be more comprehensively reflected. In specific practice, the present invention assigns a prior distribution to each weight, which condenses the belief in the initial state of the weight and provides prior knowledge for subsequent parameter estimation.

[0043] Initialize the model for training;

[0044] A unified generalized model is used to initialize cross-domain networks. First, a general Bayesian neural network architecture suitable for multi-domain features is constructed to clearly define the expected functions of each parameter and ensure that parameters in the same position play similar roles in each domain. Secondly, at the beginning of network training in each domain, the generalized model is uniformly used for initialization, and consistent initial parameter values ​​and distributions are set to promote cross-domain consistency of parameter functions. Finally, during the training process, the approximate consistency of parameter functions is maintained through collaborative strategies and regular adjustments. At the same time, the network performance and parameter function consistency are monitored, and the training strategy is optimized in a timely manner to ensure that the model can adapt to specific domains while maintaining cross-domain functional coordination, greatly improving the interpretability and generalization ability of the model.

[0045] Infer the posterior distribution of domain-invariant parameters;

[0046] The posterior distribution of domain-invariant information focuses on those features that are stable across domains. These features are more likely to be effective in new domains, thereby improving the generalization ability of the model. Here, there is no need to use feature distribution to represent domain-invariant information. It is only necessary to assume that there are two abstract sufficient statistics: domain-invariant information D c and domain specific information D v . D v and D v represents all domain invariant information and other information from D, and they should be independent. With this condition, the given D can be directly calculated by Bayesian formula or other formulas c Parameter posterior distribution. Given different training domains, these domains can be regarded as samples and the given D can be obtained by empirical approximation. c The specific form of the parameter posterior. In multi-domain or multi-task learning, the goal of the model is to perform well not only in the trained domain or task, but also to generalize in unseen domains or tasks.

[0047] Simplify the distribution form of the domain invariant parameter posteriors;

[0048] Choose a parameterized distribution family as the variational distribution q(ω|θ i ) of the basis, where θ i is the parameter of the variational distribution. By optimizing θ i , so that the variational distribution q(ω|θ i ) as closely as possible to the true posterior distribution p(ω|D c ). The optimization process involves calculating and minimizing the difference between the two. Preferably, KL divergence is used as the objective function to ensure that the variational distribution can accurately reflect the true posterior properties of the domain invariant parameters.

[0049] Use the trained model to classify new text data.

[0050] For a trained Bayesian neural network-based text classification model, when performing text classification, the input text is first preprocessed and forward propagation calculations are performed. In order to estimate the uncertainty of the prediction, the model is forward propagated multiple times, sampling different weight values ​​each time, thereby obtaining a series of prediction results; the average of multiple prediction results is calculated as the final classification prediction, and the variance or standard deviation of the prediction results is calculated as a measure of prediction uncertainty; the predicted mean is compared with the preset classification threshold, or the category with the highest probability is selected as the final classification result, providing prediction uncertainty information, such as confidence intervals or probability distributions, to help evaluate the reliability of the prediction.

[0051] Preprocessing of text data: including cleaning, tokenization, removal of stop words, stemming, and conversion of text into numerical representation.

[0052] In the preprocessing of text data, cleaning includes removing HTML tags. If the text data comes from a web page, it may contain HTML tags, which need to be removed using regular expressions or specialized libraries; removing special characters and numbers. Unless they are meaningful for analysis, special characters and numbers in the text are usually removed; converting to lowercase, converting all text to lowercase to reduce the size of the vocabulary and avoid treating the same word as different words due to different case. Tokenization includes word segmentation, which splits the text into separate words or tokens. This can be done with spaces, punctuation, or using more complex tokenizers. Remove stop words Create or use an existing stop word list to remove common words in the text. These words appear frequently in the text but usually do not carry much information. Stemming is the process of reducing words to their basic form, which helps reduce the size of the vocabulary and improve the efficiency of the model.

[0053] Initialization training refers to the initialization training of the Bayesian neural network on the joint data of all fields using empirical risk minimization.

[0054] Faced with Bayesian neural networks trained independently in different data domains, directly using this method to calculate the posterior distribution of domain-invariant information may lead to the dilemma of significant differences in the functions of convolution kernels. For this reason, it is proposed to use the same generalized model to initialize the networks on each domain. The preferred generalized model should be trained through empirical risk minimization (ERM) to ensure that the initial configuration of network parameters has good generalization ability and stability. By implementing this strategy, the problem of disordered parameter dimensions can be avoided to a certain extent, that is, it ensures that the parameters at the same position show approximate functional correspondence, significantly reducing the difficulty of interpreting the functions of convolution kernels in cross-domain model fusion, and also improving the overall stability and generalization ability of the model.

[0055] Inferring the posterior distribution of domain-invariant parameters refers to inferring the posterior distribution of domain-invariant parameters from an approximate set of posterior distributions of parameters on different training domains by using a Gaussian distribution as the variational distribution.

[0056] Use Gaussian distribution as variational distribution and use q(ω|θ i ) represents the variational distribution, where θ i is the parameter of the variational distribution. i Take the training of a Bayesian neural network as an example, its loss function is: Where p(ω) represents the prior distribution of the parameter, which is usually set to a standard Gaussian distribution. After training, a controllable variational distribution q(ω|θ i ) approximates the intractable posterior p(ω|D i ). Since we previously assumed that D c and D v are independent and can be obtained by v ) to empirically estimate p(ω|D c ). Since p(D c ) is a constant, so from p(D v ) sampling and sampling from p(D c ) sampling is the same, and this is exactly At the same time, Because D c and Yes D i Considering p(ω|D i ) can be approximated by variational inference as q(ω|θ i ), then p(ω|D c ) can be approximated as the distribution q(ω|θ i )’s mean.

[0057] Simplifying the distribution form of the domain invariant parameter posteriors refers to simplifying the parameter distribution through variational inference techniques.

[0058] Use Gaussian variational inference to approximate p(ω|D c ), used to solve the distribution q(ω|θ i ) is not a question of the mean of the parameter ω. c ) can be calculated by approximating the expectation and variance of . Therefore, q(ω|θ0) is used instead of the true domain-invariant posterior distribution, q(ω|θ0) = N(ω; μ, σ 2 ) where θ0=(μ,σ 2 ) represents the real, learnable parameters, including the mean μ and variance σ 2 After completing the training process, the model is constructed by sampling from the variational distribution q(ω|θ0).

[0059] like Figure 2 As shown, a text classification device includes: a data collection module, which is used to collect text data to be processed and screen out data that does not meet the integrity and accuracy standards in the text data after inspection; a data processing module, which is used to preprocess the text data and enhance the diversity and scale of the training set by transforming existing data; and a text classification module, which is used to obtain classification results and their probabilities to classify the text data.

[0060] This embodiment obtains the target text to be processed and performs text classification through a Bayesian neural network model. The model can capture common features across domains by inferring the posterior distribution of domain-invariant parameters from the set of posterior distributions of parameters on different training domains, thereby showing good classification performance on unseen domain data.

[0061] In some embodiments, the training module includes a preprocessing module and a data enhancement module. The preprocessing module is used to clean, segment, remove stop words, extract stems, and convert text into numerical representations of the text data; the data enhancement module increases the diversity and scale of the training set by transforming existing data, thereby enhancing model generalization.

[0062] like Figure 3 As shown, in some optional embodiments, an electronic device is also provided, the electronic device comprising: a processor and a memory. The processor and the memory are connected, such as through a bus. Optionally, the electronic device may also include a transceiver. It should be noted that in actual applications, the transceiver is not limited to one, and the structure of the electronic device does not constitute a limitation on the embodiments of the present application.

[0063] The present application also provides a computer-readable storage medium for storing computer instructions, which, when executed on a computer, enables the computer to execute the steps of the text classification method described in any of the above embodiments. Compared with the prior art, in the embodiments of the present application, the model can capture common features across domains by inferring the posterior distribution of domain-invariant parameters from the set of posterior distributions of parameters on different training domains, thereby showing good classification performance on unseen domain data, and not only providing classification predictions, but also estimating the uncertainty of the predictions, which is crucial for text classification tasks because it can help evaluate the model's confidence in different texts, especially when dealing with ambiguous or borderline cases.

[0064] The embodiments of the present invention are described in detail above, but the contents described are only preferred embodiments of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of the patent coverage of the present invention.

[0065] The scheme of the present invention is described below in conjunction with the accompanying drawings, wherein the experimental methods without specific operating steps are all carried out in accordance with the corresponding product instructions, and the instruments, reagents, and consumables used in the examples can all be purchased from commercial companies unless otherwise specified.

Claims

1. A cross-domain text classification method based on Bayesian neural network, characterized in that: include: Obtain text datasets from at least two domains; Preprocess the text data in the dataset; Build models based on Bayesian neural networks; Initialize and train the model; Infer the posterior distribution of domain-invariant parameters; Simplify the distribution form of the domain invariant parameter posteriors; Use the trained model to classify new text data.

2. The method according to claim 1, characterized in that The text data is preprocessed, including cleaning, word segmentation, removal of stop words, stemming, and conversion of text into numerical representation.

3. The method according to claim 1, characterized in that The initialization training refers to initializing the Bayesian neural network on joint data from all fields using empirical risk minimization.

4. The method according to claim 1, characterized in that Inferring the posterior distribution of the domain-invariant parameter refers to inferring the posterior distribution of the domain-invariant parameter from an approximate set of posterior distributions of the parameters on different training domains by using Gaussian distribution as variational distribution.

5. The method according to claim 1, characterized in that The simplified domain invariant parameter posteriori distribution form refers to simplifying parameter distribution through variational inference technology.

6. A cross-domain text classification device based on Bayesian neural network, characterized in that: include: A data collection module is used to collect text data to be processed, and to filter out data that does not meet the requirements for completeness and accuracy in the text data after checking; A data processing module, used for preprocessing the text data and enhancing the diversity and scale of the training set by transforming the existing data; The text classification module is used to obtain classification results and their probabilities to classify text data.

7. A cross-domain text classification device based on Bayesian neural network according to claim 6, characterized in that: The data processing module comprises: A preprocessing module, for cleaning, segmenting, removing stop words, extracting stems, and converting text into numerical representations of the text data; The data augmentation module increases the diversity and size of the training set by transforming existing data, thereby enhancing model generalization.

8. An electronic device, characterized in that: It includes: processor, memory, and bus; The bus is used to connect the processor and the memory; The memory is used to store operation instructions; The processor is used to execute the text classification method according to any one of claims 1 to 6 by calling the operation instruction.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store computer instructions, and when the computer-readable storage medium is run on a computer, the computer can execute the text classification method according to any one of claims 1 to 6.