In-domain model training method and system based on knowledge graph

By constructing domain knowledge graphs and entity embedding vector initialization, the problems of insufficient vocabulary coverage and low training efficiency of pre-trained language models in specific fields are solved, which significantly improves the comprehensiveness of the vocabulary and training efficiency of the model, and enhances its Performance in a specific field.

CN119294461AInactive Publication Date: 2025-01-10HANGZHOU CANGHAI GUANZHI TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411806009.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-01-10
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When large-scale pre-trained language models are applied in specific vertical fields, insufficient vocabulary coverage, lack of domain knowledge and low training efficiency in word embedding initialization, resulting in insufficient performance in handling professional terms and complex tasks.

Method used

By constructing a domain knowledge graph, extracting professional terms, expanding the word list, initializing word embedding using entity embedding vectors, generating question and answer pairs to fine-tune the dataset to optimize the model, and improving the model's understanding of vocabulary in specific fields and training efficiency.

Benefits of technology

It significantly improves the comprehensiveness and professionalism of the model vocabulary list, accelerates the training convergence speed of the model in specific fields, enhances the model's knowledge reasoning ability, and improves the model's performance and training efficiency in complex tasks in specific fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119294461A_ABST
    Figure CN119294461A_ABST
Patent Text Reader

Abstract

The invention discloses an intra-domain model training method and system based on a knowledge graph, and belongs to the technical field of artificial intelligence, and the method comprises the steps: constructing a domain knowledge graph; extracting newly added high-frequency professional terms from the domain knowledge graph; generating a newly-added lexical element for each newly-added high-frequency terminology, and integrating the newly-added lexical element into a vocabulary of the pre-trained large language model to obtain an expanded vocabulary; initializing a word embedding vector of the lexical element by utilizing an entity embedding vector in the knowledge graph, adjusting a word embedding layer of the pre-training large language model based on the word embedding vector of the newly-added lexical element in the expanded word list, and carrying out retraining; taking question and answer pairs constructed based on the domain knowledge graph as an instruction fine tuning data set after being audited and perfected by experts, and performing fine tuning on the retrained large language model; and performing model performance evaluation and continuous optimization. The method can provide a more comprehensive word list, improve the understanding ability of the model for vocabularies in a specific field, improve the model training efficiency, and is suitable for large language model training in the field.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of artificial intelligence technology, and specifically relates to a domain model training method and system based on knowledge graph. Background Art

[0002] With the continuous development of computer hardware systems, significant progress has been made in the field of artificial intelligence, especially natural language processing (NLP) technology. Large-scale pre-trained language models (such as GPT-4) have powerful language understanding and generation capabilities through training on massive general corpora. They can generate coherent and logical texts, and even show close to human-level conversational communication capabilities in certain situations. This has undoubtedly opened up a new path for the development of artificial intelligence.

[0003] However, although these general models perform well on general language processing tasks, when they are applied to highly specialized vertical fields (such as firefighting and finance), they often lack a deep understanding of the vocabulary and knowledge of these specific fields, resulting in the models' inadequate performance in handling specialized terminology and complex tasks.

[0004] In order to overcome this challenge, existing technologies mainly use fine-tuning methods to further train the model based on the pre-trained model using data sets in specific fields, so that it can better adapt to and understand the language characteristics of the field. For example, in the financial field, researchers will collect a large amount of financial text data, such as financial reports, market analysis reports, etc., and then use this data to fine-tune the pre-trained model. In this way, the model can learn the professional terms, concepts and industry-specific expressions in the financial field, so as to show higher accuracy and efficiency when processing financial-related tasks.

[0005] Although the fine-tuning method alleviates the shortcomings of general models in specific fields to a certain extent, it also exposes the following series of problems and challenges: (1) Insufficient vocabulary coverage: The vocabulary of the pre-trained model is usually built on general corpus, so it cannot fully cover the large number of professional terms in a specific field. This means that when the model encounters these professional terms that are not included in the vocabulary, it may not be able to correctly identify their meaning, thus affecting the overall understanding and generation effect.

