A knowledge graph construction method based on fine-tuning large language model

Through the method based on the fine-tuning large language model, automated processing and optimization of knowledge point extraction, the problems of low efficiency and poor accuracy in the existing technology are solved, and efficient construction and dynamic update of the knowledge graph are achieved.

CN119808917BActive Publication Date: 2025-09-02SUZHOU YANTU EDUCATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411934774.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-09-02
Estimated Expiration
2044-12-26

AI Technical Summary

Technical Problem

The prior art relies on manual operations in knowledge management systems, which are inefficient and costly, and it is difficult to accurately capture the complex relationships between knowledge points, and dynamic update of knowledge graphs is difficult.

Method used

Using a method based on a fine-tuning large language model, the fine-tuning model and anti-disorder technology are extracted through data preprocessing and knowledge point extraction, knowledge points and their relationships are automatically identified and constructed, knowledge graphs are stored using graph databases, and knowledge point matching is optimized based on context and semantic similarity.

Benefits of technology

It realizes the automated construction and dynamic update of the knowledge graph, improves the efficiency and accuracy of data processing, reduces the dependence on manuals, and ensures the accuracy of knowledge point extraction and the accuracy of relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119808917B_ABST
    Figure CN119808917B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for constructing a knowledge graph based on a fine-tuned large language model, which comprises the following steps: S1): data preprocessing, S2): extracting knowledge points and relationships in a data source to obtain preprocessed knowledge points and relationships; S3): disambiguating knowledge points and relationships; S4): constructing a knowledge graph to form a dynamically extensible knowledge graph, and periodically using an AI model to reanalyze text materials and update the knowledge graph during later use. The present invention automatically extracts knowledge points to determine entities and relationship edges by utilizing a knowledge point extraction fine-tuning model, further identifies knowledge points through a variety of disambiguation methods, and constructs complex relationships between knowledge points, thereby effectively improving the efficiency and accuracy of data processing. Finally, the disambiguated data is stored in a graph database model to construct a knowledge graph, thereby realizing the automated construction and updating of the knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of data processing technology, and in particular relates to a knowledge graph construction method based on fine-tuning a large language model. Background Art

[0002] In knowledge management systems, the extraction and organization of knowledge points often rely on manual operations, which is labor-intensive, inefficient, and easily influenced by subjective judgment. With the development of artificial intelligence technology, large AI models such as BERT and GPT have made significant progress in natural language processing, making automated knowledge extraction possible. Although some models are trained through deep learning algorithms and can understand and process large amounts of text data, identifying entities, concepts, attributes, and the relationships between them, existing technical solutions have the following problems:

[0003] 1. Currently, most knowledge management systems use keyword matching and expert systems to extract and organize knowledge points.

[0004] 2. Keyword matching methods rely on a predefined keyword list and identify relevant knowledge points by searching for keywords in documents. However, this method often fails to understand the context and easily ignores information that does not contain keywords but is still important.

[0005] 3. Expert systems rely on the knowledge and rules of domain experts to extract and organize knowledge points through a series of customized rules. However, this method requires a lot of manual participation and is difficult to adapt to the ever-changing knowledge system.

[0006] 4. Another method is to use traditional relational databases to store knowledge points, but this method has limitations in processing complex relationships and dynamically updating knowledge graphs because it cannot effectively represent complex relationships and attributes between entities.

[0007] At the same time, there are still some limitations in existing technologies in data processing:

[0008] Existing technologies often require a lot of manual intervention when processing large amounts of unstructured data, which not only increases costs but also reduces efficiency.

[0009] Existing technologies have difficulty accurately capturing the complex relationships between knowledge points, especially in cross-domain and cross-document situations. The construction and maintenance of knowledge graphs often require professional knowledge and skills, which limits their application in a wider range of fields. Existing technical solutions perform poorly in terms of dynamic updates of knowledge graphs and are difficult to adapt to rapidly changing information environments. In summary, the extraction of knowledge points in the existing technical data processing process relies heavily on manual labor, resulting in low work efficiency and high costs. Moreover, the relationships between knowledge points are difficult to accurately capture, which increases the difficulty of extracting and processing knowledge points. Even though some existing technologies use knowledge graphs, the subsequent dynamic updates and maintenance are more difficult. Therefore, the existing technologies have problems such as inaccurate knowledge point extraction, time-consuming knowledge graph construction, and difficulty in maintenance. Summary of the Invention

[0010] Purpose of the invention: In order to overcome the above shortcomings, the purpose of the present invention is to provide a knowledge graph construction method based on a fine-tuned large language model, obtain processed data from data preprocessing, and then automatically extract knowledge points by utilizing the knowledge point extraction fine-tuning model to determine entities and relationship edges, further identify and optimize the extracted knowledge points through a variety of disambiguation means, identify and construct complex relationships between knowledge points, and effectively improve the efficiency and accuracy of data processing, and finally store the disambiguated data in a graph database model to construct a knowledge graph, thereby realizing the automatic construction and update of the knowledge graph.

[0011] Technical solution: To achieve the above objectives, the present invention provides a method for constructing a knowledge graph based on a fine-tuned large language model, comprising the following steps:

[0012] S1): Data preprocessing, i.e. processing the data source of the knowledge points to be extracted. The data source of the knowledge points to be extracted includes structured data and unstructured data. The structured data is directly input into the mapper, and the text data in the unstructured data is cleaned and segmented.

[0013] S2): Extract knowledge points and relationships from the data source. First, build a dedicated knowledge point extraction fine-tuning model. Input the pre-processed data into the knowledge point extraction fine-tuning model. The knowledge point extraction fine-tuning model automatically identifies entities in the text and extracts the relationships between the entities to obtain pre-processed knowledge points and relationships.

[0014] S3): Knowledge point and relationship disambiguation, that is, identification and mapping of different descriptions of the same knowledge point. The specific disambiguation process is as follows:

[0015] S31): Establishing a standard knowledge point database, that is, first constructing a standard set of knowledge point entities. The established standard set of knowledge point entities is used as a mapping target set to disambiguate the knowledge points extracted from the text;

[0016] S32): Similarity calculation and mapping, i.e., using text embedding technology in natural language processing to convert knowledge points and related text into vectors; similarity calculation is then performed to determine whether the extracted different expressions point to the same knowledge point by calculating the cosine similarity or Euclidean distance between the text embedding vectors;

[0017] S33): Context-based semantic disambiguation: Using sliding window technology to take context information into account, knowledge point relationships are extracted from preprocessed knowledge points;

[0018] S34): Iterative Verification and Feedback Optimization: After disambiguation, the knowledge points and relationships extracted in the previous step are mapped to the standard set of knowledge point entities. The two are matched to find possible corresponding relationships. Further verification is performed using the extracted relationships (including inclusion, subordination, synonymy, etc.). If there is no match, the entity is deleted.

[0019] S4): Knowledge graph construction: First, establish a graph database model, innovate entity nodes, and create relationships between entity nodes to form relationship edges. Then, store the disambiguated entity nodes and relationship edges in the graph database model to form a dynamic and scalable knowledge graph. During later use, use the AI ​​model regularly to re-analyze text materials and update the knowledge graph to ensure that it promptly reflects the latest knowledge points and their changes.

[0020] In the method for constructing a knowledge graph based on a fine-tuned large language model of the present invention, the specific method for preprocessing text materials in unstructured data in S1) is as follows:

[0021] S11): Text cleaning: First, the text data in the unstructured data is cleaned. The deep learning model is used to classify different text regions in the text. The irrelevant content is distinguished from the main text based on the context and semantic features of the text. The main text and irrelevant content are automatically identified and removed using regular expressions. The noise in the text data is eliminated, and extra spaces, special characters, irrelevant HTML tags, and repeated text are deleted.

[0022] S12): Sentence processing: In order to provide a clear context for subsequent knowledge point extraction, the cleaned text needs to be sentence-separated;

[0023] S13): Extract repeated content, extract repeated content in the text data by detecting repeated sentences and repeated paragraphs, specifically:

[0024] Detect duplicate sentences, using text similarity detection algorithms to identify and merge similar or duplicate sentences;

[0025] Detect duplicate paragraphs: Detect longer texts through text comparison and clustering algorithms, and merge duplicate paragraphs;

[0026] S14): Context preservation: To preserve the original context of the text, the following measures are taken:

[0027] Maintain paragraph structure: While dividing sentences, maintain the paragraph structure of the original text so that the complete paragraph information can be referenced when extracting knowledge points;

[0028] Use sliding windows: To capture a wider range of contextual information, a sliding window technique can be used when extracting knowledge points. This allows the model to consider information about a sentence and its surrounding sentences simultaneously.

[0029] In the knowledge graph construction method based on fine-tuning a large language model described in the present invention, the specific process of sentence processing in S12) is as follows:

[0030] S121): Based on punctuation: using periods, question marks, exclamation points and other punctuation marks as sentence separators;

[0031] S122): Sentence segmentation using AI models or natural language processing libraries based on natural language processing tools. These tools can more accurately identify sentence boundaries even in the absence of obvious punctuation;

[0032] S123): Dependency-based syntactic analysis: By analyzing the dependency relationships in a sentence, the main and subordinate structures of the sentence are determined, thereby more accurately dividing the sentence. The core idea is to decompose the sentence into a "dependency relationship" graph between words, thereby determining the predicate verb, subject, object and other elements in the sentence and their mutual relationships.

[0033] In the knowledge graph construction method based on fine-tuning a large language model described in the present invention, the specific analysis process of the dependency syntax analysis in S123) is as follows:

[0034] S1231): Input preprocessing, which includes word segmentation, denoising, and normalization of the input text; the details are as follows:

[0035] Text cleaning: First, the input text data needs to be cleaned and preprocessed. Specifically, this involves removing noise, symbols, and irrelevant HTML tags, and normalizing complex text, including converting it to lowercase and correcting typos.

[0036] Word segmentation: Before analyzing the syntax, use word segmentation tools to split the sentence into individual words or phrases;

[0037] S1232): Part-of-speech tagging

[0038] First, use natural language processing tools to mark the part of speech for each word. That is, use a part-of-speech tagger to tag each word or phrase after word segmentation, and determine the grammatical role of each word or phrase in the sentence, including noun, verb, and adjective. Part-of-speech tagging provides basic information for subsequent dependency analysis.

[0039] Then, simplify the parts of speech: simplify the parts of speech according to the specific application scenarios of words or phrases, including simplifying detailed verb forms into a single "verb" category;

[0040] S1233): Dependency parsing, using the dependency syntax analysis model to generate a dependency tree, as follows:

[0041] First, sentence component analysis is performed: through dependency syntactic analysis, the dependency relationship between words in the sentence is analyzed to obtain a dependency tree. The goal of dependency syntactic analysis is to find the subordinate relationship between the "core word" in the sentence and other words;

[0042] Then determine the core components of the sentence: Analyze the predicate verb in the sentence and its related subject, object, and adverbial components. For example, the subject is dependent on the verb, and the object is also dependent on the verb. These components form the basic structure of the sentence.

[0043] Model selection: Select an appropriate dependency syntax model based on the actual application and build dependency relationships;

[0044] S1234): Extracting the main structure, i.e. analyzing the subject, predicate, object, attributive, adverbial and complement in the sentences in the text to identify the main components of the sentences;

[0045] S1235): Dependency tree construction, using visualization tools to display dependency relationships for more intuitive analysis of sentence structure, as follows:

[0046] Dependency tree structured representation: A dependency tree is generated for each sentence. The root node of the tree is the sentence's predicate verb. Other words are attached to the trunk of the dependency tree in sequence according to their dependencies. The dependency tree makes it easy to see the master-slave relationship of the sentence components, thereby enabling grammatical analysis and sentence reorganization.

