A common sense knowledge generation method and system based on a bidirectional relation integrated graph, a storage medium and a terminal
By constructing a bidirectional relational ensemble graph and comparing pre-training, combined with a multi-layer scoring mechanism, the problems of high cost, limitations of unidirectional relations, and insufficient semantic understanding in common sense knowledge acquisition are solved, thus achieving efficient and systematic common sense knowledge generation.
Patent Information
- Application Number
- CN202410848125.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2044-06-27
AI Technical Summary
Existing methods for acquiring common sense knowledge are costly, have limited scale, suffer from strong limitations in handling one-way relationships, lack semantic understanding, and produce insufficient quality and diversity, thus lacking systematic solutions.
By constructing a bidirectional relational ensemble graph, using a large language model for comparative pre-training and task-driven instruction optimization, and combining a multi-layer scoring mechanism, high-quality common sense knowledge is generated.
It reduces the cost of knowledge acquisition, overcomes the limitations of one-way relationships, improves the depth of semantic understanding and generation efficiency, provides a systematic solution, and ensures the accuracy and novelty of generated knowledge.
Smart Images

Figure CN118733787B_ABST
Abstract
Description
Technical Field
[0001] This 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 relational integration graph. Background Technology
[0002] In many knowledge-intensive applications, commonsense knowledge graph acquisition (CKGA) is crucial. Traditional CKGA methods rely on node-level and unidirectional relationships, resulting in a superficial understanding of the relationship between entities and relationships. Furthermore, these methods require expensive and labor-intensive manual annotation, leading to a lack of diversity and quality in the generated commonsense knowledge.
[0003] Existing CKGA methods mainly fall into the following categories:
[0004] 1. Crowdsourcing-based methods: For example, WordNet and ConceptNet acquire high-quality common-sense knowledge through annotations from human experts or the general public. However, these methods are costly and difficult to scale.
[0005] 2. Language pattern-based methods: These methods extract common-sense knowledge from patterns in text. They typically involve complex engineering processes such as document retrieval, rule-based extraction, and knowledge clustering. The quality of these methods is inconsistent because the effect of each step significantly impacts the final result.
[0006] 3. Language Model-Based (LM) Approaches: These methods utilize pre-trained language models (such as the GPT series) to generate knowledge. They employ carefully designed prompt-word query models to generate knowledge that conforms to specific relationships. However, existing methods typically handle node-level relationships, neglecting the semantics of inverse relationships, thus limiting the model's ability to understand relationships.
[0007] Besides the aforementioned popular methods, completion methods based on Large Language Models (LLMs) such as ChatGPT and GPT-4 have demonstrated the potential to handle various complex problems. However, directly using these models for commonsense knowledge generation presents issues related to quality, format, and novelty.
[0008] In summary, the shortcomings and deficiencies of the existing technology are as follows:
[0009] 1. High cost and limited scale
[0010] While traditional crowdsourcing methods can obtain high-quality common-sense resources, their labor intensity and cost limit the scalability of these resources. Language pattern-based methods, while addressing the cost issue to some extent, are still constrained by multiple steps, including text selection and extraction strategies, in terms of the quality and stability of the generated knowledge.
[0011] 2. Limitations of one-way relationships
[0012] Most existing methods focus on unidirectional relationships (e.g., A is part of B), neglecting inverse relationships (e.g., B contains A). This limitation leads to significant shortcomings in knowledge graphs when handling complex reasoning tasks. For example, learning "A is B" may not automatically lead to the inference "B is A," a problem known as the "reversal curse."
[0013] 3. Insufficient semantic understanding
[0014] Existing methods often employ node-level processing when handling common-sense knowledge, directly inputting entities and relationships into the model. This approach 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, leading to unsatisfactory knowledge extraction results.
[0015] 4. High cost of manual labeling
[0016] While crowdsourcing methods can acquire high-quality common-sense knowledge, they rely heavily on human annotation, which is time-consuming, labor-intensive, and costly, limiting the scale and scalability of resources.
[0017] 5. Insufficient quality and diversity of output.
[0018] The common sense knowledge generated by existing methods is insufficient in terms of quality and diversity, and often requires further manual verification and adjustment.
[0019] 6. Lack of systematic solutions
[0020] Existing contrastive learning methods have achieved some success in knowledge graph completion tasks, 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 this invention is to overcome at least one technical problem existing in the prior art and to provide a method, system, storage medium and terminal for generating common sense knowledge based on a bidirectional relational integration graph, so as to generate high-quality common sense knowledge.
[0022] The objective of this invention is achieved through the following technical solution:
[0023] Firstly, a commonsense knowledge generation method based on a bidirectional relation integration graph is provided, the method comprising the following steps:
[0024] S1. Constructing a bidirectional relation dataset: Constructing a symmetric graph by introducing reverse relations;
[0025] S2. Contrastive Pre-training: Enhance the model's bidirectional understanding of common sense knowledge by using positive and negative contrastive learning;
[0026] S3, Instruction Tuning: Based on the comparison with pre-training, perform task-driven instruction tuning to ensure that the model effectively generates common sense knowledge that meets the requirements;
[0027] S4. Determine whether the optimized model meets the standard. If it does not meet the standard, return to step S3 to continue optimization.
[0028] S5. Use the tuned model to generate new knowledge.
[0029] Preferably, the method further includes the step of:
[0030] S6. Determine whether the generated new knowledge is reasonable.
[0031] Preferably, a bidirectional relation dataset is constructed, including:
[0032] Generate forward and backward triples using a seed dataset and template sentences.
[0033] Preferably, the comparative pre-training includes:
[0034] By utilizing positive and negative contrast learning, the similarity between positive and negative samples is calculated, the contrast 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] Instruction fine-tuning was performed using three different instruction datasets, with the ratio of the three tasks being 8:1:1.
[0038] Preferably, determining whether the optimized model meets the standard includes:
[0039] Through preliminary filtering and multi-level scoring mechanisms, the accuracy and novelty of the generated knowledge are ensured.
[0040] Preferably, a bias-removal-based BERT model is used for initial filtering, and a multi-level scoring mechanism is adopted, which combines a three-level scoring system with novelty calculation.
[0041] Secondly, a commonsense knowledge generation system based on a bidirectional relation integration graph is provided, the system comprising:
[0042] The bidirectional relation dataset building module is used to construct bidirectional relation datasets, where a symmetric graph is built by introducing reverse relations;
[0043] The comparison pre-training module is used for comparison pre-training, which utilizes positive and negative comparison 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 comparison with 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 determine whether the tuned model meets the standards. If it does not meet the standards, it returns to the tuning module to continue tuning.
[0046] The new knowledge generation module is used to generate new knowledge using a tuned model.
[0047] Thirdly, a computer-readable storage medium is provided, the computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the common sense knowledge generation methods described above.
[0048] Fourthly, a terminal is provided, including a memory and a processor, wherein the memory stores computer instructions that can be executed on the processor, and the processor executes the aforementioned common sense knowledge generation method when executing the computer instructions.
[0049] It should be further noted that the technical features corresponding to the above options can be combined or substituted to form new technical solutions if there is no conflict.
[0050] Compared with existing technologies, this invention, by introducing the Bidirectional Relationship Integration Graph Contrast Pre-training Method (BIRGHT), demonstrates significant advantages in the field of commonsense knowledge graph acquisition. The main beneficial effects are as follows:
[0051] 1. It solved the problems of high cost and limited scale.
[0052] While traditional crowdsourcing methods can acquire high-quality common sense resources, their labor intensity and cost limit the scalability of these resources. This invention introduces Large Language Models (LLMs), such as ChatGPT and GPT-4, and utilizes 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. It overcomes the limitations of one-way relationships.
[0054] Most existing methods focus on unidirectional relationships (e.g., A is part of B), neglecting inverse relationships (e.g., B contains A). This limitation leads to significant shortcomings in knowledge graphs when handling complex reasoning tasks. This invention constructs a symmetric graph of positive and inverse relationships and utilizes a bidirectional relationship ensemble graph to ensure that the model can learn both positive and inverse relationships simultaneously, solving the "reversal curse" problem and improving the model's relational understanding ability.
[0055] 3. Improved the depth of semantic understanding
[0056] Existing methods often employ node-level processing when handling common-sense knowledge, directly inputting entities and relationships into the model without fully utilizing contextual information, resulting in insufficient semantic understanding. This invention designs natural language template sentences, transforming each relationship into diverse sentence templates, enhancing the model's ability to understand context, thereby improving the depth and accuracy of semantic understanding.
[0057] 4. Provides a systematic solution
[0058] Existing contrastive learning methods have achieved some success 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 optimization, and multi-layered filtering and evaluation mechanisms, ensuring a comprehensive improvement in the quality and diversity of the generated knowledge.
[0059] 5. Innovative filtering and scoring mechanism
[0060] This invention employs a bias-removal-based BERT model for initial filtering, combined with a three-level scoring system and a novelty calculation model to ensure the accuracy and novelty of the generated knowledge. The three-level scoring system uses multi-level evaluation with GPT-3.5 and GPT-4, combined with human scoring, to ensure the reliability of the evaluation results. The novelty score, calculated using cosine similarity based on an embedding model, overcomes the limitations of character matching methods, ensuring the semantic consistency and originality 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, this invention achieves significant improvements in the efficiency and quality of generating common-sense knowledge. Employing diverse bundle search methods and refined instruction tuning, the model can generate high-quality knowledge triples that meet the requirements, and its rationality and innovativeness are ensured through multi-layered filtering and scoring mechanisms. Attached Figure Description
[0063] Figure 1This is a flowchart illustrating a common sense knowledge generation method based on a bidirectional relation integration graph, as shown in an embodiment of the present invention.
[0064] Figure 2 This is a flowchart illustrating a common knowledge generation method including a new knowledge judgment step, as shown in an embodiment of the present invention.
[0065] Figure 3 This is a diagram illustrating the overall framework architecture of an embodiment of the present invention;
[0066] Figure 4 This is a schematic diagram illustrating the instruction fine-tuning content structure according to an embodiment of the present invention;
[0067] Figure 5 This is a diagram illustrating the filtering model architecture of an embodiment of the present invention;
[0068] Figure 6 This is a flowchart illustrating a specific implementation of an embodiment of the present invention;
[0069] Figure 7 This is a schematic diagram illustrating the construction of forward and reverse datasets and comparative learning pre-training in an embodiment of the present invention;
[0070] Figure 8 This is a schematic diagram illustrating the construction of a command fine-tuning dataset and command fine-tuning in an embodiment of the present invention. Detailed Implementation
[0071] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0072] It should be noted that the defects in the solutions in the prior art are all the results of the inventors' practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the embodiments of this application in the following text should be the inventors' contributions to this application in the process of invention and creation, and should not be understood as technical content known to those skilled in the art.
[0073] To address the technical problems mentioned in the background section, this invention proposes a novel paradigm: BIRGHT (Bio-Relation Integration Graph Contrastive Pre-training) using state-of-the-art base models to expand common-sense knowledge. BIRGHT is a complete closed-loop framework encompassing corpus construction, contrastive pre-training, task-driven instruction tuning, filtering strategies, and an evaluation system. Specific embodiments provided by this invention are as follows:
[0074] Example 1
[0075] Reference Figure 1 In one exemplary embodiment, a method for generating common sense knowledge based on a bidirectional relationship integration graph is provided, the method comprising the following steps:
[0076] S1. Construct a bidirectional relationship dataset: By introducing reverse relationships, a symmetric graph is constructed to provide supplementary information and improve the understanding of relationships between entities;
[0077] S2. Contrastive Pre-training: Enhance the model's bidirectional understanding of common sense knowledge by using positive and negative contrastive learning;
[0078] S3, Instruction Tuning: Based on the comparison with pre-training, perform task-driven instruction tuning to ensure that the model effectively generates common sense knowledge that meets the requirements;
[0079] S4. Determine whether the optimized model meets the standards. Through preliminary filtering and multi-level scoring mechanisms, ensure the accuracy and novelty of the generated knowledge. If it does not meet the standards, return to step S3 to continue optimization.
[0080] S5. Use the tuned model to generate new knowledge.
[0081] The core of the BIRGHT proposed in this invention lies in creating a symmetric graph using reverse relationships, transforming bidirectional relationships into sentence-level relationships, and solving the "curse of reversal" problem by introducing positive and negative examples for comparative learning, thereby generating high-quality common sense knowledge.
[0082] Example 2
[0083] Based on the inventive concept of Embodiment 1, this embodiment proposes a method to enhance common-sense knowledge through comparison of pre-training methods using a bidirectional relation ensemble graph of a large model. Optimizations have been made in three parts: dataset construction, model fine-tuning, filtering, and evaluation. The overall architecture diagram of the proposed framework is shown below. Figure 3 As shown. The following is combined with... Figure 3 Analyze the implementation details of each step.
[0084] First, a dataset is constructed. Traditional methods for acquiring common sense knowledge graphs often rely on unidirectional relationships, which not only limits the breadth of knowledge but also fails to fully understand the complex relationships between entities. To address this issue, this invention first proposes a method for constructing reverse and validation datasets, by introducing reverse relationships and a validation corpus to compensate for this deficiency.
[0085] The core of this process lies in ensuring the symmetry of relations in the corpus through the construction of reverse relations, thereby providing richer and more comprehensive contextual information. Based on existing commonsense knowledge graphs (such as Concept Net and ATOMIC), a dataset of positive and negative relations is constructed:
[0086] Forward Dataset (D) f ): Contains the original triple (h,r,t), where h represents the head entity, r represents the relation, and t represents the tail entity.
[0087] Reverse Dataset (D) r ): By swapping the head entity and the tail entity, a new triple (t, r) is formed. -1 ,h), where r -1 Indicates an inverse relationship.
[0088] Validation dataset (D) v ): Construct a labeled validation dataset (t,r,h,l) for the filtering model. A label of 1 indicates a reasonable tail entity, and a label of 0 indicates an unreasonable tail entity.
[0089] To further enhance the model's learning performance, this invention designs various natural language template sentences. First, template sentences need to be defined, with multiple template sentences defined for each relation. For example, the template for the relation "CapableOf" is "[H]canperform[T]", and the template for the reverse relation "performedBy" is "[T]is an activity was completed by[H]". Then, sentence pairs are generated based on the templates. For example, the positive triple "(human, CapableOf, love)" generates the sentence pairs "humancanperformlover." and "loveis an activitywas completed by human."
[0090] Furthermore, after the corpus is constructed, the model enters the contrastive pre-training stage. Through positive and negative contrastive learning, the model can more comprehensively understand the bidirectional relationships of common sense knowledge. In contrastive pre-training, this invention selects the positive relation triple (h,r,t) and its corresponding negative relation triple (t,r',h) as positive pairs for contrastive learning. In each mini-batch training, the model is optimized by calculating the similarity between the positive and negative sample pairs.
[0091] To enhance the model's discriminative ability, three negative sampling strategies were introduced: intra-batch negative sampling, queued negative sampling, and self-similar negative sampling. These strategies ensure the diversity and quality of samples, thereby improving the model's discriminative power. The contrastive loss function was optimized to maximize positive sample similarity and minimize negative sample similarity, further enhancing the model's semantic understanding depth and generative capabilities.
[0092] Selection of positive sample pairs: Using the positive triple (h,r,t) as the anchor sample, select the reverse triple (t,r) with deep semantic connections from the reverse dataset.-1 ,h) are used as positive samples.
[0093] Negative sample pair selection: Three sampling methods are used for negative sample pair selection: intra-batch negative sampling, queue negative sampling, and self-similar negative sampling, to ensure the diversity and efficiency of negative samples. Intra-batch negative sampling uses non-anchor samples from the same batch as negative samples, increasing the diversity of training samples; queue negative sampling uses a fixed-size queue to store samples from previous batches, expanding the coverage of negative samples and improving the model's generalization ability; self-similar negative sampling selects samples similar to the current sample as negative samples, ensuring the model can recognize subtle semantic differences.
[0094] To achieve a more symmetrical and discriminative representation, this invention employs an extended InfoNCE loss function. This function maximizes the similarity of positive sample pairs while minimizing the similarity of the three types of negative sample pairs. By maximizing positive sample affinity and minimizing negative sample affinity, the contrastive learning loss function is optimized, enhancing the model's symmetry and discriminative ability.
[0095] The main steps involved in the comparative learning optimization process are as follows:
[0096] 1. Input sentence pairs: Input the generated sentence pairs into the model and extract the sentence embeddings.
[0097] 2. Calculate similarity: Calculate the similarity between positive and negative sample pairs using cosine similarity.
[0098] 3. Optimize the contrastive learning loss function: Substitute the similarity scores of positive and negative sample pairs in the input sentence pairs into the loss function, and iterate the model to optimize the loss function. The optimization function for contrastive pre-training is:
[0099]
[0100] Where, x f and x r x represents the embedding of forward and reverse sentences, respectively. j This represents the embedding of negative samples, where τ is the temperature parameter.
[0101] Furthermore, after completing the comparative pre-training, the model already possesses a certain ability to generate common sense knowledge. However, to make the model perform better in real-world applications, further task-driven instruction tuning is needed. This process aims to enable the model to generate high-quality common sense knowledge that meets the needs of real-world applications through specific task training.
[0102] First, create a fine-tuning dataset for the instructions, including<instruction,examples,outputs> Three parts. The instruction describes the knowledge graph completion task; the example includes relation descriptions and input entities, and the output includes predicted tail entities. A diagram illustrating the instruction fine-tuning content structure is shown below. Figure 4 As shown.
[0103] During instruction tuning, the language model parameters are further updated to adapt to the knowledge graph completion task. This enables the model to generate knowledge output that meets the requirements. The loss function used in updating the model is as follows:
[0104]
[0105] During training, the model's output is continuously evaluated and optimized to ensure it accurately reflects the required knowledge points. Furthermore, to further improve the model's adaptability and accuracy, a fine-tuning strategy is employed to optimize the model parameters, enabling the model to better adapt to new task requirements while maintaining its original performance.
[0106] Furthermore, after the preceding training and optimization, the model possesses the ability to generate common-sense knowledge. However, the diversity, accuracy, and novelty of the generated knowledge still require a rigorous filtering and evaluation process. The goal of this stage is to ensure that the final generated common-sense knowledge is of high quality and high reliability.
[0107] To ensure the diversity of generated knowledge, a diversified beam search was used when generating data. Diversified beam search is an improved beam search algorithm designed to generate more diverse candidate sequences. Traditional beam search algorithms often produce similar candidate sequences when searching the solution space, lacking diversity. To overcome this problem, diversified beam search introduces a diversity penalty term during the search process, making the generated candidate sequences more diverse. Therefore, the diversified beam search generation strategy can improve the diversity of generated data while ensuring the accuracy of the model's generated results. The formula for diversified beam search is as follows:
[0108]
[0109] Where S(y) i ) is a candidate sequence y i The corrected score, λ is a hyperparameter used to control the weight of the diversity penalty. ∑ j<i D(y i ,y j ) is y i The algorithm calculates the sum of similarities between the sequence and the previously selected candidate sequences, and selects the sequence with the highest corrected score S(y) at each search step. iCandidate sequences of ).
[0110] The knowledge obtained will then undergo preliminary filtering and multi-layered scoring mechanisms for evaluation.
[0111] The initial filtering employs a bias-reduced BERT model trained on a binary classification dataset to evaluate the reasonableness of the generated knowledge and output a probability value representing the reasonableness of the input triples. The main purpose is to initially filter out unreasonable data. Through this operation, newly generated entities can be filtered semantically and based on biases, ensuring that the filtered new entities are relatively good in terms of moral bias and the rationality of triple combinations. The filtering model architecture is as follows: Figure 5 As shown.
[0112] Regarding accuracy, this invention proposes a three-tiered scoring mechanism:
[0113] 1. The first-level scoring uses GPT-3.5 to initially score the generated tail entities, with the result being "Yes" or "No".
[0114] Or "Unrecognized";
[0115] 2. For instances that received an "unrecognizable" result in the first-level scoring, the second-level scoring is further evaluated by GPT-4.
[0116] 3. For instances that are still "unrecognizable" after the first two levels of scoring, the third level of scoring will be determined by a human judge.
[0117] To ensure high novelty and diversity of the generated knowledge, this invention employs a cosine similarity-based matching mechanism to calculate the similarity between newly generated tail entities and existing tail entities. The cosine similarity calculation formula is as follows:
[0118]
[0119] Here, A and B are two vectors, A·B represents the dot product of the two vectors, and |A| and |B| represent the magnitudes (i.e. the lengths of the vectors) of vectors A and B, respectively.
[0120] Through the above steps, this invention makes significant improvements on the existing technology, greatly enhancing the quality and efficiency of common sense knowledge graph acquisition. Experimental results show that the method of this invention performs excellently on various basic models and knowledge bases, demonstrating broad applicability and robustness.
[0121] Example 3
[0122] Based on the same inventive concept as in Embodiment 1, and referring to... Figure 2 , Figure 6 The method provided in this embodiment further includes the following steps:
[0123] S6. Determine whether the generated new knowledge is reasonable.
[0124] Specifically, the model's performance is assessed using metrics such as training loss, validation loss, and perplexity. If the model meets the criteria, in step S5, 2000 seed generation instructions are used to generate new knowledge using the fine-tuned model. After validation and evaluation steps, the rationality and novelty of the knowledge are ensured. If the new knowledge is unreasonable, the process returns to step 5 to regenerate the knowledge. If the new knowledge is reasonable, the process continues to the next step. Reasonable new knowledge is stored and used for further applications.
[0125] Example 4
[0126] Based on Example 2, referring to Figure 7 This embodiment provides a detailed process for constructing forward and reverse datasets 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 the original triples, and a corresponding template sentence is constructed for each retained relation.
[0129] 2. Construct a positive dataset:
[0130] Extract positive triples (h, r, t) from the seed dataset, replace the middle relation of the triples with the template sentence of the constructed correspondence, and replace the head entity and tail entity in the template sentence to obtain the positive dataset.
[0131] 3. Construct a reverse dataset:
[0132] For each positive relation, construct a corresponding negative relation, and then construct a negative triple (t, r) from the positive triple by swapping the head and tail entities. -1 (h) Construct a reverse template sentence for the corresponding relation, and then use the constructed template sentence to replace the middle relation of the triple. At the same time, replace the head entity and tail entity in the template sentence to obtain the reverse dataset.
[0133] 4. Construct positive sample pairs:
[0134] The positive relation sentence S1 and the negative relation sentence obtained from the same original triple (h1, r1, h1) As a positive sample pair, there will be only one positive sample pair in a batch of training.
[0135] 5. Construct negative sample pairs:
[0136] Three strategies were employed: intra-batch negative sampling, queued negative sampling, and self-similar negative sampling. In a batch of 512 samples, 510 samples other than the reverse sample corresponding to the current sample were used to generate intra-batch negative sample pairs, providing a total of 255 negative sample pairs. Queued negative sampling, with a queue length of 1024, provided a total of 1024 negative sample pairs. Self-similar negative sampling provided 1 hard negative sample pair. Therefore, a total of 1280 negative sample pairs were generated in a single training batch.
[0137] 6. Comparative 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, referring to Figure 8 This embodiment provides a detailed process for constructing the instruction fine-tuning dataset and fine-tuning the instructions. The specific steps are as follows:
[0141] 1. Seed dataset and template sentences:
[0142] Positive triples are generated using a seed dataset and template sentences, and a positive dataset is generated by replacing the template sentences.
[0143] 2. Construct a positive instruction fine-tuning dataset:
[0144] Construct a positive instruction fine-tuning dataset from positive triples and the positive dataset, containing...<instruction,examples,outputs> Three parts.
[0145] 3. Construct a reverse instruction fine-tuning dataset:
[0146] Constructing a reverse instruction fine-tuning dataset from reverse triples, also including<instruction,examples,outputs> The three parts ensure the symmetry of the corpus.
[0147] 4. Construct a binary classification instruction fine-tuning dataset:
[0148] A binary classification instruction fine-tuning dataset is constructed from both forward and reverse datasets to assist the model in performing classification tasks.
[0149] 5. Fine-tune the instructions:
[0150] Three instruction fine-tuning datasets were used for instruction fine-tuning, with a ratio of 8:1:1. The purpose of using three different types and objectives of instruction fine-tuning tasks was to improve the model's robustness and avoid overfitting, which could reduce its generalizability. The model was then optimized using these three instruction fine-tuning datasets to obtain the fine-tuned model.
[0151] 6. Generation and Evaluation:
[0152] New knowledge is generated through diverse beam searches, and evaluated using preliminary filtering and multi-layered scoring mechanisms to ensure the diversity, accuracy, and novelty of the generated knowledge.
[0153] Example 6
[0154] Based on the same inventive concept as Embodiment 1, a common sense knowledge generation system based on a bidirectional relation integration graph is provided, the system comprising:
[0155] The bidirectional relation dataset building module is used to construct bidirectional relation datasets, where a symmetric graph is built by introducing reverse relations;
[0156] The comparison pre-training module is used for comparison pre-training, which utilizes positive and negative comparison 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 comparison with 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 determine whether the tuned model meets the standards. If it does not meet the standards, it returns to the tuning module to continue tuning.
[0159] The new knowledge generation module is used to generate new knowledge using a tuned model.
[0160] Example 7
[0161] Based on the same inventive concept as Embodiment 1, a computer-readable storage medium is provided. This computer-readable storage medium stores a computer program, which, when executed by a processor, implements the common knowledge generation method provided in this embodiment of the invention. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, 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 Embodiment 1, a terminal is provided, including a memory and a processor. The memory stores computer instructions that can be executed on the processor. When the processor executes the computer instructions, it performs the common knowledge generation method provided in the embodiments of the present invention.
[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] The embodiments of the subject matter and functional operation described in this specification can be implemented in: tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or combinations thereof. Embodiments of the subject matter described in this specification can 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 for execution by a data processing device or for controlling the operation of a data processing device. Alternatively or additionally, the program instructions may be encoded on artificially generated propagation signals, such as machine-generated electrical, optical, or electromagnetic signals, which are generated to encode information and transmit it to a suitable receiving device for execution by the data processing device.
[0166] The processing and logic flow described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform corresponding functions by operating on input data and generating output. The processing and logic flow can also be executed by dedicated logic circuitry—such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuitry.
[0167] Suitable processors for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit receives instructions and data from read-only memory and / or 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, a computer will also include one or more mass storage devices for storing data, such as disks, magneto-optical disks, or optical disks, or the computer will be operatively coupled to such mass storage devices to receive data from or transfer data to them, or both. However, a computer is not required to have such devices. Furthermore, a 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, to name a few.
[0168] It should be understood that each block in a flowchart or block diagram can represent a module, segment, or portion of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the figures. For example, two consecutive blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0169] The above detailed embodiments are a description of the present invention. It should not be considered that the specific embodiments of the present invention are limited to these descriptions. For those skilled in the art, several simple deductions and substitutions can be made without departing from the concept of the present invention, and all of these should be considered to fall within the protection scope of the present invention.
Claims
1. A method for generating common sense knowledge based on a bidirectional relational integration graph, characterized in that, The method includes the following steps: S1. Constructing a bidirectional relation dataset: A symmetric graph is constructed by introducing inverse relations; the bidirectional relation dataset is constructed, including: Forward and backward triples are generated using a seed dataset and template sentences. The forward triples contain the original triple (h, r, t), where h represents the head entity, r represents the relation, and t represents the tail entity. New triples are formed by swapping the head and tail entities of the forward triples. ,in Indicates an inverse relationship; S2. Contrastive Pre-training: Enhancing the model's bidirectional understanding of common-sense knowledge through positive and negative contrastive learning; the contrastive pre-training includes: By utilizing 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. The positive triples (h, r, t) are used as anchor samples, and negative triples with deep semantic connections are selected from the negative dataset. As positive samples, negative samples are sampled using three strategies: intra-batch negative sampling, queue negative sampling, and self-similar negative sampling. Intra-batch negative sampling uses non-anchor samples from the same batch as negative samples, increasing the diversity of training samples. Queue negative sampling uses a fixed-size queue to store samples from previous batches, expanding the coverage of negative samples and improving the model's generalization ability. Self-similar negative sampling selects samples similar to the current sample as negative samples, ensuring that the model can recognize subtle semantic differences. The contrastive learning loss function is: , where x f and x r x represents the embedding of forward and reverse sentences, respectively. j This represents the embedding of negative samples, where τ is the temperature parameter; S3, Instruction Tuning: Based on the comparison with pre-training, perform task-driven instruction tuning to ensure that the model effectively generates common sense knowledge that meets the requirements; S4. Determine whether the optimized model meets the standard. If it does not meet the standard, return to step S3 to continue optimization. S5. Use the tuned model to generate new knowledge. To ensure the diversity of generated knowledge, a diversified beam search is used when generating data. The diversified beam search introduces a diversity penalty term during the search process, making the generated candidate sequences more diverse. The formula for the diversified beam search is as follows: Where S(yi) is the candidate sequence y i The corrected score, λ is a hyperparameter used to control the weight of the diversity penalty. It is y i The sum of similarities between the sequence and the previously selected candidate sequences.
2. The common sense knowledge generation method based on a bidirectional relation integration graph according to claim 1, characterized in that, The method further includes the following steps: S6. Determine whether the generated new knowledge is reasonable.
3. The common sense knowledge generation method based on a bidirectional relation integration graph according to claim 1, 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; Instruction fine-tuning was performed using three different instruction datasets, with the ratio of the three tasks being 8:1:
1.
4. The common sense knowledge generation method based on a bidirectional relation integration graph according to claim 1, characterized in that, The determination of whether the optimized model meets the standard includes: Through preliminary filtering and multi-level scoring mechanisms, the accuracy and novelty of the generated knowledge are ensured.
5. The common sense knowledge generation method based on a bidirectional relation integration graph according to claim 1, characterized in that, The initial filtering is performed using a BERT model based on bias removal, and the multi-level scoring mechanism adopts a scoring model that combines a three-level scoring system and novelty calculation.
6. A common-sense knowledge generation system based on a bidirectional relational integration graph, characterized in that, The system includes: A bidirectional relation dataset construction module is used to build bidirectional relation datasets, where a symmetric graph is constructed by introducing inverse relations; the construction of a bidirectional relation dataset includes: Forward and backward triples are generated using a seed dataset and template sentences. The forward triples contain the original triple (h, r, t), where h represents the head entity, r represents the relation, and t represents the tail entity. New triples are formed by swapping the head and tail entities of the forward triples. ,in Indicates an inverse relationship; A contrastive pre-training module is used for contrastive pre-training, wherein forward and backward contrastive learning is used to enhance the model's bidirectional understanding of common-sense knowledge; the contrastive pre-training includes: By utilizing 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. The positive triples (h, r, t) are used as anchor samples, and negative triples with deep semantic connections are selected from the negative dataset. As positive samples, negative samples are sampled using three strategies: intra-batch negative sampling, queue negative sampling, and self-similar negative sampling. Intra-batch negative sampling uses non-anchor samples from the same batch as negative samples, increasing the diversity of training samples. Queue negative sampling uses a fixed-size queue to store samples from previous batches, expanding the coverage of negative samples and improving the model's generalization ability. Self-similar negative sampling selects samples similar to the current sample as negative samples, ensuring that the model can recognize subtle semantic differences. The contrastive learning loss function is: , where x f and x r x represents the embedding of forward and reverse sentences, respectively. j This represents the embedding of negative samples, where τ is the temperature parameter; The instruction tuning module is used for instruction tuning, which performs task-driven instruction tuning based on comparison with pre-training to ensure that the model effectively generates common sense knowledge that meets the requirements. The model tuning judgment module is used to determine whether the tuned model meets the standards. If it does not meet the standards, it returns to the tuning module to continue tuning. The new knowledge generation module is used to generate new knowledge using the tuned model. To ensure the diversity of generated knowledge, a diversified beam search is used when generating data. The diversified beam search introduces a diversity penalty term during the search process, making the generated candidate sequences more diverse. The formula for the diversified beam search is as follows: Where S(yi) is the candidate sequence y i The corrected score, λ is a hyperparameter used to control the weight of the diversity penalty. It is y i The sum of similarities between the sequence and the previously selected candidate sequences.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the common sense knowledge generation method according to any one of claims 1-5.
8. A terminal, comprising a memory and a processor, wherein the memory stores computer instructions executable by the processor, characterized in that, The processor executes the common sense knowledge generation method according to any one of claims 1-5 when running computer instructions.
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