Bidirectional relation integration graph-based common sense knowledge generation method and system, storage medium and terminal

Through comparative pre-training and task-driven instruction tuning based on the bidirectional relationship integration graph, the problems of high cost, limited scale and insufficient semantic understanding in acquiring common sense knowledge graphs are solved, and high-quality, diverse and systematic knowledge generation is achieved. , overcoming the limitations of one-way relationships and improving the understanding ability and generation efficiency of knowledge graphs.

CN118733787AActive Publication Date: 2024-10-01UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202410848125.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-01
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

Existing commonsense knowledge graph acquisition methods rely on node levels and one-way relationships, resulting in high costs, limited scale, insufficient semantic understanding, lack of systematic solutions, and the 'inversion curse' problem, and the quality and diversity of generated knowledge are insufficient. .

Method used

A contrastive pre-training method based on a bidirectional relationship integration graph is used to generate high-quality common sense knowledge by constructing a symmetric graph, utilizing forward and reverse contrastive learning and task-driven instruction tuning, combined with a multi-layer scoring mechanism.

Benefits of technology

It reduces the cost of knowledge acquisition, expands the scale of the knowledge graph, solves the limitations of one-way relationships, improves the depth of semantic understanding and the efficiency and quality of knowledge generation, and provides a systematic solution to ensure the accuracy and novelty of generated knowledge. sex.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733787A_ABST
    Figure CN118733787A_ABST
Patent Text Reader

Abstract

The invention discloses a common sense knowledge generation method and system based on a bidirectional relation integration graph, a storage medium and a terminal, and belongs to the field of data processing, the method comprises the following steps: S1, constructing a bidirectional relation data set: constructing a symmetric graph by introducing a reverse relation; s2, comparison pre-training: utilizing forward and reverse comparison learning to enhance bidirectional understanding of the common knowledge by the model; s3, instruction adjustment and optimization: performing task-driven instruction adjustment and optimization on the basis of comparison and pre-training to ensure that the model effectively generates common knowledge conforming to requirements; s4, judging whether the adjusted and optimized model reaches the standard or not, and if not, returning to the step S3 to continue adjusting and optimizing; and S5, generating new knowledge by using the adjusted model. By comparing pre-training and task-driven instruction tuning, the efficiency and quality of generating common knowledge are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a method, system, storage medium and terminal for generating common sense knowledge based on a bidirectional relationship integrated graph. Background Art

[0002] Commonsense Knowledge Graph Acquisition (CKGA) is crucial in many knowledge-intensive applications. Traditional CKGA methods rely on node-level and unidirectional relationships, which makes them shallow in understanding the relationship between entities and relationships. In addition, these methods also require expensive and labor-intensive manual annotations, resulting in a lack of diversity and quality in the generated commonsense knowledge.

[0003] The existing CKGA methods are mainly divided into the following categories:

[0004] 1. Crowdsourcing-based methods: For example, WordNet and ConceptNet, which obtain high-quality common sense knowledge through annotation by human experts or the general public. However, these methods are costly and difficult to scale up on a large scale.

[0005] 2. Language pattern-based methods: These methods obtain common sense knowledge by extracting patterns from text. These methods usually involve complex engineering processes such as document retrieval, rule-based extraction, and knowledge clustering. The quality of such methods is unstable because the effect of each step will significantly affect the final result.

[0006] 3. Language model (LM) based methods: Using pre-trained language models (such as the GPT series) to generate knowledge, these methods query the model through carefully designed prompt words to generate knowledge that conforms to specific relationships. However, existing methods usually deal with node-level relationships and ignore the semantics of reverse relationships, which leads to limitations in the model's understanding of relationships.

[0007] In addition to the above popular methods, completion methods based on large language models (LLMs) such as ChatGPT and GPT-4 have shown the potential to handle various complex problems. However, directly using these models for common sense knowledge generation has quality, format and novelty issues.

[0008] In summary, the defects and shortcomings of the prior art are as follows:

[0009] 1. High cost and limited scale

[0010] Although traditional crowdsourcing methods can obtain high-quality common sense resources, their labor intensity and cost limit the scalability of resources. Although language-based methods solve the cost problem to a certain extent, the quality and stability of the knowledge they generate are limited by multiple steps such as text selection and extraction strategies.

[0011] 2. Limitations of One-Way Relationships

