Small sample relation classification method introduced by external information

By explicit and implicitly introducing modules to integrate external information and prototype representation, the problems of noise propagation and knowledge selection complexity in small sample relationship classification are solved, the classification accuracy and robustness are improved, and the relationship classification effect is achieved.

CN120296171APending Publication Date: 2025-07-11CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510365397.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-26
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

The existing small sample relationship classification methods have problems with noise propagation, semantic drift and knowledge selection complexity when utilizing external information, making it difficult to construct representative prototype representations, resulting in a degradation of classification performance.

Method used

A small sample relationship classification method for external information introduction was designed. Through explicit and implicit introduction modules, external information and prototype representation are fused, features are extracted using the BERT encoder, and prototype representation is optimized in combination with attention mechanism and gating mechanism to build a final enhanced prototype representation.

Benefits of technology

It improves the accuracy and robustness of relationship classification, achieves classification effect beyond mainstream baseline methods, and alleviates the problem of insufficient utilization of external information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120296171A_ABST
    Figure CN120296171A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of natural language processing, and particularly relates to a small sample relation classification method introduced by external information. Comprising the following steps: preprocessing a training text, and extracting global information and local information of sentence instances and external information obtained by preprocessing; fusing the global information and the local information to obtain complete feature representation of the sentence instance and the external information; calculating prototype representation of each class according to the complete feature representation of the sentence instance; processing prototype representation of each class and complete feature representation of external information by using an implicit and explicit introduction module to obtain implicit and explicit enhanced prototype representation; fusing the implicit enhanced prototype representation and the explicit enhanced prototype representation to obtain a final enhanced prototype representation of each class; calculating the total loss of the model according to the final enhanced prototype representation, and adjusting model parameters to obtain a trained small sample relationship classification model; performing small sample relation classification by using the trained model; the method achieves a relation classification effect beyond a mainstream baseline method, and has a good application prospect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of natural language processing, and particularly relates to a few-shot relation classification method with external information introduction. Background Art

[0002] In the field of natural language processing, relation classification is a key task, aiming to identify the relationships between entities in text. Relation classification has extensive practical application value and plays an important role in fields such as information extraction, sentiment analysis, and knowledge graph construction. However, traditional relation classification methods usually rely on a large amount of labeled data, which requires professional personnel to manually annotate. This process not only consumes time and energy but also is prone to label errors. To solve this problem, researchers have proposed the distant supervision method. This method automatically labels data by using an external knowledge base, matches the text with the knowledge base, and provides annotations for the entities and relationships in the text. However, the distant supervision method is easily affected by the incompleteness or inaccuracy of the knowledge base, resulting in annotation errors. In addition, in the case of scarce data, the performance of the distant supervision-based model in the relation classification task will significantly decline.

[0003] To address these challenges, few-shot learning has become a hot topic of concern for researchers. Initially, few-shot learning achieved remarkable success in the field of computer vision, and subsequently various methods have been introduced into the relation classification field. The current few-shot relation classification methods mainly focus on three technical routes: prototype network optimization, external knowledge fusion, and pre-trained model adaptation. The method based on the prototype network generates class prototypes by calculating the mean of support set samples, but it is vulnerable to noisy samples in low-resource scenarios and difficult to handle semantic overlapping relationships. Although subsequent studies have introduced contrastive learning and hierarchical prototypes for improvement, the problem of prototype representation bias has not been fundamentally solved. In terms of the utilization of external knowledge, existing methods have significant limitations: the relation description guidance method directly concatenates text descriptions and instance features, resulting in noise propagation and semantic drift; although the entity type enhancement method fuses type information through the attention mechanism, it lacks explicit encoding of structural constraints. The latest pre-trained model adaptation scheme attempts to align the semantic space using prompt learning, but faces the dual challenges of template design complexity and knowledge selection dynamics.

[0004] Researchers have taken advantage of the benefits of few-shot relation classification and combined it with pre-trained language models, greatly promoting the development of pre-trained language models. The introduction of BERT has significantly improved the ability to extract context information from text. Among them, the prototype network has demonstrated superior classification performance. To further enhance the classification performance of the model, researchers have proposed various enhanced prototype networks that utilize external information to assist model training and achieved remarkable results. However, the enhanced prototype network faces two main challenges: (1) how to fully utilize external information, and (2) how to construct a more representative prototype representation. Summary of the Invention