[0006] (2) Word embedding initialization lacks domain knowledge: During the fine-tuning process, the word embeddings of newly added professional vocabulary are usually randomly initialized. This method lacks domain-specific prior knowledge, resulting in the model's weak understanding of these new words in the initial stage.

[0007] (3) Low training efficiency: Due to the lack of structured domain knowledge guidance, the model often needs to spend a lot of time and computing resources when learning specific domain knowledge, which not only increases the cost of model training, but also may limit the deployment and update speed of the model in practical applications.

[0008] In summary, although large-scale pre-trained language models have achieved remarkable achievements in general language processing tasks, they still face many challenges in applications in specific vertical fields. Future research needs to explore in more depth how to effectively integrate domain knowledge into pre-trained models to improve the application performance and efficiency of models in specific fields. Summary of the invention

[0009] In view of the above, the purpose of the present invention is to provide a method and system for in-domain model training based on a knowledge graph, which can provide a more comprehensive vocabulary and improve the model's understanding of vocabulary in a specific field, and further improve the efficiency of model training, and is particularly suitable for large-scale language model training in vertical fields such as fire protection and finance.

[0010] In order to achieve the above-mentioned invention object, the technical solution provided by the present invention is as follows: In a first aspect, an embodiment of the present invention provides a method for training a model in a domain based on a knowledge graph, comprising the following steps: Collect professional text data in a specific field, extract entities and relationships from it, and build a domain knowledge graph; Extract professional terms from the domain knowledge graph, analyze the frequency of professional terms in professional text data, and select professional terms with a frequency higher than the set threshold as new high-frequency professional terms; Generate new word units for each new high-frequency professional term, and integrate the new word units into the vocabulary of the pre-trained large language model to obtain an expanded vocabulary; Use the entity embedding vectors in the knowledge graph to initialize the word embedding vectors of the tokens, and adjust the word embedding layer of the pre-trained large language model based on the word embedding vectors of the newly added tokens in the expanded vocabulary and retrain; The question-answer pairs built based on the domain knowledge graph are used as instruction fine-tuning datasets after being reviewed and improved by experts. The instruction fine-tuning datasets are used to fine-tune the retrained large language model. Perform performance evaluation and continuous optimization on the fine-tuned large language model.

[0011] Specifically, the extraction of professional terms from the domain knowledge graph includes: Entities are extracted from the domain knowledge graph to obtain entity sets, which are further processed to remove common words and use the remaining entity sets as professional terms.

[0012] Specifically, the word embedding vector of the word unit is initialized by using the entity embedding vector in the knowledge graph, and the word embedding layer of the pre-trained large language model is adjusted and retrained based on the word embedding vector of the newly added word unit in the expanded vocabulary, including: For the pre-trained large language model obtained by pre-training on general data, the entities in the knowledge graph are converted into entity embedding vectors, and the entity embedding vectors are used as the initial values ​​of the word embedding vectors of the tokens in the pre-trained large language model. The word embedding vectors of the newly added tokens in the expanded vocabulary are used to adjust the word embedding layer of the pre-trained large language model, and the adjusted large language model is retrained based on the general data to adapt to the expanded vocabulary.

[0013] Specifically, the question-answer pairs constructed based on the domain knowledge graph are reviewed and improved by experts as instruction fine-tuning datasets, including: Based on the entities and relationships in the domain knowledge graph, question generation templates are used to generate questions for specific domain knowledge points, and answers corresponding to the questions are generated. Experts review and improve the questions and answers, and the reviewed and improved questions and answers are constructed into an instruction fine-tuning dataset.

[0014] Specifically, the question generation template is represented as a set of question generation template sets , where each template Contains fixed text and placeholders to fill in entities and relationships in the knowledge graph, subscript Indicates the total number of templates, subscript Represents the template index; when using the question generation template to generate questions, first extract entities and relationships from the knowledge graph, and then select the template And fill the extracted entities and relationships into the template middle.

[0015] Specifically, fine-tuning the retrained large language model using the instruction fine-tuning dataset includes: The questions in the instruction fine-tuning dataset are input into the retrained large language model to obtain the predicted values, and the corresponding answers in the instruction fine-tuning dataset are taken as the true values. The model parameters are optimized based on the predicted values ​​and the true values ​​through the cross-entropy loss function.