[0047] Dependency tree visualization: Use spaCy's displaCy tool or other dependency tree visualization tools to graphically represent the parsed dependency relationships, making it easier to understand the sentence structure.

[0048] S1236): Syntax rule verification and optimization

[0049] Dependency tree trunk and subordinate structure identification: By analyzing the dependency tree, we can determine the trunk structure of the sentence, that is, the predicate verb and its main modifying components. The subject and object directly depend on the predicate verb, while subordinate components such as attributives and adverbials depend on the core component.

[0050] Syntactic rule optimization: Based on the needs of the field, specific syntactic rules can be set to correct dependency relationships. For example, for complex sentence patterns such as compound sentences and parallel sentences, conjunctions can be processed through dependency syntax to clarify their position and function in the sentence structure. Conjunctions can be specially processed to ensure the accuracy of semantic dependency relationships.

[0051] In the knowledge graph construction method based on fine-tuning a large language model described in the present invention, a context embedding model is used in the knowledge point and relationship disambiguation in S3) to convert the extracted knowledge points and their contexts into high-dimensional vectors, thereby achieving more accurate semantic matching. Compared with traditional word vectors, context embedding can better capture the different meanings of the same word in different contexts, thereby improving the robustness of disambiguation.

[0052] The details are as follows:

[0053] For the input text t, the contextual embedding model BERT is used to convert the input text into a vector representation;

[0054] v t =BERT(t)

[0055] Among them, v t is the context embedding vector of text t,

[0056] Let cosine similarity calculate the angle between two vectors, which is defined as:

[0057]

[0058] Among them, v1 and v2 are the contextual embedding vector representations of the two texts;

[0059] In dynamic weighted cosine similarity, a weight w is assigned to each dimension, taking into account the different contributions of different dimensions to similarity. i , which enables similarity calculation to more flexibly reflect important information in the text:

[0060]

[0061] Among them, the dimension is d, d is the hidden layer size of the BERT model;

[0062] Among them, w iIt is the weight used for weighted cosine similarity, which is a weight dynamically calculated according to the context or category. It is used to measure the contribution of different dimensions to similarity. If two knowledge points have consistency in a certain category, the weight w of the dimension related to the category can be increased. i ;

[0063] The w i Based on the following factors

[0064] Term frequency (TF): the frequency with which a word appears in a text, reflecting its importance;

[0065] Inverse Document Frequency (IDF): how rare a word is in the entire corpus;

[0066] w i =TFi·IDFi

[0067] It can also be calculated by semantic level similarity, as follows:

[0068] Assume two sentences s1 and s2, their semantic vector representations are and

[0069] SBERT uses cosine similarity to measure the similarity between two sentences s1 and s2:

[0070]

[0071] Compared with traditional sentence representation methods, SBERT can capture more fine-grained semantic information, making the calculation of the similarity between two sentences at the semantic level more accurate;

[0072] Multi-level similarity:

[0073] In order to match semantics more precisely, the similarity of knowledge points can be calculated at multiple levels; the details are as follows:

[0074] First, the similarity at the word level is calculated, and then the similarity at the sentence level and the paragraph level is calculated. The final similarity can be the weighted average of the similarities at each level.

[0075] During the processing, if there are multiple representations of the same entity, we fine-tune the large model to determine whether they are the same knowledge point, and then perform mapping recognition to obtain the final knowledge points and relationships;

[0076] By similarity calculation, it is mapped to the knowledge point entity standard set.

[0077] It also includes mapping methods, and introduces context-aware semantic matching in the matching process by capturing the context of knowledge points in the text;

[0078] Contextual analysis, combining the contextual information of surrounding words and sentences to enhance the ability to distinguish synonyms or related knowledge points;

[0079] The knowledge graph construction method based on fine-tuning a large language model described in the present invention, the specific construction process of the knowledge point extraction and fine-tuning model is as follows:

[0080] (1) Data preparation, that is, preparing enough domain-related text data, including annotations of knowledge points. For different expressions of knowledge points, it is necessary to prepare a standardized knowledge point set to facilitate subsequent mapping and verification. The data source can be manually annotated text or use existing knowledge bases such as Wikipedia or expert-annotated domain datasets;

[0081] (2) Model selection

[0082] Choose a pre-trained large language model (such as BERT, GPT, etc.) as the pre-training model. This model has been pre-trained on a large amount of general data and has good language understanding capabilities. For the task of knowledge point extraction, you can choose a model based on the Transformer architecture. These models perform well in natural language processing tasks.

[0083] (3) Data labeling and cleaning of text

[0084] Preprocess the data, including text cleaning (removing noise and irrelevant content) and sentence segmentation. Next, use annotation tools or write rules to mark entities and relationships in the text. This step can use tools such as SpaCy or NLTK for automatic sentence segmentation and part-of-speech tagging.

[0085] (4) Fine-tune the pre-trained model to obtain a fine-tuned model.

[0086] For the knowledge point extraction task, the pre-trained model is fine-tuned to obtain a fine-tuned model. The training process of the pre-trained model is completed through the following stages:

[0087] Entity recognition: Use models to automatically identify entities in text, including concepts, facts, and principles;

[0088] Relationship extraction: extract the relationships between entities, including containment, subordination, and predecessor;

[0089] Disambiguation: For different descriptions of the same knowledge point, vectorization technology is used to calculate similarity and map similar expressions to the same entity.

[0090] 5. Model Validation and Optimization

[0091] The fine-tuned model is tested on the validation set to evaluate its accuracy in knowledge point recognition and relationship extraction tasks. The similarity algorithm is used to verify the accuracy and consistency of the extracted entities and relationships. If the accuracy and consistency meet the requirements, it means that the model can meet the needs.

[0092] The knowledge graph construction method based on fine-tuning a large language model described in the present invention includes the following specific methods for model verification and optimization:

[0093] Adaptive threshold adjustment: During the similarity calculation process, the similarity threshold is dynamically adjusted by continuously learning the accuracy of historical data;

[0094] The specific process is as follows:

[0095] Data initialization: Collect the initial historical data of similarity calculation, including the results of each similarity calculation and the correctness of actual verification;

[0096] Initial threshold setting: Set the similarity threshold based on common empirical values. The default threshold for cosine similarity is 0.8.

[0097] Similarity calculation: For the knowledge points to be processed, calculation is performed based on cosine similarity, SBERT or other similarity algorithms to obtain a preliminary similarity score;

[0098] Feedback collection: Based on the results of previous processing, the system collects feedback data from users or experts and marks whether each ambiguity resolution is correct;

[0099] Adaptive learning: The system uses accumulated feedback data and errors in disambiguation results to trigger threshold adjustments. The system uses machine learning algorithms to dynamically adjust the similarity threshold within a range of 0.05 to 0.10. The threshold can be adaptively adjusted based on different fields, text length, and semantic complexity.

[0100] Apply dynamic threshold: In a new round of similarity calculation, a dynamically adjusted threshold is used to determine whether two knowledge points are considered the same.

[0101] The knowledge graph construction method based on fine-tuning a large language model described in the present invention can be combined with symbolic reasoning during the disambiguation process. Symbolic reasoning can further correct the disambiguation results using known rules and logic. The specific process is as follows:

[0102] (1) Knowledge point extraction: extract potential similar knowledge points from the original document data and obtain preliminary semantic similarity through deep learning model;

[0103] (2): Semantic disambiguation: Use deep learning methods to perform preliminary similarity calculations and disambiguate some basic knowledge points;

[0104] (3): Application of symbolic reasoning rules: For knowledge points that cannot be disambiguated or have insufficient similarity, symbolic reasoning is combined with defined rule sets or logical reasoning to further correct the results based on known knowledge in the field;

[0105] (4): Reasoning optimization: The results of symbolic reasoning in the previous step are fed back to the deep learning model to further adjust the weights or thresholds of the deep learning model to reduce errors;

[0106] (5): Output the final result: Combine the final results of symbolic reasoning and deep learning disambiguation to determine whether the two knowledge points are the same.

[0107] The knowledge graph construction method based on fine-tuning a large language model described in the present invention uses a domain knowledge-based disambiguation mechanism during the disambiguation process. In addition to general semantic matching and similarity calculation in a specific domain, it can also combine domain-specific expert knowledge or rules for disambiguation.

[0108] Implementation process:

[0109] A. Knowledge point semantic matching: Use deep learning models to perform general semantic matching on the extracted knowledge points;

[0110] B. Domain Expert Knowledge Introduction: Introducing domain-specific expert rules, definitions, vocabularies, or knowledge graphs to further verify and correct semantic matching results through this domain knowledge.

[0111] C. Domain rule disambiguation: Based on the rule set of a specific domain, the matching results can be more finely classified or excluded;

[0112] D. Output disambiguation results: Combine the domain knowledge disambiguation results with the general semantic matching results to output the final disambiguated knowledge point matching.

[0113] The knowledge graph construction method based on fine-tuning a large language model described in the present invention uses the following multiple means to ensure the accuracy of inserted knowledge points and relationships during the knowledge graph construction process, as follows:

[0114] (1) Multi-level verification

[0115] Rule-based verification: Different validation rules are defined for different fields to detect knowledge points and relationships. If data that does not meet the validation rules is matched, the potential error is marked, and the knowledge points and relationships marked as not incorrect will be deleted.

[0116] Context consistency verification: By analyzing the context of the knowledge point, we ensure that the extracted entities and relationships are consistent with the logic in the text;

[0117] Domain expert review: For knowledge in a specific field, expert-annotated knowledge bases can be introduced for comparison to ensure that the extracted knowledge points are consistent with the information in the existing knowledge base;

[0118] (2) Semantic similarity matching

[0119] Use semantic similarity calculation to verify the extracted knowledge points. For example, use language models such as BERT and SBERT to vectorize the extracted knowledge points and standard knowledge points, and then calculate the similarity to determine whether the knowledge points are accurately extracted. If the similarity is lower than the set threshold, it is marked as a potential error and deleted.

[0120] (3) Relational logic verification

[0121] Relationship type restrictions: Ensure that relationship types conform to domain logic and perform logical verification of relationship types using the domain rule base. For example, in the education domain, the relationship between "course" and "chapter" should be "included" rather than "preceded";

[0122] Loop detection: Use graph algorithms to detect whether there are unreasonable loops in the knowledge graph to avoid incorrect relationships that lead to unreasonable knowledge graph structures.

[0123] In the method for constructing a knowledge graph based on a fine-tuned large language model of the present invention, the means and process for verifying the accuracy of extracting knowledge points and relationships from the data source in S2) are specifically as follows:

[0124] Before storing the knowledge points and relationships in the graph database, use the following steps to verify the accuracy of the extracted knowledge points and relationships:

[0125] (1): Automated test dataset

[0126] Build a standard annotated dataset and use it as a benchmark input to the AI ​​model. Then compare the knowledge points extracted by the model with the standard answers. If the extracted knowledge points and relationships are consistent with those in the annotated dataset, the model passes verification; otherwise, further model debugging or algorithm adjustment is required.

[0127] (2): Manual review and expert feedback

[0128] Knowledge points in specific fields are manually reviewed by experts to ensure that the extracted content meets industry standards;

[0129] (3): Context verification

[0130] After the knowledge points are extracted, they are verified again in combination with their context to ensure that the extracted knowledge points are consistent with their meaning in the context;

[0131] (4): Model adaptive optimization

