A domain-specific model training method based on expert knowledge base

Through the domain-specific model training method based on the expert knowledge base, the scaling factor in the LoRA model is adaptively adjusted, which solves the learning inadequate and overfitting problems caused by fixed scaling factors, and improves the performance of language model in specific fields.

CN119691178BActive Publication Date: 2025-06-06BEIJING ZHONGWEI SHENGDING TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510192148.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-21
Publication Date
2025-06-06
Estimated Expiration
2045-02-21

AI Technical Summary

Technical Problem

When fine-tuning the language model through the LoRA model, fixed scaling factors lead to insufficient learning of high-professional sentences or overfitting low-professional sentences, affecting the performance of language model in a specific field.

Method used

A specific domain model training method based on expert knowledge base is proposed. By obtaining the initial general knowledge base and expert knowledge base, word segmentation processing and word vector acquisition, target similarity between texts, clustering and knowledge base expansion and deletion, determining the degree of contribution of the target professional and updating the scaling factor, and fine-tuning the language model.

Benefits of technology

By adaptively adjusting the scaling factor, the learning of high-professional sentences is improved and the overfitting of low-professional sentences is reduced, and the performance of language model in specific fields is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119691178B_ABST
    Figure CN119691178B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of text data processing, and in particular to a method for training a specific domain model based on an expert knowledge base, the method comprising: performing word segmentation processing on each sentence in each text in an acquired initial general knowledge base and an initial expert knowledge base; determining the target similarity between every two texts; clustering all texts, and respectively expanding and deleting the initial expert knowledge base and the initial general knowledge base; determining the target professional contribution degree corresponding to each target word segmentation in the initial expert knowledge base and the target learning rate corresponding to each sentence; updating the scaling factor corresponding to each sentence in the initial expert knowledge base in the LoRA model to its corresponding target learning rate, and fine-tuning the language model through the LoRA model to obtain a trained language model. The present invention improves the rationality of training a language model in a specific domain by processing text data in a knowledge base.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text data processing, and in particular to a method for training a specific domain model based on an expert knowledge base. Background Art

[0002] With the development of science and technology, the application fields of language models are becoming more and more extensive. For example, they can be applied to machine translation, handwritten Chinese character recognition, and information retrieval. Language models in specific fields are also called specific domain models. The BERT (Bidirectional Encoder Representations from Transformers, pre-trained language) model is a relatively common language model. In order to improve the performance of the language model, it is often necessary to fine-tune the language model during the language model training process. For example, the BERT model can be fine-tuned through the LoRA (Low-Rank Adaptation of Large Language Models, used to fine-tune low-rank adaptation of large language models) model. At present, when fine-tuning the language model through the LoRA model, the scaling factor in the LoRA model is often set to a fixed constant.

[0003] However, when fine-tuning the language model through the LoRA model based on a fixed scaling factor, the following technical problems often occur:

[0004] Since the professional values ​​of different sentences in the expert knowledge base are often different, for example, some sentences may contain professional terms, while some sentences may just be simple common sense descriptions. If a fixed scaling factor is used when learning these sentences, it may lead to insufficient learning of highly professional sentences, or may lead to overfitting of low-professional sentences, which in turn leads to poor rationality when training language models in specific fields, thereby affecting the performance of language models in specific fields. Summary of the invention

[0005] In order to solve the technical problem that the rationality of training a language model in a specific domain is poor due to unreasonable setting of a scaling factor in a LoRA model, the present invention proposes a specific domain model training method based on an expert knowledge base.

[0006] In a first aspect, the present invention provides a method for training a specific domain model based on an expert knowledge base, the method comprising:

[0007] Obtain an initial general knowledge base and an initial expert knowledge base, and perform word segmentation on each sentence in each text in the initial general knowledge base and the initial expert knowledge base to obtain target word segments, and obtain the word vector corresponding to each target word segment;

[0008] Determine the target similarity between each two texts based on the similarity between the word vectors corresponding to the target word segments in each two texts;

[0009] According to the target similarity between the texts, all the texts are clustered to obtain the target clusters, and based on the target clusters to which the texts in the initial expert knowledge base belong, the initial expert knowledge base and the initial general knowledge base are expanded and deleted respectively to obtain the expanded expert knowledge base and the deleted general knowledge base;

[0010] According to the distribution of each target segmentation in the initial expert knowledge base in the expanded expert knowledge base and the deleted general knowledge base, the target professional contribution degree corresponding to each target segmentation in the initial expert knowledge base is determined;

[0011] Determine the target learning rate corresponding to each sentence in the initial expert knowledge base according to the target professional contribution degree corresponding to the target word in each sentence and its adjacent sentences in the initial expert knowledge base;

[0012] The scaling factors of each sentence in the initial expert knowledge base in the LoRA model are updated to their corresponding target learning rates, and the language model is fine-tuned through the LoRA model to obtain a trained language model.

[0013] In combination with the first aspect above, in a possible implementation, determining the target similarity between each two texts according to the similarity between the word vectors corresponding to the target word segments in each two texts includes:

[0014] Determine the TF-IDF value corresponding to each target word, and select a preset number of target words with the largest corresponding TF-IDF value from each text to form a keyword set corresponding to each text;

[0015] Determine any two texts in the union of the initial general knowledge base and the initial expert knowledge base as first marked text and second marked text respectively;

[0016] Determine each target segmentation in the keyword set corresponding to the first marked text as a reference segmentation, and determine each target segmentation in the keyword set corresponding to the second marked text as a temporary segmentation;

[0017] The cosine similarity between the word vector corresponding to each reference participle and the word vector corresponding to each temporary participle is determined as the participle similarity between each reference participle and each temporary participle;