[0012] Most existing methods focus on unidirectional relationships (e.g. A is part of B) and ignore reverse relationships (e.g. B contains A). This limitation leads to obvious defects in knowledge graphs when dealing with complex reasoning tasks. For example, when learning "A is B", it may not be possible to automatically infer "B is A". This problem is called the "Reversal Curse".

[0013] 3. Insufficient semantic understanding

[0014] Existing methods often use node-level processing to process common sense knowledge, directly inputting entities and relationships into the model. This method fails to fully utilize contextual information, resulting in insufficient semantic understanding. For example, many methods fail to effectively combine contextual semantic information when processing text, resulting in unsatisfactory knowledge extraction results.

[0015] 4. High cost of manual labeling

[0016] Although crowdsourcing-based methods can obtain high-quality common sense knowledge, they rely heavily on manual annotations. The process is time-consuming, labor-intensive and costly, which limits the scale and scalability of resources.

[0017] 5. Insufficient generation quality and diversity

[0018] The common sense knowledge generated by existing methods is insufficient in quality and diversity, and often requires further manual verification and adjustment.

[0019] 6. Lack of systematic solutions

[0020] Existing contrastive learning methods have achieved certain results in the task of knowledge graph completion, but most methods only focus on a specific aspect, such as optimizing the model architecture or improving the learning algorithm, and lack a comprehensive, closed-loop system solution. Summary of the invention

[0021] The purpose of the present invention is to overcome at least one technical problem existing in the prior art, and to provide a common sense knowledge generation method, system, storage medium and terminal based on a bidirectional relationship integrated graph to achieve the generation of high-quality common sense knowledge.

[0022] The objective of the present invention is achieved through the following technical solutions:

[0023] In a first aspect, a common sense knowledge generation method based on a bidirectional relationship integration graph is provided, the method comprising the following steps:

[0024] S1. Constructing a bidirectional relationship dataset: constructing a symmetric graph by introducing reverse relationships;

[0025] S2, contrastive pre-training: using forward and reverse contrastive learning to enhance the model’s bidirectional understanding of common sense knowledge;

[0026] S3, instruction tuning: Perform task-driven instruction tuning based on pre-training to ensure that the model effectively generates common sense knowledge that meets the requirements;

[0027] S4: Determine whether the tuned model meets the standard. If not, return to step S3 to continue tuning.

[0028] S5. Use the tuned model to generate new knowledge.

[0029] Preferably, the method further comprises the steps of:

[0030] S6. Determine whether the generated new knowledge is reasonable.

[0031] Preferably, constructing a bidirectional relationship dataset includes:

[0032] Generate forward and reverse triplets using the seed dataset and template sentences.

[0033] Preferably, the comparative pre-training includes:

[0034] Using positive and negative contrastive learning, the similarity between positive and negative samples is calculated, the contrastive learning loss function is optimized, and the model weights are updated.

[0035] Preferably, the instruction tuning includes:

[0036] Construct a forward instruction fine-tuning dataset, a reverse instruction fine-tuning dataset, and a binary classification instruction fine-tuning dataset;

[0037] Three instruction fine-tuning datasets are used for instruction fine-tuning, and the ratio of the three tasks is 8:1:1.

[0038] Preferably, the step of determining whether the optimized model meets the requirements includes:

[0039] Through preliminary filtering and multi-layer scoring mechanisms, the accuracy and novelty of the generated knowledge are ensured.

[0040] Preferably, the bias-removed BERT model is used for preliminary filtering, and the multi-layer scoring mechanism adopts a scoring model that combines a three-level scoring system and novelty calculation.

[0041] In a second aspect, a common sense knowledge generation system based on a bidirectional relationship integrated graph is provided, the system comprising:

[0042] A bidirectional relationship dataset construction module is used to construct a bidirectional relationship dataset, wherein a symmetric graph is constructed by introducing a reverse relationship;

[0043] The contrastive pre-training module is used for contrastive pre-training, which uses forward and reverse contrastive learning to enhance the model's bidirectional understanding of common sense knowledge;

[0044] The instruction tuning module is used for instruction tuning, which performs task-driven instruction tuning based on pre-training to ensure that the model effectively generates common sense knowledge that meets the requirements;

[0045] The model tuning judgment module is used to judge whether the tuned model meets the standard. If not, it returns to the instruction tuning module to continue tuning;

[0046] The new knowledge generation module is used to generate new knowledge using the tuned model.