[0132] By continuously collecting model extraction errors, analyzing them, providing feedback, and incorporating this feedback into training data, the model's performance is continuously optimized. This cyclical feedback mechanism can effectively improve extraction accuracy. During the knowledge graph construction process, complex knowledge graphs can be constructed by inserting extracted knowledge points and relationships into a graph database using tools such as Neo4j and JanusGraph. At the same time, the accuracy and logic of the inserted data are ensured through contextual consistency checks, rule-based validation, semantic similarity matching, and loop detection. To further verify the accuracy of knowledge points and relationships, various methods such as automated dataset testing, expert review, and contextual verification can be used to ensure the high quality and accuracy of the knowledge graph.

[0133] It can be seen from the above technical solution that the present invention has the following beneficial effects:

[0134] 1. The present invention describes a method for constructing a knowledge graph based on a fine-tuned large language model, which obtains processed data from data preprocessing, and then automatically extracts knowledge points by utilizing a knowledge point extraction fine-tuning model to determine entities and relationship edges. The extracted knowledge points are further identified and optimized through a variety of disambiguation methods, and the complex relationships between knowledge points are identified and constructed, effectively improving the efficiency and accuracy of data processing. Finally, the disambiguated data is stored in a graph database model to construct a knowledge graph, realizing the automatic construction and update of the knowledge graph, and effectively solving the problems of large workload and time-consuming data processing.

[0135] 2. The data preprocessing process described in the present invention effectively improves the accuracy of data processing, effectively removes invalid data, and improves the efficiency of data processing through text cleaning, sentence processing, repeated content extraction, and context preservation.

[0136] 3. Extract knowledge points and relationships from the data source by building a specialized extraction and fine-tuning model to accurately identify the relationships between entities, effectively solving the problem of difficulty in identifying relationships between entities in current data processing.

[0137] 4. This invention utilizes a large AI model combined with vector embedding, semantic similarity calculation, and symbolic reasoning to efficiently identify and disambiguate different representations of the same knowledge point. Dynamic updates to the standard set and integration with domain knowledge further enhance the accuracy and flexibility of knowledge point disambiguation. This approach is particularly effective in building and maintaining large-scale knowledge graphs, ensuring high accuracy and robustness. BRIEF DESCRIPTION OF THE DRAWINGS

[0138] Figure 1 This is a schematic diagram of the structure of the knowledge graph construction method based on fine-tuning the large language model according to the present invention;

[0139] Figure 2 Flowchart for disambiguating knowledge points and relationships in the present invention. DETAILED DESCRIPTION

[0140] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments.

[0141] Example

[0142] like Figure 1 The method for constructing a knowledge graph based on fine-tuning a large language model shown in FIG includes the following steps:

[0143] S1): Data preprocessing, i.e. processing the data source of the knowledge points to be extracted. The data source of the knowledge points to be extracted includes structured data and unstructured data. The structured data is directly input into the mapper, and the text data in the unstructured data is cleaned and segmented.

[0144] S2): Extract knowledge points and relationships from the data source. First, build a dedicated knowledge point extraction fine-tuning model. Input the pre-processed data into the knowledge point extraction fine-tuning model. The knowledge point extraction fine-tuning model automatically identifies entities in the text and extracts the relationships between the entities to obtain pre-processed knowledge points and relationships.

[0145] S3): Knowledge point and relationship disambiguation, that is, identification and mapping of different descriptions of the same knowledge point. The specific disambiguation process is as follows:

[0146] S31): Establishing a standard knowledge point database, that is, first constructing a standard set of knowledge point entities. The established standard set of knowledge point entities is used as a mapping target set to disambiguate the knowledge points extracted from the text;

[0147] S32): Similarity calculation and mapping, i.e., using text embedding technology from natural language processing to convert knowledge points and related text into vectors; similarity calculation is then performed to determine whether the extracted different expressions point to the same knowledge point by calculating the cosine similarity or Euclidean distance between the text embedding vectors. Cosine similarity is used to measure the angle between vectors to determine their similarity;

[0148] S33): Context-based semantic disambiguation: To ensure the accuracy of the disambiguation process, a sliding window technique is used to take contextual information into account. This allows the system to consider not only the current sentence but also the preceding and following sentences when identifying knowledge points, extracting knowledge point relationships from preprocessed knowledge points.

[0149] S34): Iterative Verification and Feedback Optimization: After disambiguation, the knowledge points and relationships extracted in the previous step are mapped to the standard set of knowledge point entities. The two are matched to find possible corresponding relationships. Further verification is performed based on the extracted relationships. If there is a mismatch, the entity is deleted.

[0150] S4): Knowledge graph construction: First, establish a graph database model, innovate entity nodes, and create relationships between entity nodes to form relationship edges. Then, store the disambiguated entity nodes and relationship edges in the graph database model to form a dynamic and scalable knowledge graph. During later use, use the AI ​​model regularly to re-analyze text data and update the knowledge graph.

[0151] In the method for constructing a knowledge graph based on fine-tuning a large language model described in this embodiment, the specific method for preprocessing text materials in unstructured data in S1) is as follows:

[0152] S11): Text cleaning: First, the text data in the unstructured data is cleaned, and the different text regions in the text are classified using a deep learning model. The irrelevant content is distinguished from the main text through the context and semantic features of the text. The main text and irrelevant content (headers, footers, advertisements, copyright notices) are automatically identified, and irrelevant content is removed using regular expressions. The noise in the text data is eliminated, and extra spaces, special characters, irrelevant HTML tags (for web page data), and repeated text are deleted.

[0153] S12): Sentence processing: In order to provide a clear context for subsequent knowledge point extraction, the cleaned text needs to be sentence-separated;

[0154] S13): Extract repeated content, extract repeated content in the text data by detecting repeated sentences and repeated paragraphs, specifically:

[0155] Detect duplicate sentences, using text similarity detection algorithms to identify and merge similar or duplicate sentences;

[0156] Detect duplicate paragraphs: Detect longer texts through text comparison and clustering algorithms, and merge duplicate paragraphs;

[0157] S14): Context preservation: To preserve the original context of the text, the following measures are taken:

[0158] Maintain paragraph structure: While dividing sentences, maintain the paragraph structure of the original text so that the complete paragraph information can be referenced when extracting knowledge points;

[0159] Use sliding windows: To capture a wider range of contextual information, a sliding window technique can be used when extracting knowledge points. This allows the model to consider information about a sentence and its surrounding sentences simultaneously.

[0160] The knowledge graph construction method based on fine-tuning the large language model described in this embodiment, the specific process of sentence processing in S12) is as follows:

[0161] S121): Based on punctuation: using periods, question marks, exclamation points and other punctuation marks as sentence separators;

[0162] S122): Sentence segmentation using AI models or natural language processing libraries (such as SpaCy, NLTK, etc.) based on natural language processing tools. These tools can more accurately identify sentence boundaries even in the absence of obvious punctuation;

[0163] S123): Dependency-based syntactic analysis: By analyzing the dependency relationships in a sentence, the main and subordinate structures of the sentence are determined, thereby more accurately dividing the sentence. The core idea is to decompose the sentence into a "dependency relationship" graph between words, thereby determining the predicate verb, subject, object and other elements in the sentence and their mutual relationships.

[0164] In the knowledge graph construction method based on fine-tuning a large language model described in this embodiment, the specific analysis process of the dependency syntax analysis in S123) is as follows:

[0165] S1231): Input preprocessing, which includes word segmentation, denoising, and normalization of the input text; the details are as follows:

[0166] Text cleaning: First, the input text data needs to be cleaned and preprocessed. Specifically, this involves removing noise, symbols, and irrelevant HTML tags, and normalizing complex text, including converting it to lowercase and correcting typos.

[0167] Word segmentation: Before syntactic analysis, the sentence is segmented into individual words or phrases. The accuracy of word segmentation is the foundation of dependency parsing. Using mature word segmentation tools such as SpaCy, Stanford NLP, and HanLP can significantly improve word segmentation accuracy.

[0168] S1232): Part-of-Speech Tagging (POS),

[0169] First, use natural language processing tools to tag each word with a part-of-speech tag. This involves using a part-of-speech tagger to tag each word or phrase after segmentation, determining its grammatical role in the sentence, including noun, verb, or adjective. Part-of-speech tagging provides basic information for subsequent dependency analysis. Commonly used tools include spaCy, NLTK, and StanfordPOS Tagger.

[0170] Then, simplify the parts of speech: simplify the parts of speech according to the specific application scenarios of words or phrases, including simplifying detailed verb forms into a single "verb" category;

[0171] S1233): Dependency Parsing: Use the dependency parsing model to generate a dependency tree to determine the predicate verb, subject, and object elements in the sentence and their relationships. The details are as follows: First, perform sentence component analysis: Use dependency parsing to analyze the dependency relationships between words in the sentence and obtain a dependency tree. The goal of dependency parsing is to find the subordinate relationships between the "core words" (such as predicate verbs) in the sentence and other words;

[0172] Then determine the core components of the sentence: analyze the predicate verb (core component) in the sentence and its related subject, object, and adverbial components;

[0173] Model selection: Choose an appropriate dependency syntax model based on the actual application and build dependency relationships. Common dependency syntax models include transition-based models and graph-based models. The former gradually builds dependency relationships through serialization, while the latter optimizes global dependency relationships through graph structures.

[0174] S1234): Trunk structure extraction, i.e., analyzing the subject, predicate, object, attributive, adverbial, and complement components in the text to identify the main components of the sentence; S1235): Dependency tree construction, using visualization tools to display dependency relationships for more intuitive analysis of sentence structure. Specifically, dependency tree structured representation: A dependency tree is generated for each sentence. The root node of the tree is the sentence's predicate verb. Other words are sequentially attached to the trunk of the dependency tree based on dependency relationships. The dependency tree makes it easy to see the master-slave relationship of the components in the sentence, thereby achieving grammatical analysis and sentence reorganization;

[0175] Dependency tree visualization: Use spaCy's displaCy tool or other dependency tree visualization tools to graphically represent the parsed dependency relationships, making it easier to understand the sentence structure.

[0176] S1236): Grammatical rule verification and optimization: Dependency tree trunk and subordinate structure identification: By analyzing the dependency tree, the main structure of the sentence can be determined, that is, the predicate verb and its main modifying components (such as subject, object, etc.). The subject and object directly depend on the predicate verb, while the subordinate components such as attributives and adverbials depend on the core components; Syntactic rule optimization: According to the needs of the field, some specific syntactic rules can be set to correct the dependency relationship, for example, for complex sentences and parallel sentences,

[0177] For complex sentences, conjunctions can be processed through dependency syntax to clarify their position and function in the sentence structure.

[0178] It should be noted that the subordinate relationship between core words and other words mainly follows the following principles:

[0179] 1. Take the predicate verb as the core: The predicate verb is the root node of the dependency tree, and other words establish dependency relationships around it.

[0180] 2. Dependency of main components: The subject and object directly depend on the predicate verb, while subordinate components such as attributives and adverbials depend on the core component.

[0181] 3. Hierarchical structure: Through the form of a dependency tree, the master-slave relationship of each component in the sentence is clearly displayed, facilitating grammatical analysis and sentence reorganization.

[0182] 4. Grammatical rules: Specific syntactic rules will be set according to the needs of specific fields, especially when dealing with complex sentence patterns such as compound sentences and parallel sentences, to ensure the accuracy of semantic dependencies.

[0183] The words in S1235) are linked based on grammatical relationships and hierarchical structures, and the linking process follows the following principles:

[0184] -First, use the predicate verb as the root node and trunk of the dependency tree.