[0018] The average of the segmentation similarities between all reference segmentations and all temporary segmentations is determined as the target similarity between the first marked text and the second marked text.

[0019] In combination with the first aspect above, in a possible implementation, clustering all texts according to target similarities between texts to obtain target clusters includes:

[0020] Determine the distance measure between each two texts according to the target similarity between each two texts, wherein the target similarity is negatively correlated with the distance measure;

[0021] According to the distance measurement between texts, all texts are clustered by DBSCAN algorithm, and each cluster obtained is determined as the target cluster, wherein the core objects belonging to the initial expert knowledge base selected when clustering by DBSCAN algorithm are determined as the real core objects when clustering.

[0022] In combination with the first aspect, in a possible implementation, based on the target cluster to which the text in the initial expert knowledge base belongs, the initial expert knowledge base and the initial general knowledge base are expanded and deleted respectively to obtain the expanded expert knowledge base and the deleted general knowledge base, including:

[0023] All the texts in the target cluster to which all the texts in the initial expert knowledge base belong, which belong to the initial general knowledge base, are added to the initial expert knowledge base to obtain an expanded expert knowledge base;

[0024] All the texts in the target cluster to which all the texts in the initial expert knowledge base belong and which belong to the initial general knowledge base are deleted from the initial general knowledge base to obtain a reduced general knowledge base.

[0025] In combination with the first aspect above, in a possible implementation, determining the target professional contribution degree corresponding to each target segmentation in the initial expert knowledge base according to the distribution of each target segmentation in the initial expert knowledge base in the expanded expert knowledge base and the deleted general knowledge base respectively includes:

[0026] Use CFG to obtain the structure tree corresponding to each sentence;

[0027] Determine any target segmentation in the initial expert knowledge base as a standard segmentation;

[0028] Filtering target participles identical to the standard participles from the expanded expert knowledge base to form a professional similar participle set corresponding to the standard participles;

[0029] Filtering target participles identical to the standard participles from the deleted general knowledge base to form a set of general similar participles corresponding to the standard participles;

[0030] The target professional contribution degree corresponding to the standard participle is determined based on the tree edit distance between the structure tree corresponding to the sentence to which the standard participle belongs and the structure tree corresponding to the sentence to which the target participle belongs in its corresponding professional similar participle set and the universal similar participle set.

[0031] In combination with the first aspect above, in a possible implementation, the formula corresponding to the target professional contribution degree corresponding to the target word segmentation in the initial expert knowledge base is:

[0032] ;

[0033] ;

[0034] ;in, is the first h The degree of contribution of the target specialty corresponding to each target participle; h is the serial number of the target word in the initial expert knowledge base; In the initial expert knowledge base, h The average tree edit distance between the structure tree corresponding to the sentence to which the target participle belongs and the structure tree corresponding to the sentence to which the target participle belongs in the corresponding universal similar participle set; In the initial expert knowledge base, h The average tree edit distance between the structure tree corresponding to the sentence to which the target word belongs and the structure tree corresponding to the sentence to which the target word belongs in the corresponding professional similar word set; is a natural exponential function; is the normalization function; is the initial expert knowledge base, h The number of target segmentations in the set of common similar segmentations corresponding to the target segmentation; x is the initial expert knowledge base, h The sequence number of the target segmentation word in the set of common similar segmentations corresponding to the target segmentation word; is the initial expert knowledge base, h The number of target segmentations in the professional similar segmentation set corresponding to the target segmentation; t is the initial expert knowledge base, h The sequence number of the target segmentation in the professional similar segmentation set corresponding to the target segmentation; is the initial expert knowledge base, h The structure tree corresponding to the sentence to which the target word belongs is h The first one in the set of common similar segmented words corresponding to the target segmented word x The tree edit distance between the structure trees corresponding to the sentences to which the target word belongs; is the initial expert knowledge base, hThe structure tree corresponding to the sentence to which the target word belongs is h The first one in the professional similar word set corresponding to the target word t The tree edit distance between the structure trees corresponding to the sentences to which the target word belongs.

[0035] In combination with the first aspect above, in a possible implementation, determining the target learning rate corresponding to each sentence in the initial expert knowledge base according to the target professional contribution degree corresponding to the target word in each sentence and its adjacent sentences in the initial expert knowledge base includes:

[0036] According to the target professional contribution degree corresponding to all target participles in each sentence, the overall professional contribution degree corresponding to each sentence is determined, wherein the target professional contribution degree is positively correlated with the overall professional contribution degree;

[0037] Determine any sentence in the initial expert knowledge base as a marked sentence, and select a preset number of sentences closest to the marked sentence from the text to which the marked sentence belongs to form a reference sentence set corresponding to the marked sentence;

[0038] According to the overall professional contribution degree of all sentences in the reference sentence set corresponding to the marked sentence, the target learning rate corresponding to the marked sentence is determined, wherein the overall professional contribution degree is positively correlated with the target learning rate.

[0039] In combination with the first aspect above, in a possible implementation, determining the overall professional contribution level corresponding to each sentence according to the target professional contribution levels corresponding to all target word segments in each sentence includes:

[0040] The average of the target professional contribution levels corresponding to all target participles in each sentence is determined as the overall professional contribution level corresponding to each sentence.

[0041] In combination with the first aspect above, in a possible implementation manner, determining the target learning rate corresponding to the marked sentence according to the overall professional contribution degree corresponding to all sentences in the reference sentence set corresponding to the marked sentence includes:

[0042] The target learning rate corresponding to the marked sentence is determined according to the overall professional contribution degree of all sentences in the reference sentence set corresponding to the marked sentence and the distance between the marked sentence and the sentences in the reference sentence set corresponding to the marked sentence.

[0043] In combination with the first aspect above, in a possible implementation, the formula corresponding to the target learning rate corresponding to the labeled sentence is:

[0044] ;in, is the target learning rate corresponding to the labeled sentence; is the normalization function; G is the number of sentences in the reference sentence set corresponding to the labeled sentence; is the sequence number of the sentence in the reference sentence set corresponding to the labeled sentence; is the first sentence in the set of labeled sentences and their corresponding reference sentences. The distance between sentences; is the reference sentence set corresponding to the labeled sentence. The overall professional contribution level corresponding to each sentence.

[0045] In a second aspect, the present invention provides a domain-specific model training system based on an expert knowledge base, the system comprising:

[0046] An acquisition processing module is used to acquire an initial general knowledge base and an initial expert knowledge base, and perform word segmentation processing on each sentence in each text in the initial general knowledge base and the initial expert knowledge base to obtain target word segments, and obtain a word vector corresponding to each target word segment;

[0047] A similarity determination module is used to determine the target similarity between each two texts based on the similarity between the word vectors corresponding to the target word segments in each two texts;

[0048] The clustering expansion and deletion module is used to cluster all texts according to the target similarity between the texts to obtain the target clusters, and based on the target clusters to which the texts in the initial expert knowledge base belong, expand and delete the initial expert knowledge base and the initial general knowledge base respectively to obtain the expanded expert knowledge base and the deleted general knowledge base;

[0049] A professional contribution degree determination module is used to determine the target professional contribution degree corresponding to each target segmentation in the initial expert knowledge base according to the distribution of each target segmentation in the initial expert knowledge base in the expanded expert knowledge base and the deleted general knowledge base;

[0050] A learning rate determination module is used to determine a target learning rate corresponding to each sentence in the initial expert knowledge base according to a target professional contribution degree corresponding to a target word in each sentence and its adjacent sentences in the initial expert knowledge base;

[0051] The factor update model fine-tuning module is used to update the scaling factor of each sentence in the initial expert knowledge base in the LoRA model to its corresponding target learning rate, and fine-tune the language model through the LoRA model to obtain a trained language model.

[0052] In a third aspect, a server is provided, comprising a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, so that the device executes the method in the first aspect or any possible implementation of the first aspect.

[0053] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.

[0054] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.

[0055] The present invention has the following beneficial effects:

[0056] The present invention provides a method for training a specific domain model based on an expert knowledge base, which solves the technical problem of poor rationality when training a language model in a specific domain by processing text data in the knowledge base, and improves the rationality of training a language model in a specific domain. Compared with fine-tuning a language model by a LoRA model with a fixed scaling factor, the present invention comprehensively considers multiple indicators related to the professional situation of a sentence, such as target similarity and target professional contribution, thereby quantifying the target learning rate that characterizes the degree of professionalism that a sentence needs to be learned, and then adaptively adjusts the scaling factor of each sentence in the initial expert knowledge base corresponding to the LoRA model, which can improve the learning of highly professional sentences to a certain extent, and can also reduce the overfitting of low professional sentences to a certain extent, thereby improving the rationality of training a language model in a specific domain, thereby improving the performance of the language model in a specific domain. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are 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 paying creative work.

[0058] Figure 1 A flowchart of a method for training a specific domain model based on an expert knowledge base of the present invention;

[0059] Figure 2A schematic diagram of the composition structure of a specific domain model training system based on an expert knowledge base of the present invention;

[0060] Figure 3 The figure is a schematic diagram of the structure of a computer device of the present invention. DETAILED DESCRIPTION

[0061] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects of the technical solutions proposed by the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0062] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0063] refer to Figure 1 , shows the process of some embodiments of a method for training a specific domain model based on an expert knowledge base according to the present invention. The method for training a specific domain model based on an expert knowledge base comprises the following steps:

[0064] Step S1, obtain an initial general knowledge base and an initial expert knowledge base, and perform word segmentation processing on each sentence in each text in the initial general knowledge base and the initial expert knowledge base to obtain target word segments, and obtain the word vector corresponding to each target word segment.

[0065] Among them, the initial general knowledge base can be an existing general knowledge base, that is, a general knowledge base that has not been deleted, which may include non-specific field texts. For example, the initial general knowledge base may include but is not limited to: online encyclopedia (Wikipedia), news data and open forum content. The initial expert knowledge base, that is, the expert knowledge base that has not been expanded, may be an existing expert knowledge base in a specific field. The specific field may be a field that needs to be analyzed. For example, the specific field may be but is not limited to: software development field, medical field, legal field and financial field. If the specific field is the software development field, then the initial expert knowledge base may include: literature, papers, professional terminology sets and reports in the software development field. A text may represent a document, which may be a paper, a report or a journal article. A sentence may be a sentence ending with a period. The target segmentation may be the segmentation obtained after the sentence is segmented. The word vector may represent the real number vector of the segmentation.

[0066] As an example, this step may include the following steps:

[0067] The first step is to obtain the initial general knowledge base.

[0068] For example, online encyclopedias, news data, and open forum content can be collected to form an initial general knowledge base.

[0069] The second step is to obtain the initial expert knowledge base.

[0070] For example, if the specific field is software development, then literature, papers, professional terminology sets and reports in the field of software development can be collected to form an initial expert knowledge base.

[0071] The third step is to perform word segmentation on each sentence in each text in the initial general knowledge base and the initial expert knowledge base to obtain the target word segmentation.