[0016] Specifically, the performance evaluation and continuous optimization of the fine-tuned large language model include: Through automatic evaluation and manual review by domain experts, the performance of the fine-tuned large language model in question-answering tasks in specific fields is evaluated. The vocabulary expansion and word embedding initialization methods are optimized based on the evaluation results, and the fine-tuned large language model is continuously optimized.

[0017] In the second aspect, in order to achieve the above-mentioned invention object, the embodiment of the present invention also provides a domain model training system based on knowledge graph, which is implemented by the above-mentioned domain model training method based on knowledge graph, including: a knowledge graph construction module, a professional term extraction module, a vocabulary expansion module, an adjustment and retraining module, a model fine-tuning module, and an evaluation and optimization module; The knowledge graph construction module is used to collect professional text data in a specific field and extract entities and relationships from it to construct a domain knowledge graph; The professional term extraction module is used to extract professional terms from the domain knowledge graph, analyze the word frequency of professional terms in professional text data, and select professional terms with a word frequency higher than a set threshold as new high-frequency professional terms; The vocabulary expansion module is used to generate new word units for each new high-frequency professional term, and integrate the new word units into the vocabulary of the pre-trained large language model to obtain an expanded vocabulary; The adjustment and retraining module is used to initialize the word embedding vector of the word unit using the entity embedding vector in the knowledge graph, and adjust the word embedding layer of the pre-trained large language model based on the word embedding vector of the newly added word unit in the expanded vocabulary and perform retraining; The model fine-tuning module is used to use the question set constructed based on the domain knowledge graph and the corresponding answer labels as an instruction fine-tuning dataset, and use the instruction fine-tuning dataset to fine-tune the retrained large language model; The evaluation and optimization module is used to perform performance evaluation and continuous optimization on the fine-tuned large language model.

[0018] In the third aspect, in order to achieve the above-mentioned purpose of the invention, an embodiment of the present invention also provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to implement the above-mentioned knowledge graph-based in-domain model training method when executing the computer program.

[0019] In a fourth aspect, in order to achieve the above-mentioned purpose of the invention, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a computer, the above-mentioned domain model training method based on the knowledge graph is implemented.

[0020] Compared with the prior art, the present invention has the following beneficial effects: (1) By constructing a domain knowledge graph and extracting new high-frequency professional terms, the present invention can expand the vocabulary of the pre-trained model and significantly improve the comprehensiveness and professionalism of the model vocabulary.

[0021] (2) The present invention uses the entity embedding vectors in the knowledge graph to initialize the newly added words, improve the model's ability to understand professional terms, and accelerate the convergence speed of the model in specific field training.

[0022] (3) The present invention constructs a question set based on a structured domain knowledge graph, generates answers through human experts or teacher models, constructs them into instruction fine-tuning data, and further fine-tunes the large language model, making full use of the information in the knowledge graph and enhancing the model's knowledge reasoning ability, thereby improving the model's performance in complex tasks in specific fields.

[0023] (4) The present invention first retrains the large language model after adjusting the word embedding layer on general data to maintain the generality and adaptability of the model and ensure that the model still performs well in a wide range of language tasks. Then, the model is fine-tuned based on an instruction fine-tuning dataset constructed in a specific field. Through a phased training strategy, the model can be optimized based on new vocabulary, thereby improving the efficiency of model training. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0025] Figure 1 It is a flowchart of a domain model training method based on a knowledge graph provided in an embodiment of the present invention; Figure 2 It is a structural diagram of the domain model training system based on the knowledge graph provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] To make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific implementation methods described herein are only used to explain the present invention and do not limit the scope of protection of the present invention.

[0027] The inventive concept of the present invention is: in view of the problems in the prior art that general models have insufficient vocabulary coverage, lack of domain knowledge in word embedding initialization and low training efficiency when applied in specific fields, the embodiments of the present invention provide a method and system for in-domain model training based on a knowledge graph, which automatically identifies and adds professional terms in specific fields based on the knowledge graph, expands the vocabulary of the pre-trained model, and ensures the comprehensiveness of the vocabulary; improves the model's understanding of domain-specific vocabulary by using entity embeddings in the domain knowledge graph to initialize the word embedding vectors of newly added words; optimizes the model training process based on structured domain knowledge support and problem set generation, accelerates the convergence speed of model training in specific fields, and improves model training efficiency.