[0185] -The main grammatical components (such as subject and object) are directly dependent on the predicate verb, while other modifying components (such as attributives and adverbials) are dependent on the core components they modify.

[0186] -The whole sentence forms a hierarchical structure, clearly showing the master-slave relationship of each component in the sentence.

[0187] In the specific process of linking, the main structure of the sentence is identified by analyzing the subject, predicate, object, attributive, adverbial, and complement components of the sentence. Specific grammatical rules are followed, especially when dealing with complex sentence patterns such as compound sentences and parallel sentences, to ensure the accuracy of semantic dependencies. It should be noted that the predicate verb is the core and the root node of the dependency tree, which is an important part of the main structure of the entire sentence.

[0188] The core components and their subordinate relationships are as follows:

[0189] The subject and object are directly dependent on the predicate verb, while the attributive, adverbial, etc. are subordinate components, which are dependent on the core component. 3. The concept of core component:

[0190] - "Core word" refers specifically to the word that acts as the dominant factor in a sentence, usually the predicate verb

[0191] - "Core components of a sentence" is a broader concept, including the predicate verb and its directly related sentence components such as the subject, object, and adverbial modifier;

[0192] This hierarchical structure clearly shows the master-slave relationship of each component in a sentence in the form of a dependency tree.

[0193] Application Scenario

[0194] Machine translation: Dependency analysis can help machine translation systems better understand the structure of complex sentences and ensure translation accuracy.

[0195] Text Summarization: Dependency parsing can be used to generate concise text summaries by extracting the backbone structure of sentences.

[0196] Question answering system: Dependency parsing can help question answering systems understand the core components of user questions and thus generate more accurate answers.

[0197] Dependency parsing, as an effective method for analyzing the internal structure of sentences, has been widely used in text analysis, information extraction and other fields.

[0198] In the process of extracting knowledge points and relationships from the data source in S2) described in this embodiment, an AI big model is used to identify entities and concepts in the text as pre-processed knowledge points. For the application of the big model, the extraction of knowledge points is mainly done through Prompt and mounting a limited knowledge set. It should be noted that the AI ​​big model uses an existing pre-trained model, Ali qwen-max, and it can also choose other models that can meet the requirements according to actual needs. Mounting a limited knowledge set is to clarify the limited set of knowledge points within the vertical range. This part of the content comes from an external knowledge base, such as Wikipedia or annotations by domain experts within the company, such as a computer teacher defining 408 subject test knowledge points and a custom rule set: according to specific needs, define a set of your own limited knowledge sets as constraints for entity and relationship extraction.

[0199] The following is a prompt text:

[0200] You are a knowledge graph expert in the field of online education, specializing in entity extraction and relationship extraction. You extract entities and relationships between entities from text.

[0201] The entity types are limited to the following:

[0202] Facts: Information describing observed facts, knowledge about specific things, such as capitals, dates, formulas, etc.

[0203] Composition: refers to the understanding of the components of things, such as human body structure, engine parts, computer hardware, etc.

[0204] Concept: refers to the abstract and general definition of things, such as democracy, evolution, force, etc.

[0205] Principle: refers to the understanding of how things work, such as Newton's laws of motion, circuit principles, programming languages, etc., including subcategories such as rules and formulas.

[0206] Procedure: refers to the steps and methods of how to complete a task, such as solving math problems, doing experiments, writing essays, etc.

[0207] Core curriculum: In an education system, core courses are essential and fundamental to achieving specific educational goals. Core courses typically cover a broad range of basic knowledge and skills. For example, "Advanced Mathematics: A required foundational course for university science and engineering students."

[0208] Entity relationships are limited to the following scopes:

[0209] Contains: One entity contains another entity, meaning that a larger entity contains a smaller part or subset. For example: "The mathematics curriculum includes algebra, geometry, and calculus."

[0210] Belong to: two knowledge points B are part of knowledge point A. For example: "Hardware is part of the computer system."

[0211] Precedence: One entity is a previous state or stage of another, usually an earlier stage in a process. For example: "Algebra is a prerequisite to calculus."

[0212] Synonymy: Two entities are identical or very similar in meaning and can be used interchangeably. For example, "differential and derivative are synonymous in some contexts."

[0213] Reference: a correlation or relationship between two entities, such as "the instruction word length depends on the length of the opcode and the length and number of operand addresses."

[0214] Application: Apply to. Knowledge point A is a way or method to apply knowledge point B. For example: "Through study and practice, theoretical knowledge can be transformed into practical skills."

[0215] Correlation: There is some association or connection between two entities, but it is not necessarily a causal relationship. For example: "There is a correlation between study time and test scores."

[0216] Follow these steps:

[0217] Step 1: High-precision entity recognition and entity extraction

[0218] - Deeply understand the entity context and accurately identify entity attributes and meanings.

[0219] -Entity types are limited to the provided types, and new categories cannot be generated arbitrarily.

[0220] Step 2: Complex relationship parsing and extracting relationships between entities

[0221] - Ensure that the parsing logic is rigorous and complies with the construction principles and standards of the knowledge graph.

[0222] -Entity relationships are limited to the pre-provided relationship range, and new relationships cannot be generated arbitrarily.

[0223] Step 3: The final output data format is as follows:

[0224] "entities":[

[0225] {

[0226] "name":"Entity name",

[0227] "type":"Entity type"

[0228] }

[0229] ],

[0230] "relations":[

[0231] {

[0232] "head": "Relationship head entity name",

[0233] "tail": "Relationship tail entity name",

[0234] "type":"Relationship type"

[0235] } ]

[0237] }

[0238] It should be noted that the data format of json type contains array keys such as "entities".

[0239] For example:

[0240] Content: Recursion and iteration are two common methods for solving data structure problems. Recursion is breaking down a problem into smaller sub-problems, while iteration is repeatedly executing a set of instructions until a condition is met.

[0241] result:

[0242] {

[0243] "entities":[

[0244] {

[0245] "name":"Semiconductor Random Access Memory",

[0246] "type":"concept"

[0247] },

[0248] {

[0249] "name":"Computer Performance Index",

[0250] "type":"concept"

[0251] },

[0252] {

[0253] "name":"Basic principles of multiplication and division operations",

[0254] "type":"principle"

[0255] },

[0256] {

[0257] "name":"Calculation method",

[0258] "type":"principle"

[0259] },

[0260] {

[0261] "name":"command",

[0262] "type":"concept"

[0263] },

[0264] {

[0265] "name":"Basic Principles of Cache",

[0266] "type":"principle"

[0267] },

[0268] {

[0269] "name":"Replacement algorithm for main memory blocks in cache",

[0270] "type":"principle"

[0271] },

[0272] {

[0273] "name":"Instruction format",

[0274] "type":"concept"

[0275] },

[0276] {

[0277] "name":"Data Structure",

[0278] "type":"core course"

[0279] }

[0280] ],

[0281] "relations":[

[0282] {

[0283] "head":"Calculation method",

[0284] "tail":"Basic principles of multiplication and division operations",

[0285] "type":"include"

[0286] },

[0287] {

[0288] "head":"Instructions",

[0289] "tail":"command format",

[0290] "type":"include"

[0291] },

[0292] {

[0293] "head":"Replacement algorithm of main memory blocks in cache",

[0294] "tail":"Basic Principles of Cache",

[0295] "type":"related"

[0296] } ]

[0298] }

[0299] Here's an example scenario:

[0300] enter:

[0301] Advanced mathematics is a foundational course for university students majoring in science and engineering. It includes calculus, linear algebra, and probability theory. Calculus is a prerequisite for further study in physics, while linear algebra is closely related to engineering mathematics. Probability theory is primarily used in the field of data analysis.

[0302] Output:

[0303]

[0304]

[0305]

[0306] The knowledge point and relationship disambiguation uses cosine similarity to measure the angle between two vectors to determine whether they represent the same concept. The calculation formula of cosine similarity is:

[0307] Where a and b are two vectors, and ||a|| and ||b|| are their modulos.

[0308] In this way, similar knowledge points can be mapped to the same entity, thereby constructing accurate entities and relationships in the knowledge graph. This method can improve the accuracy and robustness of the knowledge graph, allowing the knowledge graph to better reflect the knowledge and information in the text material.

[0309] The standard set of knowledge point entities is the foundation of knowledge disambiguation. It is usually derived from authoritative public resources (such as Wikipedia and DBpedia), specialized knowledge bases annotated by domain experts, or internal enterprise knowledge bases. In this process, ensuring the accuracy and coverage of the standard set is crucial.

[0310] Authoritative public resources: such as the structured data provided by WikiData, which can cover basic concepts and entities in multiple fields.

[0311] Expert-labeled specialized data sources: By combining knowledge in specific fields, enterprises can build customized sets of standard knowledge points based on their business needs. These sets are particularly suitable for applications in vertical scenarios (such as mathematics, education, etc.).

[0312] Dynamic update mechanism: The standard set of knowledge point entities is regularly updated from the latest literature and databases during use, and new knowledge points are continuously introduced to ensure the real-time nature of the system's knowledge.

[0313] Standardization and naming conventions:

[0314] Name and standardize each knowledge point to ensure consistent naming. For example, a course can be standardized as "Linear Algebra" rather than variations like "Linear Algebra" or "Linear Algebra Class." Furthermore, these standardized knowledge points must include unique identifiers (such as knowledge point IDs) for subsequent mapping and querying.

[0315] In the knowledge graph construction method based on fine-tuning a large language model described in this embodiment, a contextual embedding model (such as BERT and RoBERTa) is used in the knowledge point and relationship disambiguation in S3) to convert the extracted knowledge points and their context into high-dimensional vectors, thereby achieving more accurate semantic matching. Compared with traditional word vectors (such as Word2Vec), contextual embedding can better capture the different meanings of the same word in different contexts, thereby improving the robustness of disambiguation;

[0316] The details are as follows:

[0317] For the input text t, the contextual embedding model BERT is used to convert the input text into a vector representation;

[0318] v t =BERT(t)

[0319] Among them, v t is the contextual embedding vector of text t, with dimension d, where d is usually the hidden layer size of the BERT model (e.g., 768 dimensions);

[0320] Compared with the formula of traditional word embedding models (such as Word2Vec), the latter's word vector is expressed as:

[0321] v w =Word2Vec(w)

[0322] Among them, w is a word, v_w is a fixed vector of the word, Word2Vec does not consider the context, and the representation of a word in different contexts is fixed.

[0323] The context embedding model maps the meaning of the same word in different scenarios to different vectors through contextual information, greatly improving the accuracy of similarity calculation.

[0324] Let cosine similarity calculate the angle between two vectors, which is defined as:

[0325] Among them, v t is the context embedding vector of text t,

[0326] Let cosine similarity calculate the angle between two vectors, which is defined as:

[0327]

[0328] Among them, v1 and v2 are the contextual embedding vector representations of the two texts;

[0329] In the dynamic weighted cosine similarity, considering that different dimensions contribute differently to the similarity, a

[0330] Weight w i , which enables similarity calculation to more flexibly reflect important information in the text:

[0331]

[0332] Among them, the dimension is d, d is the hidden layer size of the BERT model;

[0333] Among them, w i It is the weight used for weighted cosine similarity, which is a weight dynamically calculated according to the context or category. It is used to measure the contribution of different dimensions to similarity. If two knowledge points have consistency in a certain category, the weight w of the dimension related to the category can be increased. i ;

[0334] The w i Based on the following factors

[0335] Term frequency (TF): the frequency with which a word appears in a text, reflecting its importance;

[0336] Inverse Document Frequency (IDF): how rare a word is in the entire corpus;

[0337] It can also be calculated by semantic level similarity, as follows:

[0338] Assume two sentences s1 and s2, their semantic vector representations are and

[0339] SBERT uses cosine similarity to measure the similarity between two sentences s1 and s2:

[0340]

[0341] Compared with traditional sentence representation methods, SBERT can capture more fine-grained semantic information, making the calculation of the similarity between two sentences at the semantic level more accurate;

[0342] Multi-level similarity:

[0343] In order to match semantics more precisely, the similarity of knowledge points can be calculated at multiple levels; the details are as follows:

[0344] First, we calculate the similarity based on the word level, then calculate the similarity at the sentence level and the paragraph level. The final similarity can be the weighted average of the similarities at each level:

[0345] During the processing, if there are multiple representations of the same entity, we fine-tune the large model to determine whether they are the same knowledge point, and then perform mapping recognition to obtain the final knowledge points and relationships;

[0346] By similarity calculation, it is mapped to the knowledge point entity standard set.

[0347] It also includes mapping methods, and introduces context-aware semantic matching in the matching process by capturing the context of knowledge points in the text;

[0348] Contextual analysis combines the contextual information of surrounding words and sentences to enhance the ability to distinguish synonyms or related knowledge points. For example, if "quantum mechanics" is mentioned in the context of physics, it can be inferred that the expression is consistent with the relevant knowledge points in this field.

[0349] It should be noted that dynamic weighted cosine similarity is suitable for scenarios where the importance of different dimensions needs to be considered. By assigning weights w_i to different dimensions, the calculation results can more flexibly reflect important information. In particular, when two knowledge points have consistency in a certain category, the weight of the relevant dimension of the category can be increased;

[0350] Semantic Level Similarity (SBERT): Suitable for scenarios requiring more fine-grained semantic analysis. Compared to traditional sentence representations, SBERT can capture more fine-grained semantic information, making the similarity calculation between sentences more accurate.

[0351] Multi-level similarity: Suitable for scenarios that require more comprehensive semantic matching; this method calculates similarity at multiple levels simultaneously.

[0352] The knowledge graph construction method based on fine-tuning a large language model described in this embodiment, the specific construction process of the knowledge point extraction and fine-tuning model is as follows:

[0353] 1. Data preparation: This involves preparing sufficient domain-related text data, including annotations of knowledge points. For different knowledge point expressions, a standardized set of knowledge points is required to facilitate subsequent mapping and verification. The data source can be manually annotated text or an existing knowledge base.

[0354] 2. Model Selection

[0355] Choose a pre-trained large language model (such as BERT, GPT, etc.) as the pre-training model. This model has been pre-trained on a large amount of general data and has good language understanding capabilities. For the task of knowledge point extraction, you can choose a model based on the Transformer architecture. These models perform well in natural language processing tasks.

[0356] 3. Label and clean the text

[0357] Preprocess the data, including text cleaning (removing noise and irrelevant content) and sentence segmentation. Next, use annotation tools or write rules to mark entities and relationships in the text. This step can use tools such as SpaCy or NLTK for automatic sentence segmentation and part-of-speech tagging.

[0358] 4. Fine-tune the pre-trained model to obtain the fine-tuned model.

[0359] For the knowledge point extraction task, the pre-trained model is fine-tuned to obtain a fine-tuned model. The training process of the pre-trained model is completed through the following stages:

[0360] Entity recognition: Use models to automatically identify entities in text, including concepts, facts, and principles;

[0361] Relationship extraction: The extraction model automatically identifies the relationships between entities in the text, including inclusion, subordination, and predecessor;

[0362] Disambiguation: For different descriptions of the same knowledge point, vectorization technology is used to calculate similarity and map similar expressions to the same entity.

[0363] 5. Model Validation and Optimization

[0364] The fine-tuned model is tested on the validation set to evaluate its accuracy in knowledge point recognition and relationship extraction tasks. The similarity algorithm is used to verify the accuracy and consistency of the extracted entities and relationships. If the accuracy and consistency meet the requirements, it means that the model can meet the needs.

[0365] The specific process of fine-tuning the pre-trained model to obtain the fine-tuned model is as follows:

[0366] (401) First, determine the task objectives: that is, determine the task objectives of entity recognition, relationship extraction, and disambiguation processing respectively;

[0367] (402) Prepare the dataset: label the entities and relationships (BI0 labels, entity pairs and relationship categories);

[0368] (403) Model selection: that is, according to actual needs, select a suitable model from “BERT-type models (suitable for classification and sequence labeling), GPT-type models (suitable for generation tasks), and graph neural networks (suitable for complex relationship modeling)”;

[0369] (404) Design fine-tuning tasks: that is, setting fine-tuning tasks for the selected model, specifically, performing sequence labeling (BI0) for entity recognition and fine-tuning using a linear layer; relation extraction: extracting relations from entities and contexts, extracting and outputting relations through a classifier; for disambiguation processing, performing entity vectorization description and training a similarity classifier or clustering model for fine-tuning;

[0370] (405): Train and optimize the fine-tuned model using the AdamW optimizer and set the learning rate to 1e -5 to 5e -5 ;

[0371] (406): Evaluate the fine-tuned training model, specifically: evaluate the entity recognition extraction through the F1 score performance indicator; evaluate the accuracy of relationship extraction by judging the text classification accuracy and F1 score performance indicator during the relationship extraction process; evaluate the effect of disambiguation processing through Top-k accuracy and similarity evaluation.

[0372] The knowledge graph construction method based on fine-tuning the large language model described in this embodiment, and the specific methods of model verification and optimization are as follows:

[0373] Adaptive threshold adjustment: During the similarity calculation process, the similarity threshold is dynamically adjusted by continuously learning the accuracy of historical data. The specific process is as follows:

[0374] Data initialization: Collect the initial historical data of similarity calculation, including the results of each similarity calculation and the correctness of actual verification;

[0375] Initial threshold setting: Set the similarity threshold based on common empirical values. The default threshold for cosine similarity is 0.8.

[0376] Similarity calculation: For each knowledge point to be processed, a preliminary similarity score is obtained based on cosine similarity, SBERT, or other similarity algorithms.

[0377] Feedback collection: Based on the results of previous processing, the system collects feedback data from users or experts and marks whether each ambiguity resolution is correct;

[0378] Adaptive learning: The system uses machine learning algorithms to dynamically adjust the similarity threshold based on accumulated feedback data and errors in disambiguation results. The adjustment range is between 0.05 and 0.10. The threshold can be adaptively adjusted based on different fields, text length, and semantic complexity.

[0379] Apply dynamic threshold: In a new round of similarity calculation, a dynamically adjusted threshold is used to determine whether two knowledge points are considered the same.

[0380] For example, when the system disambiguates “quantum physics” and “quantum mechanics,” based on similar data previously processed, the system can adaptively adjust the threshold to ensure that these statements are considered the same knowledge point.

[0381] In this embodiment, the extracted knowledge points and relationships are stored in the graph database. The specific process of forming the knowledge graph is as follows: 1. Insert the knowledge points and relationships into the graph database

[0382] Graph databases (such as Neo4j, JanusGraph, and ArangoDB) store data in the form of nodes and edges. Nodes represent entities (knowledge points), and edges represent relationships between entities. The process of building a knowledge graph mainly involves the following steps:

[0383] (1) Design of graph data model

[0384] Entity Nodes: Each extracted knowledge point is inserted into the graph database as a node. Nodes usually have multiple attributes, such as entity name, type, unique ID, etc.

[0385] Edges: The relationship between each two entities is represented as an edge. The attributes of the edge include the relationship type (such as "contains", "related", "predecessor", etc.) and the direction of the relationship.

[0386] (2) Insertion process using Neo4j as an example

[0387] Connect to the graph database: Use the Neo4j Python client (such as `neo4j-driver`) to connect to the Neo4j database:

[0388] ```Python

[0389] from neo4j import GraphDatabase

[0390] uri="bolt: / / localhost:7687"

[0391] driver=GraphDatabase.driver(uri,auth=("username","password"))

[0392] Create nodes and relationships:

[0393] Create entity nodes: Each extracted knowledge point is inserted into the graph database as a node.

[0394] ```cypher

[0395] CREATE(n:Entity{name:'Advanced Mathematics',type:'Course'})

[0396] ```

[0397] You can use the Python API to insert nodes in batches:

[0398]

[0399] 2. Create relationship edges: Create relationships between entity nodes.

[0400] ```cypher

[0401] MATCH(a:Entity{name:'Advanced Mathematics'}),(b:Entity{name:'Calculus'})

[0402] CREATE(a)-[:contains]->(b)

[0403] ```

[0404] In Python, you can create relationships in batches:

[0405]

[0406] (3) Insertion process using JanusGraph

[0407] For distributed graph databases such as JanusGraph, Gremlin is often used as a query language, similar to Neo4j's Cypher. Bulk insert nodes and relationships through the Gremlin interface:

[0408] ```gremlin

[0409] g.addV('Entity').property('name','Advanced Mathematics').property('type','Course')

[0410] gV().has('name','Advanced Mathematics').addE('includes').to(gV().has('name','Calculus')).

[0411] The knowledge graph construction method based on fine-tuning the large language model described in this embodiment can be combined with symbolic reasoning during the disambiguation process. The specific process is as follows:

[0412] (1) Knowledge point extraction: Extract potential similar knowledge points from the original document data and obtain preliminary semantic similarity through deep learning models (such as BERT or SBERT);

[0413] (2): Semantic disambiguation: Use deep learning methods to perform preliminary similarity calculations and disambiguate some basic knowledge points;

[0414] (3): Application of symbolic reasoning rules: For knowledge points that cannot be disambiguated or have insufficient similarity, symbolic reasoning is combined with defined rule sets or logical reasoning (such as reasoning of premises and conclusions) to further correct the results based on known knowledge in the field;

[0415] (4): Reasoning optimization: The results of symbolic reasoning in the previous step are fed back to the deep learning model to further adjust the weights or thresholds of the deep learning model;

[0416] (5): Output the final result: Combine the final results of symbolic reasoning and deep learning disambiguation to determine whether the two knowledge points are the same.

[0417] The known rules include logical rules based on logical expressions (mutual exclusivity, transitivity), ontology rules for defining the hierarchy, attributes and relationships of concepts, data consistency rules for verifying the consistency of data, semantic rules for reasoning through context or defined semantic relationships, mathematical or physical laws and priority rules.

[0418] The deep learning model (such as BERT or SBERT) obtains preliminary semantic similarity and generates fixed word vectors, which can be used to calculate semantic similarity as follows:

[0419] Word2Vec: Generates word vectors based on a context window and uses cosine similarity of the vectors to compare semantic similarity;

[0420] GloVe: Generates word embeddings based on global statistical information, suitable for semantic similarity calculation.

[0421] FastText: Extends Word2Vec to support subword representation, which can better handle word form variations. The rule set defined above is the core of symbolic reasoning. In specific implementations, its definition usually needs to be combined with domain knowledge. The following are some general principles and examples for defining rule sets:

[0422] The rule set is composed as follows:

[0423] (1) Static rules, which are deterministic rules based on known facts and domain constraints. For example:

[0424] Classification rules: If a knowledge point belongs to a certain category, it may have attributes common to the category.

[0425] Association rule: Two knowledge points are equivalent or associated under certain conditions.

[0426] (2) Dynamic rules, which involve data-driven patterns and can often be combined with statistical analysis or frequent item set discovery: Conditional probability rules, if knowledge points A and B appear frequently together, it can be inferred that they are likely to be the same or related. Context-sensitive rules, where the meaning of a knowledge point changes with the context.

