US 12,380,180 B2
Method and apparatus for few-shot relation classification and filtering, and device
Fei Cai, Hunan (CN); Peihong Li, Hunan (CN); Honghui Chen, Hunan (CN); Jianming Zheng, Hunan (CN); Taihua Shao, Hunan (CN); Mengru Wang, Hunan (CN); Siyuan Wang, Hunan (CN); Dengfeng Liu, Hunan (CN); and Yanying Mao, Hunan (CN)
Assigned to National University of Defense Technology, Changsha (CN)
Filed by National University of Defense Technology, Hunan (CN)
Filed on Aug. 26, 2024, as Appl. No. 18/815,286.
Claims priority of application No. 202311083691.1 (CN), filed on Aug. 25, 2023.
Prior Publication US 2025/0068700 A1, Feb. 27, 2025
Int. Cl. G06N 20/00 (2019.01); G06F 18/2415 (2023.01)
CPC G06F 18/2415 (2023.01) [G06N 20/00 (2019.01)] 3 Claims
OG exemplary drawing
 
1. A method for few-shot relation classification and filtering, comprising, executed by a processor:
constructing a coarse-grained filter, the coarse-grained filter being configured for filtering an unlabeled corpus to obtain a first candidate instance with a same entity as a seed instance and a second candidate instance with semantics to the seed instance;
constructing a fine-grained filter, the fine-grained filter being configured for filtering the first candidate instance and the second candidate instance to obtain a third candidate instance with a same relation concept as the seed instance;
pre-training the coarse-grained filter, the fine-grained filter and the classifier respectively based on obtained labeled instances that meet occurring relations;
filtering the corpus based on the pre-trained coarse-grained filter and fine-grained filter to obtain the positive instance set and the negative sample set;
training the pre-trained classifier based on the positive instance set, the negative sample set and the small number of labeled instances belonging to the newly emerging relation;
defining the third candidate instance as a positive instance set, and defining a candidate instance among the first candidate instance and the second candidate instance with a different relation concept from the seed instance as a negative sample set, the relation concept being configured for describing a relation between different instances;
constructing a false positive instance correction module, the false positive instance correction module, executed on the processor, being configured for adjusting and controlling a proportion of the negative sample set used by a classifier during training;
training the classifier based on a number of obtained labeled instances belonging to a newly emerging relation and the positive instance set and the negative sample set adjusted by the false positive instance correction module; and
performing relational classification on few-shot data based on the trained classifier, wherein the constructing the coarse-grained filter comprises:
providing an entity alignment module, executed on the processor, which is configured for identifying the first candidate instance in the corpus with the same entity as the seed instance;
providing a relation siamese network, which is configured for filtering out the second candidate instance with similar semantics to the seed instance by measuring distances between instances in the corpus and a word vector in the seed instance; and
forming the coarse-grained filter based on the entity alignment module and the relation siamese network;
wherein there are a plurality of seed instances, and the filtering out the second candidate instance with similar semantics to the seed instance by measuring distances between instances in the corpus and the word vector in the seed instance comprises:
determining a similarity score between two instances by measuring Euclidean distances between the instances in the corpus and the word vector in the seed instance by the relation siamese network;

OG Complex Work Unit Math
calculating an average similarity score based on similarity scores between respective instances in the corpus and respective seed instances; and
filtering out the second candidate instance with similar semantics to the respective seed instances based on a plurality of the average similarity scores;
wherein σ(·) is a sigmoid activation function, ƒp(·) is used to encode a sentence vector, and a range of SRSN(·) is from 0 to 1, a weight wp and deviation bp are trainable parameters, xsi is the seed instance in the corpus; and
wherein the classifier is facilitated to understand a relation between an input text and the seed instance by changing the input text into a new text that meets the requirements of an input template, thereby improving accuracy of the classifier in few-shot relation classification, and the classifier has a classification effect under a condition of resources, and a recall rate and a F1 value (namely, F1-score, which is a measure of a classification problem, and is a harmonic average of an accuracy rate and the recall rate) has also been improved relative to a baseline, thus overcoming limitation related to information in the input data, and realizing that the classifier is able to learn text semantics and carry out relation classification regardless of a length of an input text sequence, a number of seed instances, or interference from false positive instances, thus addressing shortage of few-shot training data and improving few-shot recognition accuracy;
wherein the pre-training the coarse-grained filter, the fine-grained filter and the classifier respectively based on obtained labeled instances that meet occurring relations comprises:
pre-training the coarse-grained filter based on any two of the labeled instances that meet occurring relations, combined with a cross entropy loss;
constructing different input templates, and pre-training the fine-grained filter based on the different input templates and the labeled instances that meet occurring relations, the input templates containing template format content, the text descriptions in candidate instances, the relation concept and the label column; and
pre-training the classifier based on a few-shot learning mode and the labeled instances that meet occurring relations;
wherein the constructing the different input templates comprises:
constructing an input template with text description and a relation concept at different positions, an input template which is absence of part or all of template format content, and an input template which forms a negative template by changing a relation concept;
correcting parameters of the classifier and a loss function by the false positive instance correction module to be:

OG Complex Work Unit Math
where Bpos represents a batch of positive instances, Bneg represents a batch of negative examples in the negative sample set, custom characterw is a classifier, and u a negative sampling loss coefficient, which is used to control a proportion of negative examples used by the classifier during training,
through training of above different templates, a final learning goal-loss function is minimized for the fine-grained filter.