Training method of few-sample relation classification model and related equipment

By using knowledge graphs and large language models to generate candidate sentences and expand the training set in the field of power design, the problem of the generalization ability and low prediction accuracy of traditional methods in the case of few samples is solved. Achieve higher model accuracy and generalization capabilities.

CN119398195APending Publication Date: 2025-02-07CHINA ENERGY ENG GRP GUANGDONG ELECTRIC POWER DESIGN INST CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411503254.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the field of power design, traditional machine learning methods have problems with low generalization ability and prediction accuracy in relational classification tasks, especially in the case of limited data volume.

Method used

A training method for a small sample relationship classification model is proposed. By obtaining and cleaning business documents, building a knowledge graph, pre-training using the original language model, generating candidate sentences and expanding the training set, and finally training network models through the prototype network model.

Benefits of technology

Effective relationship classification in the case of few samples and zero samples improves the accuracy and generalization ability of the model, reduces the cost of data labeling, and is suitable for knowledge graph construction and information extraction tasks in the field of power design.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119398195A_ABST
    Figure CN119398195A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence, and relates to a training method of a few-sample relation classification model and related equipment, and the method comprises the steps: constructing a business knowledge graph according to cleaning business data; performing data set division on the business knowledge graph to obtain an initial training set, a verification set and a test set; training the original language model according to the initial training set to obtain a pre-trained language model; constructing a seed relationship r and a seed sentence set Sr according to the verification set and the test set, and inputting the seed relationship r and the seed sentence set Sr into a sentence generator to obtain an optimal candidate sentence; expanding the seed sentence set Sr according to the optimal candidate sentence to obtain an expanded training set; and performing model training on the prototype network model according to the extended training set to obtain a target network model. According to the method, relation classification is effectively carried out under the situation of few samples and zero samples, the accuracy and generalization ability of the model are improved, the data annotation cost is reduced, and the method is suitable for knowledge graph construction and information extraction tasks in the field of electric power design.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a training method and related equipment for a few-sample relational classification model. Background Art

[0002] In the field of power design, building an efficient and accurate knowledge graph is a key step in promoting the intelligent transformation of the industry. As power systems become increasingly complex, a large number of documents containing rich business logic have been accumulated in the design work, such as technical specifications, standard manuals, engineering cases, etc. These documents carry professional knowledge in the field of power design, but their unstructured characteristics make information retrieval and utilization inefficient, making it difficult to meet the needs of modern power systems for rapid decision-making and accurate analysis.

[0003] To solve this problem, converting unstructured data into structured knowledge and constructing knowledge graphs has become a research hotspot. Knowledge graphs can display the relationships between entities in an intuitive graphical form, which is not only easy to understand and query, but also supports advanced analysis and intelligent decision-making. However, it is not easy to automatically extract entities and relationships from unstructured text and build high-quality knowledge graphs. This requires not only that the algorithm can understand complex power terms and concepts, but also must have the ability to handle changing contexts.

[0004] Traditional machine learning methods, such as rule-based methods or deep learning models, encounter challenges in constructing knowledge graphs in the field of power design.

[0005] However, the applicant found that the field of power design is highly professional and knowledge is updated quickly, resulting in a shortage of training data. Especially in relationship classification tasks, it often faces the "few sample" problem, that is, the amount of data for certain key relationship types is very limited, which directly affects the generalization ability and prediction accuracy of the model. It can be seen that traditional machine learning methods have problems with low generalization ability and prediction accuracy. Summary of the invention

[0006] The purpose of the embodiments of the present application is to propose a training method and related equipment for a few-sample relationship classification model to solve the problems of low generalization ability and prediction accuracy of traditional machine learning methods.

[0007] In order to solve the above technical problems, the present application embodiment provides a training method for a few-sample relationship classification model, which adopts the following technical solution:

[0008] Get business documents to be processed;

[0009] Performing data cleaning operations on the business document to obtain cleaned business data;

[0010] Constructing a business knowledge graph based on the cleaning business data;

[0011] Divide the business knowledge graph into a data set to obtain an initial training set, a validation set, and a test set;

[0012] Calling an original language model, and performing a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model;

[0013] Construct a seed relationship r and a seed sentence set S according to the verification set and the test set r ;

[0014] The seed relationship r and the seed sentence set S r Inputting into a sentence generator to perform a candidate sentence generation operation to obtain an optimal candidate sentence, wherein the sentence generator is composed of a large language model;