[0047] According to a third aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any one of the common sense knowledge generation methods is implemented.

[0048] In a fourth aspect, a terminal is provided, including a memory and a processor, wherein the memory stores computer instructions executable on the processor, and the processor executes the common sense knowledge generating method when executing the computer instructions.

[0049] It should be further explained that the technical features corresponding to the above options can be combined or replaced with each other to form a new technical solution if there is no conflict.

[0050] Compared with the prior art, the present invention shows significant advantages in the field of common sense knowledge graph acquisition by introducing the bidirectional relational integrated graph comparison pre-training method (BIRGHT). The main beneficial effects are as follows:

[0051] 1. Solved the problems of high cost and limited scale

[0052] Although traditional crowdsourcing methods can obtain high-quality common sense resources, their labor intensity and cost limit the scalability of resources. This paper introduces large language models (LLMs), such as ChatGPT, GPT-4, etc., and uses comparative pre-training and task-driven instruction tuning to reduce the cost of knowledge acquisition and expand the scale of the knowledge graph.

[0053] 2. Overcoming the limitations of one-way relationships

[0054] Most existing methods focus on unidirectional relationships (such as A is part of B) and ignore reverse relationships (such as B contains A). This limitation leads to obvious defects in knowledge graphs when dealing with complex reasoning tasks. This invention solves the "Reversal Curse" problem and improves the model's ability to understand relationships by constructing a symmetric graph of forward and reverse relationships and using a bidirectional relationship integration graph to ensure that the model can learn both forward and reverse relationships at the same time.

[0055] 3. Improved semantic understanding depth

[0056] Existing methods mostly use node-level processing when processing common sense knowledge, directly input entities and relationships into the model, and fail to make full use of context information, resulting in insufficient semantic understanding. This invention enhances the model's ability to understand context by designing natural language template sentences and converting each relationship into a diversified sentence template, thereby improving the depth and accuracy of semantic understanding.

[0057] 4. Provides a systematic solution

[0058] Existing contrastive learning methods have achieved certain results in knowledge graph completion tasks, but most methods only focus on a specific aspect and lack a comprehensive, closed-loop system solution. This invention provides a systematic solution by introducing corpus construction, contrastive pre-training, task-driven instruction tuning, and multi-layer filtering and evaluation mechanisms to ensure the overall improvement of the quality and diversity of the generated knowledge.

[0059] 5. Innovative filtering and scoring mechanism

[0060] The present invention uses the BERT model based on bias removal for preliminary filtering, combined with a three-level scoring system and a scoring model for novelty calculation to ensure the accuracy and novelty of the generated knowledge. The three-level scoring system ensures the reliability of the evaluation results through multi-layer evaluation of GPT-3.5 and GPT-4, combined with manual scoring. The novelty scoring overcomes the limitations of the character matching method through cosine similarity calculation based on the embedding model, ensuring the semantic consistency and innovation of the newly generated knowledge.

[0061] 6. Improved the efficiency and quality of knowledge generation

[0062] By comparing pre-training and task-driven instruction tuning, the present invention has achieved significant improvements in the efficiency and quality of generating common sense knowledge. Using a variety of beam search methods and refined instruction tuning, the model can generate high-quality knowledge triples that meet the requirements, and ensure its rationality and innovation through a multi-layer filtering and scoring mechanism. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Figure 1A flow chart of a common sense knowledge generation method based on a bidirectional relationship integration graph is shown in an embodiment of the present invention;

[0064] Figure 2 A flowchart of a common sense knowledge generation method including a new knowledge judgment step according to an embodiment of the present invention;

[0065] Figure 3 This is a diagram showing the overall framework of an embodiment of the present invention;

[0066] Figure 4 A schematic diagram of the structure of instruction fine-tuning content shown in an embodiment of the present invention;

[0067] Figure 5 A filtering model architecture diagram shown in an embodiment of the present invention;

[0068] Figure 6 A specific implementation flow chart of an embodiment of the present invention;

[0069] Figure 7 A schematic diagram of constructing a forward and reverse data set and comparative learning pre-training shown in an embodiment of the present invention;

[0070] Figure 8 A schematic diagram of constructing an instruction fine-tuning data set and instruction fine-tuning according to an embodiment of the present invention. DETAILED DESCRIPTION