[0028] Figure 1 Schematic diagram of the process of the domain model training method based on the knowledge graph provided by the embodiment of the present invention. Figure 1 As shown, the embodiment provides a method for training a model in a domain based on a knowledge graph, comprising the following steps: S1, collects professional text data in a specific field and extracts entities and relationships from it to construct a domain knowledge graph.

[0029] S1.1, data collection. In the embodiment, the specific fields of application include fire protection and finance. For the fire protection field, professional text data including fire protection manuals, rescue operation procedures, fire protection equipment manuals, fire case analysis, etc. are collected to build a comprehensive fire protection knowledge graph. For the financial field, professional text data including financial regulations, market analysis reports, financial product manuals, investment strategy literature, etc. are collected to build a comprehensive financial knowledge graph.

[0030] S1.2, Entity and relationship extraction. For the fire protection field, key entities such as "fire extinguisher type", "fire classification", "rescue equipment", "fire fighting tactics" and their relationships are extracted from the fire protection professional text data. For the financial field, key entities such as "financial instruments", "investment strategies", "risk assessment indicators", "financial regulations" and their relationships are extracted from the financial professional text data.

[0031] S2, extract professional terms from the domain knowledge graph, analyze the frequency of professional terms in professional text data, and select professional terms with a frequency higher than the set threshold as new high-frequency professional terms.

[0032] S2.1, term extraction. Entities are extracted from the domain knowledge graph to obtain entity sets, which are further processed to remove common words and use the remaining entity sets as professional terms.

[0033] In the field of fire protection, professional terms such as "foam fire extinguisher", "high-rise building fire escape route", "fire pump system" are identified. In the field of finance, professional terms such as "derivatives trading", "quantitative investment strategy", "credit default swap (CDS)", "asset securitization" are identified.

[0034] S2.2, word frequency analysis. Determine the word frequency of professional terms in professional text data through statistical analysis, and select words with high frequency and high importance for expansion. Specifically, professional terms with a word frequency higher than a set threshold are selected as new high-frequency professional terms.

[0035] S3, generates new word-grams for each new high-frequency professional term, and integrates the new word-grams into the vocabulary of the pre-trained large language model to obtain an expanded vocabulary.

[0036] S3.1, Generate new tokens. Generate corresponding tokens for each newly identified high-frequency professional term in the fire protection or financial field to ensure that it has an independent representation in the model's vocabulary.

[0037] S3.2, vocabulary update: Integrate the newly added word units into the existing vocabulary of the pre-trained large language model to obtain an expanded vocabulary, and adjust the word embedding layer of the model to adapt to the expanded vocabulary.

[0038] S4, use the entity embedding vector in the knowledge graph to initialize the word embedding vector of the word unit, adjust the word embedding layer of the pre-trained large language model based on the word embedding vector of the newly added word unit in the expanded vocabulary, and retrain it.

[0039] S4.1, word embedding initialization. For the pre-trained large language model obtained by pre-training on general data, the entities in the knowledge graph are converted into entity embeddings vectors, and the entity embedding vectors are used as the initial values ​​of the word embedding vectors of the tokens in the pre-trained large language model.

[0040] S4.2, word embedding layer expansion. Use the word embedding vectors of the newly added words in the expanded vocabulary to adjust the word embedding layer of the pre-trained large language model, while adding new word embedding vectors and keeping the original word embedding unchanged or making appropriate adjustments.

[0041] S4.3, retraining. The adjusted large language model is retrained based on common data to adapt to the expanded vocabulary, ensure the synergy between the new word units and the original word units, and improve the model's ability to understand and generate the expanded vocabulary.

[0042] S5, the question-answer pairs built based on the domain knowledge graph are used as the instruction fine-tuning dataset after being reviewed and improved by experts, and the instruction fine-tuning dataset is used to fine-tune the retrained large language model.