[0015] According to the optimal candidate sentence, the seed sentence set S r Perform an expansion operation to obtain an expanded training set;

[0016] The prototype network model is called, and a network model training operation is performed on the prototype network model according to the extended training set to obtain a target network model.

[0017] Furthermore, the seed relationship r and the seed sentence set S r Inputting the sentence into the sentence generator to generate candidate sentences and obtain the optimal candidate sentence specifically includes the following steps:

[0018] The seed relationship r and the seed sentence set S r Input into the sentence generator to obtain a candidate sentence set C;

[0019] The seed sentence set S is calculated according to the pre-trained language model r and a similarity score of the candidate sentence set C;

[0020] The candidate sentence set C is screened according to the similarity score to obtain the optimal candidate sentence.

[0021] Further, in the step of converting the seed relationship r and the seed sentence set S r After the step of inputting the candidate sentence into the sentence generator to generate the candidate sentence and obtaining the optimal candidate sentence, the following steps are also included:

[0022] Performing a new relation classification operation on the optimal candidate sentence according to a binary classifier to obtain a new relation sentence;

[0023] The seed sentence set S is compared according to the optimal candidate sentence rPerforming an expansion operation to obtain a step of expanding the training set specifically includes the following steps:

[0024] According to the new relation sentence, the seed sentence set S r An expansion operation is performed to obtain the expanded training set.

[0025] Further, in the step of converting the seed relationship r and the seed sentence set S r After the step of inputting into the sentence generator to obtain the optimal candidate sentence, the following steps are also included:

[0026] Receiving feedback information corresponding to the optimal candidate sentence sent by a user terminal;

[0027] The strategy and template of the sentence generator are optimized according to the feedback information.

[0028] Further, in the step of converting the seed relationship r and the seed sentence set S r After the step of inputting into the sentence generator to obtain the optimal candidate sentence, the following steps are also included:

[0029] The optimal candidate sentence is evaluated according to the model evaluation algorithm to obtain an evaluation result, wherein the evaluation result is expressed as:

[0030] Loss = ρL triple +(1-ρ0L E

[0031]

[0032]

[0033] Among them, G i Represents the vector representation of the instance generated by the large language model, R i A represents the vector representation of the original instance used to generate the new instance. i represents the anchor point sample, P i represents the positive samples generated by the large model, N i represents the negative samples generated by the large model, d represents the distance function between samples, and margin represents the distance threshold;

[0034] If the evaluation result meets a preset evaluation threshold, confirming that the large language model can be used to generate instances;

[0035] If the evaluation result does not meet the preset evaluation threshold, it is confirmed that the large language model cannot be used to generate instances, and parameters of the large language model need to be optimized.

[0036] Furthermore, the step of calling the prototype network model and performing a network model training operation on the prototype network model according to the extended training set to obtain a target network model specifically includes the following steps:

[0037] The input data of the prototype network model is constructed according to the extended training set, wherein the input data is represented as:

[0038]

[0039] in, represents the pseudo label, ε represents the smoothing parameter, y i The label representing the original entity;

[0040] Inputting the input data into the prototype network model to train the prototype network model's ability to distinguish relationship types;

[0041] Whenever the large language model generates a candidate sentence, the candidate sentence is constructed as the input data and a model iteration operation is performed on the prototype network model until all candidate sentences generated by the large language model complete the iteration operation, thereby obtaining the target network model.

[0042] In order to solve the above technical problems, the embodiment of the present application also provides a training device for a few-sample relational classification model, which adopts the following technical solution:

[0043] A business document acquisition module is used to acquire business documents to be processed;

[0044] A data cleaning module, used to perform data cleaning operations on the business document to obtain cleaned business data;

[0045] A knowledge graph construction module, used to construct a business knowledge graph based on the cleaning business data;

[0046] A data set partitioning module is used to partition the business knowledge graph into data sets to obtain an initial training set, a validation set, and a test set;

[0047] A language model training module, used for calling an original language model and performing a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model;

[0048] A seed construction module is used to construct a seed relationship r and a seed sentence set S according to the verification set and the test set. r ;

[0049] A candidate sentence generation module is used to generate the seed relationship r and the seed sentence set S rInputting into a sentence generator to perform a candidate sentence generation operation to obtain an optimal candidate sentence, wherein the sentence generator is composed of a large language model;

[0050] An expansion module is used to expand the seed sentence set S according to the optimal candidate sentence r Perform an expansion operation to obtain an expanded training set;

[0051] The network model training module is used to call the prototype network model and perform a network model training operation on the prototype network model according to the extended training set to obtain a target network model.

[0052] Furthermore, the candidate sentence generation module includes:

[0053] The generator input submodule is used to convert the seed relation r and the seed sentence set S r Input into the sentence generator to obtain a candidate sentence set C;

[0054] A similarity score calculation submodule is used to calculate the seed sentence set S according to the pre-trained language model. r and a similarity score of the candidate sentence set C;

[0055] The screening submodule is used to screen the candidate sentence set C according to the similarity score to obtain the optimal candidate sentence.

[0056] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0057] The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the training method of the few-sample relational classification model as described above when executing the computer-readable instructions.