[0427] The specific rule set examples are as follows:

[0428] (1) Field: Mathematical knowledge points

[0429] Equivalent rule: If the description of a knowledge point contains "equivalent to" or "also known as", they may be the same concept. TextContains(x,"also known as") → Equivalent(x,y)

[0430] If two formulas have the same transformation form, they may be equivalent, such as FormulaSimilar(A,B)∧Transform(A,B)→Equivalent(A,B)

[0431] Derivation rule: If a formula can be derived from another formula through simple algebraic transformation, they may be the same knowledge point;

[0432] AlgebraicTransform(Equation1,Equation2)→SamePoint(Equation1,

[0433] Equation2)

[0434] (2) Field: Biological terminology

[0435] Synonym rule: If the spelling of two terms differs only in the suffix (such as British and American spellings), they may be synonyms. Hyponym rule: If one term is a hyponym of another term and meets certain conditions, they may be partially related: (3) Cross-domain rule

[0436] Temporal correlation: If knowledge points A and B are frequently cited in the same time period, they may be related.

[0437] 4. The rule set is constructed as follows:

[0438] Expert knowledge-based: Domain experts summarize the relationships between concepts and manually define rules.

[0439] Based on data mining: extracting potential pattern generation rules from corpus.

[0440] Use tools such as the Apriori algorithm to generate frequent itemsets.

[0441] Using knowledge graphs to mine term relationships.

[0442] Automatic generation and optimization: Combine deep learning and reinforcement learning to generate new rules and optimize them through verification feedback.

[0443] 5. Rule verification and optimization

[0444] Verification: Test the defined rules and verify the correctness of the reasoning using known data.

[0445] Optimization: Adjust rule weights based on feedback from actual applications, or design meta-rules to prioritize conflicting rules.

[0446] By combining these rule sets, symbolic reasoning can effectively correct ambiguous semantics during the disambiguation process and further improve the accuracy and interpretability of the final results.

[0447] The specific logic of reasoning, specifically, the reasoning logic can be divided into the following key steps:

[0448] 1. Formalization of input data. To enable symbolic reasoning to handle problems, the input data (knowledge points, semantic information) must first be formalized into a logical language. Common forms include:

[0449] Predicate logic: describes the relationship between knowledge points through logical predicates.

[0450] Term("Optical Diffraction") → Related("Light Wave Interference")

[0451] Graph structure: Knowledge points can be represented by knowledge graphs, where nodes are knowledge points and edges are relationships.

[0452] 2. Application of knowledge point matching rules, using predefined rule sets to perform pattern matching on knowledge points and their contextual information to extract potential logical relationships.

[0453] The rule matching method is as follows:

[0454] 2.1 Static matching: directly matching the conditions in the rules with known knowledge points or context;

[0455] For example, the rule:

[0456] Synonym(a,b)→Equivalent(a,b)

[0457] If Synonym("Optical Diffraction","Diffraction") holds, then it follows that:

[0458] Equivalent("Optical Diffraction","Diffraction")

[0459] 2.2 Dynamic Conditional Deduction: For uncertain knowledge points, conditional judgment is made based on the logical rules of the context;

[0460] Context("optics")∧Related("light wave","interference")→Related("optics","diffraction")

[0461] 2.3 Fuzzy rule processing: For knowledge points with insufficient semantic similarity, fuzzy logic is used to define the credibility threshold:

[0462] For example: rule:

[0463] Similarity(a,b)>0.7→PossibleEquivalent(a,b)

[0464] If Similarity("Optical Diffraction", "Diffraction") = 0.75, then it is inferred that they are likely equivalent.

[0465] 3. Application of the inference engine. Using the inference engine to execute the rule set and combine it with logical deduction to deduce the relationship between knowledge points, the recommendation engine can achieve the following reasoning:

[0466] 3.1 Forward reasoning, that is, starting from known conditions, triggering rules in sequence to deduce new knowledge point relationships;

[0467] Known:

[0468] Synonym("Optical Diffraction","Diffraction")

[0469] rule:

[0470] Equivalent(a,b)→Related(a,b)

[0471] Derivation:

[0472] Related("Optical diffraction","Diffraction").

[0473] 3.2 Backward reasoning: starting from the goal, reversely looking for the conditions that meet the goal;

[0474] 3.3 Fuzzy logic reasoning, which introduces confidence between conditions and conclusions.

[0475] 4. Conflict resolution and priority handling. During symbolic reasoning, multiple rule conflicts may occur, and it is necessary to clarify the priorities:

[0476] 4.1. Priority based on weight: Define weights for rules, and rules with higher weights will be executed first.

[0477] 4.2. Meta-rule based conflict resolution: Conflict resolution strategies are defined through meta-rules.

[0478] During the reasoning process, the rule Synonym(a,b) is used to match the text, check whether the context supports it, and finally merge the reasoning results to draw a conclusion.

[0479] If RuleA∧RuleB conflict→Prefer(RuleA)

[0480] 5. Example Process

[0481] Question: Are "optical diffraction" and "interference" equivalent knowledge points?

[0482] Known:

[0483] rule:

[0484] Synonym(a,b)→Equivalent(a,b)

[0485] Context("optics")∧Related(a,b)→Equivalent(a,b)

[0486] data:

[0487] Synonym("Optical Diffraction","Diffraction")

[0488] Context("Optics")

[0489] Related("light wave","interference")

[0490] Reasoning process:

[0491] 1. Use the rule Synonym(a,b) to match:

[0492] Synonym("Optical Diffraction","Diffraction") → Equivalent("Optical Diffraction","Diffraction")

[0493] 2. Check if the context supports:

[0494] Context("optics")∧Related("light wave","interference")→Equivalent("optical diffraction","interference")

[0495] 3. Combine inference results:

[0496] Equivalent("Optical Diffraction","Interference")∧Equivalent("Optical Diffraction","Diffraction")→True

[0497] Finally, it is concluded that "optical diffraction" is equivalent to "interference".

[0498] 5. Integrate the feedback of the deep learning model, that is, after the symbolic reasoning is completed, the results can be used as feedback to further adjust the similarity calculation or knowledge representation of the deep learning model. For example:

[0499] Update the semantic similarity model: If the symbolic reasoning result is True, adjust the similarity weight to make it closer to the corrected standard.

[0500] Retrain the semantic embedding model: add new disambiguation results to the corpus and update the word vectors or relationship graph.

[0501] In this way, symbolic reasoning and deep learning can optimize each other, improving the accuracy and robustness of overall disambiguation. The knowledge graph construction method based on fine-tuning the large language model described in this embodiment, in the disambiguation process, uses a disambiguation mechanism based on domain knowledge. In addition to general semantic matching and similarity calculation in a specific domain, it can also combine expert knowledge or rules in a specific domain to perform disambiguation.

[0502] Implementation process:

[0503] A. Knowledge point semantic matching: Use deep learning models to perform general semantic matching on the extracted knowledge points;

[0504] B. Domain Expert Knowledge Introduction: Introducing domain-specific expert rules, definitions, vocabularies, or knowledge graphs to further verify and correct semantic matching results through this domain knowledge.

[0505] C. Domain rule disambiguation: Based on a set of rules in a specific domain (e.g., precise definitions of different disease names in the medical field), matching results are more finely classified or excluded. For example, the distinction between "myocardial infarction" and "heart attack" is ensured by combining strict definitions within the domain.

[0506] D. Output disambiguation results: Combine the domain knowledge disambiguation results with the general semantic matching results to output the final disambiguated knowledge point matching.

[0507] In knowledge point disambiguation, the combination method in part D is not a simple direct superposition. Instead, it integrates the results of domain knowledge disambiguation and general semantic matching through methods such as weight distribution, multi-layer decision logic, or collaborative optimization to improve the accuracy and robustness of the final result. The following is an analysis of the specific combination method, as well as a detailed explanation of the purpose and function of the combination:

[0508] The core process of knowledge point semantic matching is as follows:

[0509] (1) The semantic representation of knowledge points converts knowledge points into comparable semantic vectors through a deep learning model.

[0510] The following methods are used for embedding based on word vectors:

[0511] Use pre-trained word vector models (such as Word2Vec, GloVe) to convert knowledge points into vectors.

[0512] Use language models (such as BERT, RoBERTa) to generate context-sensitive vector representations.

[0513] If a knowledge point contains multimodal information (such as text, formulas, images), a joint embedding representation can be generated through a multimodal model (such as CLIP).

[0514] (2) Semantic similarity calculation, that is, calculating the similarity between the vector representations of two knowledge points.

[0515] (3) Setting the matching threshold: Based on the similarity score, define a matching threshold:

[0516] Exact match: if similarity > 0.9

[0517] Possible match: 0.7≤similarity≤0.9

[0518] Mismatch: Similarity < 0.7

[0519] It should be noted that the setting of the threshold can be adjusted according to the actual field.

[0520] 3. Tools and models for implementing universal semantic matching can use the following models and tools:

[0521] (1) Pre-trained language model, using a model pre-trained on large-scale corpus to generate semantic embeddings, for example:

[0522] BERT and RoBERTa: suitable for text semantic matching; SciBERT: optimized for scientific literature; Sentence-BERT: generates sentence-level semantic vectors, suitable for calculating similarity.

[0523] (2) Knowledge base and dictionary: use general knowledge base (such as WordNet, ConceptNet) to expand semantic information, and use domain-related dictionaries to supplement terminology.

[0524] (3) Semantic similarity calculation library, including Python tools, scikit-learn: provides cosine similarity and Euclidean distance calculation; sentence-transformers directly calculates embedding vector similarity.

[0525] Example: The complete process of general semantic matching

[0526] Question: Are “optical diffraction” and “interference of waves” the same knowledge point?

[0527] 1 Generate embeddings using BERT:

[0528] "Optical Diffraction" → [0.32, 0.45, 0.76]

[0529] "Interference of Waves" → [0.33, 0.44, 0.78]

[0530] 2. Calculate cosine similarity: CosineSimilarity = 0.98

[0531] 3. Matching rule verification: Verify by checking spelling variants:

[0532] If "optical diffraction", "interference of waves"

[0533] EditDistance("Optical Diffraction","Wave Interference") > 3 → NoMatchEditDistance(a,b): Represents the edit distance between strings a and b. The Levenshtein distance is a commonly used metric for measuring the similarity between two strings. It indicates the minimum number of edit operations required to transform one string into the other.

[0534] These editing operations typically include:

[0535] Insert a character;

[0536] Delete a character;

[0537] Replaces a character.

[0538] >3: Indicates that the edit distance is greater than 3; that is, the number of edit operations between strings a and b is greater than 3.

[0539] NoMatch: If the condition is met, that is, the edit distance is greater than 3, then a and b are considered to be unmatched (NoMatch).

[0540] Check context overlap: If the context overlap is greater than or equal to 0.7, then a match is possible;

[0541] 4. Matching threshold judgment: Based on the similarity and rule results, it is judged as a "possible match";

[0542] In the process of combining domain knowledge disambiguation results with general semantic matching results, weighted fusion is used to combine them.

[0543] Different weights are assigned to the domain knowledge disambiguation results and the general semantic matching results, and the two are weighted according to the importance of the actual task;

[0544] The details are as follows:

[0545] General semantic similarity score: S1 = 0.8

[0546] Domain rule disambiguation score: S2 = 0.9

[0547] Weighted formula: S final =w1·S1+w2·S2

[0548] Among them, w1 and w2 are weight coefficients, which can be adjusted through experiments;

[0549] Assume weights are w1=0.4, w2=0.6

[0550] S final =0.4·0.8+0.6·0.9=0.86

