A knowledge enhancement method and system for large language models
By building a high-quality vertical domain knowledge base and extracting topic words using Monte Carlo tree structure, the general big model answers poor correlation in the vertical domain, and the accuracy and professional knowledge question and answer of the large language model in the vertical domain are achieved. Reduced training costs.
Patent Information
- Application Number
- CN202411260647.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2044-09-10
AI Technical Summary
The existing general-purpose large language models lack vertical domain knowledge in vertical fields, resulting in poor relevance of answers and the need for frequent retraining to consume a lot of resources and time, making it difficult to meet the precise Q&A needs of vertical domain expertise.
By obtaining vertical domain data information, a high-quality vertical domain knowledge base is built, important topic words are extracted using Monte Carlo tree structure and subject word identification method, prompt word templates are generated, and large language models are enhanced to achieve accurate question and answers.
It realizes the accuracy and professionalism of knowledge questions and answers of large models in vertical fields, reduces training resources and time costs, and ensures the accurate division of knowledge content between different technical directions and systems.
Smart Images

Figure CN118779470B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a knowledge enhancement method and system for a large language model. Background Art
[0002] In today's "information explosion" era, people receive fragmented knowledge every day, and it takes a lot of time to extract valuable data information. The emergence of large language models has effectively promoted the empowerment and efficiency of life and production. Users can directly interact with large models for knowledge questions and answers and quickly obtain high-value information. However, when general large models directly answer questions related to vertical fields, "illusion" answers with poor relevance to user questions often appear. The fundamental reason is that vertical field knowledge is not fully utilized to enhance the professional answering ability of large models. For vertical fields, technological innovation is increasingly iterative. The existing general large models are mainly based on vertical field knowledge for parameterized representation and fine-tuning training. Every time the ever-changing external knowledge is learned, the knowledge needs to be retrained, which consumes a lot of training resources and time costs. There is also a lack of in-depth mining of high-quality vertical field knowledge, which makes it difficult to meet the precise question-and-answer needs of professional knowledge in vertical fields.
[0003] Therefore, there is a need for a large model knowledge enhancement method that fully utilizes vertical field knowledge and improves professional answering capabilities, so as to achieve the goal of accurate question and answer of professional knowledge in vertical fields with small training resources and time costs. Summary of the invention
[0004] The purpose of the present invention is to provide a knowledge enhancement method and system for a large language model to improve the above problems. In order to achieve the above purpose, the technical solution adopted by the present invention is as follows:
[0005] In a first aspect, the present application provides a knowledge enhancement method for a large language model, comprising:
[0006] Obtain vertical field data information to be processed;
[0007] Sending the vertical field data information to be processed to a preset data processing model to construct a vertical field knowledge base, thereby obtaining a vertical field knowledge base containing at least two text blocks;
[0008] Based on the preset topic identification method, the subject words in the vertical domain knowledge base are extracted, and the Monte Carlo tree structure corresponding to the vertical domain knowledge base is constructed;
[0009] Based on the preset subject word identification method, the Monte Carlo tree structure of the vertical field is used to identify the subject words, and the subject word category of each text block in the vertical field knowledge base is determined;
[0010] Sending the subject word category and preset user questions of each text block in the vertical domain knowledge base to a preset enhanced retrieval model for processing, and obtaining a sentence ranking table corresponding to the text block with the highest relevance to the user question;
[0011] A prompt word template of a large language model is generated based on the sentence ranking table and the user question, and an enhanced large language model is constructed based on the prompt word template.
[0012] In a second aspect, the present application also provides a knowledge enhancement system for a large language model, including:
[0013] An acquisition unit, used to acquire vertical field data information to be processed;
[0014] A first processing unit is used to send the vertical field data information to be processed to a preset data processing model to construct a vertical field knowledge base, so as to obtain a vertical field knowledge base including at least two text blocks;
[0015] The second processing unit is used to extract the subject words in the vertical field knowledge base based on a preset subject identification method, and construct a Monte Carlo tree structure corresponding to the vertical field knowledge base;
[0016] The third processing unit is used to perform subject word identification on the Monte Carlo tree structure of the vertical field based on a preset subject word identification method, and determine the subject word category of each text block in the vertical field knowledge base;
[0017] A fourth processing unit, configured to send the subject word category of each text block in the vertical domain knowledge base and the preset user question to a preset enhanced retrieval model for processing, and obtain a sentence ranking table corresponding to the text block with the highest relevance to the user question;
[0018] The fifth processing unit is used to generate a prompt word template of the large language model based on the sentence ranking table and the user question, and to construct an enhanced large language model based on the prompt word template.
[0019] The beneficial effects of the present invention are:
[0020] To address the problem that existing general large models lack vertical domain knowledge, the present invention removes low-quality redundant texts to build a high-quality vertical domain knowledge base, extracts important keywords for building a vertical domain knowledge structure, and ensures the accurate division of the large model knowledge question and answer content between different technical directions, equipment and systems.
[0021] The present invention also takes the text blocks in the vertical domain knowledge base as input, proposes a text block keyword identification method based on Monte Carlo tree search, endows a large model with non-parametric knowledge, captures the implicit relationship between each text block, and realizes the tracking and tracing of the text block content in the vertical domain knowledge base based on the keyword.
[0022] The present invention also proposes a method for accurate retrieval of text block content, which queries and returns a set of text block content of the keyword category most relevant to the user's question, ensuring that the large model question and answer content is highly relevant to the user's question, and further improving the accuracy and professionalism of the large model knowledge answer content.
[0023] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or be understood by implementing the embodiments of the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 A schematic flow chart of a method for knowledge enhancement of a large language model according to an embodiment of the present invention;
[0026] Figure 2 Schematic diagram of the knowledge enhancement system structure of the large language model described in an embodiment of the present invention.
[0027] In the figure: 701, acquisition unit; 702, first processing unit; 703, second processing unit; 704, third processing unit; 705, fourth processing unit; 706, fifth processing unit; 7021, first processing subunit; 7022, first calculation subunit; 7023, second processing subunit; 7031, second calculation subunit; 7032, third processing subunit; 7033, third calculation subunit; 70331, fourth calculation subunit; 70332, fourth processing subunit; 70333, fifth processing subunit; 7041, sixth processing subunit; 7042, seventh processing subunit; 7043, eighth processing subunit; 7051, fifth calculation subunit; 7052, ninth processing subunit; 7053, tenth processing subunit; 7054, sixth calculation subunit. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0029] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. Embodiment 1:
[0030] This embodiment provides a knowledge enhancement method for a large language model.
[0031] See also Figure 1 , the figure shows that the method includes step S1, step S2, step S3, step S4, step S5 and step S6.
[0032] Step S1, obtaining vertical field data information to be processed;
[0033] It can be understood that this step prepares for subsequent data processing by acquiring data information in vertical fields from books, journals, patents, the Internet or within the enterprise, wherein this information is uploaded to a storage device for storage.
[0034] Step S2: sending the vertical field data information to be processed to a preset data processing model to construct a vertical field knowledge base, thereby obtaining a vertical field knowledge base containing at least two text blocks;
[0035] It can be understood that this step establishes a high-quality vertical field knowledge base by deleting meaningless data in the vertical field data information to be processed to ensure the simplicity of the knowledge base. In this step, step S2 includes step S21, step S22 and step S23.
[0036] Step S21: Construct text blocks for the vertical domain data information to be processed according to their sources, delete the first preset vocabulary information in all text blocks, retain and perform vector conversion on the second preset vocabulary information in all text blocks to obtain the word vector information corresponding to the second preset vocabulary information;
[0037] It can be understood that in this step, by taking multi-source vertical domain knowledge as input and removing虚词 or实词 that are irrelevant and meaningless to vertical domain knowledge, such as words like "的", "地", "在", "基于", "研究", "考虑", etc., the simplicity of the knowledge base is ensured. However, in the process of finally generating knowledge Q&A, it is still responsible for connecting the topic words in the vertical domain, such as words like "技术方向、设备、系统", etc. Therefore, they are retained in the basic corpus and represented by word vectors, but removed from the vertical domain knowledge base.
[0038] Step S22: Calculate the similarity between the word vector information corresponding to adjacent two text blocks. If the similarity is greater than the threshold, then judge the text quality of the two text blocks. Among them, by judging the occurrence frequency of the word vector information corresponding to the two text blocks, if the occurrence frequency of the word vector information corresponding to one of the text blocks is less than the preset first threshold, then delete that text block to obtain the text blocks with the occurrence frequency of the word vector information greater than the preset first threshold;
[0039] It can be understood that in this step, the similarity and text quality between adjacent two text blocks are calculated. If the similarity value is greater than the preset parameter (the preset parameter can be dynamically adjusted according to requirements), then remove the text with relatively lower text quality. Finally, retain the vertical domain knowledge base with relatively higher text quality and relatively smaller content redundancy.
[0040] Step S23:汇总所有词向量信息出现频次大于预设第一阈值的文本块,得到垂直领域知识库。
[0041] It can be understood that in this step, by summarizing the text blocks corresponding to the frequencies of all word vectors, a vertical domain knowledge base containing all text with relatively higher text quality and relatively smaller content redundancy is obtained, improving the efficiency and accuracy of subsequent processing.
[0042] Step S3: Extract the topic words in the vertical domain knowledge base based on the preset topic recognition method and construct the Monte Carlo tree structure corresponding to the vertical domain knowledge base;
[0043] It should be noted that the Chinese expression "汇总所有词向量信息出现频次大于预设第一阈值的文本块" in the original text seems a bit inaccurate in grammar. The translated "汇总所有词向量信息出现频次大于预设第一阈值的文本块" is a literal translation. A more accurate expression might be "Summarize all text blocks with the occurrence frequency of the word vector information greater than the preset first threshold".It can be understood that the vertical domain knowledge in this step not only has professional barriers, but also has hierarchical relationships between different technical directions, equipment and systems. Therefore, a vertical domain knowledge structure with clear hierarchy is constructed to improve the professionalism of the large model knowledge answer. In this step, step S3 includes step S31, step S32 and step S33.
[0044] Step S31, extracting word vector information corresponding to the second preset vocabulary information in the vertical domain knowledge base, and calculating the distance between the word vector information corresponding to all the second preset vocabulary information according to a preset distance calculation formula;
[0045] Step S32: classify the word vector information corresponding to all the second preset vocabulary information based on the distance, wherein if the distance between the word vector information corresponding to two second preset vocabulary information is less than a preset second threshold, they are classified into the same set to obtain at least two theme word sets;
[0046] It can be understood that this step calculates the distance between the word vector information corresponding to all the second preset vocabulary information through the preset distance calculation formula, and then classifies the subject words with similar meanings, and divides the word vector information corresponding to the vocabulary information of the same category into the same set, wherein the preset distance calculation formula is as follows:
[0047] ;
[0048] in, Represents the word vector information corresponding to the a-th vocabulary information, Represents the word vector information corresponding to the b-th vocabulary information, represents a preset second threshold, and N represents a classification set.
[0049] Step S33: Calculate the frequency of occurrence of each subject word in the subject word set based on all subject word sets, and select a preset number of subject words from them to construct a Monte Carlo tree structure.
[0050] It can be understood that in this step, step S33 includes step S331, step S332 and step S333.
[0051] Step S331, calculating the frequency of all subject words based on a preset subject word frequency calculation formula to obtain the frequency of each subject word;
[0052] It can be understood that this step calculates the frequency of all subject words and selects a preset number of subject words to build a Monte Carlo tree structure to improve the professionalism of the large model knowledge answer. The calculation formula for the frequency of each subject word in this step is as follows:
[0053]
[0054] Among them, τ represents the frequency of the subject word, I represents the number of subject words, i represents the i-th subject word, Indicates the number of times the i-th topic word appears.
[0055] Step S332: Map the frequency of occurrence of each subject word with a preset expert scoring table to determine the frequency score of each subject word, and compare the frequency score of each subject word with a preset third threshold value. If the frequency score of the subject word is greater than the third threshold value, the subject word corresponding to the score greater than the third threshold value is regarded as an important subject word;
[0056] It can be understood that this step scores the frequency of each keyword, selects keywords with higher scores as the main keywords, reduces the amount of calculation of the vertical field large model, and improves the efficiency and accuracy of the response.
[0057] Step S333, constructing a Monte Carlo tree structure based on the important keywords, wherein the important keywords are semantically recognized and the recognized important keywords are divided into three levels, the first level being keywords corresponding to preset technical direction names, the second level being keywords corresponding to preset system equipment names, and the third level being keywords corresponding to preset subsystem equipment names.
[0058] It can be understood that this step constructs a Monte Carlo tree structure through important keywords. For example, taking the railway vertical field as an example, the vertical field knowledge is defined as a Monte Carlo tree structure, and the keywords of the first-level parent node are set to the four main technical directions of the vertical field, namely "civil engineering", "mobile equipment", "communication signal", and "operation management". The second-level child nodes are specific systems or equipment in the vertical field, and the third-level child nodes are subsystems or sub-equipment of the second-level child nodes. The child nodes of "civil engineering" are "roadbed", "sleeper", "rail", "bridge", "tunnel", etc. It should be noted that some keywords with the same name (such as turnout) will be involved in multiple keywords of the previous level (such as civil engineering, communication signal), so the above keywords should be marked with the keywords of the previous level, that is, "civil engineering-turnout" and "communication signal-turnout".
[0059] Step S4: perform subject word identification on the Monte Carlo tree structure of the vertical field based on a preset subject word identification method to determine the subject word category of each text block in the vertical field knowledge base;
[0060] It can be understood that this step improves the accuracy of search content by performing subject word identification on the Monte Carlo tree structure in the vertical field through a preset subject word identification method. In this step, step S4 includes step S41, step S42 and step S43.
[0061] Step S41, starting from the root node of the Monte Carlo tree structure, performing Monte Carlo simulation on all child nodes from top to bottom, and calculating the upper confidence interval value of each child node;
[0062] It can be understood that this step starts from the root node state, traverses the child nodes of the topic word step by step, and the state function value is set to the topic word of the tth text block and the traversed keywords The distance between The calculation formula for the upper confidence interval value of each child node in this step is as follows:
[0063] ;
[0064] in, Represents the upper confidence interval value of each child node, Indicates the subject word The number of times the corresponding child node wins, Represents the total number of Monte Carlo simulations.
[0065] Step S42: during the simulation process, determine whether the current child node is the last-level child node. If not, select the next-level child node and expand the next-level child node to obtain the status information of all the next-level child nodes after expansion.
[0066] It can be understood that in this step, when the Monte Carlo simulation runs to a certain keyword subnode at the last level of the Monte Carlo tree, and the node has not been visited, the keyword subnode is expanded and its new state is added to the tree, while continuing the Monte Carlo simulation.
[0067] Step S43, perform Monte Carlo simulation on the status information of all child nodes of the next level after expansion in sequence until all levels of child nodes are simulated, obtain the upper confidence interval values of all levels of child nodes, and determine the category corresponding to each keyword based on the upper confidence interval values of all levels of child nodes.
[0068] It can be understood that this step determines the upper confidence interval values of all levels of sub-nodes, and determines the category corresponding to each subject word based on the upper confidence interval values of all levels of sub-nodes, thereby quickly classifying each subject word to achieve the purpose of rapid classification.
[0069] Step S5: Send the subject word category and preset user questions of each text block in the vertical domain knowledge base to the preset enhanced retrieval model for processing, and obtain a sentence ranking table corresponding to the text block with the highest relevance to the user question;
[0070] It can be understood that this step determines the subject word category most relevant to the user's question and retrieves the text block content related thereto, further improving the accuracy of the vertical field large model knowledge enhancement method in terms of content retrieval. In this step, step S5 includes step S51, step S52, step S53 and step S54.
[0071] Step S51, performing cosine similarity calculation on the subject word category of each text block in the vertical domain knowledge base and the preset user question, associating the user question with the subject word category with the greatest similarity, and determining the text content corresponding to the associated subject word category;
[0072] It can be understood that this step calculates the cosine similarity between the subject word category of each text block in the vertical field knowledge base and the preset user question, determines the text content corresponding to each subject word category, and provides a basis for the accuracy of the retrieval content.
[0073] Step S52, query all text blocks in sequence, and construct a set of text contents corresponding to all associated subject word categories;
[0074] Step S53: Divide all the contents in the set into minimum granularity units of sentences, and convert the sentences obtained by segmentation into vectors to obtain vector information corresponding to each sentence;
[0075] Step S54: perform cosine similarity calculation based on the vector information corresponding to each sentence and the preset user question, and sort the sentences according to the similarity between the vector information corresponding to each sentence and the preset user question to obtain a sentence sorting list, in which the sorting order is from large to small.
[0076] It can be understood that the above steps convert the sentence vectors to generate a ranking function of the sentence vectors, thereby preparing for the subsequent generation of a prompt word template for a large language model.
[0077] Step S6: generating a prompt word template of a large language model based on the sentence ranking table and the user question, and constructing an enhanced large language model based on the prompt word template.
[0078] It can be understood that this step takes the sorted sentence list of the user's question text vector as input, customizes the heuristic rules, generates the prompt word template of the vertical field big model, and then takes the prompt word template as input, calls the application program interface of the general big model, builds the vertical field big model, and accurately and professionally answers the user's relevant questions. Embodiment 2:
[0079] like Figure 2 As shown, this embodiment provides a knowledge enhancement system for a large language model, see Figure 2 The system includes an acquisition unit 701 , a first processing unit 702 , a second processing unit 703 , a third processing unit 704 , a fourth processing unit 705 and a fifth processing unit 706 .
[0080] An acquisition unit 701 is used to acquire vertical field data information to be processed;
[0081] The first processing unit 702 is used to send the vertical field data information to be processed to a preset data processing model to construct a vertical field knowledge base, so as to obtain a vertical field knowledge base including at least two text blocks;
[0082] The first processing unit 702 includes a first processing sub-unit 7021 , a first calculation sub-unit 7022 and a second processing sub-unit 7023 .
[0083] The first processing sub-unit 7021 is used to construct text blocks according to the source of the vertical field data information to be processed, delete the first preset vocabulary information in all the text blocks, and retain and vectorize the second preset vocabulary information in all the text blocks to obtain the word vector information corresponding to the second preset vocabulary information;
[0084] The first calculation subunit 7022 is used to calculate the similarity between the word vector information corresponding to two adjacent text blocks. If the similarity is greater than a threshold, the text quality of the two text blocks is determined, wherein the appearance frequency of the word vector information corresponding to the two text blocks is determined. If the appearance frequency of the word vector information corresponding to one of the text blocks is less than a preset first threshold, the text block is deleted to obtain a text block whose appearance frequency of the word vector information is greater than the preset first threshold;
[0085] The second processing sub-unit 7023 is used to aggregate all text blocks whose word vector information occurrence frequency is greater than a preset first threshold to obtain a vertical field knowledge base.
[0086] The second processing unit 703 is used to extract the subject words in the vertical domain knowledge base based on a preset subject identification method, and construct a Monte Carlo tree structure corresponding to the vertical domain knowledge base;
[0087] The second processing unit 703 includes a second calculation subunit 7031 , a third processing subunit 7032 and a third calculation subunit 7033 .
[0088] The second calculation subunit 7031 is used to extract the word vector information corresponding to the second preset vocabulary information in the vertical domain knowledge base, and calculate the distance between the word vector information corresponding to all the second preset vocabulary information according to the preset distance calculation formula;
[0089] The third processing subunit 7032 is used to classify the word vector information corresponding to all the second preset vocabulary information based on the distance, wherein if the distance between the word vector information corresponding to two second preset vocabulary information is less than a preset second threshold, they are divided into the same set to obtain at least two theme word sets;
[0090] The third calculation subunit 7033 is used to calculate the frequency of occurrence of each subject word in the subject word set based on all subject word sets, and select a preset number of subject words from the subject words to construct a Monte Carlo tree structure.
[0091] The third calculation subunit 7033 includes a fourth calculation subunit 70331 , a fourth processing subunit 70332 and a fifth processing subunit 70333 .
[0092] The fourth calculation subunit 70331 is used to calculate the frequency of occurrence of all subject words based on a preset subject word frequency calculation formula to obtain the frequency of occurrence of each subject word;
[0093] The fourth processing subunit 70332 is used to map the frequency of occurrence of each subject word with a preset expert scoring table, determine the frequency score of each subject word, and compare the frequency score of each subject word with a preset third threshold value. If the frequency score of the subject word is greater than the third threshold value, the subject word corresponding to the score greater than the third threshold value is regarded as an important subject word;
[0094] The fifth processing sub-unit 70333 is used to construct a Monte Carlo tree structure based on the important keywords, wherein the important keywords are semantically recognized and the recognized important keywords are divided into three levels, the first level is the keywords corresponding to the preset technical direction names, the second level is the keywords corresponding to the preset system equipment names, and the third level is the keywords corresponding to the preset subsystem equipment names.
[0095] The third processing unit 704 is used to perform subject word identification on the Monte Carlo tree structure of the vertical field based on a preset subject word identification method, and determine the subject word category of each text block in the vertical field knowledge base;
[0096] The third processing unit 704 includes a sixth processing sub-unit 7041 , a seventh processing sub-unit 7042 and an eighth processing sub-unit 7043 .
[0097] The sixth processing sub-unit 7041 is used to start from the root node of the Monte Carlo tree structure, perform Monte Carlo simulation on all child nodes from top to bottom, and calculate the upper confidence interval value of each child node;
[0098] The seventh processing sub-unit 7042 is used to determine whether the current child node is the last-level child node during the simulation process. If not, select the next-level child node and expand the next-level child node to obtain the state information of all the next-level child nodes after expansion.
[0099] The eighth processing sub-unit 7043 is used to perform Monte Carlo simulation on the state information of all child nodes of the next level after expansion in sequence until all child nodes of all levels are simulated, to obtain the upper confidence interval values of the child nodes of all levels, and to determine the category corresponding to each keyword based on the upper confidence interval values of the child nodes of all levels.
[0100] The fourth processing unit 705 is used to send the subject word category of each text block in the vertical domain knowledge base and the preset user question to the preset enhanced retrieval model for processing, and obtain a sentence ranking table corresponding to the text block with the highest relevance to the user question;
[0101] The fourth processing unit 705 includes a fifth calculation subunit 7051 , a ninth processing subunit 7052 , a tenth processing subunit 7053 and a sixth calculation subunit 7054 .
[0102] The fifth calculation subunit 7051 is used to calculate the cosine similarity between the subject word category of each text block in the vertical domain knowledge base and the preset user question, associate the user question with the subject word category with the greatest similarity, and determine the text content corresponding to the associated subject word category;
[0103] The ninth processing subunit 7052 is used to query all text blocks in sequence and construct a set of text contents corresponding to all associated subject word categories;
[0104] The tenth processing subunit 7053 is used to divide all the contents in the set into minimum granularity units based on sentences, and perform vector conversion on the sentences obtained by the division to obtain vector information corresponding to each sentence;
[0105] The sixth calculation subunit 7054 is used to calculate the cosine similarity based on the vector information corresponding to each sentence and the preset user question, and sort the sentences according to the similarity between the vector information corresponding to each sentence and the preset user question to obtain a sentence sorting list, where the arrangement order is from large to small.
[0106] The fifth processing unit 706 is configured to generate a prompt word template of a large language model based on the sentence ranking table and the user question, and construct an enhanced large language model based on the prompt word template.
[0107] It should be noted that, regarding the system in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0108] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0109] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A knowledge enhancement method for a large language model, characterized in that: include: Obtain vertical field data information to be processed; Sending the vertical field data information to be processed to a preset data processing model to construct a vertical field knowledge base, thereby obtaining a vertical field knowledge base containing at least two text blocks; Based on the preset topic identification method, the subject words in the vertical domain knowledge base are extracted, and the Monte Carlo tree structure corresponding to the vertical domain knowledge base is constructed; Based on the preset subject word identification method, the Monte Carlo tree structure of the vertical field is used to identify the subject words, and the subject word category of each text block in the vertical field knowledge base is determined; Sending the subject word category and preset user questions of each text block in the vertical domain knowledge base to a preset enhanced retrieval model for processing, and obtaining a sentence ranking table corresponding to the text block with the highest relevance to the user question; A prompt word template of a large language model is generated based on the sentence ranking table and the user question, and an enhanced large language model is constructed based on the prompt word template.
2. The knowledge enhancement method for a large language model according to claim 1, characterized in that , sending the vertical field data information to be processed to the preset data processing model to build a vertical field knowledge base, including: The vertical field data information to be processed is constructed into text blocks according to the source, and the first preset vocabulary information in all the text blocks is deleted, and the second preset vocabulary information in all the text blocks is retained and vectorized to obtain the word vector information corresponding to the second preset vocabulary information; Calculate the similarity between the word vector information corresponding to two adjacent text blocks. If the similarity is greater than a threshold, determine the text quality of the two text blocks. Deleting the text block if the frequency of occurrence of the word vector information corresponding to one of the text blocks is less than a preset first threshold is performed to obtain a text block whose frequency of occurrence of the word vector information is greater than the preset first threshold. All text blocks whose word vector information occurrence frequency is greater than a preset first threshold are aggregated to obtain a vertical domain knowledge base.
3. The knowledge enhancement method for a large language model according to claim 1, characterized in that ,Based on the preset topic identification method, the subject words in the vertical domain knowledge base are extracted, and the Monte Carlo tree structure corresponding to the vertical domain knowledge base is constructed, including: Extracting word vector information corresponding to the second preset vocabulary information in the vertical domain knowledge base, and calculating the distance between all word vector information corresponding to the second preset vocabulary information according to a preset distance calculation formula; Based on the distance, the word vector information corresponding to all the second preset vocabulary information is classified and processed, wherein if the distance between the word vector information corresponding to two second preset vocabulary information is less than a preset second threshold, they are divided into the same set to obtain at least two theme word sets; Based on all the subject word sets, the frequency of occurrence of each subject word is calculated, and a preset number of subject words are selected to construct a Monte Carlo tree structure.
4. The knowledge enhancement method for a large language model according to claim 3, characterized in that , based on all the subject word sets, calculate the frequency of each subject word, and select a preset number of subject words to build a Monte Carlo tree structure, including: Calculate the frequency of all subject words based on the preset subject word frequency calculation formula to obtain the frequency of each subject word; Map the frequency of occurrence of each subject word with a preset expert scoring table to determine the frequency score of each subject word, and compare the frequency score of each subject word with a preset third threshold value. If the frequency score of the subject word is greater than the third threshold value, the subject word corresponding to the score greater than the third threshold value is regarded as an important subject word; A Monte Carlo tree structure is constructed based on the important keywords, in which the important keywords are semantically recognized and the recognized important keywords are divided into three levels, the first level is the keywords corresponding to the preset technical direction names, the second level is the keywords corresponding to the preset system equipment names, and the third level is the keywords corresponding to the preset subsystem equipment names.
5. The knowledge enhancement method for a large language model according to claim 1, characterized in that ,Based on the preset subject word identification method, the Monte Carlo tree structure of the vertical field is identified by subject words, including: Starting from the root node of the Monte Carlo tree structure, Monte Carlo simulation is performed on all child nodes from top to bottom, and an upper confidence interval value of each child node is calculated; In the simulation process, it is determined whether the current child node is the last-level child node. If not, the next-level child node is selected and the next-level child node is expanded to obtain the status information of all the next-level child nodes after expansion. The state information of all the child nodes of the next level after expansion is subjected to Monte Carlo simulation in sequence until all the child nodes of all levels are simulated, and the upper confidence interval values of the child nodes of all levels are obtained. The category corresponding to each keyword is determined based on the upper confidence interval values of the child nodes of all levels.
6. A knowledge enhancement system for a large language model, characterized in that: include: An acquisition unit, used to acquire vertical field data information to be processed; A first processing unit is used to send the vertical field data information to be processed to a preset data processing model to construct a vertical field knowledge base, so as to obtain a vertical field knowledge base including at least two text blocks; The second processing unit is used to extract the subject words in the vertical field knowledge base based on a preset subject identification method, and construct a Monte Carlo tree structure corresponding to the vertical field knowledge base; The third processing unit is used to perform subject word identification on the Monte Carlo tree structure of the vertical field based on a preset subject word identification method, and determine the subject word category of each text block in the vertical field knowledge base; A fourth processing unit, configured to send the subject word category of each text block in the vertical domain knowledge base and the preset user question to a preset enhanced retrieval model for processing, and obtain a sentence ranking table corresponding to the text block with the highest relevance to the user question; The fifth processing unit is used to generate a prompt word template of the large language model based on the sentence ranking table and the user question, and to construct an enhanced large language model based on the prompt word template.
7. The knowledge enhancement system of the large language model according to claim 6, characterized in that: The first processing unit comprises: A first processing subunit is used to construct text blocks according to the source of the vertical field data information to be processed, delete the first preset vocabulary information in all the text blocks, and retain and vector-convert the second preset vocabulary information in all the text blocks to obtain the word vector information corresponding to the second preset vocabulary information; The first calculation subunit is used to calculate the similarity between the word vector information corresponding to two adjacent text blocks. If the similarity is greater than a threshold, the text quality of the two text blocks is judged, wherein the appearance frequency of the word vector information corresponding to the two text blocks is judged. If the appearance frequency of the word vector information corresponding to one of the text blocks is less than a preset first threshold, the text block is deleted to obtain a text block whose appearance frequency of the word vector information is greater than the preset first threshold; The second processing sub-unit is used to aggregate all text blocks whose word vector information occurrence frequency is greater than a preset first threshold to obtain a vertical field knowledge base.
8. The knowledge enhancement system of a large language model according to claim 6, characterized in that: The second processing unit comprises: The second calculation subunit is used to extract the word vector information corresponding to the second preset vocabulary information in the vertical field knowledge base, and calculate the distance between the word vector information corresponding to all the second preset vocabulary information according to the preset distance calculation formula; A third processing subunit is used to classify the word vector information corresponding to all the second preset vocabulary information based on the distance, wherein if the distance between the word vector information corresponding to two second preset vocabulary information is less than a preset second threshold, they are divided into the same set to obtain at least two theme word sets; The third calculation subunit is used to calculate the frequency of occurrence of each subject word in the subject word set based on all subject word sets, and select a preset number of subject words from the subject words to construct a Monte Carlo tree structure.
9. The knowledge enhancement system of the large language model according to claim 8, characterized in that: The third computing subunit comprises: The fourth calculation subunit is used to calculate the occurrence frequency of all subject words based on a preset subject word frequency calculation formula to obtain the occurrence frequency of each subject word; The fourth processing subunit is used to map the frequency of occurrence of each subject word with a preset expert scoring table, determine the frequency score of each subject word, and compare the frequency score of each subject word with a preset third threshold value. If the frequency score of the subject word is greater than the third threshold value, the subject word corresponding to the score greater than the third threshold value is regarded as an important subject word; The fifth processing sub-unit is used to construct a Monte Carlo tree structure based on the important keywords, wherein the important keywords are semantically recognized and the recognized important keywords are divided into three levels, the first level is the keywords corresponding to the preset technical direction names, the second level is the keywords corresponding to the preset system equipment names, and the third level is the keywords corresponding to the preset subsystem equipment names.
10. The knowledge enhancement system of a large language model according to claim 6, characterized in that: The third processing unit comprises: A sixth processing subunit is used to start from the root node of the Monte Carlo tree structure, perform Monte Carlo simulation on all child nodes from top to bottom, and calculate the upper confidence interval value of each child node; The seventh processing sub-unit is used to determine whether the current child node is the last-level child node during the simulation process. If not, the next-level child node is selected and the next-level child node is expanded to obtain the state information of all the next-level child nodes after the expansion. The eighth processing sub-unit is used to perform Monte Carlo simulation on the state information of all child nodes of the next level after expansion in sequence until all levels of child nodes are simulated, to obtain the upper confidence interval values of the child nodes of all levels, and to determine the category corresponding to each keyword based on the upper confidence interval values of the child nodes of all levels.
Citation Information
Cited By
Power enterprise knowledge base updating and maintaining system and method based on NLP large model
CN120388384A