[0005] In view of the deficiencies in the prior art, the present invention proposes a few-shot relation classification method with the introduction of external information. The method includes: obtaining the text to be recognized and preprocessing it, and inputting the preprocessed text into a trained relation classification model to obtain a relation classification result;

[0006] The training process of the few-shot relation classification model includes:

[0007] S1: Obtain training text and preprocess it to obtain preprocessed sentence instances and external information; the external information includes relation description instances and entity category instances;

[0008] S2: Input the preprocessed sentence instances and external information into the BERT encoder to obtain the global information and local information of the sentence instances and external information;

[0009] S3: Fuse the global information and local information of the sentence instances and external information to obtain the complete feature representation of the sentence instances and external information;

[0010] S4: Calculate the prototype representation of each class according to the complete feature representation of the sentence instances;

[0011] S5: Use an explicit introduction module to inject the complete feature representation of the external information into the prototype representation of each class to obtain the explicit enhanced prototype representation of each class;

[0012] S6: Adopt an implicit introduction module based on the attention mechanism to fuse the complete feature representation of the external information and the prototype representation of each class to obtain the implicit enhanced prototype representation of each class;

[0013] S7: Fuse the implicit enhanced prototype representation and the explicit enhanced prototype representation of each class respectively to obtain the final enhanced prototype representation of each class;

[0014] S8: Calculate the total loss of the model according to the final enhanced prototype representation and adjust the model parameters according to the total loss of the model to obtain a trained few-shot relation classification model.

[0015] Preferably, the process of preprocessing the training text includes: removing special characters in the text; marking the head and tail entity positions of sentences in the text; obtaining relation description instances in the external information according to the relation description text predefined in the text; and obtaining entity type instances according to the head and tail entities of the relation description text.

[0016] Preferably, the process of fusing the global and local information of sentence instances and external information includes:

[0017] Adding the global and local information of the sentence instance as the complete feature representation of the sentence instance;

[0018] Adding the global and local information of the relation description instance as the complete feature representation of the relation description instance;

[0019] Adding the global and local information of the head entity type representation in the entity category instance to obtain the complete feature representation of the head entity; adding the global and local information of the tail entity type representation in the entity category instance to obtain the complete feature representation of the tail entity; concatenating the complete feature representation of the head entity and the complete feature representation of the tail entity to obtain the complete feature representation of the entity category instance.

[0020] Preferably, the formula for calculating the prototype representation of each class is:

[0021]

[0022] where, Proto i represents the prototype representation of the i-th class, K represents the number of instances randomly selected in each relation category, represents the head and tail entity representation of sentence instance j under the i-th class.

[0023] Preferably, the process of obtaining the explicit enhanced prototype representation includes:

[0024] Adding the complete feature representation of the head entity, the complete feature representation of the relation description instance and the head entity representation in the prototype representation to obtain the enhanced head entity representation;

[0025] Adding the complete feature representation of the tail entity, the complete feature representation of the relation description instance and the head entity representation in the prototype representation to obtain the enhanced tail entity representation;

[0026] Concatenating the enhanced head entity representation and the enhanced tail entity representation to obtain the explicit enhanced prototype representation.

[0027] Preferably, the process of obtaining the implicit enhanced prototype representation includes:

[0028] Processing the complete features of the external information to obtain the external knowledge representation;

[0029] Taking the prototype representation as a query, performing attention calculation with the external knowledge representation as keys and values to obtain attention scores;

[0030] Weightedly fusing the external knowledge representation according to the attention scores to obtain attention features;

[0031] Fusing the attention features and the prototype representation to obtain an implicitly enhanced prototype representation.

[0032] Preferably, the formula for fusing the explicitly enhanced prototype representation and the implicitly enhanced prototype representation is:

[0033]

[0034] where NewProto represents the final enhanced prototype representation, ImpProto represents the implicitly enhanced prototype representation, and ExpProto represents the explicitly enhanced prototype representation.

[0035] Preferably, the formula for calculating the total loss of the model is:

[0036]

[0037] where loss represents the total loss of the model, NewProto i represents the final enhanced prototype representation of category i, N represents the number of relationship categories, q j represents the query instance, and Q represents the total number of query instances.