[0058] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0059] The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the training method of the few-sample relational classification model as described above are implemented.

[0060] The present application provides a training method for a few-sample relation classification model, comprising: obtaining a business document to be processed; performing a data cleaning operation on the business document to obtain cleaned business data; constructing a business knowledge graph based on the cleaned business data; dividing the business knowledge graph into a data set to obtain an initial training set, a validation set, and a test set; calling an original language model, and performing a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model; constructing a seed relation r and a seed sentence set according to the validation set and the test set; inputting the seed relation r and the seed sentence set into a sentence generator to perform a candidate sentence generation operation to obtain an optimal candidate sentence, wherein the sentence generator is composed of a large language model; performing an expansion operation on the seed sentence set according to the optimal candidate sentence to obtain an extended training set; calling a prototype network model, and performing a network model training operation on the prototype network model according to the extended training set to obtain a target network model. Compared with the prior art, the present application effectively performs relation classification in few-sample and zero-sample scenarios, improves the accuracy and generalization ability of the model, reduces the data annotation cost, and is suitable for knowledge graph construction and information extraction tasks in the field of power design. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0062] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0063] Figure 2 It is a flowchart for implementing the training method of the few-sample relation classification model provided in the embodiment of the present application;

[0064] Figure 3 It is a system diagram for implementing the training method of the few-sample relation classification model provided in the embodiment of the present application;

[0065] Figure 4 This is a schematic diagram of the effect of an embodiment of the present application, which is divided into a support set and a query set according to relationship distribution;

[0066] Figure 5 It is a structural schematic diagram of a training device for a few-sample relational classification model provided in an embodiment of the present application;

[0067] Figure 6 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0068] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0069] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0070] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0071] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0072] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0073] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to the laptop computer 1011, tablet computer 1012 or mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.

[0074] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .

[0075] It should be noted that the training method for the few-sample relational classification model provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the training device for the few-sample relational classification model is generally set in the server / terminal device.

[0076] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0077] Continue to refer Figure 2 as well as Figure 3 , showing a flow chart and system diagram of an embodiment of a training method for a few-sample relational classification model according to the present application. The training method for a few-sample relational classification model comprises: step S201, step S202, step S203, step S204, step S205, step S206, step S207, step S208 and step S209.

[0078] In step S201, a business document to be processed is obtained.

[0079] In step S202, a data cleansing operation is performed on the business document to obtain cleansed business data.

[0080] In an embodiment of the present application, structured business data is cleaned out from business documents in the field of power design, including power equipment, system architecture, business processes, etc.

[0081] In step S203, a business knowledge graph is constructed based on the cleansing business data.

[0082] In an embodiment of the present application, a business ontology in the power field is constructed based on the cleaned data to form a knowledge graph in the power design field.

[0083] In step S204, the business knowledge graph is divided into data sets to obtain an initial training set, a validation set, and a test set.

[0084] In the embodiment of the present application, the constructed data set is divided into a training set, a validation set and a test set according to the relationship distribution. The training set is used to train the pre-trained language model and as part of the query set, and the validation set and the test set are used for model evaluation and selection of new relationship instances.

[0085] In an embodiment of the present application, the data set is divided into a support set (S) and a query set (Q) according to the relationship distribution. The support set is used to train the pre-trained language model to calculate the degree of similarity between the sentences generated by the large model and the seed sentences, while the query set is used for verification and testing. From the verification set or the test set, a new relationship r that has not been seen in the model training and k instances of the relationship are randomly selected to construct a seed sentence set of the new relationship r. Subsequently, the entity pairs of the seed sentences are extracted, and the seed sentence entity set and the relevant semantic information obtained by linking to the knowledge graph and the relevant hyponymous and hyponymous words are input into the large language model to generate a set of candidate sentences that are highly similar to the seed sentence set in terms of pattern and semantics. The specific logic is similar to Figure 4 effect.