[0071] The technical solution of the present invention is clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the accompanying drawings can be arranged and designed in various configurations. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0072] It should be noted that the defects existing in the solutions in the above-mentioned prior art are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above-mentioned problems and the solutions proposed in the embodiments of the present application for the above-mentioned problems below should all be the contributions made by the inventor to the present application in the process of invention and creation, and should not be understood as technical contents known to technical personnel in this field.

[0073] In view of the technical problems pointed out in the background technology, the present invention proposes a new paradigm to expand common sense knowledge by performing comparative pre-training of bidirectional relational integrated graphs (BIRGHT) through the latest basic model. BIRGHT is a complete closed-loop framework, including corpus construction, comparative pre-training, task-driven instruction tuning, filtering strategy and evaluation system. The specific embodiments provided by the present invention are as follows:

[0074] Example 1

[0075] Reference Figure 1 In an exemplary embodiment, a common sense knowledge generation method based on a bidirectional relationship integration graph is provided, the method comprising the following steps:

[0076] S1. Constructing a bidirectional relationship dataset: By introducing reverse relationships to construct a symmetric graph, it provides supplementary information and improves the understanding of the relationship between entities;

[0077] S2, contrastive pre-training: using forward and reverse contrastive learning to enhance the model’s bidirectional understanding of common sense knowledge;

[0078] S3, instruction tuning: Perform task-driven instruction tuning based on pre-training to ensure that the model effectively generates common sense knowledge that meets the requirements;

[0079] S4: Determine whether the tuned model meets the standards. Through preliminary filtering and multi-layer scoring mechanism, ensure the accuracy and novelty of the generated knowledge. If it does not meet the standards, return to step S3 to continue tuning.

[0080] S5. Use the tuned model to generate new knowledge.

[0081] The core of BIRGHT proposed in this invention is to create a symmetric graph by using reverse relations, transform bidirectional relations into sentence-level relations, and solve the "inversion curse" problem by introducing positive and negative example comparative learning, thereby generating high-quality common sense knowledge.

[0082] Example 2

[0083] Based on the inventive concept of Example 1, this example proposes a pre-training method for comparing bidirectional relationship integrated graphs of large models to enhance common sense knowledge, and optimizes the three parts of data set construction, model fine-tuning, filtering and evaluation. The overall architecture of the proposed framework is shown in Figure 3 The following combination Figure 3 Analyze the implementation details of each step.

[0084] First, the dataset is constructed. Traditional methods for acquiring common sense knowledge graphs mostly rely on one-way relationships, which not only limits the breadth of knowledge, but also fails to fully understand the complex relationships between entities. In order to solve this problem, the present invention first proposes a method for constructing reverse and verification datasets, and makes up for this deficiency by introducing reverse relationships and verification corpora.

[0085] The core of this process is to ensure the symmetry of the relations in the corpus by constructing reverse relations, thereby providing richer and more comprehensive context information. Based on existing common sense knowledge graphs (such as Concept Net and ATOMIC), construct a positive and negative relation dataset:

[0086] Forward dataset (D f ): contains the original triple (h, r, t), where h represents the head entity, r represents the relationship, and t represents the tail entity.

[0087] Reverse dataset (D r ): By exchanging the head entity and the tail entity, a new triple (t, r -1 ,h), where r -1 Indicates an inverse relationship.

[0088] Validation dataset (D v ): Construct a validation dataset (t, r, h, l) containing labels for the filtering model. The label is 1 for a reasonable tail entity and the label is 0 for an unreasonable tail entity.

[0089] In order to further enhance the learning effect of the model, the present invention designs a variety of natural language template sentences. First, it is necessary to define template sentences, and define multiple template sentences for each relationship. For example, the template of the relationship "CapableOf" is "[H] can perform [T]", and the template of the reverse relationship "performedBy" is "[T] is an activity was completed by [H]". Then generate sentence pairs according to the templates. For example, the positive triple "(human, CapableOf, love)" generates the sentence pairs "human can perform love." and "love is an activity was completed by human.".