[0072] For example, through the Jieba word segmentation method, each sentence in each text in the initial general knowledge base and the initial expert knowledge base is segmented, and each obtained word segmentation is used as the target word segmentation.

[0073] The fourth step is to obtain the word vector corresponding to each target word.

[0074] For example, the word vector corresponding to each target word can be obtained through the Word2Vec (Word to Vector) model.

[0075] Step S2, determining the target similarity between each two texts based on the similarity between the word vectors corresponding to the target word segments in each two texts.

[0076] It should be noted that in actual situations, the general knowledge base often contains data in some specific fields, that is, some data in the general knowledge base may belong to the field where the expert knowledge base is located. In order to improve the richness of the expert knowledge base, the data in the general knowledge base that belongs to the field where the expert knowledge base is located can be expanded to the expert knowledge base. Therefore, quantifying the target similarity between each two texts can facilitate the subsequent screening of data belonging to the field where the expert knowledge base is located from the general knowledge base.

[0077] As an example, this step may include the following steps:

[0078] The first step is to determine the TF-IDF (Term Frequency–Inverse Document Frequency) value corresponding to each target word, and select a preset number of target words with the largest corresponding TF-IDF value from each text to form a keyword set corresponding to each text.

[0079] The larger the TF-IDF value corresponding to the target word, the greater the importance of the target word to the text. The preset number can be a preset number greater than or equal to 20, which can be equal to the larger value of 20 and the target number. The target number can be equal to the number obtained by rounding the ratio of the number of target words in the text to 100.

[0080] For example, if there are 300 target participles in a text, the target number is 30, and the larger value between 20 and 30 is 30, so the preset number is 30. At this time, the 30 target participles with the largest TF-IDF values ​​can be screened out from the text to form the keyword set corresponding to the text, wherein the keyword set corresponding to the text can include 30 target participles.

[0081] It should be noted that the keyword set corresponding to a text can represent important information of the text to a certain extent.

[0082] In the second step, any two texts in the union of the initial general knowledge base and the initial expert knowledge base are respectively determined as the first marked text and the second marked text.

[0083] In the third step, each target segmentation in the keyword set corresponding to the first marked text is determined as a reference segmentation, and each target segmentation in the keyword set corresponding to the second marked text is determined as a temporary segmentation.

[0084] In the fourth step, the cosine similarity between the word vector corresponding to each reference participle and the word vector corresponding to each temporary participle is determined as the participle similarity between each reference participle and each temporary participle.

[0085] In the fifth step, the average of the segmentation similarities between all reference segmentations and all temporary segmentations is determined as the target similarity between the first marked text and the second marked text.

[0086] For example, the formula for determining the target similarity between any two texts can be:

[0087] ;in, is the union of the initial general knowledge base and the initial expert knowledge base, i The text and j The target similarity between the texts. i and j It is the sequence number of different texts in the union of the initial general knowledge base and the initial expert knowledge base. is the union of the initial general knowledge base and the initial expert knowledge base, i The number of target word segments in the keyword set corresponding to the text. is the union of the initial general knowledge base and the initial expert knowledge base, j The number of target word segments in the keyword set corresponding to the text. a is the union of the initial general knowledge base and the initial expert knowledge base, i The sequence number of the target word in the keyword set corresponding to the text. b is the union of the initial general knowledge base and the initial expert knowledge base, j The sequence number of the target word in the keyword set corresponding to the text. is the union of the initial general knowledge base and the initial expert knowledge base, i The first keyword in the set of keywords corresponding to the text a The target word and j The first keyword in the set of keywords corresponding to the text b The similarity between the target words; that is, a The word vector corresponding to the target word is b The cosine similarity between the word vectors corresponding to the target word segments.

[0088] It should be noted that when The larger the i The keyword set corresponding to the text is j The more similar the keyword sets corresponding to the two texts are, the more likely it is that the i The important information of the text is j The more similar the important information of the two texts is, the more likely it is that the i The text and j The more similar the two texts are, the more likely they are to be i The text and j The more likely the texts are of the same type.

[0089] Step S3, clustering all texts according to the target similarity between texts to obtain target clusters, and based on the target clusters to which the texts in the initial expert knowledge base belong, expanding and deleting the initial expert knowledge base and the initial general knowledge base respectively to obtain an expanded expert knowledge base and a deleted general knowledge base.

[0090] As an example, this step may include the following steps:

[0091] In the first step, the distance measure between each two texts is determined according to the target similarity between each two texts.

[0092] Among them, target similarity can be negatively correlated with the distance metric.

[0093] For example, the formula for determining the distance measure between any two texts can be:

[0094] ;in, is the union of the initial general knowledge base and the initial expert knowledge base, i The text and j The distance measure between two texts. i and j It is the sequence number of different texts in the union of the initial general knowledge base and the initial expert knowledge base. is the union of the initial general knowledge base and the initial expert knowledge base, i The text and j The target similarity between the texts.

[0095] It should be noted that when The larger the i The text and j The more similar the two texts are, the more likely they are to be i The text and j The more likely the texts are of the same type. The larger the i The text and j The more likely the texts are not of the same type, the more likely it is that the i The text and j The more texts should not be clustered into one category.

[0096] In the second step, all texts are clustered according to the distance measurement between texts using the DBSCAN (Density-Based Spatial Clustering of Applications with Noise) algorithm, and each resulting cluster is identified as the target cluster.

[0097] Among them, when clustering by DBSCAN algorithm, the core objects selected from the initial expert knowledge base can be determined as the real core objects when clustering. Here, the parameter Eps in clustering can be 0.03; the minimum number of points within the domain radius to become a core object can be 10.