[0086] In step S205, the original language model is called, and a language model training operation is performed on the original language model according to the initial training set to obtain a pre-trained language model.

[0087] In step S206, a seed relationship r and a seed sentence set S are constructed based on the validation set and the test set. r .

[0088] In an embodiment of the present application, a new relation r that has not been seen by the model and k instances of the relation are randomly selected from the validation set or the test set to construct a seed sentence set Sr of the new relation r. For example, if the new relation r is "transmission", the seed sentence set Sr may include the following sentences:

[0089] "Generators transmit electricity through transformers."

[0090] "Electricity is transmitted through transmission lines to substations."

[0091] In step S207, the seed relationship r and the seed sentence set S r The sentence is input into a sentence generator to generate candidate sentences and obtain the optimal candidate sentence, wherein the sentence generator is composed of a large language model.

[0092] In the embodiment of the present application, a large language model (such as GPT-4) is used to generate a candidate sentence set C. The specific steps are as follows:

[0093] Input the entity pairs and relationship prompts in the seed sentence, such as "the relationship between [entity 1] and [entity 2] is [relationship]", and let the model generate similar sentences. Moreover, since most model generation is based on context generation, this actually has little effect on our few-shot relationship classification task. Therefore, the upper and lower relationship words in the knowledge graph are used as auxiliary information for the large model to generate highly similar but more diverse relationship instances. According to the distance of the knowledge graph triple embedding, similar triplets or similar relationships are calculated, and input into the prompt of the large model to finally generate highly relevant instances. There are two ways of generation here: the first is to generate instances based on similar or identical relationships, but the entity pairs obtained are not necessarily the types we care about. The second is to generate some irrelevant instances based on the same or similar entity pairs but different relationships.

[0094] Example prompt: "The relationship between a generator and a transformer is transmission." Model generation: "The transformer transmits power through the generator."

[0095] The specific format of the prompt can be designed as follows:

[0096] "Given the relationship'[relation]'between[entity1]and[entity2],generate a sentence that illustrates this relationship.'[entity1]'can be replaced by'[similar entity1]'.'[relation]'can be replaced by'[similarrelation]'."

[0097] Specific example:

[0098] Prompt to enter: "Given the relationship'transmit'between'generator'and'transformer',generate a sentence that illustrates this relationship."

[0099] Model output: “The transformer transmits electricity from the generator.”

[0100] In step S208, the seed sentence set S is sorted according to the optimal candidate sentence. rPerform an expansion operation to obtain an expanded training set.

[0101] In the embodiment of the present application, the description information is injected into the entity relationship pair in combination with the constructed knowledge graph. The specific steps are as follows:

[0102] (1) Extract new relationship instances and corresponding description information from the knowledge graph, such as the “transmission” relationship between “generator” and “transformer”.

[0103] (2) Inject this description information into new relation instances to form an expanded training set.

[0104] A prototype network model is trained using the expanded dataset to improve the classification accuracy and generalization ability of new relations.

[0105] In step S209, the prototype network model is called, and a network model training operation is performed on the prototype network model according to the extended training set to obtain a target network model.

[0106] In an embodiment of the present application, a training method for a few-sample relation classification model is provided, including: obtaining a business document to be processed; performing a data cleaning operation on the business document to obtain cleaned business data; constructing a business knowledge graph based on the cleaned business data; dividing the data set of the business knowledge graph to obtain an initial training set, a validation set, and a test set; calling the original language model, and performing a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model; constructing a seed relation r and a seed sentence set according to the validation set and the test set; inputting the seed relation r and the seed sentence set into a sentence generator to perform a candidate sentence generation operation to obtain an optimal candidate sentence, wherein the sentence generator is composed of a large language model; performing an expansion operation on the seed sentence set according to the optimal candidate sentence to obtain an extended training set; calling a prototype network model, and performing a network model training operation on the prototype network model according to the extended training set to obtain a target network model. Compared with the prior art, the present application effectively performs relation classification in few-sample and zero-sample scenarios, improves the accuracy and generalization ability of the model, reduces the data annotation cost, and is suitable for knowledge graph construction and information extraction tasks in the field of power design.