[0551] Just determine whether it matches based on the set threshold;

[0552] The combination of weighted fusion can effectively overcome the limitations of a single method and make the final disambiguation result more comprehensive and accurate. The details are as follows:

[0553] (1) Make up for the shortcomings of a single method

[0554] Disadvantages of general semantic matching: General semantic matching is less capable of processing domain-specific terms or rare knowledge points, which may lead to misjudgments or omissions. For example, a general model may mistakenly consider "optical diffraction" and "wave interference" to be unrelated.

[0555] Disadvantages of domain rule disambiguation: Domain rules are highly dependent on known expert knowledge and may be powerless for unknown or uncovered situations;

[0556] By combining the broad coverage of general semantic matching and the high precision of domain rules, the disambiguation results are made more reliable.

[0557] (2) Handling special situations,

[0558] Some matching pairs may have low scores in general semantic matching, but domain knowledge shows that the two are closely related;

[0559] For example: General matching result: Similarity = 0.6

[0560] Domain rules: rules indicate that there is a causal relationship between the two;

[0561] After combination: determined to be a match;

[0562] (3) Improve confidence and explainability. The introduction of domain rules provides a clear logical basis, making the matching results more explainable, while the general semantic matching results provide quantitative support.

[0563] (4) Optimize model performance,

[0564] Combined with the feedback of domain rules, the parameters of the semantic model can be dynamically adjusted to gradually adapt it to domain requirements.

[0565] Although the domain rule disambiguation in Part C has classified and excluded common semantic matching results, the following reasons make it more necessary to combine them:

[0566] (1) Improve matching coverage,

[0567] Domain rules have limited coverage and cannot cover all knowledge points. Combined with general semantic matching, it can handle parts that are not defined or covered by the rules;

[0568] (2) Handling low confidence matches

[0569] In semantic matching and rule disambiguation, some knowledge points may be in a boundary state at the same time:

[0570] For example, the semantic similarity score is close to the threshold or the domain rules are contradictory or incomplete;

[0571] By combining the results from both, these boundary cases can be treated more comprehensively;

[0572] (3) Verification and calibration results, combined with the results of general semantic matching, can verify the judgment of domain rules, thereby reducing errors;

[0573] (4) Improved scalability. Combined with semantic matching, the system can still output valid results even when domain rules are insufficiently covered, making the model more versatile and flexible.

[0574] The following are examples:

[0575] Determine whether "interference of waves" and "optical diffraction" are the same

[0576] 1. General semantic matching:

[0577] Semantic similarity score: 0.6 (below the matching threshold);

[0578] Preliminary judgment: mismatch;

[0579] 2. Domain rule disambiguation:

[0580] Rule 1: If the knowledge point contains "wave" and "diffraction", the correlation is high;

[0581] Rule application results: correlation score 0.9;

[0582] 3. Weighted fusion:

[0583] Weight distribution: w1 = 0.3, w2 = 0.7;

[0584] Final score:

[0585] S final =0.3·0.6+0.7·0.9=0.78

[0586] From the above results, it can be seen that the matching threshold is exceeded and it is determined to be a match.

[0587] 4. Output result: Knowledge point matching: "Wave interference" = "Optical diffraction"

[0588] Therefore, combining general semantic matching and domain rule disambiguation not only improves coverage and confidence, but also provides the model with the ability to dynamically adjust and expand. This combined strategy can output more accurate and reliable disambiguation results when a single method is insufficient.

[0589] For example, although "myocardial infarction" and "heart attack" in the medical field are similar in general semantics, they have more subtle differences in some literature and therefore need to be strictly distinguished in combination with domain rules.

[0590] The knowledge graph construction method based on fine-tuning a large language model described in this embodiment uses the following multiple means to ensure the accuracy of inserted knowledge points and relationships during the knowledge graph construction process, as follows:

[0591] (1) Multi-level verification

[0592] Rule-based validation: Different validation rules are defined for different fields to detect knowledge points and relationships. If data that does not meet the validation rules is matched, it will be marked as a potential error, and the knowledge points and relationships marked as not incorrect will be deleted. For example, in the education field, "course" and "chapter" should have an inclusion relationship. If the relationship type between them is detected as "related", it will be marked as a potential error.

[0593] Contextual consistency verification: By analyzing the context of knowledge points, we ensure that the extracted entities and relationships are consistent with the logic in the text. For example, the relationship between "calculus" and "advanced mathematics" is "included" rather than "preceded." Contextual verification can automatically detect these logical inconsistencies.

[0594] Domain expert review: For knowledge in a specific field, expert-annotated knowledge bases can be introduced for comparison to ensure that the extracted knowledge points are consistent with the information in the existing knowledge base;

[0595] (2) Semantic similarity matching

[0596] Use semantic similarity calculation to verify the extracted knowledge points. For example, use language models such as BERT and SBERT to vectorize the extracted knowledge points and standard knowledge points, and then calculate the similarity to determine whether the knowledge points are accurately extracted. If the similarity is lower than the set threshold, it is marked as a potential error and deleted.

[0597] It should be noted that the threshold is usually adjusted dynamically according to specific task requirements and application scenarios, rather than a fixed range.

[0598] Semantic similarity models such as BERT and SBERT: The output similarity is usually in the range [0,1], representing the cosine similarity or dot product result of two vectors:

[0599] High threshold (0.8-0.9): Applicable to scenarios with high matching requirements, such as building knowledge graphs in highly sensitive fields such as medicine and law; purpose: to avoid introducing incorrect knowledge points as much as possible, even if it means sacrificing a certain recall rate.

[0600] Medium threshold (0.6-0.8): Applicable to generalized scenarios, such as education and general domain knowledge. Purpose: To ensure accuracy while also taking into account knowledge point coverage.

[0601] Low threshold (0.4-0.6): Applied to exploratory tasks, such as generating new knowledge or expanding knowledge in unlabeled domains. Purpose: Allowing a certain amount of fuzzy matching to discover potential related knowledge;

[0602] The threshold in this case is preferably [0.4, 0.9].

[0603] (3) Relational logic verification

[0604] Relationship type restrictions: Ensure that relationship types conform to domain logic and perform logical verification of relationship types using the domain rule base. For example, in the education domain, the relationship between "course" and "chapter" should be "included" rather than "preceded";

[0605] Loop detection: Use graph algorithms to detect whether there are unreasonable loops in the knowledge graph to avoid incorrect relationships that lead to unreasonable knowledge graph structures.

[0606] The knowledge graph construction method based on fine-tuning the large language model described in this embodiment uses the following steps to verify the accuracy of the extracted knowledge points and relationships before storing them in the graph database:

[0607] (1): Automated test dataset

[0608] Build a standard annotated dataset and use it as a benchmark input to the AI ​​model. Then compare the knowledge points extracted by the model with the standard answers. If the extracted knowledge points and relationships are consistent with those in the annotated dataset, the model passes verification; otherwise, further model debugging or algorithm adjustment is required.

[0609] (2): Manual review and expert feedback

[0610] Knowledge points in specific fields are manually reviewed by experts to ensure that the extracted content meets industry standards;

[0611] (3): Context verification

[0612] After extracting knowledge points, perform secondary verification based on their context to ensure that the extracted knowledge points are consistent with their meaning in the context. For example, "Java," as a knowledge point for a programming language, may also represent other concepts in different contexts. Verifying the context can reduce such errors.

[0613] (4): Model adaptive optimization

[0614] By continuously collecting error cases extracted by the model, analyzing and providing feedback, adding this feedback to the training data, and continuously optimizing the model's performance, this circular feedback mechanism can effectively improve the accuracy of extraction.

[0615] During the knowledge graph construction process, complex knowledge graphs can be constructed by inserting extracted knowledge points and relationships into a graph database using tools such as Neo4j and JanusGraph. Simultaneously, contextual consistency checks, rule-based validation, semantic similarity matching, and loop detection are used to ensure the accuracy and logic of the inserted data. To further verify the precision of knowledge points and relationships, various methods such as automated dataset testing, expert review, and contextual verification can be used to ensure the high quality and accuracy of the knowledge graph.

Claims

1. A method for constructing a knowledge graph based on fine-tuning a large language model, characterized by: include: The steps are as follows: S1): Data preprocessing, i.e. processing the data source of the knowledge points to be extracted. The data source of the knowledge points to be extracted includes structured data and unstructured data. The structured data is directly input into the mapper, and the text materials in the unstructured data are cleaned; S2): Extract knowledge points and relationships from the data source. First, build a dedicated knowledge point extraction fine-tuning model. Input the pre-processed data into the knowledge point extraction fine-tuning model. The knowledge point extraction fine-tuning model automatically identifies entities in the text and extracts the relationships between the entities to obtain pre-processed knowledge points and relationships. S3): Knowledge point and relationship disambiguation, that is, identification and mapping of different descriptions of the same knowledge point. The specific disambiguation process is as follows: S31): Establishing a standard knowledge point database, that is, first constructing a standard set of knowledge point entities. The established standard set of knowledge point entities is used as a mapping target set to disambiguate the knowledge points extracted from the text; S32): Similarity calculation and mapping, i.e., using text embedding technology in natural language processing to convert knowledge points and related text into vectors; similarity calculation is then performed to determine whether the extracted different expressions point to the same knowledge point by calculating the cosine similarity or Euclidean distance between the text embedding vectors; S33): Context-based semantic disambiguation: Using sliding window technology to take context information into account, knowledge point relationships are extracted from preprocessed knowledge points; S34): Iterative Verification and Feedback Optimization: After disambiguation, the knowledge points and relationships extracted in the previous step are mapped to the standard set of knowledge point entities. The two are matched to find possible corresponding relationships. Further verification is performed based on the extracted relationships. If there is a mismatch, the entity is deleted. S4): Knowledge graph construction: First, a graph database model is established, new entity nodes are created, and relationships between entity nodes are created to form relationship edges. The disambiguated entity nodes and relationship edges are then stored in the graph database model to form a dynamic and scalable knowledge graph. During later use, the AI ​​model is periodically used to reanalyze text data and update the knowledge graph. In the process of disambiguation, incorporate symbolic reasoning: (1) Knowledge point extraction: extract potential similar knowledge points from the original data from the literature and obtain preliminary semantic similarity through the deep learning model; (2): Semantic disambiguation: Use deep learning methods to perform preliminary similarity calculations. Those with similarities lower than the target value will be deleted to disambiguate some basic knowledge points; (3): Application of symbolic reasoning rules: For knowledge points that cannot be disambiguated or have insufficient similarity, symbolic reasoning is combined with defined rule sets or logical reasoning to further correct the results based on known knowledge in the field; (4): Reasoning optimization: The results of symbolic reasoning in the previous step are fed back to the deep learning model to further adjust the weights or thresholds of the deep learning model; (5): Output the final result: Combine the final results of symbolic reasoning and deep learning disambiguation to determine whether the two knowledge points are the same.

2. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 1, characterized in that: The specific method for performing data cleaning on text materials in unstructured data in S1) is as follows: S11): Text cleaning: First, the text data in the unstructured data is cleaned. The deep learning model is used to classify different text regions in the text. The irrelevant content is distinguished from the main text based on the context and semantic features of the text. The main text and irrelevant content are automatically identified and removed using regular expressions. The noise in the text data is eliminated, and extra spaces, special characters, irrelevant HTML tags, and repeated text are deleted. S12): Sentence processing: In order to provide a clear context for subsequent knowledge point extraction, the cleaned text needs to be sentence-separated; S13): Extract repeated content, extract repeated content in the text data by detecting repeated sentences and repeated paragraphs, specifically: Detect duplicate sentences, using text similarity detection algorithms to identify and merge similar or duplicate sentences; Detect duplicate paragraphs: Detect longer texts through text comparison and clustering algorithms, and merge duplicate paragraphs; S14): Context preservation: To preserve the original context of the text, the following measures are taken: Maintain paragraph structure: While dividing sentences, maintain the paragraph structure of the original text so that the complete paragraph information can be referenced when extracting knowledge points; Use sliding window: In order to capture a wider range of contextual information, a sliding window technique is used when extracting knowledge points, which allows the model to consider the information of a sentence and its surrounding sentences at the same time.

3. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 2, characterized in that: The specific process of sentence processing in S12) is as follows: S121): Based on punctuation: using periods, question marks, exclamation points and other punctuation marks as sentence separators; S122): Sentence segmentation using AI models or natural language processing libraries based on natural language processing tools. These tools can more accurately identify sentence boundaries even in the absence of obvious punctuation; S123): Dependency-based syntactic analysis: By analyzing the dependency relationships in a sentence, the main and subordinate structures of the sentence are determined, thereby dividing the sentence more accurately; The core idea is to decompose a sentence into a "dependency" graph between words, so as to determine the predicate verb, subject, object elements in the sentence and their relationship.

4. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 3, characterized in that: The specific analysis process of the dependency syntax analysis in S123) is as follows: S1231): Input preprocessing, which includes word segmentation, denoising, and normalization of the input text; the details are as follows: Text cleaning: First, the input text data needs to be cleaned and preprocessed. Specifically, this involves removing noise, symbols, and irrelevant HTML tags, and normalizing complex text, including converting it to lowercase and correcting typos. Word segmentation: Before analyzing the syntax, use word segmentation tools to split the sentence into individual words or phrases; S1232): Part-of-speech tagging First, use natural language processing tools to mark the part of speech for each word. That is, use a part-of-speech tagger to tag each word or phrase after word segmentation, and determine the grammatical role of each word or phrase in the sentence, including noun, verb, and adjective. Part-of-speech tagging provides basic information for subsequent dependency analysis. Then, simplify the parts of speech: simplify the parts of speech according to the specific application scenarios of words or phrases, including simplifying detailed verb forms into a single "verb" category; S1233): Dependency parsing, using the dependency syntax analysis model to generate a dependency tree, as follows: First, sentence component analysis is performed: through dependency syntactic analysis, the dependency relationship between words in the sentence is analyzed to obtain a dependency tree. The goal of dependency syntactic analysis is to find the subordinate relationship between the "core word" in the sentence and other words; Then determine the core components of the sentence: analyze the predicate verb in the sentence and its related subject, object, and adverbial components; Model selection: Select an appropriate dependency syntax model based on the actual application and build dependency relationships; S1234): Extracting the main structure, i.e. analyzing the subject, predicate, object, attributive, adverbial and complement in the sentences in the text to identify the main components of the sentences; S1235): Dependency tree construction, using visualization tools to display dependency relationships for more intuitive analysis of sentence structure, as follows: Dependency tree structured representation: A dependency tree is generated for each sentence. The root node of the tree is the sentence's predicate verb. Other words are attached to the trunk of the dependency tree in sequence according to their dependencies. The dependency tree makes it easy to see the master-slave relationship of the sentence components, thereby enabling grammatical analysis and sentence reorganization. Dependency tree visualization: Use spaCy's displaCy tool or other dependency tree visualization tools to graphically represent the parsed dependency relationships, making it easier to understand the sentence structure. S1236): Syntax rule verification and optimization Dependency tree trunk and subordinate structure identification: By analyzing the dependency tree, the main structure of the sentence is determined, that is, the predicate verb and its main modifying components. The subject and object are directly dependent on the predicate verb, while the attributive and adverbial subordinate components are dependent on the core component. Syntactic rule optimization: According to the needs of the field, specific syntactic rules are set to correct dependency relationships, connectives are processed through dependency syntax, the position and function of connectives in the sentence structure are clarified, and the accuracy of semantic dependency relationships is ensured.

5. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 1, characterized in that: In the knowledge point and relationship disambiguation in S3), a contextual embedding model is used to convert the extracted knowledge points and their context into high-dimensional vectors, thereby achieving more accurate semantic matching. Compared with traditional word vectors, contextual embedding can better capture the different meanings of the same word in different contexts, improving the robustness of disambiguation. The details are as follows: For the input text t, the contextual embedding model BERT is used to convert the input text into a high-dimensional vector representation; v t =BERT(t) Among them, v t is the context embedding vector of text t, Let cosine similarity calculate the angle between two vectors, which is defined as: Among them, v1 and v2 are the contextual embedding vector representations of the two texts; In dynamic weighted cosine similarity, a weight w is assigned to each dimension, taking into account the different contributions of different dimensions to similarity. i , which enables similarity calculation to more flexibly reflect important information in the text: Where d is the dimension and d is the hidden layer size of the BERT model; Among them, w i It is the weight used for weighted cosine similarity, which is a weight dynamically calculated according to the context or category. It is used to measure the contribution of different dimensions to similarity. If two knowledge points have consistency in a certain category, the weight w of the dimension related to the category is increased. i ; The w i Determined based on: Word frequency: The frequency with which a word appears in a text, reflecting its importance; Inverse document frequency: how rare a word is in the entire corpus; It is also calculated by semantic level similarity, as follows: Assume two sentences s1 and s2, their semantic vector representations are and SBERT uses cosine similarity to measure the similarity between two sentences s1 and s2: Compared with traditional sentence representation methods, SBERT can capture more fine-grained semantic information, making the calculation of the similarity between two sentences at the semantic level more accurate; Multi-level similarity: In order to more precisely match semantics, the similarity of knowledge points at multiple levels is calculated; the details are as follows: First, we calculate the similarity based on the word level, then calculate the similarity at the sentence level and the paragraph level. The final similarity is the weighted average of the similarities at each level: During the processing, if there are multiple representations of the same entity, we fine-tune the large model to determine whether they are the same knowledge point, and then perform mapping recognition to obtain the final knowledge points and relationships; By similarity calculation, it is mapped to the knowledge point entity standard set. It also includes a mapping method, which introduces context-aware semantic matching in the matching process by capturing the context of knowledge points in the text; contextual analysis combines the contextual information of surrounding words and sentences to enhance the ability to distinguish synonyms or related knowledge points.

6. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 5, characterized in that: The specific construction process of the knowledge point extraction and fine-tuning model in S2) is as follows: (1) Data preparation, that is, preparing enough domain-related text data, including annotations of knowledge points. For different expressions of knowledge points, it is necessary to prepare a standardized set of knowledge points to facilitate subsequent mapping and verification. The data source is manually annotated text or using an existing knowledge base; (2) Model selection Select a pre-trained large language model as the pre-training model. This model has been pre-trained on massive general data and has good language understanding capabilities. For the task of knowledge point extraction, choose a model based on the Transformer architecture; (3) Data labeling and cleaning of text Preprocess the data, including text cleaning and sentence segmentation. Next, use annotation tools or write rules to mark entities and relationships in the text. This step uses SpaCy or NLTK tools for automatic sentence segmentation and part-of-speech tagging. (4) Fine-tune the pre-trained model to obtain a fine-tuned knowledge point extraction fine-tuning model. For the knowledge point extraction task, the pre-trained model is fine-tuned to obtain a fine-tuned model. The training process of the pre-trained model is completed through the following stages: Entity recognition: Use pre-trained models to automatically identify entities in text, including concepts, facts, and principles; Relationship extraction: Extract the relationships between text entities automatically identified by the pre-trained model, including inclusion, subordination, and predecessor; Disambiguation: For different descriptions of the same knowledge point, vectorization technology is used to calculate similarity and map similar expressions to the same entity. (5) Model verification and optimization The fine-tuned model is tested on the validation set to evaluate its accuracy in knowledge point recognition and relationship extraction tasks. The similarity algorithm is used to verify the accuracy and consistency of the extracted entities and relationships. If the accuracy and consistency meet the requirements, it means that the model meets the needs.

7. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 6, characterized in that: The specific methods for model verification and optimization are as follows: Adaptive threshold adjustment: During the similarity calculation process, the similarity threshold is dynamically adjusted by continuously learning the accuracy of historical data; The specific process is as follows: Data initialization: Collect the initial historical data of similarity calculation, including the results of each similarity calculation and the correctness of actual verification; Initial threshold setting: Set the similarity threshold based on common empirical values. The default threshold for cosine similarity is 0.

8. Similarity calculation: For each knowledge point to be processed, a preliminary similarity score is obtained based on cosine similarity and SBERT. Feedback collection: Based on the results of previous processing, the system collects feedback data from users or experts and marks whether each ambiguity resolution is correct; Adaptive learning: The system uses machine learning algorithms to dynamically adjust the similarity threshold based on accumulated feedback data and errors in disambiguation results. The adjustment range is between 0.05 and 0.10, and the threshold changes adaptively based on different fields, text length, and semantic complexity. Apply dynamic threshold: In a new round of similarity calculation, a dynamically adjusted threshold is used to determine whether two knowledge points are considered the same.

8. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 6, characterized in that: In the disambiguation process, the domain knowledge-based disambiguation mechanism, in addition to general semantic matching and similarity calculation in a specific domain, also combines domain-specific expert knowledge or rules to perform disambiguation; Implementation process: A. Knowledge point semantic matching: Use deep learning models to perform general semantic matching on the extracted knowledge points; In the disambiguation task, the general semantic matching in Part A relies on a deep learning model to compare knowledge points at the semantic level. This process involves specific semantic embedding representations, similarity calculations, and matching rules. B. Introduction of domain expert knowledge: Introducing expert rules, definitions, vocabularies or knowledge graphs in a specific field through these domain knowledge; C. Domain rule disambiguation: Based on the rule set of a specific domain, the matching results can be more finely classified or excluded; D. Output disambiguation results: Combine the domain knowledge disambiguation results with the general semantic matching results to output the final disambiguated knowledge point matching; In knowledge point disambiguation, the combination method of part D is not a simple direct superposition, but the results of domain knowledge disambiguation and general semantic matching are integrated through weight distribution, multi-layer decision logic or collaborative optimization methods to improve the accuracy and robustness of the final result.

9. The method for constructing a knowledge graph based on a fine-tuned large language model according to claim 6, characterized in that: Before storing the knowledge points and relationships in the graph database, use the following steps to verify the accuracy of the extracted knowledge points and relationships: (1): Automated test dataset Build a standard annotated dataset and use it as a benchmark input to the AI ​​model. Then compare the knowledge points extracted by the knowledge point extraction and fine-tuning model with the standard answers. If the extracted knowledge points and relationships are consistent with those in the annotated dataset, the model passes verification. Otherwise, further debugging of the knowledge point extraction and fine-tuning model or adjustment of the algorithm is required. (2): Manual review and expert feedback Knowledge points in specific fields are manually reviewed by experts to ensure that the extracted content meets industry standards; (3): Context verification After the knowledge points are extracted, they are verified again in combination with their context to ensure that the extracted knowledge points are consistent with their meaning in the context; (4): Model adaptive optimization By continuously collecting error cases extracted by the knowledge point extraction fine-tuning model, analyzing and providing feedback, adding this feedback to the training data, and continuously optimizing the model's performance, this circular feedback mechanism can effectively improve the accuracy of extraction.

Citation Information

Patent Citations

  • Knowledge graph construction method and device and electronic device

    CN109885698A

  • Knowledge graph question-answering method and system based on entity relationship disambiguation, and terminal

    CN111259653A