[0038] The beneficial effects of the present invention are as follows: The present invention proposes an enhanced prototype network specifically designed for few-shot relation classification, aiming to effectively utilize external information to improve the relation classification performance. The present invention designs two modules: an implicit introduction module and an explicit introduction module. The introduction of these two modules makes the prototype representation more comprehensive and accurate, thus ensuring that the prototype network has good classification performance. Experimental results show that the overall classification accuracy has been improved. In addition, the present invention constructs a new prototype representation by combining the two introduction methods, and the two introduction methods can constrain each other, giving full play to their respective advantages and alleviating the problem that the model cannot fully learn external information. Finally, the present invention achieves a relation classification effect that surpasses the mainstream baseline methods and has good application prospects. Description of the Drawings

[0039] Figure 1 It is a training flow chart of the few-shot relation classification model in the present invention. Detailed Embodiments

[0040] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0041] The present invention proposes a small-sample relation classification method for introducing external information, and the method includes the following content:

[0042] Obtain the text to be recognized and preprocess it, and input the preprocessed text into the trained relation classification model to obtain the relation classification result.

[0043] As Figure 1 shown, the training process of the small-sample relation classification model includes:

[0044] S1: Obtain the training text and preprocess it to obtain the preprocessed sentence instances and external information; the external information includes relation description instances and entity category instances.

[0045] Obtain the training text. Preferably, the publicly available dataset FewRel can be used. The FewRel dataset developed by Tsinghua University is a benchmark for evaluating the model. This large dataset is carefully designed by combining distant supervision and manual annotation, making it an indispensable dataset for the small-sample relation classification task. Consisting of 100 relations, each relation supported by 700 instances, FewRel provides a solid foundation for evaluating the model's performance and generalization ability.

[0046] This dataset includes a training set, a validation set, and a test set. Since 64 training set tasks and 16 validation set tasks are publicly available, and the label data of the test set is still not public, the predictions of this model are generated using 16 validation set tasks. It should be noted that the data in the training, validation, and test datasets do not overlap. In addition, the dataset also provides relation description information to assist in training.

[0047] The preprocessing of the training text includes:

[0048] Remove special characters in the text; mark the positions of the head and tail entities in the sentences of the text; the relation description instances in the external information are obtained through predefined relation description texts; the entity category instances are obtained from the head and tail entities in the relation description texts; that is, the sentence x is processed as:

[0049] x = {w1, w2, …, w n ; pos1, pos2}

[0050] where wn It represents the nth word segment, pos1 represents the position of the head entity, and pos2 represents the position of the tail entity.

[0051] S2: Input the preprocessed sentence instance and external information into the BERT encoder to obtain the global and local information of the sentence instance and external information.

[0052] The sentence encoder can use the bert-base-uncased model. The pre-trained parameters are fine-tuned, and the initial learning rate assigned to the above pre-trained language model is 1e-5.

[0053] The global representation corresponds to the [CLS] label in the sequence. It passes through all the transformer layers and can be considered as a summary representation of the entire input sequence.

[0054] The local representation is obtained by taking the average of the embeddings of all tokens, providing a representation of the complete instance.

[0055] Input the preprocessed text into the sentence encoder for processing to obtain the global representation S_gol and local representation S_loc of the sentence instance in the sentence encoder, the global representation Rel_gol and local representation Rel_loc of the relation description instance, and the global representation Type_gol and local representation Type_loc of the entity category instance. Specifically, for the relation description instance, BERT is used to obtain its global and local representations of the embeddings, Rel_gol and Rel_loc. Among them, Rel_loc is obtained by taking the average of the relation description instance, and Rel_gol represents the [CLS] label.

[0056] Similarly, for the entity category instance, the head entity type representations Htype_gol and Htype_loc, and the tail entity type representations Ttype_gol and Ttype_loc can be obtained by the same method.

[0057]

[0058] S3: Fuse the global and local information of the sentence instance and external information to obtain the complete feature representation of the sentence instance and external information.

[0059] Add the global and local information of the sentence instance as the complete feature representation of the sentence instance; add the global and local information of the relation description instance as the complete feature representation of the relation description instance:

[0060] Rel = Rel_gol + Rel_loc.

[0061] S = S_gol + S_loc.

[0062] The processing of entity category instances is special. It is necessary to concatenate the complete feature representations of the head entity and the tail entity to obtain the embedding representation of the final entity type. The calculation formula is as follows:

[0063] Htype = Htype_gol + Htype_loc,

[0064] Ttype = Ttype_gol + Ttype_loc,

[0065]

[0066] Among them, represents the concatenation operation,

[0067] S4: Calculate the prototype representation of each class according to the complete feature representation of the sentence instance.

[0068] Extract the embedding representation corresponding to the entity pair through the position of the entity pair, denoted as Head and Tail. The sentence instance consists of the head entity representation Head and the tail entity representation Tail. The formula is as follows:

[0069]

[0070] Among them, i represents the current i-th relationship category, and K represents the number of instances randomly selected in each relationship category. represents the j-th instance in relationship i,

[0071] In each class, calculate the prototype representation of each class according to the complete feature representation of the sentence instances of this class during the training process. The calculation formula is:

[0072]

[0073] Among them, Proto i represents the prototype representation of the i-th class, and K represents the number of instances randomly selected in each relationship category. represents the head and tail entity representations of sentence instance j under the i-th class.

[0074] Therefore, Proto can be expressed as:

[0075] Proto = [Heads, Tails],

[0076] Among them

[0077] S5: Inject the complete feature representation of external information into the prototype representation of each class using an explicit introduction module to obtain the explicitly enhanced prototype representation of each class.

[0078] The main purpose of this module is to alleviate the problem of inconsistent feature distributions between head and tail entities, allowing each entity to independently learn its corresponding features. The explicit introduction module avoids using complex neural networks and achieves efficient learning of external information through only the simplest gating mechanism.

[0079] The simple gating mechanism can efficiently integrate the prototype representation and external information, avoiding an increase in parameters, avoiding the risk of overfitting, and enhancing the interpretability of the model. The overall injection of external information makes the prototypes of each class more representative. Therefore, for the head and tail entity representations in the prototype representation, the direct injection of external information will be carried out separately; the process of obtaining the explicitly enhanced prototype representation is specifically as follows:

[0080] Add the complete feature representation of the head entity, the complete feature representation of the relation description instance, and the head entity representation in the prototype representation of each class to obtain the enhanced head entity representation Head, and the calculation formula is as follows:

[0081] Head = Heads + Rel + β * Htype,

[0082] where β represents the type learning rate, and * represents multiplication.

[0083] Add the complete feature representation of the tail entity, the complete feature representation of the relation description instance, and the head entity representation in the prototype representation of each class to obtain the enhanced tail entity representation Tail, and the calculation formula is as follows:

[0084] Tail = Tails + Rel + β * Ttype.

[0085] Finally, concatenate the enhanced head entity representation and the enhanced tail entity representation to obtain the explicitly enhanced prototype representation, denoted as:

[0086]

[0087] S6: Adopt an implicit introduction module based on the attention mechanism to fuse the complete feature representation of external information and the prototype representation of each class to obtain the implicitly enhanced prototype representation of each class.

[0088] Inspired by effective prototypes, the present invention proposes a method based on the multi-head attention mechanism to enable the head and tail entities in a sentence to fully learn the relation description and entity type description information and obtain better semantic representations. This method helps to obtain more comprehensive prototypes, thus better representing relation classes.

[0089] The head and tail entities in a text sentence often relate to certain objects in external information. Therefore, in order to enable the head and tail entities in the sentence to fully learn external information, an implicit introduction module based on the attention mechanism is proposed. In this module, the complete feature representation Rel of the relationship description instance and the complete feature representation Type of the entity category instance need to be concatenated along the feature dimension and projected into a unified feature space to obtain the external knowledge representation h ext :

[0090]

[0091] where, W c is the dimensionality reduction matrix, represents the concatenation operation.

[0092] Subsequently, the prototype representation Proto and the external knowledge representation h ext are subjected to fine-grained interaction:

[0093] First, the external knowledge representation is used as the key-value pair K and the value V, and the prototype representation is used as the query Q for attention parameterization. This process can be formally defined as the formula:

[0094] Q = ProtoW q

[0095] K = Repeat(h ext , n)W k

[0096] V = Repeat(h ext , n)W v

[0097] where, W q , W k , W v represent the projection matrices, and Repeat(x·n) represents replicating the vector x n times along the sequence dimension.

[0098] According to the above attention weights, calculate the attention scores and weighted fusion of external information, and the calculation formula is as follows:

[0099]