[0090] Furthermore, after the corpus is constructed, the comparative pre-training stage is entered. Through forward and reverse comparative learning, the model can more comprehensively understand the bidirectional relationship of common sense knowledge. In the comparative pre-training, the present invention selects the positive relationship triple (h, r, t) and its corresponding reverse relationship triple (t, r', h) as positive example pairs for comparative learning. In each small batch training, the model is optimized by calculating the similarity between the forward and reverse sample pairs.

[0091] In order to enhance the distinguishing ability of the model, three negative sampling strategies are introduced: intra-batch negative sampling, queue negative sampling, and self-similar negative sampling. These negative sampling strategies ensure the diversity and quality of samples, thereby improving the distinguishing ability of the model. The contrast loss function is optimized to maximize the similarity of positive samples and minimize the similarity of negative samples, further improving the semantic understanding depth and generation ability of the model.

[0092] Selection of positive sample pairs: Take the positive triple (h, r, t) as the anchor sample and select the reverse triple (t, r) with deep semantic connection from the reverse dataset.-1 ,h) as positive samples.

[0093] Selection of negative sample pairs: There are three sampling methods for sampling negative sample pairs, including intra-batch negative sampling, queue negative sampling, and self-similar negative sampling, to ensure the diversity and efficiency of negative samples. In-batch negative sampling uses non-anchor samples in the same batch as negative samples to increase the diversity of training samples; queue negative sampling uses a fixed-size queue to save previous batch samples, expands the coverage of negative samples, and improves the generalization ability of the model; self-similar negative sampling selects samples similar to the current sample as negative samples to ensure that the model can recognize subtle semantic differences.

[0094] In order to achieve a more symmetrical and recognizable representation, the present invention adopts an extended InfoNCE loss function, which maximizes the similarity of positive sample pairs and minimizes the similarity of three negative sample pairs. By maximizing the affinity of positive samples and minimizing the affinity of negative samples, the contrastive learning loss function is optimized to enhance the symmetry and discrimination ability of the model.

[0095] The contrastive learning optimization process mainly includes the following steps:

[0096] 1. Input sentence pairs: Input the generated sentence pairs into the model and extract sentence embeddings.

[0097] 2. Calculate similarity: Calculate the similarity between positive sample pairs and negative sample pairs through cosine similarity.

[0098] 3. Optimize the contrastive learning loss function: Substitute the similarity of the positive sample pairs and the negative sample pairs in the input sentence pairs into the loss function, iterate the model, and optimize the loss function. The optimization function for contrastive pre-training is:

[0099]

[0100] Among them, x f and x r denote the embedding of the forward and reverse sentences respectively, x j represents the embedding of negative samples, and τ is the temperature parameter.

[0101] Furthermore, after completing the comparative pre-training, the model has acquired a certain ability to generate common sense knowledge. However, in order to make the model perform better in practical applications, further task-driven instruction tuning is required. This process aims to enable the model to generate high-quality common sense knowledge that meets the needs of practical applications through specific task training.

[0102] First, create an instruction fine-tuning dataset, including<instruction,examples,outputs> There are three parts. The instruction describes the knowledge graph completion task, the example includes the relationship description and the input entity, and the output includes the predicted tail entity. The diagram of the instruction fine-tuning content structure is as follows Figure 4 shown.

[0103] In the process of instruction tuning, the parameters of the language model are further updated to adapt it to the knowledge graph completion task. In this way, the model can generate knowledge output that meets the requirements. The loss function used in the process of updating the model is as follows:

[0104]

[0105] During the training process, the output of the model is continuously evaluated and optimized to ensure that they can accurately reflect the required knowledge points. In addition, in order to further improve the adaptability and accuracy of the model, a fine-tuning strategy is used to optimize the model parameters so that the model can better adapt to new task requirements while maintaining its original performance.

[0106] Furthermore, after the previous training and tuning, the model has the ability to generate common sense knowledge. However, whether the generated knowledge is diverse, accurate and novel still needs to go through a rigorous filtering and evaluation process. The goal of this stage is to ensure that the common sense knowledge finally generated is of high quality and reliability.

[0107] In order to ensure the diversity of generated knowledge, diversified beam search is used when generating data. Diversified beam search is an improved beam search algorithm that aims to generate more diverse candidate sequences. Traditional beam search algorithms often generate similar candidate sequences and lack diversity when searching in the solution space. To overcome this problem, diversified beam search introduces a diversity penalty term in the search process to make the generated candidate sequences more diverse. Therefore, the diversified beam search generation strategy can improve the diversity of the data generated by the model while ensuring the accuracy of the model generation results. The formula for diversified beam search is as follows:

[0108]

[0109] Where S(y i ) is the candidate sequence y i The corrected score of , λ is a hyperparameter used to control the weight of the diversity penalty. j<i D(y i ,y j ) is y i The sum of similarities between the candidate sequences selected previously. In each search step, the algorithm selects the candidate with the highest correction score S(y i) candidate sequence.