[0107] In some optional implementations of the embodiments of the present application, the seed relationship r and the seed sentence set S are r Inputting the sentence into the sentence generator to generate candidate sentences and obtain the optimal candidate sentence specifically includes the following steps:

[0108] The seed relation r and the seed sentence set S r Input to the sentence generator to obtain the candidate sentence set C;

[0109] Calculate the seed sentence set S based on the pre-trained language model r and the similarity scores of the candidate sentence set C;

[0110] The candidate sentence set C is screened according to the similarity score to obtain the optimal candidate sentence.

[0111] In an embodiment of the present application, a pre-trained language model (such as BERT) is used to calculate the similarity between the seed sentence set Sr and the candidate sentence set C.

[0112] The top-K optimal candidate sentences are screened out through similarity scoring to ensure that the generated sentences are highly semantically related to the seed sentences.

[0113] sim(x,y)=σ(w T (f(x)-f(y)) 2 +b)

[0114] Where sim(x,y) takes two instances as input and outputs a value between 0 and 1, indicating the probability that the two instances have the same relation type. f(x0) and f(y) are encoder functions with shared parameters.

[0115] In some optional implementations of the embodiments of the present application, the seed relationship r and the seed sentence set S r After the step of inputting the candidate sentence into the sentence generator to generate the candidate sentence and obtaining the optimal candidate sentence, the following steps are also included:

[0116] Perform new relation classification operation on the optimal candidate sentence according to the binary classifier to obtain a new relation sentence;

[0117] According to the optimal candidate sentence, the seed sentence set S r Performing an expansion operation to obtain a step of expanding the training set specifically includes the following steps:

[0118] According to the new relation sentence, the seed sentence set S r Perform an expansion operation to obtain an expanded training set.

[0119] In the embodiment of the present application, a binary classifier is fine-tuned based on the data (including positive and negative examples) generated by the large language model to determine whether the instance generated by the large model belongs to the new relation r. Instances with high confidence are added to the seed sentence set, the seed set Sr is expanded, and the relation instances are gradually enriched. Since there is no basic fact about the length of the new instance, we iterate from 1 to the [MASK] tag, where is the length of the example entity. Then, we use the pseudo-log likelihood for all generated new instances Sort and select the best new instances:

[0120]

[0121] s i It is the conditional probability of predicting the i-th subword based on the i-1 subwords generated previously.

[0122] In some optional implementations of the embodiments of the present application, in the above-mentioned seed relationship r and the seed sentence set S r After the step of inputting into the sentence generator to obtain the optimal candidate sentence, the following steps are also included:

[0123] Receiving feedback information corresponding to the optimal candidate sentence sent by a user terminal;

[0124] The strategy and template of the sentence generator are optimized according to the feedback information.

[0125] In the embodiment of the present application, feedback collection: the generated examples are applied to actual tasks and their performance data is collected. This data may include the accuracy, efficiency or user feedback of the task. The examples are further evaluated using the information in the concept knowledge graph. The knowledge graph provides rich semantic information to help judge the quality and relevance of the prompt instance.

[0126] Feedback processing: Analyze the collected feedback data to evaluate the effectiveness of the prompt instance. Based on the feedback data, identify the instances with excellent performance and the instances that need improvement. Combine the feedback data with the patterns in the prototype network to further optimize the instance generation strategy.

[0127] Selection mapping: Use the information in the concept knowledge graph to guide the selection of prompt strategies and templates. The knowledge graph provides a rich set of concepts and relationships that can be used to adjust the strategy of the prompt generator. According to the performance and feedback data of the instance, select the appropriate prompt strategy and template and map it to the parameters or generation rules of the generator.

[0128] Optimization and evolution: Based on the feedback data and the information in the knowledge graph, the prompt generator’s strategy and templates are optimized. Reinforcement learning or adaptive algorithms can be used to adjust the generator’s parameters to improve the quality and relevance of the prompts. The prompt generator’s performance is gradually improved by continuously iterating to generate new instances, collect feedback, and optimize strategies.

[0129] In some optional implementations of the embodiments of the present application, the seed relationship r and the seed sentence set S r After the step of inputting into the sentence generator to obtain the optimal candidate sentence, the following steps are also included:

[0130] The optimal candidate sentence is evaluated according to the model evaluation algorithm to obtain the evaluation result, where the evaluation result is expressed as:

[0131] Loss = ρL triple +(1-ρ)L E

[0132]

[0133] Among them, G i Represents the vector representation of the instance generated by the large language model, R i A represents the vector representation of the original instance used to generate the new instance. i represents the anchor point sample, P i represents the positive samples generated by the large model, N i represents the negative samples generated by the large model, d represents the distance function between samples, and margin represents the distance threshold;

[0134] If the evaluation result meets the preset evaluation threshold, it is confirmed that the large language model can be used to generate instances;

[0135] If the evaluation result does not meet the preset evaluation threshold, it is confirmed that the large language model cannot be used to generate instances, and the parameters of the large language model need to be optimized.

[0136] In some optional implementations of the embodiments of the present application, the above-mentioned steps of calling the prototype network model and performing a network model training operation on the prototype network model according to the extended training set to obtain the target network model specifically include the following steps:

[0137] The input data of the prototype network model is constructed according to the extended training set, where the input data is expressed as:

[0138]

[0139] in, represents the pseudo label, ε represents the smoothing parameter, y i The label representing the original entity;

[0140] Inputting the input data into the prototype network model to train the prototype network model's ability to distinguish relationship types;

[0141] Whenever the large language model generates a candidate sentence, the candidate sentence is constructed as input data and the prototype network model is iterated until all candidate sentences generated by the large language model have completed the iteration operation, and then the target network model is obtained.

[0142] In the embodiment of the present application, the training steps of the prototype network model include:

[0143] (1) Use new high-confidence relation instances generated by the large language model to construct the input of the prototype network.

[0144]

[0145] For each given entity mention m, when the type words output by the MLM head become stable, we can generate new instances after half of the total training time. i , using the soft distribution on y as its pseudo label ε is the smoothing parameter.

[0146] (2) Train the model to distinguish different types of relationships and improve the performance of the model on new relationships.

[0147] (3) The large model bootstrap generation module is continuously iterated, the prototype of each iteration is calculated, and it is optimized in combination with the support set prototype to obtain the final prototype used for relationship classification.

[0148]

[0149] Among them, α, β, and γ are the embedded weights obtained through learning and are used to optimize the effect of the prototype.

[0150] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0151] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0152] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0153] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0154] Further references Figure 5 , as a response to the above Figure 2 The present application provides an embodiment of a training device for a few-sample relational classification model. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0155] like Figure 5 As shown, the training device 200 of the few-sample relational classification model in the embodiment of the present application includes:

[0156] A business document acquisition module 210 is used to acquire a business document to be processed;

[0157] The data cleaning module 220 is used to perform data cleaning operations on business documents to obtain cleaned business data;

[0158] A knowledge graph construction module 230 is used to construct a business knowledge graph based on the cleaning business data;

[0159] The data set partitioning module 240 is used to partition the business knowledge graph into data sets to obtain an initial training set, a validation set, and a test set;

[0160] The language model training module 250 is used to call the original language model and perform a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model;

[0161] The seed construction module 260 is used to construct the seed relationship r and the seed sentence set S according to the verification set and the test set. r ;

[0162] The candidate sentence generation module 270 is used to generate the seed relationship r and the seed sentence set S r Input to the sentence generator to generate candidate sentences and obtain the optimal candidate sentence, wherein the sentence generator is composed of a large language model;

[0163] The expansion module 280 is used to expand the seed sentence set S according to the optimal candidate sentence r Perform an expansion operation to obtain an expanded training set;

[0164] The network model training module 290 is used to call the prototype network model and perform a network model training operation on the prototype network model according to the extended training set to obtain a target network model.

[0165] In an embodiment of the present application, a training device 200 for a few-sample relational classification model is provided, including: a business document acquisition module 210, used to acquire business documents to be processed; a data cleaning module 220, used to perform data cleaning operations on business documents to obtain cleaned business data; a knowledge graph construction module 230, used to construct a business knowledge graph based on the cleaned business data; a data set partitioning module 240, used to perform data set partitioning on the business knowledge graph to obtain an initial training set, a validation set, and a test set; a language model training module 250, used to call the original language model, and perform a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model; a seed construction module 260, used to construct a seed relationship r and a seed sentence set S according to the validation set and the test set. r ; Candidate sentence generation module 270, for seed relationship r and seed sentence set S r The input is sent to the sentence generator to generate candidate sentences to obtain the optimal candidate sentence, wherein the sentence generator is composed of a large language model; the expansion module 280 is used to generate the seed sentence set S according to the optimal candidate sentence. r The network model training module 290 is used to call the prototype network model and perform the network model training operation on the prototype network model according to the extended training set to obtain the target network model. Compared with the prior art, the present application effectively classifies relationships in the context of few samples and zero samples, improves the accuracy and generalization ability of the model, reduces the cost of data annotation, and is suitable for knowledge graph construction and information extraction tasks in the field of power design.

