A cross-domain small sample relation extraction method and system based on collaborative adaptive feature transformation
Patent Information
- Application Number
- CN202410529092.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2026-10-20
- Estimated Expiration
- 2044-04-29
AI Technical Summary
当支持集中存在容易混淆的关系时,可能导致错误的分类
[0035]本发明针对现有跨域小样本关系抽取方法的不足,提出了一种新颖的解决方案,旨在提高模型在不同领域间的泛化能力,尤其是在源域和目标域之间存在显著差异时。通过引入域感知变换模块和协同自适应原型网络,本发明显著提升了模型对于目标域特征的理解和适应性,从而在目标域中获得更好的性能。具体来说,本发明的有益效果表现在以下几个方面:
Smart Images

Figure CN118349820B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of information technology, specifically relating to a method and system for cross-domain small sample relationship extraction based on collaborative adaptive feature transformation. Background Technology
[0002] In today's information age, with the rapid development of the internet and digital technologies, we have entered a new era of data explosion. Every day, countless structured and unstructured data are generated online, including text, images, and audio. This massive increase and diversity of data presents unprecedented challenges to traditional data processing methods, especially in extracting valuable information from massive amounts of unstructured data. Information extraction technology has emerged to address this challenge. This technology aims to automatically identify and extract key information such as entities, relationships, and events from unstructured text, transforming it into structured data that is easy to store and retrieve. This technology has become one of the core tasks in the field of natural language processing, and is of great significance for understanding and utilizing large-scale text data. Relation extraction, as a subfield of information extraction, focuses on identifying semantic relationships between entities in text and structuring these relationships. Traditional relation extraction methods typically require a large amount of labeled data to train the model; however, in practical applications, the cost of acquiring labeled data is often very high. At the same time, with the diversification of application scenarios, single-domain relation extraction is no longer sufficient to meet practical needs. Therefore, cross-domain small-sample relation extraction has emerged, aiming to transfer a small-sample relation extraction model from one domain to another, so as to effectively extract relations in the new domain relying only on a small number of samples. This has broad application prospects in professional fields such as finance, healthcare, and e-commerce. For example, in finance, relation extraction can extract key information from complex financial reports to assist in risk assessment and investment decisions; in healthcare, it can extract patient medical history and symptom information from medical records to help doctors make more accurate diagnoses; in e-commerce, by automating the extraction of product information, relation extraction technology can significantly improve the efficiency of product classification and the user's shopping experience.
[0003] Current methods for cross-domain few-shot relation extraction primarily rely on meta-learning, which aims to train a model to learn how to learn. It samples a small number of classification tasks from the source domain and optimizes the model to achieve better performance in the target domain. Therefore, the model can acquire cross-domain knowledge and quickly adapt to the target domain. However, these methods cannot effectively develop potential exploitable knowledge, such as knowledge from the target domain, which could provide valuable information for domain adaptation. To address this, some researchers have proposed adversarial training-based methods, which utilize unsupervised target domain data for adversarial training during meta-learning. Since these methods are often unstable, some researchers have proposed feature transformation-based methods, which use feature transformation layers to adapt the model to the domain. The aim of this method is to enhance source domain features by applying affine transformations, thereby simulating a wider range of feature distribution changes during training. These methods can significantly improve the model's cross-domain learning ability. Furthermore, some methods based on large language models have also shown great potential in few-shot learning tasks and have achieved state-of-the-art results on numerous natural language processing benchmarks.
[0004] While existing methods for cross-domain few-shot relation extraction have made significant progress, several unresolved issues remain. First, most existing methods mitigate the domain adaptation problem by implicitly guiding the expansion of source domain feature distributions through adversarial training or leveraging statistical information. However, since these domain-agnostic methods primarily focus on the source domain, where the domain gap can sometimes be substantial, they may fail to accurately transfer useful knowledge from the source domain to the target domain. Consequently, these methods do not effectively improve the model's cross-domain generalization ability. For methods based on large language models, despite deriving rich knowledge from extensive corpora, they may suffer from severe model illusions when adapting to certain specialized domains due to their limited understanding of domain-specific texts. Therefore, these methods may perform poorly in the target domain. Second, current mainstream meta-learning methods typically focus only on acquiring similarity information between query samples and support samples, then directly performing classification based on this information. This can lead to misclassification when easily confused relations exist in the support set. Summary of the Invention
[0005] To address the shortcomings of existing cross-domain few-sample relation extraction methods, this invention proposes a cross-domain few-sample relation extraction method based on collaborative adaptive feature transformation. This method aims to alleviate the disparity in the distribution of samples across different domains in the feature space and promote the learning of features capable of distinguishing confusing relations.
[0006] The technical solution adopted in this invention is as follows:
[0007] A method for cross-domain small sample relation extraction based on collaborative adaptive feature transformation includes the following steps:
[0008] The samples in the support set and query set are encoded to obtain the preliminary features of the samples;
[0009] The preliminary features of the encoded samples are input into the domain-aware transformation module, which uses the distribution features of the target domain data to transform the features of the source domain data to obtain the domain-aware features.
[0010] By leveraging domain-aware features, a collaborative adaptive prototype network is used to compute relational prototype features for each category in the support set.
[0011] Calculate the distance between the query sample and the relation prototype features of each category, and select the category to which the nearest relation prototype feature belongs as the relation category of the query sample.
[0012] Furthermore, the encoding is performed using a pre-trained BERT language model to obtain the context-related embedding vector for each word in the sentence.
[0013] Furthermore, the domain-aware transformation module utilizes parameter θ γ and θ β A scaling vector γ and an offset vector β are sampled from a Gaussian distribution. Then, the domain-aware features of the samples are calculated using element-wise multiplication and addition of the scaling vector γ and the offset vector β, where the parameter θ... γ and θ β represents the standard deviation of the Gaussian distribution used to sample the scaling and bias terms of the affine transformation, respectively.
[0014] Furthermore, the domain-aware features are calculated using the following formula:
[0015]
[0016]
[0017] in, To support the initial features of the k-th sample of the ith relation category in the set, The domain-aware features are obtained after domain-aware feature transformation, where softplus() is the activation function, N() is a Gaussian distribution, and θ is the domain-aware feature value. γ and θ β For trainable parameters, use domain difference loss. Optimize, The calculation method is as follows:
[0018]
[0019] Wherein, DTM represents Domain-Aware Feature Transform. To support the set of sample data, This is a set of unlabeled target domain samples.
[0020] Furthermore, the collaborative adaptive prototype network includes an intra-class aggregation layer and an inter-class adaptive layer. The intra-class aggregation layer uses a transformer encoder and a feedforward neural network to calculate the weight of each sample for samples of the same class in the support set, and then calculates the relational prototype features of that class through weighted summation. The inter-class adaptive layer uses a transformer encoder and activation layer to calculate the adaptive offset between the relational prototype features of each class, and uses this offset to optimize the relational prototype features through residual connections to enhance the distinguishability between relational prototype features.
[0021] Furthermore, the specific representation of the preliminary relational prototype features calculated by the intra-class aggregation layer is as follows:
[0022]
[0023]
[0024] in, Let be the domain-aware feature set of all samples in the i-th relation category, TE() be a standard transformer encoder, FFN() be a feedforward neural network with an output dimension of 1, and softmax() be a normalization function. It is the sample weight vector. p represents the weight of the k-th sample representing the i-th relation category. i These are the preliminary relation prototype features for the i-th relation category;
[0025] The specific representation of the relational prototype features calculated by the inter-class adaptive layer is as follows:
[0026]
[0027]
[0028] in, To query the domain-aware features of the sample, σ is the ReLU activation function. These are the adaptive offsets for the i-th prototype and the query sample, respectively. For the operation of adding elements, These are the final feature representations used for classification of the i-th prototype and the query sample, respectively.
[0029] Furthermore, the distance between the query sample and the relational prototype features of each category is calculated using cosine similarity.
[0030] A cross-domain few-sample relation extraction system based on collaborative adaptive feature transformation, comprising:
[0031] The feature encoding module is used to encode samples in the support set and query set to obtain preliminary features of the samples;
[0032] The domain-aware transformation module is used to transform the source domain data based on the preliminary features of the encoded samples and the distribution characteristics of the target domain data to obtain domain-aware features.
[0033] The collaborative adaptive prototype computation module is used to utilize domain-aware features and compute relational prototype features supporting various categories in the set through a collaborative adaptive prototype network.
[0034] The query sample classification module is used to calculate the distance between the query sample and the relation prototype features of each category, and select the category to which the nearest relation prototype feature belongs as the relation category of the query sample.
[0035] This invention addresses the shortcomings of existing cross-domain few-sample relation extraction methods by proposing a novel solution aimed at improving the model's generalization ability across different domains, especially when there are significant differences between the source and target domains. By introducing a domain-aware transformation module and a collaborative adaptive prototype network, this invention significantly enhances the model's understanding and adaptability to target domain features, thereby achieving better performance in the target domain. Specifically, the beneficial effects of this invention are manifested in the following aspects:
[0036] 1) Enhanced Domain Adaptability: By introducing a domain-aware transformation module, this invention significantly reduces the differences between source and target domain data in the feature space. This module utilizes the statistical properties of the target domain to guide feature transformation, ensuring that the features of the source domain data are more closely aligned with those of the target domain data. This explicit domain-guided strategy enables the model to effectively generalize in the target domain, thereby achieving higher accuracy in the target domain.
[0037] 2) Enhanced Relationship Class Discrimination Ability: The Collaborative Adaptive Prototype Network enhances the model's ability to capture subtle differences between supporting relation classes through the design of intra-class aggregation layers and inter-class adaptive layers. The intra-class aggregation layer strengthens the contribution of representative instances to the prototype by assigning weights to different instances, while the inter-class adaptive layer enhances the dimensionality of features that can distinguish prototypes of different classes through the use of feature transformation layers. This enables the model to classify more accurately when faced with confusing relation classes. Attached Figure Description
[0038] Figure 1 This is a flowchart illustrating the method of the present invention.
[0039] Figure 2 This is a schematic diagram of the collaborative adaptive feature transformation method proposed in this invention. Detailed Implementation
[0040] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to specific embodiments and accompanying drawings.
[0041] This invention proposes a cross-domain few-sample relation extraction method based on collaborative adaptive feature transformation, aiming to alleviate the gap in the distribution of samples from different domains in the feature space and promote the learning of features that can distinguish confusing relations. The method mainly consists of three parts: an encoder, a domain-aware transformation module, and a collaborative adaptive prototype network. 1) The encoder is used to convert each word in a sentence into a low-level embedding representation. 2) The domain-aware transformation module utilizes the distribution characteristics of unsupervised data in the target domain dataset to guide the domain-aware transformation module in performing feature transformation on the source domain data. The domain-aware transformation module can enhance the source domain data, making it more closely aligned with the target domain. By doing so, the model can effectively train on data related to the target domain features. Therefore, more useful and transferable knowledge can be learned, resulting in better model performance in the target domain. 3) To highlight the differences between features of different relation categories, the collaborative adaptive prototype network uses a Transformer mechanism to model the interaction between all samples in the support set and query set to highlight discriminative information. The intra-class aggregation layer and inter-class adaptive layer in this network help the model select more informative samples and highlight key features that help distinguish various relation prototypes, thereby constructing better relation category prototype features to help distinguish different relation categories.
[0042] Good feature representations are crucial for solving the task, and the encoder's role is to extract useful feature representations from the input text data. In this invention, the encoder can employ a pre-trained language model from deep learning, such as BERT, GPT, or a neural network model specifically tailored for relation extraction tasks. These models can capture the contextual relationships between words in a sentence, providing rich feature representations for the subsequent relation extraction process.
[0043] The goal of a domain-aware transformation module is to minimize the distributional differences between source and target domain samples in the feature space. Often, the semantic gap between the source and target domains can be quite large, potentially leading to overfitting of the model to the source domain and difficulty in generalizing to the target domain. To address this challenge, this invention simulates model training on target domain data through explicit target domain-guided feature transformations. By providing the model with more information about the distribution of features in the target domain, this invention can explicitly guide feature transformations, bringing the source domain data more closely aligned with the target domain. This invention achieves this goal through a learnable domain-aware transformation module with domain difference loss. It utilizes the mean and standard deviation of the target domain features to encode basic "domain style" information, enabling the domain-aware transformation module to perform domain-aware transformations reliably and efficiently.
[0044] To facilitate the differentiation of different relation categories, this invention proposes a collaborative adaptive prototype network. This network employs a self-attention mechanism to further transform and improve the domain-aware enhanced features. The network consists of two feature transformation layers: an intra-class aggregation layer and an inter-class adaptive layer. The goal of this network is to make the features of samples within the same category more tightly clustered around their respective prototypes, while ensuring that prototypes of different categories are as far apart as possible. In existing prototype networks, existing research typically averages the features of all instances within a relation to obtain the relation prototype. However, in small-sample scenarios, due to the lack of sufficient support data, if the representation of one instance differs significantly from the representations of other instances, it may ultimately lead to significant bias in the calculated relation category prototype. To improve the effectiveness of the prototype network, this invention proposes an intra-class aggregation layer. This layer can assign different weights to each instance in the relation, and these weights are jointly determined by all instances in that relation category. This allows the model to prioritize central instances that are more informative and representative of the relation prototype for aggregating relation prototype features. Once the prototype representation of each relation is obtained, the distance between the query sample and each relation prototype feature can be easily calculated, and classification can be performed based on similarity scores. However, this approach does not take into account the discriminative information between different relation prototypes, which can severely impact performance when handling confusing relations. To capture the complex interactions between all relation prototypes and query instances, this invention proposes an inter-class adaptive layer. By using a feature transformation layer in both relation prototypes and query features, we can focus more on discriminative feature dimensions that help distinguish various relation prototypes, thereby improving classification performance.
[0045] According to the design scheme provided by this invention, a cross-domain small sample relationship extraction method based on collaborative adaptive feature transformation specifically includes the following steps:
[0046] Step 1. Feature Encoding. Given a support set and query samples, all samples in the support set and the query samples are first encoded to obtain preliminary features. When encoding the samples, a pre-trained BERT language model is used to obtain the context-dependent embedding vectors of each word in the sentence. Furthermore, to clearly define entity boundaries, special markers are added around entities in the sentence, which helps the encoder to highlight entity representations. Simultaneously, for parallel processing, all sentences are padded to a preset maximum length; this invention achieves this using special padding markers.
[0047] Step 2. Domain-Aware Feature Transformation. After obtaining the preliminary features of the text through the encoder, these features are input into a domain-aware transformation module. The domain-aware transformation module consists of parameter θ. γ and θ β The control terms, θ, represent the standard deviations of the Gaussian distributions used to sample the scaling and bias terms of the affine transformation, respectively. To perform domain-aware feature transformation on the initial features of the text, the parameters θ are first used... γ and θ β Scaling vector γ and offset vector β are sampled from a Gaussian distribution. These vectors are then used to compute the domain-aware features of the samples through element-wise multiplication and addition. If this is during model training, the mean and standard deviation of these domain-aware features need to be calculated additionally and then compared with the mean and standard deviation of features from a small number of target domain samples. The domain difference loss is calculated using weighted mean squared error to continuously optimize the parameters θ in the domain-aware transformation module. γ and θ β .
[0048] Step 3. Collaborative Adaptive Prototype Calculation. After calculating the domain-aware features for each sample, the collaborative adaptive prototype network is used to calculate the relational prototype features for each category in the support set. This network includes an intra-class aggregation layer and an inter-class adaptive layer. First, in the intra-class aggregation layer, a single-layer transformer encoder and feedforward neural network (FFN) are used to calculate the weights for each sample of the same category in the support set. Then, the relational prototype features for that category are initially calculated by weighted summation. Second, in the inter-class adaptive layer, the adaptive offset between the relational prototype features of each category is calculated using a transformer encoder and activation layers. This offset is then used to further optimize the relational prototype features through residual connections to enhance the discriminability between them.
[0049] Step 4. Classify the query sample based on the enhanced relation prototype features. After obtaining the collaborative adaptive relation prototype features for each relation category, calculate the distance between the query sample and each relation prototype feature using cosine similarity, and use the category to which the nearest relation prototype feature belongs as the predicted relation category of the query sample.
[0050] In step 2 above, the parameter θ is used. γ and θ β The specific method for sampling scaling vector γ and offset vector β from a Gaussian distribution, and then using these vectors to perform domain-aware feature transformation on the sample features, is as follows:
[0051]
[0052]
[0053] in, To support the initial features of the k-th sample of the i-th relation category encoded by the BERT language model in the set, These are the features after domain-aware feature transformation, i.e., domain-aware features. `softplus()` is the softplus activation function. `N(,)` represents a Gaussian distribution. θ γ and θ β For trainable parameters, use domain difference loss. Optimize, The calculation method is as follows:
[0054]
[0055] In this formula, DTM represents Domain-Aware Feature Transform. To support the set of sample data, This is a set of unlabeled target domain samples.
[0056] In step 3 above, the intra-class aggregation layer uses a transformer encoder and a feedforward neural network to calculate the preliminary relational prototype features, specifically as follows:
[0057]
[0058]
[0059] in, Let be the set of domain-aware features for all samples of the i-th relation category. TE() is a standard transformer encoder, FFN() is a feedforward neural network with an output dimension of 1, and softmax() is a normalization function. It is the sample weight vector. p represents the weight of the k-th sample representing the i-th relation category. i These are the initial relation prototype features for the i-th relation category.
[0060] In step 3 above, the inter-class adaptive layer uses the inter-class adaptive network to calculate the specific representation of the collaborative adaptive relational prototype features as follows:
[0061]
[0062]
[0063] in, To query the domain-aware features of the sample, σ is the ReLU activation function. These are the adaptive offsets of the i-th relation prototype feature and the query sample feature, respectively. For the operation of adding elements, These are the final feature representations used for classification of the i-th prototype and the query sample, respectively.
[0064] In step 4 above, collaborative adaptive prototype features are utilized. and query features The method for calculating the probability that a query sample belongs to each relation category is as follows:
[0065]
[0066] Where d() is the Euclidean distance and exp() is the exponential function.
[0067] The key point of this invention is:
[0068] 1. The domain-aware transformation module proposed in this invention can significantly reduce the distribution differences of samples in the source and target domains in the feature space.
[0069] To achieve this, this invention employs an explicit target domain-guided feature transformation method. Through a feature transformation layer with domain difference loss, the statistical properties of the target domain (such as the mean and standard deviation of features) can be used to encode "domain style." This design allows the model trained on the source domain to generalize better to the target domain, thereby improving performance in the target domain.
[0070] 2. The proposed collaborative adaptive prototype network comprises two key transformation layers: an intra-class aggregation layer and an inter-class adaptive layer. The intra-class aggregation layer allows features of samples within the same class to cluster more tightly around their respective prototypes, reducing prototype bias in small-sample scenarios by assigning different weights to each instance. These weights are determined based on the representativeness of the instance within its class, prioritizing instances that are information-rich and better represent the class. The inter-class adaptive layer focuses on capturing the complex interactions between the query instance and prototypes of all classes, strengthening the feature dimensions used to distinguish prototypes of different classes through a feature transformation layer, thereby improving classification performance when faced with confused classes. This collaborative adaptive approach helps improve the model's ability to discriminate between various relationship categories.
[0071] To more clearly illustrate the cross-domain few-sample relation extraction method based on collaborative adaptive feature transformation proposed in this invention, a specific case will be used in conjunction with diagrams and detailed implementation. This case involves using a support set. Classify the relationships for query instance q. The support set contains K types of relationships, with N samples for each relationship, for a total of N*K labeled samples.
[0072] Figure 1 The flowchart of the method of the present invention includes four parts: feature encoding, domain adaptive feature transformation, collaborative adaptive prototype calculation, and query sample classification. Figure 2 This is a schematic diagram of the processing procedure of this method.
[0073] Step 1. Feature Encoding. Input all samples from the support set and query set into the BERT language model as text to obtain the corresponding preliminary feature representations. and q. Let represent the features of the k-th sample in the i-th relation category, and q represent the sample features of the query example. For the input text, before input, special identifiers [unused1] and [unused2] are placed on either side of entities in the sentence to clearly indicate entity boundaries and enable the encoder to more focusedly identify entities. Then, special padding markers [pad] are used to pad all sentences to a length of 128, thus enabling parallel processing of sentences.
[0074] Step 2. Domain-Adaptive Feature Transformation. This utilizes the learnable parameters θ within the model. γ and θ β Sampling vector γ and offset vector β are sampled from a Gaussian distribution. Feature transformation is performed on all samples in the support set and query set using element-wise multiplication and addition to obtain domain-aware support set sample features. and query sample features
[0075] Step 3. Collaborative Adaptive Prototype Calculation. First, perform intra-class aggregation. For a set of k samples with support set relation i... The standard single-layer Transformer encoder and the feedforward neural network mapped to one-dimensional features are used sequentially to calculate the features of these samples, resulting in the weight vector α of the k samples in the i-th relation. i Then use this weight vector on the set. We perform a weighted summation of the sample features within the i-th relation category to obtain the preliminary prototype feature p. i Following the same method, preliminary prototype features p for all relation categories can be obtained. 1 ,p 2 …p N For these prototype features, an inter-class adaptive feature transformation is performed. These prototype features, along with the domain-aware query sample features... The inputs are sequentially fed into a standard single-layer Transformer encoder and a ReLU activation layer to calculate the adaptive offsets for all prototype and query samples. Then, through element-wise addition, these offsets are added to the original relation prototype features of the support set and the domain-aware query sample features to obtain the final features of the relation category prototype and the query sample.
[0076] Step 4. Query Sample Classification. Ultimately, the model selects the category prototype most similar to the query sample as the predicted relation category for the query sample. To measure the query sample... With each prototype To calculate the similarity score, this invention uses cosine similarity to determine the distance between the query samples. Specifically, it calculates the similarity score based on the final features of the query samples. With each prototype Calculate the cosine similarity, then use the softmax function to obtain the class probability p(y=r|S,q) for classification, and select the class category with the highest class probability value as the predicted class category of the query sample. Figure 2 Classification loss L c Used to calculate gradients to optimize the parameters of the entire model.
[0077] This invention enables cross-domain small-sample relationship extraction, and has broad application prospects in professional fields such as finance, healthcare, and e-commerce. For example, in the financial field, the method of this invention can extract relationships between different financial indicators from complex financial reports, assisting in risk assessment and investment decisions; in the medical field, the method of this invention can extract relationships between different conditions and symptoms from medical records, including patient medical history and symptom information, helping doctors make more accurate diagnoses; in e-commerce, the method of this invention can automatically extract relationships between the characteristic attributes and categories of goods, significantly improving the efficiency of product classification and the user's shopping experience.
[0078] Another embodiment of the present invention provides a cross-domain small sample relation extraction system based on collaborative adaptive feature transformation, comprising:
[0079] The feature encoding module is used to encode samples in the support set and query set to obtain preliminary features of the samples;
[0080] The domain-aware transformation module is used to transform the source domain data based on the preliminary features of the encoded samples and the distribution characteristics of the target domain data to obtain domain-aware features.
[0081] The collaborative adaptive prototype computation module is used to utilize domain-aware features and compute relational prototype features supporting various categories in the set through a collaborative adaptive prototype network.
[0082] The query sample classification module is used to calculate the distance between the query sample and the relation prototype features of each category, and select the category to which the nearest relation prototype feature belongs as the relation category of the query sample.
[0083] For the specific implementation process of each module, please refer to the description of the method of the present invention above.
[0084] Another embodiment of the present invention provides a computer device (computer, server, smartphone, etc.) including a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the steps of the method of the present invention.
[0085] Another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, disk, optical disk) storing a computer program that, when executed by a computer, implements the various steps of the method of the present invention.
[0086] Although the specific details, implementation algorithms, and accompanying drawings of the present invention have been disclosed for illustrative purposes to aid in understanding and implementing the invention, those skilled in the art will understand that various substitutions, variations, and modifications are possible without departing from the spirit and scope of the invention and the appended claims. The invention should not be limited to the content disclosed in the preferred embodiments and accompanying drawings; the scope of protection claimed by the invention is defined by the claims.
Claims
1. A method for extracting cross-domain small sample relationships based on collaborative adaptive feature transformation, characterized in that, Includes the following steps: The samples in the support set and query set are encoded to obtain the preliminary features of the samples; The preliminary features of the encoded samples are input into the domain-aware transformation module, which uses the distribution features of the target domain data to transform the features of the source domain data to obtain the domain-aware features. By leveraging domain-aware features, a collaborative adaptive prototype network is used to compute relational prototype features for each category in the support set. Calculate the distance between the query sample and the relation prototype features of each category, and select the category to which the nearest relation prototype feature belongs as the relation category of the query sample; The collaborative adaptive prototype network includes an intra-class aggregation layer and an inter-class adaptive layer. The intra-class aggregation layer uses a transformer encoder and a feedforward neural network to calculate the weight of each sample for samples of the same class in the support set, and then calculates the relational prototype features of the class through weighted summation. The inter-class adaptive layer uses a transformer encoder and an activation layer to calculate the adaptive offset between the relational prototype features of each class, and uses this offset to optimize the relational prototype features through residual connections to enhance the distinguishability between the relational prototype features. The specific representation of the preliminary relational prototype features calculated by the intra-class aggregation layer is as follows: in, TE is the set of domain-aware features for all samples of the i-th relation category. For standard transformer encoders, FFN This is a feedforward neural network with an output dimension of 1. It is a normalization function. It is the sample weight vector. The weight represents the weight of the k-th sample representing the i-th relation category. These are the preliminary relation prototype features for the i-th relation category; The domain-aware features are obtained after domain-aware feature transformation; The specific representation of the relational prototype features calculated by the inter-class adaptive layer is as follows: in, To query the domain-aware features of the sample. It is the ReLU activation function. , These are the adaptive offsets for the i-th prototype and the query sample, respectively. For the operation of adding elements, These are the final feature representations used for classification of the i-th prototype and the query sample, respectively.
2. The method according to claim 1, characterized in that, The encoding is performed using a pre-trained BERT language model to obtain the context-related embedding vector of each word in the sentence.
3. The method according to claim 1, characterized in that, The domain-aware transformation module utilizes parameters and Sampling vectors from a Gaussian distribution and offset vector Then use the scaling vector and offset vector Domain-aware features of samples are calculated using element-wise multiplication and element-wise addition, where parameters... and represents the standard deviation of the Gaussian distribution used to sample the scaling and bias terms of the affine transformation, respectively.
4. The method according to claim 3, characterized in that, The domain-aware features are calculated using the following formula: in, To support the initial features of the k-th sample of the ith relation category in the set, These are the domain-aware features obtained after domain-aware feature transformation. For activation function, It follows a Gaussian distribution. and For trainable parameters, use domain difference loss. Optimize, The calculation method is as follows: Wherein, DTM represents Domain-Aware Feature Transform. To support the set of sample data, This is a set of unlabeled target domain samples.
5. The method according to claim 1, characterized in that, The distance between the query sample and the relational prototype features of each category is calculated using cosine similarity.
6. A cross-domain small-sample relation extraction system based on collaborative adaptive feature transformation, characterized in that, The method of any one of claims 1 to 5 comprises: The feature encoding module is used to encode samples in the support set and query set to obtain preliminary features of the samples; The domain-aware transformation module is used to input the preliminary features of the encoded samples into the domain-aware transformation module. The domain-aware transformation module uses the distribution characteristics of the target domain data to transform the features of the source domain data to obtain the domain-aware features. The collaborative adaptive prototype computation module is used to utilize domain-aware features and compute relational prototype features supporting various categories in the set through a collaborative adaptive prototype network. The query sample classification module is used to calculate the distance between the query sample and the relation prototype features of each category, and select the category to which the nearest relation prototype feature belongs as the relation category of the query sample.
7. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the method of any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a computer, implements the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Cross-domain small sample image recognition method and system
CN116342906A
Cross-domain small sample relation extraction method and system based on enhanced contrast learning fine tuning
CN116561308A