[0098] It should be noted that core objects are often selected when clustering is performed using the DBSCAN algorithm. Generally, the selected core objects include texts belonging to the initial expert knowledge base and texts belonging to the initial general knowledge base. Since the embodiment of the present invention subsequently needs to screen general knowledge base texts that can be supplemented to the initial expert knowledge base, it is often necessary to focus on general knowledge base texts that can be clustered into the expert knowledge base. Therefore, when clustering is performed using the DBSCAN algorithm, the selected core objects belonging to the initial general knowledge base can be regarded as ordinary objects, and only the selected core objects belonging to the initial expert knowledge base are retained as core objects for subsequent clustering.

[0099] The third step is to add all the texts in the target cluster to which all the texts in the initial expert knowledge base belong that belong to the initial general knowledge base to the initial expert knowledge base to obtain the expanded expert knowledge base.

[0100] It should be noted that all texts in the target cluster to which all texts in the initial expert knowledge base belong that belong to the initial general knowledge base often represent data in the same field as that in the initial general knowledge base.

[0101] The fourth step is to delete all the texts in the target cluster to which all the texts in the initial expert knowledge base belong that belong to the initial general knowledge base from the initial general knowledge base to obtain a reduced general knowledge base.

[0102] It should be noted that the expanded expert knowledge base may be an expert knowledge base with richer content, and the deleted general knowledge base may be a general knowledge base that does not contain data in the field where the expert knowledge base is located.

[0103] Step S4, determining the target professional contribution degree corresponding to each target segmentation in the initial expert knowledge base according to the distribution of each target segmentation in the initial expert knowledge base in the expanded expert knowledge base and the deleted general knowledge base.

[0104] As an example, this step may include the following steps:

[0105] The first step is to use CFG (Context-Free Grammar) to obtain the structure tree corresponding to each sentence.

[0106] In the second step, any target segmentation in the above initial expert knowledge base is determined as the standard segmentation.

[0107] The third step is to select target segmentations that are identical to the above-mentioned standard segmentations from the above-mentioned expanded expert knowledge base to form a set of professional similar segmentations corresponding to the above-mentioned standard segmentations.

[0108] It should be noted that the same words may exist in different sentences. For example, if the two sentences in the expanded expert knowledge base are "The patient received antibiotic treatment and the symptoms were relieved" and "The symptoms were relieved after the patient received antibiotic treatment", and "antibiotics" in the first sentence is a standard participle, then "antibiotics" in the second sentence can be the same target participle as the standard participle, which can be an element in the professional similar participle set corresponding to the standard participle.

[0109] The fourth step is to select target segmentations that are identical to the standard segmentations from the deleted general knowledge base to form a set of general similar segmentations corresponding to the standard segmentations.

[0110] The fifth step is to determine the target professional contribution degree corresponding to the above standard participle based on the tree edit distance between the structure tree corresponding to the sentence to which the above standard participle belongs and the structure tree corresponding to the sentence to which the target participle belongs in its corresponding professional similar participle set and the universal similar participle set.

[0111] For example, the formula for determining the target professional contribution degree corresponding to the target word segmentation in the initial expert knowledge base can be:

[0112] ;

[0113] ;

[0114] ;in, is the first h The target professional contribution degree corresponding to each target participle. h is the ordinal number of the target word in the initial expert knowledge base. In the initial expert knowledge base, h The average tree edit distance between the structure tree corresponding to the sentence to which the target participle belongs and the structure tree corresponding to the sentence to which the target participle belongs in the corresponding universal similar participle set. In the initial expert knowledge base, h The average tree edit distance between the structure tree corresponding to the sentence to which the target participle belongs and the structure tree corresponding to the sentence to which the target participle belongs in the corresponding professional similar participle set. is a natural exponential function. is a normalization function. is the initial expert knowledge base, h The number of target segmentations in the set of common similar segmentations corresponding to the target segmentation. x is the initial expert knowledge base, h The sequence number of the target segmentation in the set of common similar segmentations corresponding to the target segmentation. is the initial expert knowledge base,h The number of target segmentations in the professional similar segmentation set corresponding to the target segmentation. t is the initial expert knowledge base, h The sequence number of the target word in the professional similar word set corresponding to the target word. is the initial expert knowledge base, h The structure tree corresponding to the sentence to which the target word belongs is h The first one in the set of common similar segmented words corresponding to the target segmented word x The tree edit distance between the structure trees corresponding to the sentences to which the target word belongs. is the initial expert knowledge base, h The structure tree corresponding to the sentence to which the target word belongs is h The first one in the professional similar word set corresponding to the target word t The tree edit distance between the structure trees corresponding to the sentences to which the target word belongs.

[0115] It should be noted that, in actual situations, the contexts of highly specialized participles in their respective fields are often relatively similar, and the more the participle appears in the field, the more representative it is, and the more it should be learned. The larger the h The more times a target word appears in the expanded expert knowledge base, the more likely it is that the h The more times a target word appears in this field, the more likely it is that the h The more representative the target word is, the more likely it is that h The more target segmentations should be learned. The smaller the time, the more likely it is that h The more similar the contexts of a target word are in different sentences in its domain, the more likely it is that the h The higher the professionalism of the target word, the more likely it is. In practice, words with higher professionalism tend to appear more frequently in specific fields and less frequently or not at all in other fields. And if the contexts of the same word in different fields are similar, it often means that the word is more likely to be a common word and less likely to be a professional word, for example, it may be a word that represents a process step. The smaller the time, the more likely it is that h The fewer times a target word appears in the deleted general knowledge base, the more likely it is that the h The fewer times a target word appears in other fields, the less likely it is that the h The higher the professionalism of the target word, the higher the The smaller the time, the more likely it is that h The more similar the contexts of the target word are in this field and other fields, the more likely it is that theh The more likely the target word is to be a more common word. The larger the h The higher the professionalism of the target word, the higher the h The more target segmentations should be learned.