[0043] S5.1, question-answer pair generation. Automatically generate question-answer pairs covering domain knowledge based on the constructed fire protection or financial domain knowledge graph. When generating questions, use the entities and relationships in the knowledge graph to generate questions targeting specific domain knowledge points, such as "What is a foam fire extinguisher?", "What is the role of credit default swaps (CDS) in the financial market?", etc.

[0044] In the embodiment, a question generation template is used to generate questions for knowledge points in a specific field. The question generation template is represented as a set of question generation template sets. , where each template Contains fixed text and placeholders (placeholders are represented by [ ]) to fill in entities and relationships in the knowledge graph. Indicates the total number of templates, subscript Represents a template index.

[0045] Example template: a. “What is [entity]?”; Example: "What is a foam fire extinguisher?".

[0046] b. “What is the [relationship] of [entities]?”; Example: "How does a foam fire extinguisher work?".

[0047] c. “How does [entity] affect [relationship]?”; Example: "How does the fire pump system affect fire suppression efficiency?".

[0048] d. “What is the relationship between [entity] and [entity]?”; Example: "What is the relationship between credit default swaps (CDS) and asset securitization?".

[0049] Template application process: (1) Extracting entities and relationships from knowledge graphs; (2) Choose the appropriate template ; (3) Fill the extracted entities and relationships into the template , generate the complete question.

[0050] S5.2, creation of instruction fine-tuning dataset. The generated question-answer pairs are reviewed and improved by human experts or teacher models to ensure the accuracy and coverage of questions and answers. The reviewed and improved question-answer pairs are converted into instruction fine-tuning datasets to further optimize the performance of the model in the fire protection and financial fields.

[0051] S5.3, model fine-tuning. Inputting the questions in the instruction fine-tuning dataset into the retrained large language model enables the model to answer domain-specific questions more accurately and obtain predicted values. The corresponding answers in the instruction fine-tuning dataset are used as the true values. Based on the predicted values ​​and true values, the model parameters are optimized through the cross-entropy loss function to improve the performance of the large language model in firefighting and financial tasks.

[0052] S6, evaluates and continuously optimizes the performance of the fine-tuned large language model.

[0053] S6.1, Performance Evaluation. The performance of the fine-tuned large language model in domain-specific question-answering tasks is evaluated through automatic evaluation and manual review by domain experts. The performance of the model in firefighting and financial tasks is evaluated.

[0054] S6.2, Optimization feedback. Based on the evaluation results, optimize the vocabulary expansion and word embedding initialization methods, and continue to optimize the fine-tuned large language model.

[0055] In summary, the embodiment of the present invention provides a method for training a model in a domain based on a knowledge graph. By constructing a domain knowledge graph and extracting new high-frequency professional terms, the vocabulary of the pre-trained model can be expanded, and the comprehensiveness and professionalism of the model vocabulary can be significantly improved; the entity embedding vector in the knowledge graph is used to initialize the new word, which can improve the model's ability to understand professional terms and accelerate the convergence speed of the model in specific domain training; the large language model is further fine-tuned through instruction fine-tuning data, and the information in the knowledge graph is fully utilized to enhance the model's knowledge reasoning ability, thereby improving the model's performance in complex tasks in specific domains; the versatility and adaptability of the model are maintained through retraining to ensure that the model still performs well in a wide range of language tasks, and then fine-tuned based on the instruction fine-tuning data set constructed in a specific domain. Through a phased training strategy, the optimization of the model based on the new vocabulary can be ensured, and the model training efficiency can be improved. It can be applied to the development of intelligent products such as intelligent assistants, automatic report generation systems, risk assessment tools, and regulatory interpretation systems for the fire protection and financial fields, and improve work efficiency and accuracy in professional fields.

[0056] Based on the same inventive concept, Figure 2 As shown, an embodiment of the present invention also provides a domain model training system 200 based on a knowledge graph, including: a knowledge graph construction module 210, a professional terminology extraction module 220, a vocabulary expansion module 230, an adjustment and retraining module 240, a model fine-tuning module 250, and an evaluation and optimization module 260.