[0110] The obtained knowledge is then evaluated through preliminary filtering and a multi-layer scoring mechanism.

[0111] The initial filtering uses the debiased BERT model trained on a binary classification dataset to evaluate the rationality of the generated knowledge and output a probability value to represent the rationality of the input triple. The main purpose is to initially filter out unreasonable data. Through this operation, the newly generated entities can be filtered in terms of semantics and bias to ensure that the filtered new entities are relatively good in terms of moral bias and triple combination rationality. The filtering model architecture is as follows: Figure 5 shown.

[0112] In terms of accuracy, the present invention proposes a three-tier scoring mechanism:

[0113] 1. The first level of scoring is performed by GPT-3.5 on the generated tail entity, and the result is "yes" or "no"

[0114] or “unrecognizable”;

[0115] 2. Second-level scoring: For instances that are rated “unrecognizable” in the first-level scoring, GPT-4 performs a more in-depth evaluation;

[0116] 3. For instances that are still rated as “unrecognizable” in the first two levels of scoring, the third level of scoring will be judged manually.

[0117] In order to ensure the high novelty and diversity of the generated knowledge, the present invention adopts a matching mechanism based on cosine similarity to calculate the similarity between the newly generated tail entity and the existing tail entity. The cosine similarity calculation formula is as follows:

[0118]

[0119] Among them, A and B are two vectors, A·B represents the dot product of two vectors, and |A| and |B| represent the modulus of vector A and B respectively (that is, the length of the vector).

[0120] Through the above steps, the present invention has made important improvements on the basis of the existing technology, greatly improving the quality and efficiency of obtaining common sense knowledge graphs. Experimental results show that the method of the present invention performs well on a variety of basic models and knowledge bases, and has wide applicability and robustness.

[0121] Example 3

[0122] Based on the same inventive concept as in Example 1, Figure 2 , Figure 6 , the method provided in this embodiment further comprises the steps of:

[0123] S6. Determine whether the generated new knowledge is reasonable.

[0124] Specifically, the training loss, validation loss, and perplexity are used to determine whether the model meets the standards. If the model indicators meet the standards, 2000 seed generation instructions are used in step S5 to generate new knowledge using the fine-tuned model. After the verification and evaluation steps, the rationality and novelty of the knowledge are ensured. If the new knowledge is unreasonable, return to step 5 to regenerate the knowledge. If the new knowledge is reasonable, proceed to the next step. Reasonable new knowledge is stored and used for further applications.

[0125] Example 4

[0126] Based on Example 2, refer to Figure 7 This embodiment provides a detailed process of constructing a forward and reverse data set and contrastive learning pre-training. The specific steps are as follows:

[0127] 1. Seed dataset and template sentences:

[0128] Duplicate relations are filtered out from seed datasets such as ConceptNet and ATOMIC to obtain original triples, and corresponding template sentences are constructed for each retained relation.

[0129] 2. Build a positive dataset:

[0130] Extract positive triples (h, r, t) from the seed data set, use the template sentence with the constructed corresponding relationship to replace the middle relationship of the triple, and replace the head entity and tail entity in the template sentence to obtain the positive data set.

[0131] 3. Build reverse dataset:

[0132] Construct a corresponding reverse relationship for each forward relationship, and then construct a reverse triple (t, r) from the forward triple by exchanging the head and tail entities. -1 ,h), construct the reverse template sentence of the corresponding relationship, and then use the constructed template sentence to replace the middle relationship of the triple, and replace the head entity and tail entity in the template sentence to obtain the reverse data set.

[0133] 4. Construct positive sample pairs:

[0134] The positive relation sentence S1 and the reverse relation sentence S2 obtained from the same original triple (h1, r1, h1) As a positive sample pair. There will be only one positive sample pair in a training batch.

[0135] 5. Construct negative sample pairs:

[0136] Through three strategies of in-batch negative sampling, queue negative sampling and self-similar negative sampling. In a batch of size 512, the other 510 samples except the reverse sample corresponding to the current sample are used to form negative sample pairs for in-batch negative sampling, providing a total of 255 pairs of negative sample pairs. Because the queue length of queue negative sampling is 1024, a total of 1024 pairs of negative sample pairs are provided. Self-similar negative sampling provides 1 pair of difficult negative sample pairs, so a total of 1280 pairs of negative sample pairs are provided in a training batch.