[0100] Context = αV

[0101] where, d k is the scaling factor.

[0102] After obtaining the attention output Context, it is necessary to perform representation fusion with the initial prototype to realize the implicit introduction of entity relationship and type information, and the calculation formula is as follows:

[0103] ImpProto = LayerNorm(Proto + W o Context)

[0104] S7: Fuse the implicit enhanced prototype representation and explicit enhanced prototype representation for each class respectively to obtain the final enhanced prototype representation for each class.

[0105] To achieve the effect of mutual constraint on model training between the two introduction methods, the present invention uses the simplest gating mechanism to obtain the final enhanced prototype representation, and the calculation formula is as follows:

[0106]

[0107] S8: Calculate the total model loss according to the final enhanced prototype representation and adjust the model parameters according to the total model loss to obtain a trained few-shot relation classification model.

[0108] After obtaining the final enhanced prototype representation for each class, use the distance calculation method of vector dot product to calculate the distance between each final enhanced prototype representation and the query embedding obtained by BERT. Finally, calculate the total model loss of the trained model using the cross-entropy based on the enhanced prototype and query instances:

[0109]

[0110] where loss represents the total model loss, NewProto i represents the final enhanced prototype representation of class i, N represents the number of relation classes, q j represents the j-th query instance, and Q represents the total number of query instances.

[0111] The core idea of the present invention is to construct a feature mapping space, whose optimization goal is to shorten the representation distance between the prototypes of the same-class samples and the positive samples through a metric learning strategy, while expanding the difference metric with the negative samples. Specifically, this method aims to enhance the distinguishability of cross-class samples in the feature space, and through optimizing the feature distribution, make the same-class samples form a tight clustering cluster in the embedding space, while the different-class samples achieve a significant spatial separation effect, thereby improving the clarity of the classification decision boundary.

[0112] After completing the optimization of the model parameters, enter the inference and prediction stage. The text data to be classified needs to go through the same standardized preprocessing process, and then be input into the pre-trained language model adapted to the domain for deep semantic representation extraction. By calculating the similarity metric between the feature vector of the sample to be tested and the prototype vectors of each candidate class in the multi-dimensional space, finally determine its class label according to the nearest neighbor principle.

[0113] During the testing process, the model uses the same parameters as those in training. In addition, there is no overlap between the training data and the testing data. In the training stage, the model learns from the support set with limited labels, while in the testing stage, its prediction performance will be evaluated on the query set with unknown labels. During the prediction process, when a new instance is provided, the distance between it and each prototype is calculated, and the predicted category is determined according to the category associated with the closest prototype. When considering the query set, the predicted probability of the k-th query instance q i k belonging to the relation category r i can be calculated by the following formula:

[0114]

[0115] where dist(x,y) represents the Euclidean distance between two embeddings. Proto i represents the prototype representation of the i-th class.

[0116] To illustrate the inference process:

[0117] Randomly select an example from the test set: the input sentence [Mozart composed The Magic Flute in Vienna in 1791.]. Immediately perform preprocessing: processed_text = "[CLS] <e1>Mozart< / e1> composed <e2>The Magic Flute< / e2> in Vienna in 1791.[SEP]". Next, obtain the feature representation of the sentence through the sentence encoder, and calculate the similarity between it and the prototypes of each class: distances = {"composer": 1.3, "work_location": 3.9, "genre": 4.8}; then calculate through Softmax probability: probs = [0.89, 0.10, 0.01] (corresponding to composer / work_location / genre). Final prediction: composer (probability: 0.89).

[0118] After the training of the few-shot relation classification model is completed, obtain the text to be recognized and preprocess it, and input the preprocessed text into the trained model to obtain the few-shot relation classification result.

[0119] Evaluate the present invention:

[0120] Conduct a simulation experiment on the dataset FewRel. The present invention uses precision to measure the classification ability of the model. Precision calculates how many of the samples predicted as positive examples are truly positive examples.

[0121] Table 1 Comparison of Simulation Results between the Present Invention and Comparative Methods on the FewRel Dataset

[0122]

[0123] As can be seen from Table 1, the present invention can achieve better results than the existing benchmark models on the FewRel dataset. Therefore, compared with the existing methods, the present invention has a better classification effect and more accurate entity relationship extraction results.