[0057] The knowledge graph construction module 210 is used to collect professional text data in a specific field and extract entities and relationships therefrom to construct a domain knowledge graph.

[0058] The professional term extraction module 220 is used to extract professional terms from the domain knowledge graph, analyze the frequency of professional terms in professional text data, and select professional terms with a frequency higher than a set threshold as new high-frequency professional terms.

[0059] The vocabulary expansion module 230 is used to generate a new word element for each new high-frequency professional term, and integrate the new word element into the vocabulary of the pre-trained large language model to obtain an expanded vocabulary.

[0060] The adjustment and retraining module 240 is used to initialize the word embedding vector of the word unit using the entity embedding vector in the knowledge graph, and adjust the word embedding layer of the pre-trained large language model based on the word embedding vector of the newly added word unit in the expanded vocabulary and perform retraining.

[0061] The model fine-tuning module 250 is used to use the question-answer pairs constructed based on the domain knowledge graph as instruction fine-tuning datasets after being reviewed and improved by experts, and use the instruction fine-tuning datasets to fine-tune the retrained large language model.

[0062] The evaluation and optimization module 260 is used to perform performance evaluation and continuous optimization on the fine-tuned large language model.

[0063] Based on the same inventive concept, an embodiment of the present invention also provides an electronic device, including a memory and a processor, the memory is used to store a computer program, and the processor is used to implement the above-mentioned knowledge graph-based in-domain model training method when executing the computer program.

[0064] Based on the same inventive concept, an embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a computer, the above-mentioned domain model training method based on the knowledge graph is implemented.

[0065] It should be noted that the domain model training system based on knowledge graph, electronic device and computer-readable storage medium provided in the above embodiments all belong to the same inventive concept as the domain model training method based on knowledge graph. The specific implementation process is detailed in the embodiment of the domain model training method based on knowledge graph, which will not be repeated here.

[0066] The specific implementation methods described above provide a detailed description of the technical solutions and beneficial effects of the present invention. It should be understood that the above is only the most preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, supplements and equivalent substitutions made within the scope of the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A domain model training method based on knowledge graph, characterized in that: The following steps are involved: Collect professional text data in a specific field, extract entities and relationships from it, and build a domain knowledge graph; Extract professional terms from the domain knowledge graph, analyze the frequency of professional terms in professional text data, and select professional terms with a frequency higher than the set threshold as new high-frequency professional terms; Generate new word units for each new high-frequency professional term, and integrate the new word units into the vocabulary of the pre-trained large language model to obtain an expanded vocabulary; Use the entity embedding vectors in the knowledge graph to initialize the word embedding vectors of the tokens, and adjust the word embedding layer of the pre-trained large language model based on the word embedding vectors of the newly added tokens in the expanded vocabulary and retrain; The question-answer pairs built based on the domain knowledge graph are used as instruction fine-tuning datasets after being reviewed and improved by experts. The instruction fine-tuning datasets are used to fine-tune the retrained large language model. Perform performance evaluation and continuous optimization on the fine-tuned large language model.

2. The domain model training method based on knowledge graph according to claim 1 is characterized in that: The extracting of professional terms from the domain knowledge graph includes: Entities are extracted from the domain knowledge graph to obtain entity sets, which are further processed to remove common words and use the remaining entity sets as professional terms.

3. The domain model training method based on knowledge graph according to claim 1 is characterized in that: The method of initializing the word embedding vector of a word unit by using the entity embedding vector in the knowledge graph, adjusting the word embedding layer of the pre-trained large language model based on the word embedding vector of the newly added word unit in the expanded vocabulary, and retraining the word embedding layer includes: For the pre-trained large language model obtained by pre-training on general data, the entities in the knowledge graph are converted into entity embedding vectors, and the entity embedding vectors are used as the initial values ​​of the word embedding vectors of the tokens in the pre-trained large language model. The word embedding vectors of the newly added tokens in the expanded vocabulary are used to adjust the word embedding layer of the pre-trained large language model, and the adjusted large language model is retrained based on the general data to adapt to the expanded vocabulary.