[0116] Step S5, determining the target learning rate corresponding to each sentence in the initial expert knowledge base according to the target professional contribution degree corresponding to the target word in each sentence and its adjacent sentences in the initial expert knowledge base.

[0117] As an example, this step may include the following steps:

[0118] The first step is to determine the overall professional contribution level of each sentence based on the target professional contribution levels of all target words in each sentence.

[0119] Among them, the contribution degree of the target major can be positively correlated with the overall professional contribution degree.

[0120] For example, the average of the target professional contribution levels corresponding to all target participles in each sentence may be determined as the overall professional contribution level corresponding to each sentence.

[0121] It should be noted that the overall professional contribution degree corresponding to a sentence can represent the overall professional situation of the sentence. The larger the value is, the more likely it is that the sentence is describing professional content, and it often means that a larger scaling factor needs to be set for the sentence.

[0122] In the second step, any sentence in the initial expert knowledge base is determined as a marked sentence, and a preset number of sentences closest to the marked sentence are selected from the text to which the marked sentence belongs to form a reference sentence set corresponding to the marked sentence.

[0123] The reference sentence set corresponding to the marked sentence may include the marked sentence. The preset number may be a pre-set number, which may be 21.

[0124] For example, the sentences in the text to which the marked sentence belongs can be sorted from left to right and from top to bottom. If the preset number is 21, the absolute value of the difference between the serial number corresponding to the marked sentence and the serial number corresponding to each sentence in the text to which the marked sentence belongs can be determined as the distance between the marked sentence and each sentence in the text to which it belongs. The 21 sentences closest to the marked sentence can be screened out from the text to which the marked sentence belongs to form a reference sentence set corresponding to the marked sentence.

[0125] The third step is to determine the target learning rate corresponding to the above-marked sentence according to the overall professional contribution degree of all sentences in the reference sentence set corresponding to the above-marked sentence.

[0126] Among them, the overall professional contribution level can be positively correlated with the target learning rate.

[0127] For example, the target learning rate corresponding to the marked sentence can be determined based on the overall professional contribution of all sentences in the reference sentence set corresponding to the marked sentence and the distance between the marked sentence and the sentences in the reference sentence set corresponding to the marked sentence.

[0128] For example, the formula for determining the target learning rate corresponding to the labeled sentence can be:

[0129] ;in, is the target learning rate corresponding to the labeled sentence. is a normalization function whose value range is [0, 1]. G is the number of sentences in the reference sentence set corresponding to the labeled sentence. is the sequence number of the sentence in the reference sentence set corresponding to the labeled sentence. is the first sentence in the set of labeled sentences and their corresponding reference sentences. The distance between sentences. is the reference sentence set corresponding to the labeled sentence. The overall professional contribution level corresponding to each sentence.

[0130] It should be noted that in actual situations, professional content often does not exist in isolation. Generally speaking, if a sentence describes professional content, the sentences adjacent to it are generally also sentences describing professional content. In other words, if the sentences adjacent to a sentence describe professional content, it can be said to a certain extent that the sentence is also likely to describe professional content. Can be used as When The smaller the time, the more likely it is that The closer the sentence is to the marked sentence, the more likely it is that The greater the influence of the first sentence on the marked sentence, the greater the influence of the first sentence on the marked sentence. The professional situation of the sentence can represent the professional situation of the marked sentence to a certain extent. The larger the The more likely a sentence is to describe professional content. When the value is larger, it often indicates that the marked sentence is more likely to be a sentence describing professional content, which often indicates that a larger scaling factor needs to be set for the marked sentence.

[0131] Step S6, updating the scaling factor of each sentence in the initial expert knowledge base in the LoRA model to its corresponding target learning rate, and fine-tuning the language model through the LoRA model to obtain a trained language model.

[0132] The LoRA model can be used to fine-tune the language model. The scaling factor in the LoRA model can have a value range of [0, 1]. The language model used in the embodiment of the present invention can be a BERT model.

[0133] It should be noted that there are multiple layers of Transformer encoders in the BERT model, in which each layer of encoders often contains Q (query matrix), K (key matrix) and V (value matrix). In the process of training the BERT model, Q (query matrix) and K (key matrix) are often corrected by scaling factors to achieve fine-tuning of the BERT model. Therefore, the updated scaling factors in the embodiment of the present invention can be used to correct Q (query matrix) and K (key matrix) to achieve fine-tuning of the BERT model, and finally complete the training of the BERT model.

[0134] refer to Figure 2 Based on the same inventive concept as the above method embodiment, the present invention provides a specific domain model training system based on an expert knowledge base, the system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the above computer program is executed by the processor, the steps of implementing a specific domain model training method based on an expert knowledge base may specifically include:

[0135] The acquisition processing module 201 is used to acquire an initial general knowledge base and an initial expert knowledge base, and perform word segmentation processing on each sentence in each text in the initial general knowledge base and the initial expert knowledge base to obtain target word segments, and obtain a word vector corresponding to each target word segment;

[0136] A similarity determination module 202 is used to determine the target similarity between each two texts according to the similarity between the word vectors corresponding to the target word segments in each two texts;

[0137] The clustering expansion and deletion module 203 is used to cluster all texts according to the target similarity between the texts to obtain the target cluster, and based on the target cluster to which the texts in the initial expert knowledge base belong, expand and delete the initial expert knowledge base and the initial general knowledge base respectively to obtain the expanded expert knowledge base and the deleted general knowledge base;