[0124] The above - mentioned embodiments further elaborate on the purpose, technical solutions, and advantages of the present invention. It should be understood that the above - mentioned embodiments are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made to the present invention within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. A small sample relation classification method for introducing external information, characterized in that Including: Obtain the text to be recognized and preprocess it, then input the preprocessed text into the trained relation classification model to obtain the relation classification result; The training process of the few-shot relation classification model includes: S1: Obtain the training text and preprocess it to get the preprocessed sentence instances and external information; the external information includes relation description instances and entity category instances; S2: Input the preprocessed sentence instances and external information into the BERT encoder to obtain the global information and local information of the sentence instances and external information; S3: Fuse the global information and local information of the sentence instances and external information to obtain the complete feature representations of the sentence instances and external information; S4: Calculate the prototype representation of each class according to the complete feature representation of the sentence instances; S5: Use the explicit introduction module to inject the complete feature representation of the external information into the prototype representation of each class to obtain the explicitly enhanced prototype representation of each class; S6: Adopt the implicit introduction module based on the attention mechanism to fuse the complete feature representation of the external information and the prototype representation of each class to obtain the implicitly enhanced prototype representation of each class; S7: Fuse the implicitly enhanced prototype representation and the explicitly enhanced prototype representation of each class respectively to obtain the final enhanced prototype representation of each class; S8: Calculate the total model loss according to the final enhanced prototype representation and adjust the model parameters according to the total model loss to obtain the trained few-shot relation classification model.

2. The small-sample relationship classification method for introducing external information according to claim 1, wherein The process of preprocessing the training text includes: removing special characters in the text; marking the head and tail entity positions of the sentences in the text; obtaining the relation description instances in the external information according to the predefined relation description text in the text; obtaining the entity type instances according to the head and tail entities of the relation description text.

3. The small sample relationship classification method for introducing external information according to claim 1, characterized in that The process of fusing the global information and local information of the sentence instances and external information includes: Add the global information and local information of the sentence instances as the complete feature representation of the sentence instances; Add the global information and local information of the relation description instances as the complete feature representation of the relation description instances; Add the global information and local information of the head entity type representation in the entity category instances to obtain the complete feature representation of the head entity; add the global information and local information of the tail entity type representation in the entity category instances to obtain the complete feature representation of the tail entity; concatenate the complete feature representation of the head entity and the complete feature representation of the tail entity to obtain the complete feature representation of the entity category instances.

4. The small-sample relationship classification method for introducing external information according to claim 1, wherein The formula for calculating the prototype representation of each class is: Among them, Proto i represents the prototype representation of the i-th category, and K represents the number of instances randomly selected in each relationship category. represents the head and tail entity representations of the sentence instance j under the i-th category.

5. The small-sample relationship classification method for introducing external information according to claim 1, characterized in that The process of obtaining the explicitly enhanced prototype representation includes: Add the complete feature representation of the head entity, the complete feature representation of the relation description instance and the head entity representation in the prototype representation to obtain the enhanced head entity representation; Add the complete feature representation of the tail entity, the complete feature representation of the relation description instance and the head entity representation in the prototype representation to obtain the enhanced tail entity representation; Concatenate the enhanced head entity representation and the enhanced tail entity representation to obtain the explicitly enhanced prototype representation.

6. The small sample relationship classification method for introducing external information according to claim 1, characterized in that The process of obtaining the implicitly enhanced prototype representation includes: Process the complete features of the external information to obtain the external knowledge representation; Use the prototype representation as the query, and use the external knowledge representation as the key and value for attention calculation to obtain the attention scores; Perform weighted fusion on the external knowledge representation according to the attention scores to obtain attention features; Fuse the attention features and the prototype representation to obtain an implicitly enhanced prototype representation.

7. The small sample relationship classification method for introducing external information according to claim 1, characterized in that The formula for fusing the explicitly enhanced prototype representation and the implicitly enhanced prototype representation is: Among them, NewProto represents the final enhanced prototype representation, ImpProto represents the implicitly enhanced prototype representation, and ExpProto represents the explicitly enhanced prototype representation.

8. The small-sample relationship classification method for introducing external information according to claim 1, characterized in that The formula for calculating the total loss of the model is: Among them, loss represents the total loss of the model, and NewProto i represents the final enhanced prototype representation of class i, N represents the number of relationship classes, and q j represents the query instance, and Q represents the total number of query instances.