4. The domain model training method based on knowledge graph according to claim 1, characterized in that: The question-answer pairs constructed based on the domain knowledge graph are reviewed and improved by experts as instruction fine-tuning datasets, including: Based on the entities and relationships in the domain knowledge graph, question generation templates are used to generate questions for specific domain knowledge points, and answers corresponding to the questions are generated. Experts review and improve the questions and answers, and the reviewed and improved questions and answers are constructed into an instruction fine-tuning dataset.

5. The domain model training method based on knowledge graph according to claim 4 is characterized in that: Question generation template is represented as a set of question generation templates , where each template Contains fixed text and placeholders to fill in entities and relationships in the knowledge graph, subscript Indicates the total number of templates, subscript Represents the template index; when using the question generation template to generate questions, first extract entities and relationships from the knowledge graph, and then select the template And fill the extracted entities and relationships into the template middle.

6. The domain model training method based on knowledge graph according to claim 1, characterized in that: The method of fine-tuning the retrained large language model using the instruction fine-tuning dataset includes: The questions in the instruction fine-tuning dataset are input into the retrained large language model to obtain the predicted values, and the corresponding answers in the instruction fine-tuning dataset are taken as the true values. The model parameters are optimized based on the predicted values ​​and the true values ​​through the cross-entropy loss function.

7. The domain model training method based on knowledge graph according to claim 1, characterized in that: The performance evaluation and continuous optimization of the fine-tuned large language model include: Through automatic evaluation and manual review by domain experts, the performance of the fine-tuned large language model in question-answering tasks in specific fields is evaluated. The vocabulary expansion and word embedding initialization methods are optimized based on the evaluation results, and the fine-tuned large language model is continuously optimized.

8. A domain model training system based on a knowledge graph, implemented using the domain model training method based on a knowledge graph according to any one of claims 1 to 7, characterized in that: include: Knowledge graph construction module, professional term extraction module, vocabulary expansion module, adjustment and retraining module, model fine-tuning module, and evaluation and optimization module; The knowledge graph construction module is used to collect professional text data in a specific field and extract entities and relationships from it to construct a domain knowledge graph; The professional term extraction module is used to extract professional terms from the domain knowledge graph, analyze the word frequency of professional terms in professional text data, and select professional terms with a word frequency higher than a set threshold as new high-frequency professional terms; The vocabulary expansion module is used to generate new word units for each new high-frequency professional term, and integrate the new word units into the vocabulary of the pre-trained large language model to obtain an expanded vocabulary; The adjustment and retraining module is used to initialize the word embedding vector of the word unit using the entity embedding vector in the knowledge graph, and adjust the word embedding layer of the pre-trained large language model based on the word embedding vector of the newly added word unit in the expanded vocabulary and perform retraining; The model fine-tuning module is used to use the question-answer pairs constructed based on the domain knowledge graph as instruction fine-tuning datasets after being reviewed and improved by experts, and to use the instruction fine-tuning datasets to fine-tune the retrained large language model; The evaluation and optimization module is used to perform performance evaluation and continuous optimization on the fine-tuned large language model.

9. An electronic device comprising a memory and a processor, wherein the memory is used to store a computer program, wherein: The processor is used to implement the domain model training method based on the knowledge graph as described in any one of claims 1-7 when executing the computer program.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a computer, the in-domain model training method based on the knowledge graph described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Knowledge question and answer method and device, computer readable medium and electronic equipment

    CN115292457A

  • Equipment operation and maintenance text data analysis processing method based on large model

    CN118246541A

  • Large language model training method oriented to city field and city generation type intelligent method and device

    CN118760898A

  • Traditional Chinese medicine question-answering system construction method based on large language model and knowledge graph

    CN118838996A

  • System and method for hybrid question answering over knowledge graph

    US20220292262A1

Cited By

  • Construction method and device of coal mine vertical field large model

    CN119848553A

  • Scientific and technological document question and answer method and device, storage medium and electronic equipment

    CN120296137A

  • Medical field large language model training method and system based on knowledge graph enhancement

    CN121998101A

  • A Method and System for Training Large Language Models in the Medical Field Based on Knowledge Graph Augmentation

    CN121998101B