[0138] The professional contribution degree determination module 204 is used to determine the target professional contribution degree corresponding to each target segmentation in the initial expert knowledge base according to the distribution of each target segmentation in the initial expert knowledge base in the expanded expert knowledge base and the deleted general knowledge base;

[0139] A learning rate determination module 205 is used to determine a target learning rate corresponding to each sentence in the initial expert knowledge base according to the target professional contribution degree corresponding to the target word in each sentence and its adjacent sentences in the initial expert knowledge base;

[0140] The factor update model fine-tuning module 206 is used to update the scaling factor of each sentence in the initial expert knowledge base in the LoRA model to its corresponding target learning rate, and fine-tune the language model through the LoRA model to obtain a trained language model.

[0141] Figure 3 is a schematic diagram of the structure of a computer device provided by an embodiment of the present invention. Figure 3 As shown, the computer device 300 includes: a memory 301, a processor 302, and a computer program 303 stored in the memory 301 and running on the processor 302, wherein when the processor 302 executes the computer program 303, the computer device can execute any one of the above-mentioned specific domain model training methods based on the expert knowledge base.

[0142] Based on the same inventive concept as the above method embodiment, the present invention provides a server, including a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, so that the device executes any of the above-mentioned specific domain model training methods based on the expert knowledge base.

[0143] Based on the same inventive concept as the above-mentioned method embodiment, the present invention provides a computer program product, which includes: computer program code, when the computer program code runs on a computer, enables the computer to execute any one of the above-mentioned specific domain model training methods based on an expert knowledge base.

[0144] Based on the same inventive concept as the above-mentioned method embodiment, the present invention provides a computer-readable storage medium, which stores a computer program code. When the computer program code runs on a computer, the computer executes any one of the above-mentioned specific domain model training methods based on an expert knowledge base.

[0145] In summary, compared to the LoRA model with a fixed scaling factor, the language model is fine-tuned. The present invention comprehensively considers multiple indicators related to the professional situation of the sentence, such as target similarity and target professional contribution, thereby quantifying the target learning rate that characterizes the degree of professionalism that the sentence needs to be learned, and then adaptively adjusts the scaling factor of each sentence in the initial expert knowledge base corresponding to the LoRA model, which can improve the learning of highly professional sentences to a certain extent, help the model quickly adapt to the complex knowledge in the field, and can also reduce the overfitting of low-professional sentences to a certain extent, and maintain the generalization ability of the model. Secondly, this method enables the model to maintain good adaptability in a variety of tasks and fields, optimizes the knowledge transfer effect in multi-task learning, and improves the overall learning efficiency and performance. Therefore, the adaptive learning rate adjustment based on professionalism not only improves the training speed, but also enhances the comprehensive ability of the model in professional fields and general tasks.

[0146] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A method for training a specific domain model based on an expert knowledge base, characterized in that: The following steps are involved: Obtain an initial general knowledge base and an initial expert knowledge base, and perform word segmentation on each sentence in each text in the initial general knowledge base and the initial expert knowledge base to obtain target word segments, and obtain the word vector corresponding to each target word segment; Determine the target similarity between each two texts based on the similarity between the word vectors corresponding to the target word segments in each two texts; According to the target similarity between the texts, all the texts are clustered to obtain the target clusters, and based on the target clusters to which the texts in the initial expert knowledge base belong, the initial expert knowledge base and the initial general knowledge base are expanded and deleted respectively to obtain the expanded expert knowledge base and the deleted general knowledge base; According to the distribution of each target segmentation in the initial expert knowledge base in the expanded expert knowledge base and the deleted general knowledge base, the target professional contribution degree corresponding to each target segmentation in the initial expert knowledge base is determined; Determine the target learning rate corresponding to each sentence in the initial expert knowledge base according to the target professional contribution degree corresponding to the target word in each sentence and its adjacent sentences in the initial expert knowledge base; The scaling factors of each sentence in the initial expert knowledge base in the LoRA model are updated to their corresponding target learning rates, and the language model is fine-tuned through the LoRA model to obtain a trained language model; The step of determining the target professional contribution degree corresponding to each target segmentation in the initial expert knowledge base according to the distribution of each target segmentation in the initial expert knowledge base in the expanded expert knowledge base and the deleted general knowledge base includes: Use context-free grammar CFG to obtain the structure tree corresponding to each sentence; Determine any target segmentation in the initial expert knowledge base as a standard segmentation; Filtering target participles identical to the standard participles from the expanded expert knowledge base to form a professional similar participle set corresponding to the standard participles; Filtering target participles identical to the standard participles from the deleted general knowledge base to form a set of general similar participles corresponding to the standard participles; Determine the target professional contribution degree corresponding to the standard participle according to the tree edit distance between the structure tree corresponding to the sentence to which the standard participle belongs and the structure tree corresponding to the sentence to which the target participle belongs in the corresponding professional similar participle set and the universal similar participle set; The step of determining the target learning rate corresponding to each sentence in the initial expert knowledge base according to the target professional contribution degree corresponding to the target word in each sentence and its adjacent sentences in the initial expert knowledge base includes: According to the target professional contribution degree corresponding to all target participles in each sentence, the overall professional contribution degree corresponding to each sentence is determined, wherein the target professional contribution degree is positively correlated with the overall professional contribution degree; Determine any sentence in the initial expert knowledge base as a marked sentence, and select a preset number of sentences closest to the marked sentence from the text to which the marked sentence belongs to form a reference sentence set corresponding to the marked sentence; According to the overall professional contribution degree of all sentences in the reference sentence set corresponding to the marked sentence, the target learning rate corresponding to the marked sentence is determined, wherein the overall professional contribution degree is positively correlated with the target learning rate.