[0137] 6. Contrastive Learning Pre-training:

[0138] Calculate the similarity between positive and negative samples, optimize the contrastive learning loss function, and update the model weights.

[0139] Example 5

[0140] Based on Example 2, refer to Figure 8 This embodiment provides a detailed process of constructing an instruction fine-tuning data set and instruction fine-tuning. The specific steps are as follows:

[0141] 1. Seed dataset and template sentences:

[0142] Generate positive triples using the seed dataset and template sentences, and the positive dataset replaced by the template sentences.

[0143] 2. Build a forward instruction fine-tuning dataset:

[0144] Construct a positive instruction fine-tuning dataset from the positive triples and the positive dataset, including<instruction,examples,outputs> Three parts.

[0145] 3. Build a reverse instruction fine-tuning dataset:

[0146] Constructing a reverse instruction fine-tuning dataset from reverse triplets, also includes<instruction,examples,outputs> The three parts ensure the symmetry of the corpus.

[0147] 4. Build a binary classification instruction fine-tuning dataset:

[0148] Construct a binary classification instruction fine-tuning dataset from the forward and reverse datasets to assist the model in classification tasks.

[0149] 5. Fine-tune the instructions:

[0150] Three instruction fine-tuning datasets are used for instruction fine-tuning. The ratio of the three tasks is 8:1:1. The purpose of using three different types of instruction fine-tuning tasks with different purposes is to make the model more robust and avoid overfitting, which will reduce the general ability. Then the three instruction fine-tuning datasets are used to optimize the model to obtain the model after instruction fine-tuning.

[0151] 6. Generate and evaluate:

[0152] New knowledge is generated through diversified beam search and evaluated using preliminary filtering and multi-layer scoring mechanisms to ensure the diversity, accuracy, and novelty of the generated knowledge.

[0153] Example 6

[0154] Based on the same inventive concept as in Example 1, a common sense knowledge generation system based on a bidirectional relationship integrated graph is provided, the system comprising:

[0155] A bidirectional relationship dataset construction module is used to construct a bidirectional relationship dataset, wherein a symmetric graph is constructed by introducing a reverse relationship;

[0156] The contrastive pre-training module is used for contrastive pre-training, which uses forward and reverse contrastive learning to enhance the model's bidirectional understanding of common sense knowledge;

[0157] The instruction tuning module is used for instruction tuning, which performs task-driven instruction tuning based on pre-training to ensure that the model effectively generates common sense knowledge that meets the requirements;

[0158] The model tuning judgment module is used to judge whether the tuned model meets the standard. If not, it returns to the instruction tuning module to continue tuning;

[0159] The new knowledge generation module is used to generate new knowledge using the tuned model.

[0160] Example 7

[0161] Based on the same inventive concept as Example 1, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the common sense knowledge generation method provided by the embodiment of the present invention is implemented. Based on such an understanding, the technical solution of this embodiment is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0162] Example 8

[0163] Based on the same inventive concept as Example 1, a terminal is provided, including a memory and a processor, wherein the memory stores computer instructions that can be executed on the processor, and when the processor executes the computer instructions, the common sense knowledge generation method provided in the embodiment of the present invention is executed.

[0164] The processor may be a single-core or multi-core central processing unit or a specific integrated circuit, or one or more integrated circuits configured to implement the present invention.

[0165] Embodiments of the subject matter and functional operations described in this specification may be implemented in: tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or a combination of one or more of them. Embodiments of the subject matter described in this specification may be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier to be executed by a data processing device or to control the operation of the data processing device. Alternatively or additionally, the program instructions may be encoded on an artificially generated propagated signal, such as a machine-generated electrical, optical, or electromagnetic signal, which is generated to encode and transmit information to a suitable receiver device for execution by the data processing device.

[0166] The processes and logic flows described in this specification can be performed by one or more programmable computers executing one or more computer programs to perform corresponding functions by operating on input data and generating output. The processes and logic flows can also be performed by special purpose logic circuits, such as FPGAs (field programmable gate arrays) or ASICs (application-specific integrated circuits), and the apparatus can also be implemented as special purpose logic circuits.