[0166] In some optional implementations of the embodiments of the present application, the candidate sentence generation module includes:

[0167] The generator input submodule is used to convert the seed relation r and the seed sentence set S r Input to the sentence generator to obtain the candidate sentence set C;

[0168] The similarity score calculation submodule is used to calculate the seed sentence set S based on the pre-trained language model r and the similarity scores of the candidate sentence set C;

[0169] The screening submodule is used to screen the candidate sentence set C according to the similarity score to obtain the optimal candidate sentence.

[0170] To solve the above technical problems, the present application also provides a computer device. Figure 6 , Figure 6 This is a basic structural block diagram of a computer device according to an embodiment of the present application.

[0171] The computer device 300 includes a memory 310, a processor 320, and a network interface 330 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 300 having components 310-330, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0172] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0173] The memory 310 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 310 can be an internal storage unit of the computer device 300, such as a hard disk or memory of the computer device 300. In other embodiments, the memory 310 can also be an external storage device of the computer device 300, such as a plug-in hard disk equipped on the computer device 300, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Of course, the memory 310 can also include both the internal storage unit of the computer device 300 and its external storage device. In the embodiment of the present application, the memory 310 is generally used to store the operating system and various application software installed on the computer device 300, such as computer-readable instructions of the training method of the few-sample relational classification model. In addition, the memory 310 can also be used to temporarily store various data that have been output or are to be output.

[0174] The processor 320 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 320 is generally used to control the overall operation of the computer device 300. In the embodiment of the present application, the processor 320 is used to run the computer-readable instructions or process data stored in the memory 310, such as computer-readable instructions for running the training method of the few-sample relational classification model.

[0175] The network interface 330 may include a wireless network interface or a wired network interface. The network interface 330 is generally used to establish a communication connection between the computer device 300 and other electronic devices.

[0176] The computer device provided in this application effectively performs relationship classification in few-sample and zero-sample scenarios, improves the accuracy and generalization ability of the model, reduces data annotation costs, and is suitable for knowledge graph construction and information extraction tasks in the field of power design.

[0177] The present application also provides another implementation, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the training method for the few-sample relationship classification model as described above.

[0178] The computer-readable storage medium provided in this application effectively performs relationship classification in few-sample and zero-sample scenarios, improves the accuracy and generalization ability of the model, reduces data annotation costs, and is suitable for knowledge graph construction and information extraction tasks in the field of power design.

[0179] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0180] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A training method for a few-sample relational classification model, characterized in that: The steps include: Get business documents to be processed; Performing data cleaning operations on the business document to obtain cleaned business data; Constructing a business knowledge graph based on the cleaning business data; Divide the business knowledge graph into a data set to obtain an initial training set, a validation set, and a test set; Calling an original language model, and performing a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model; Construct a seed relationship r and a seed sentence set S according to the verification set and the test set r ; The seed relationship r and the seed sentence set S r Inputting into a sentence generator to perform a candidate sentence generation operation to obtain an optimal candidate sentence, wherein the sentence generator is composed of a large language model; According to the optimal candidate sentence, the seed sentence set S r Perform an expansion operation to obtain an expanded training set; The prototype network model is called, and a network model training operation is performed on the prototype network model according to the extended training set to obtain a target network model.

2. The training method for a few-sample relational classification model according to claim 1, characterized in that: The seed relationship r and the seed sentence set S r Inputting the sentence into the sentence generator to generate candidate sentences and obtain the optimal candidate sentence specifically includes the following steps: The seed relationship r and the seed sentence set S r Input into the sentence generator to obtain a candidate sentence set C; The seed sentence set S is calculated according to the pre-trained language model r and a similarity score of the candidate sentence set C; The candidate sentence set C is screened according to the similarity score to obtain the optimal candidate sentence.