2. A method for training a specific domain model based on an expert knowledge base according to claim 1, characterized in that: Determining the target similarity between each two texts according to the similarity between the word vectors corresponding to the target word segments in each two texts includes: Determine the TF-IDF value corresponding to each target word, and select a preset number of target words with the largest corresponding TF-IDF value from each text to form a keyword set corresponding to each text; Determine any two texts in the union of the initial general knowledge base and the initial expert knowledge base as first marked text and second marked text respectively; Determine each target segmentation in the keyword set corresponding to the first marked text as a reference segmentation, and determine each target segmentation in the keyword set corresponding to the second marked text as a temporary segmentation; The cosine similarity between the word vector corresponding to each reference participle and the word vector corresponding to each temporary participle is determined as the participle similarity between each reference participle and each temporary participle; The average of the segmentation similarities between all reference segmentations and all temporary segmentations is determined as the target similarity between the first marked text and the second marked text.

3. A method for training a specific domain model based on an expert knowledge base according to claim 1, characterized in that: According to the target similarity between the texts, all the texts are clustered to obtain the target cluster, including: Determine the distance measure between each two texts according to the target similarity between each two texts, wherein the target similarity is negatively correlated with the distance measure; According to the distance measurement between texts, all texts are clustered by DBSCAN algorithm, and each cluster obtained is determined as the target cluster, wherein the core objects belonging to the initial expert knowledge base selected when clustering by DBSCAN algorithm are determined as the real core objects when clustering.

4. The method for training a specific domain model based on an expert knowledge base according to claim 1, characterized in that: The method of expanding and deleting the initial expert knowledge base and the initial general knowledge base based on the target cluster to which the text in the initial expert knowledge base belongs, to obtain an expanded expert knowledge base and a deleted general knowledge base, comprises: All the texts in the target cluster to which all the texts in the initial expert knowledge base belong, which belong to the initial general knowledge base, are added to the initial expert knowledge base to obtain an expanded expert knowledge base; All the texts in the target cluster to which all the texts in the initial expert knowledge base belong and which belong to the initial general knowledge base are deleted from the initial general knowledge base to obtain a reduced general knowledge base.

5. The method for training a specific domain model based on an expert knowledge base according to claim 1, characterized in that: The formula corresponding to the target professional contribution degree corresponding to the target word in the initial expert knowledge base is: ; ; ;in, is the first h The degree of contribution of the target specialty corresponding to each target participle; h is the serial number of the target word in the initial expert knowledge base; In the representation of the initial expert knowledge base, h The average tree edit distance between the structure tree corresponding to the sentence to which the target participle belongs and the structure tree corresponding to the sentence to which the target participle belongs in the corresponding universal similar participle set; In the representation of the initial expert knowledge base, h The average tree edit distance between the structure tree corresponding to the sentence to which the target word belongs and the structure tree corresponding to the sentence to which the target word belongs in the corresponding professional similar word set; is a natural exponential function; is the normalization function; is the initial expert knowledge base, h The number of target segmentations in the set of common similar segmentations corresponding to the target segmentation; x is the initial expert knowledge base, h The sequence number of the target segmentation word in the set of common similar segmentations corresponding to the target segmentation word; is the initial expert knowledge base, h The number of target segmentations in the professional similar segmentation set corresponding to the target segmentation; t is the initial expert knowledge base, h The sequence number of the target segmentation in the professional similar segmentation set corresponding to the target segmentation; is the initial expert knowledge base, h The structure tree corresponding to the sentence to which the target word belongs is h The first one in the set of common similar segmented words corresponding to the target segmented word x The tree edit distance between the structure trees corresponding to the sentences to which the target word belongs; is the initial expert knowledge base, h The structure tree corresponding to the sentence to which the target word belongs is h The first one in the professional similar word set corresponding to the target word t The tree edit distance between the structure trees corresponding to the sentences to which the target word belongs.

6. A method for training a specific domain model based on an expert knowledge base according to claim 1, characterized in that: Determining the overall professional contribution level corresponding to each sentence according to the target professional contribution levels corresponding to all target word segments in each sentence includes: The average of the target professional contribution levels corresponding to all target participles in each sentence is determined as the overall professional contribution level corresponding to each sentence.

7. The method for training a specific domain model based on an expert knowledge base according to claim 1, characterized in that: The step of determining the target learning rate corresponding to the marked sentence according to the overall professional contribution degree of all sentences in the reference sentence set corresponding to the marked sentence includes: The target learning rate corresponding to the marked sentence is determined according to the overall professional contribution degree of all sentences in the reference sentence set corresponding to the marked sentence and the distance between the marked sentence and the sentences in the reference sentence set corresponding to the marked sentence.

8. A method for training a specific domain model based on an expert knowledge base according to claim 7, characterized in that: The formula for the target learning rate corresponding to the labeled sentence is: ;in, is the target learning rate corresponding to the labeled sentence; is the normalization function; G is the number of sentences in the reference sentence set corresponding to the labeled sentence; is the sequence number of the sentence in the reference sentence set corresponding to the labeled sentence; is the first sentence in the set of labeled sentences and their corresponding reference sentences. The distance between sentences; is the reference sentence set corresponding to the labeled sentence. The overall professional contribution level corresponding to each sentence.

Citation Information

Patent Citations

  • Knowledge base expansion method and device, equipment and medium

    CN115525747A

  • Knowledge structure extraction and knowledge base construction method and system

    CN118861239A