[0167] Processors suitable for executing computer programs include, for example, general and / or special microprocessors, or any other type of central processing unit. Typically, the central processing unit will receive instructions and data from a read-only memory and / or a random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, the computer will also include one or more large-capacity storage devices for storing data, such as magnetic disks, magneto-optical disks, or optical disks, or the computer will be operably coupled to this large-capacity storage device to receive data from it or to transmit data to it, or both. However, the computer does not necessarily have such a device. In addition, the computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, just to name a few.

[0168] It should be understood that each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0169] The above specific implementation methods are detailed descriptions of the present invention. It cannot be determined that the specific implementation methods of the present invention are limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions and substitutions can be made without departing from the concept of the present invention, which should be regarded as belonging to the protection scope of the present invention.

Claims

1. A common sense knowledge generation method based on bidirectional relationship integration graph, It is characterized in that The method comprises the following steps: S1. Constructing a bidirectional relationship dataset: constructing a symmetric graph by introducing reverse relationships; S2, contrastive pre-training: using forward and reverse contrastive learning to enhance the model’s bidirectional understanding of common sense knowledge; S3, instruction tuning: Perform task-driven instruction tuning based on pre-training to ensure that the model effectively generates common sense knowledge that meets the requirements; S4: Determine whether the tuned model meets the standard. If not, return to step S3 to continue tuning. S5. Use the tuned model to generate new knowledge.

2. A common sense knowledge generation method based on a bidirectional relationship integrated graph according to claim 1, It is characterized in that The method further comprises the steps of: S6. Determine whether the generated new knowledge is reasonable.

3. A common sense knowledge generation method based on a bidirectional relationship integrated graph according to claim 1, It is characterized in that Construct a bidirectional relationship dataset, including: Generate forward and reverse triplets using the seed dataset and template sentences.

4. The common sense knowledge generation method based on a bidirectional relationship integrated graph according to claim 1, It is characterized in that The contrast pre-training includes: Using positive and negative contrastive learning, the similarity between positive and negative samples is calculated, the contrastive learning loss function is optimized, and the model weights are updated.

5. The common sense knowledge generation method based on a bidirectional relationship integrated graph according to claim 1, It is characterized in that The instruction tuning includes: Construct a forward instruction fine-tuning dataset, a reverse instruction fine-tuning dataset, and a binary classification instruction fine-tuning dataset; Three instruction fine-tuning datasets are used for instruction fine-tuning, and the ratio of the three tasks is 8:1:

1.

6. A common sense knowledge generation method based on a bidirectional relationship integrated graph according to claim 1, It is characterized in that The step of judging whether the tuned model meets the standard includes: Through preliminary filtering and multi-layer scoring mechanisms, the accuracy and novelty of the generated knowledge are ensured.

7. A common sense knowledge generation method based on a bidirectional relationship integrated graph according to claim 6, It is characterized in that The bias-removed BERT model is used for preliminary filtering, and the multi-layer scoring mechanism adopts a scoring model that combines a three-level scoring system and novelty calculation.

8. A common sense knowledge generation system based on bidirectional relationship integrated graph, It is characterized in that The system comprises: A bidirectional relationship dataset construction module is used to construct a bidirectional relationship dataset, wherein a symmetric graph is constructed by introducing a reverse relationship; The contrastive pre-training module is used for contrastive pre-training, which uses forward and reverse contrastive learning to enhance the model's bidirectional understanding of common sense knowledge; The instruction tuning module is used for instruction tuning, which performs task-driven instruction tuning based on pre-training to ensure that the model effectively generates common sense knowledge that meets the requirements; The model tuning judgment module is used to judge whether the tuned model meets the standard. If not, it returns to the instruction tuning module to continue tuning; The new knowledge generation module is used to generate new knowledge using the tuned model.

9. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the common sense knowledge generating method described in any one of claims 1 to 7 is implemented.

10. A terminal comprising a memory and a processor, wherein the memory stores computer instructions that can be executed on the processor, It is characterized in that When the processor runs the computer instructions, it executes the common sense knowledge generation method described in any one of claims 1-7.

Citation Information

Patent Citations

  • Knowledge graph information representation learning method, system, equipment and terminal

    CN112765369A

  • Generation method and device of intelligent question and answer model, computing equipment and storage medium

    CN114547267A

  • Question and answer library generation method and device based on knowledge graph, electronic equipment and storage medium

    CN114707000A

  • Relationship extraction method based on comparative learning

    CN115496072A

  • Writing auxiliary model construction method, writing auxiliary method and storage medium

    CN116611424A