3. The training method for a few-sample relational classification model according to claim 1, characterized in that: In the step of combining the seed relation r and the seed sentence set S r After the step of inputting the candidate sentence into the sentence generator to generate the candidate sentence and obtaining the optimal candidate sentence, the following steps are also included: Performing a new relation classification operation on the optimal candidate sentence according to a binary classifier to obtain a new relation sentence; The seed sentence set S is compared according to the optimal candidate sentence r Performing an expansion operation to obtain a step of expanding the training set specifically includes the following steps: According to the new relation sentence, the seed sentence set S r An expansion operation is performed to obtain the expanded training set.

4. The training method for a few-sample relational classification model according to claim 1, characterized in that: In the step of combining the seed relation r and the seed sentence set S r After the step of inputting into the sentence generator to obtain the optimal candidate sentence, the following steps are also included: Receiving feedback information corresponding to the optimal candidate sentence sent by a user terminal; The strategy and template of the sentence generator are optimized according to the feedback information.

5. The training method for a few-sample relational classification model according to claim 1, characterized in that: In the step of combining the seed relation r and the seed sentence set S r After the step of inputting into the sentence generator to obtain the optimal candidate sentence, the following steps are also included: The optimal candidate sentence is evaluated according to the model evaluation algorithm to obtain an evaluation result, wherein the evaluation result is expressed as: Loss=ρL triple +(1-ρ0L E Among them, G i Represents the vector representation of the instance generated by the large language model, R i A represents the vector representation of the original instance used to generate the new instance. i represents the anchor point sample, P i represents the positive samples generated by the large model, N i represents the negative samples generated by the large model, d represents the distance function between samples, and margin represents the distance threshold; If the evaluation result meets a preset evaluation threshold, confirming that the large language model can be used to generate instances; If the evaluation result does not meet the preset evaluation threshold, it is confirmed that the large language model cannot be used to generate instances, and parameters of the large language model need to be optimized.

6. The training method for a few-sample relational classification model according to claim 1, characterized in that: The step of calling the prototype network model and performing a network model training operation on the prototype network model according to the extended training set to obtain a target network model specifically includes the following steps: The input data of the prototype network model is constructed according to the extended training set, wherein the input data is represented as: in, represents the pseudo label, ε represents the smoothing parameter, y i The label representing the original entity; Inputting the input data into the prototype network model to train the prototype network model's ability to distinguish relationship types; Whenever the large language model generates a candidate sentence, the candidate sentence is constructed as the input data and a model iteration operation is performed on the prototype network model until all candidate sentences generated by the large language model complete the iteration operation, thereby obtaining the target network model.

7. A training device for a few-sample relational classification model, characterized in that: include: A business document acquisition module is used to acquire business documents to be processed; A data cleaning module, used to perform data cleaning operations on the business document to obtain cleaned business data; A knowledge graph construction module, used to construct a business knowledge graph based on the cleaning business data; A data set partitioning module is used to partition the business knowledge graph into data sets to obtain an initial training set, a validation set, and a test set; A language model training module, used for calling an original language model and performing a language model training operation on the original language model according to the initial training set to obtain a pre-trained language model; A seed construction module is used to construct a seed relationship r and a seed sentence set S according to the verification set and the test set. r ; A candidate sentence generation module is used to generate the seed relationship r and the seed sentence set S r Inputting into a sentence generator to perform a candidate sentence generation operation to obtain an optimal candidate sentence, wherein the sentence generator is composed of a large language model; An expansion module is used to expand the seed sentence set S according to the optimal candidate sentence r Perform an expansion operation to obtain an expanded training set; The network model training module is used to call the prototype network model and perform a network model training operation on the prototype network model according to the extended training set to obtain a target network model.

8. The training device for a few-sample relational classification model according to claim 7, characterized in that: The candidate sentence generation module comprises: The generator input submodule is used to convert the seed relation r and the seed sentence set S r Input into the sentence generator to obtain a candidate sentence set C; A similarity score calculation submodule is used to calculate the seed sentence set S according to the pre-trained language model. r and a similarity score of the candidate sentence set C; The screening submodule is used to screen the candidate sentence set C according to the similarity score to obtain the optimal candidate sentence.

9. A computer device comprising a memory and a processor, characterized in that: The memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the training method for the few-sample relational classification model as described in any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the training method of the few-sample relational classification model according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Model training and model question and answer method and device, electronic equipment and storage medium

    CN120523912A

  • Training sample generation method and training method for domain-specific large language model

    CN120892822A