Keyword extraction method and device based on knowledge enhancement and domain knowledge constraint
By using a large model based on knowledge enhancement and domain knowledge constraints in the power grid field for keyword extraction, the problem of low accuracy and low efficiency of keyword extraction in the power grid field is solved, and efficient and accurate keyword extraction is achieved.
Patent Information
- Application Number
- CN202510004771.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-05-16
AI Technical Summary
The prior art has problems of low accuracy and low efficiency in keyword extraction in the power grid field, and requires a large amount of human resources and computing resources.
The keyword extraction method of the power grid field big model based on knowledge enhancement and domain knowledge constraints is adopted. By obtaining the supervision data set related to the power grid field, the initial big model is trained, and the trained big model is obtained, and the keyword extraction is used for the big model.
Effectively save human resources and computing resources, improve the efficiency and accuracy of keyword extraction, and more accurately identify keywords in the power grid field.
Smart Images

Figure CN120012778A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing related to power grids, and in particular to a keyword extraction method and device based on knowledge enhancement and domain knowledge constraints. Background Art
[0002] In the field of power grid, one of the keys to improving the operation efficiency and management level of power system is to achieve effective management and utilization of power grid data. As an important application of natural language processing technology, keyword extraction is widely used in many aspects such as fault diagnosis, customer service, and information retrieval of power grid.
[0003] However, power grid data itself is highly complex and diverse, including multiple data types, including a large amount of unstructured information. In addition, the technical terms and special terms in the power grid field are rich and professional, making it very difficult to extract keywords in the power grid field. It requires a lot of human resources and computing resources, and there are problems of low extraction accuracy and efficiency. Therefore, how to achieve keyword extraction in the power grid field is a problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of the present invention is to provide a keyword extraction method and device based on knowledge enhancement and domain knowledge constraints, which can solve the problem that keyword extraction in the prior art requires a large amount of human resources and computing resources, and has low accuracy and low efficiency.
[0005] To achieve the above objectives, the present invention provides a method for extracting keywords from a large model of a power grid domain based on knowledge enhancement and domain knowledge constraints in a first aspect, the method comprising:
[0006] Acquire supervisory datasets related to the power grid domain;
[0007] Based on knowledge enhancement and domain knowledge constraints, the supervised data set is used to train an initial large model for keyword extraction in the power grid field to obtain a trained large model;
[0008] The target data of keywords to be extracted are input into the large model to extract keywords in the field of power grid, and the keywords related to the field of power grid contained in the target data output by the large model are obtained.
[0009] Furthermore, the acquisition of a supervisory data set related to the power grid field includes:
[0010] Collecting source data related to the power grid field, wherein the source data at least includes one or more of equipment data, equipment operation data, environmental data and historical fault data in the power grid field;
[0011] The source data is processed to obtain a supervision data set related to the power grid field, wherein the supervision data set is written by a natural language template.
[0012] Furthermore, the source data is processed to obtain a supervisory data set related to the power grid field, including:
[0013] Preprocessing the source data to obtain candidate data, wherein the preprocessing includes one or more of cleaning, normalization, and format conversion;
[0014] The candidate data is annotated by manual annotation, and the supervision data set is constructed. The supervision data set includes input content, prompt templates, and annotation results of keywords in the input content.
[0015] Furthermore, based on the knowledge enhancement and domain knowledge constraint, the supervised data set is used to train the initial large model for extracting keywords in the power grid field to obtain the trained large model, including:
[0016] Acquire a general data set for pre-training the initial large model, and acquire a preset specific vocabulary in the field of power grid, add the specific vocabulary to the general data set to obtain a pre-training data set, wherein the specific vocabulary includes specific technical terms related to the field of power grid;
[0017] Pre-training the initial large model using the pre-training data set to obtain a pre-trained initial large model;
[0018] Using the supervised data set to fine-tune the pre-trained initial large model to obtain a fine-tuned initial large model;
[0019] Human feedback reinforcement learning and power grid domain knowledge constraint methods are introduced, and the fine-tuned initial large model is adjusted and optimized through a reward and penalty mechanism to obtain a large model.
[0020] Furthermore, the method of introducing human feedback reinforcement learning and power grid domain knowledge constraint is used to adjust and optimize the fine-tuned initial large model through a reward and penalty mechanism to obtain a large model, including:
[0021] Use the manually input keyword data set to build a reinforcement learning preference data set;
[0022] Based on the cosine similarity-based power grid domain knowledge constraint reward function and direct preference optimization DPO reinforcement learning algorithm, the initial large model is trained using the reinforcement learning preference data set to obtain a trained large model.
[0023] Furthermore, the method of constructing a reinforcement learning preference data set using a manually input keyword data set includes:
[0024] If manually inputted i-th keyword data is detected, the i-th keyword data is inputted into the fine-tuned initial large model to obtain the keyword corresponding to the i-th keyword data, wherein the keyword data set includes N keyword data, i and N are positive integers;
[0025] A reinforcement learning preference dataset is constructed based on the keywords corresponding to each keyword data in the manually input keyword dataset.
[0026] Furthermore, the step of constructing a reinforcement learning preference data set based on the keywords corresponding to each keyword data in the manually input keyword data set includes:
[0027] Output the keywords corresponding to each keyword data to the display screen so that the displayed keywords can be manually scored and sorted;
[0028] The reinforcement learning preference data set is determined based on the results of manually scoring and sorting the keywords displayed on the display screen and the keyword data set.
[0029] Furthermore, the method further comprises:
[0030] The large model obtained through training is saved as a file in a preset format to obtain a large model file;
[0031] The large model file is loaded into the memory using the Flask framework, and the corresponding API interface is deployed for the large model file saved in the memory using the Flask framework.
[0032] To achieve the above-mentioned purpose, the second aspect of the present invention provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor executes the steps of the method described in the first aspect.
[0033] To achieve the above-mentioned purpose, the third aspect of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method described in the first aspect.
[0034] The embodiments of the present invention have the following beneficial effects:
[0035] The present invention provides a keyword extraction method based on knowledge enhancement and domain knowledge constraints, the method comprising: obtaining a supervised data set related to the power grid field; based on knowledge enhancement and domain knowledge constraints, using the supervised data set to train an initial large model for keyword extraction in the power grid field to obtain a trained large model; inputting target data of keywords to be extracted into the large model to extract keywords in the power grid field, and obtaining keywords related to the power grid field contained in the target data output by the large model. By using the large model to extract keywords in the power grid field, human resources and computing resources can be effectively saved, and the efficiency of keyword extraction can be improved. Moreover, by introducing knowledge enhancement and domain knowledge constraints, the accuracy and efficiency of keyword extraction can be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] in:
[0038] Figure 1 Schematic diagram of the flow of a keyword extraction method based on knowledge enhancement and domain knowledge constraints in an embodiment of the present invention;
[0039] Figure 2 A schematic diagram of a prompt template in an embodiment of the present invention;
[0040] Figure 3 is a structural block diagram of a keyword extraction device based on knowledge enhancement and domain knowledge constraint in an embodiment of the present invention;
[0041] Figure 4 4 is a structural block diagram of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] The data in the power grid field is highly complex and professional. It is very difficult to obtain the main information from a large amount of power grid data. It requires a lot of human and computing resources, and the extraction accuracy is low and the efficiency is low.
[0044] Based on this, the embodiment of the present invention proposes a keyword extraction method for a large model of a power grid domain based on knowledge enhancement and domain knowledge constraints, which can be referred to Figure 1 , Figure 1 The flowchart of the keyword extraction method of the large model of the power grid domain based on knowledge enhancement and domain knowledge constraint in the embodiment of the present invention is as follows:
[0045] Step 120: Obtain a supervisory data set related to the power grid field.
[0046] In an embodiment of the present invention, a keyword extraction method for a large model in the power grid domain based on knowledge enhancement and domain knowledge constraints can be implemented by a related device, which can be various types of terminals, such as computers, smart phones, tablet computers, wearable devices, personal digital assistants (English: Personal Digital Assistant, abbreviation: PDA), mobile Internet devices (English: Mobile Internet Device, abbreviation: MID) and other terminals that can perform text processing. In actual applications, a device for implementing the above method is set based on actual needs, which is not limited here.
[0047] In an embodiment of the present invention, the supervision data set related to the power grid field mainly covers data from multiple links such as power grid planning, construction, operation, maintenance, and power market transactions. These supervision data sets are of great significance for ensuring the safe and stable operation of the power grid, maintaining the order of the power market, and promoting the high-quality development of the power industry. Among them, the supervision data set is a data set in machine learning. In supervised learning, the model learns how to determine the output through the supervision data set. Each sample in the supervision data set contains one or more input data and output data corresponding to the corresponding input data.
[0048] Source data related to the power grid field can be obtained from literature, reports, technical documents and other materials publicly available on professional websites, platforms and official websites, so as to generate a supervision data set based on the obtained source data. When obtaining the supervision data set, the data can be screened to ensure the quality of the supervision data set and improve the effectiveness and availability of the supervision data set.
[0049] Step 140: Based on knowledge enhancement and domain knowledge constraints, the initial large model for extracting keywords in the power grid domain is trained using a supervised data set to obtain a trained large model.
[0050] Among them, knowledge enhancement refers to the integration of external knowledge into machine learning models to improve the performance and interpretability of the models. By combining structured knowledge with machine learning models, knowledge enhancement can not only improve the prediction performance of the models, but also enhance the interpretability and generalization capabilities of the models. Domain knowledge constraints refer to the integration of scientific domain knowledge into machine learning models. Domain knowledge has many forms, such as the relationship between instances or classes can be expressed in the form of rule constraints. By using domain knowledge constraints in the power grid field, the application effect of large models in the power grid field can be effectively improved.
[0051] Reinforcement Learning from Human Feedback (RLHF) is a training technology that combines the reinforcement learning algorithm in machine learning with human subjective judgment. Human feedback is integrated into the reinforcement learning process, and the output of the language model is optimized by building a reward model. Reinforcement learning with human feedback allows the model to better understand and meet human needs and generate content that is more in line with actual application scenarios.
[0052] A large model is a model with a large number of parameters in the field of machine learning, where the number of parameters is usually in the billions to hundreds of billions. In the field of natural language processing (NLP), the introduction of large models (such as ChatGPT, GPT-4) has changed the face of natural language processing. By processing large-scale text data, rich language representations can be learned, enabling large models to handle various natural language tasks.
[0053] The embodiment of the present invention trains the big model based on knowledge enhancement and domain knowledge constraints, utilizes the excellent semantic understanding ability of the big model, and trains the initial big model through a supervised data set related to the power grid field, so that the trained big model can complete the keyword extraction task for the power grid field, that is, the trained big model can effectively cope with the complex unstructured text data in the power grid field, significantly improve the accuracy and efficiency of keyword extraction, and save human resources and computing resources, overcome the challenges of traditional models in the power field. Scarce data and high professionalism, and provide a more accurate keyword extraction solution.
[0054] The large model obtained by training based on knowledge enhancement and domain knowledge constraints can enhance the accuracy and robustness of the large model in actual application scenarios.
[0055] Step 160: Input the target data of keywords to be extracted into the large model to extract keywords in the field of power grid, and obtain keywords related to the field of power grid contained in the target data output by the large model.
[0056] Specifically, the target data is data from which keywords are desired to be obtained. After the large model is trained, the target data is input into the large model, and keywords in the target data are extracted and output based on the large model.
[0057] In the embodiment of the present invention, the initial large model is trained based on knowledge enhancement and domain knowledge constraints to enhance the accuracy and robustness of the large model in actual application scenarios, and keywords in the target data are extracted based on the large model to reduce the burden of manually extracting keywords from the data and improve the efficiency of keyword extraction, which is beneficial to tasks that require rapid decision-making and response in the power grid field.
[0058] In one embodiment of the present invention, step 120, obtaining a supervisory data set related to the power grid field, includes:
[0059] Step 210, collecting source data related to the power grid field, the source data at least includes one or more of equipment data, equipment operation data, environmental data and historical fault data in the power grid field.
[0060] In an embodiment of the present invention, source data includes multiple data types, such as equipment data, equipment operation data, environmental data, and historical fault data in the field of power grids. Equipment data can be equipment name, model, parameters, etc.; equipment operation data can be sensor data, detection data, equipment operation log and maintenance records, etc.; environmental data can be climate, geology, biology, soil and water quality, etc.; historical fault data can be data on historical fires, component anomalies, etc. These data sources are rich and diverse, covering all aspects of the power grid system, providing a solid data foundation for large-scale keyword extraction, and through comprehensive data collection, the generalization ability and robustness of the trained large model in different scenarios can be ensured.
[0061] It is understandable that one or more data types can be selected as source data. The more the amount and types of source data collected, the more keywords the trained large model can recognize, and the more accurate the output results will be.
[0062] Step 220, process the source data to obtain a supervision data set related to the power grid field, and the supervision data set is written by a natural language template.
[0063] Due to the diverse forms of the collected source data, it is difficult to analyze the source data and obtain the key information in the source data. Therefore, after collecting the source data, the source data needs to be processed so that the processed source data is in the same reference dimension, which is convenient for analyzing the processed source data. Finally, the processed source data is used to generate a supervised data set using natural language templates.
[0064] The natural language template includes input data, prompt template and output data. The processed source data is sorted through the natural language template to generate a large amount of supervision data. The collection of a large amount of supervision data is the supervision data set. That is, the processed source data is combined with the prompt template to construct a supervision data set. Each supervision data should include input data, prompt template and corresponding keyword annotation results. For example, the input data can be a description of power grid maintenance, the prompt template can be "extract keywords from the text", and the annotation result is the keywords extracted from the text.
[0065] In a feasible embodiment of the present invention, Step 220, processing the source data to obtain a supervision data set related to the power grid field, including:
[0066] Step 221, preprocess the source data to obtain candidate data, the preprocessing includes one or more of cleaning, normalization, and format conversion.
[0067] Since the source data may contain data errors, incomplete, inconsistent or duplicate information, in order to ensure the accuracy and consistency of the data and avoid errors in the analysis results caused by these factors, the source data needs to be pre-processed by cleaning, normalization and format conversion. It is understandable that in actual processing, one or more of cleaning, normalization and format conversion can be selected for processing. For example, cleaning can be performed first, then normalization, and finally format conversion. The source data can be cleaned based on processing methods such as missing value processing, outlier processing, duplicate data removal and data consistency processing to remove invalid data and noise data in the source data, and improve the accuracy, consistency and completeness of the cleaned source data, to ensure that the source data can truly reflect the actual situation and provide a reliable basis for subsequent data analysis and decision-making.
[0068] In addition, the source data can be normalized to convert numerical features of different magnitudes or distributions to the same magnitude or range, so that in subsequent data analysis, the data have the same scale or comparability to improve the performance, stability and interpretability of the model.
[0069] Considering that the source data is collected through different channels, its data format also varies. For example, the data format may be a rule describing the data stored in a file or record, a text format in character form, a compressed format in binary data form, etc. The embodiment of the present invention converts the format of the collected source data to obtain a standard format input into the large model, which is convenient for subsequent data analysis.
[0070] In a feasible implementation, the source data may be cleaned first, then the cleaned data may be normalized, and finally the format of the normalized data may be converted to obtain preprocessed candidate data.
[0071] Through the above preprocessing steps, the quality of the data can be greatly improved.
[0072] Step 222: Manually label the candidate data and construct a supervised data set, which includes the input content, prompt templates, and labeling results of keywords in the input content.
[0073] In the embodiment of the present invention, manual labeling can be used to label the content in the candidate data, and a high-quality supervised fine-tuning keyword extraction data set in the power grid field, that is, a supervised data set, can be constructed to enable the machine to better understand the data content.
[0074] In one embodiment of the present invention, the source data may be text data, and the text data is also the input data of the big model. The text may be feature-marked to obtain the labeled data of the input data, and the labeled data includes professional terms and key concepts in the field of power grids. Specifically, by adding specific semantic, composition, context, purpose, emotion and other data labels, the big model can deeply understand human language, and use the corresponding labeled results as keywords in the text data. Text annotation methods include many methods such as entity annotation, such as names of people, places, names of organizations, dates and times, proper nouns, etc.; relationship annotation, such as the relationship between components in the distribution network, etc.; event annotation, which may include extracting the subject, object, time, place, cause, result and other elements of the event; classification annotation, such as identifying the category of sentences in the text, etc.
[0075] While annotating the data, a prompt template can be generated. The prompt template contains some fixed text or instructions to guide the large model to understand and execute the framework or mode of a specific task, so that the large model can learn how to generate answers or results that meet the requirements based on the information in the prompt template. In an embodiment of the present invention, the prompt template can guide the large model to generate corresponding keywords based on the input content, so that the large model can understand and extract keywords more accurately, significantly improving the performance of the large model in the keyword extraction task.
[0076] In order to enable the trained large model to generate keywords in combination with the sequence position of keywords, a keyword annotation mark method can be set in the prompt module to prompt the location of keywords. For example, the above prompt template can refer to Figure 2 In the content, you can use " <key> "and"< / key> " to wrap the generated keywords, so that the big model can better pay attention to the location information of the keywords, among which, <key> In front of the keyword,< / key> Located after the keyword.
[0077] like Figure 2As shown in the example, the prompt template first defines the task, which is defined as: "I am an excellent power grid expert. The task is to mark the power grid keywords in the given sentence. The following is an example: ", and the few sample examples can be: the input is "the transformer of the power station failed during the maintenance process, affecting the stable operation of the power grid", and the output is "the power station's <key> transformer< / key> exist <key> Maintenance process< / key> Appeared in <key> Fault< / key> , affecting the stable operation of the power grid". Among them, input refers to the input to the large model, and output refers to the output of the large model. It can be seen from the prompt template that through " <key> "and"< / key> " wraps the keyword, so that the location of the keyword can be quickly determined. In addition, the prompt template can also display input examples, that is, the content in the actual use process. For example, the input of the input example is "Several circuit breakers were added in this line upgrade to improve power supply reliability", and the output is: "This time <key> Line upgrade< / key> middle <key> Added< / key> More <key> breaker< / key> To improve power supply reliability.”
[0078] After the supervised data set is generated, the initial large model for keyword extraction in the power grid field can be trained using the supervised data set based on knowledge enhancement and domain knowledge constraints to obtain the trained large model, which specifically includes:
[0079] Step 410, obtain a general data set for pre-training the initial large model, and obtain a preset specific vocabulary in the power grid field, add the specific vocabulary to the general data set to obtain a pre-trained data set, and the specific vocabulary contains specific technical terms related to the power grid field.
[0080] Step 420: Pre-train the initial large model using the pre-training data set to obtain a pre-trained initial large model.
[0081] Step 430, using the supervised data set to fine-tune the pre-trained initial large model to obtain a fine-tuned initial large model.
[0082] Step 440, introduce human feedback reinforcement learning and power grid domain knowledge constraint method, adjust and optimize the fine-tuned initial large model through reward and penalty mechanism to obtain a large model.
[0083] In the embodiment of the present invention, the initial large model needs to be pre-trained first, wherein pre-training refers to the initial stage of training the model using a large amount of unlabeled data in the field of machine learning and deep learning, especially in natural language processing. The main purpose of pre-training is to allow the large model to learn common features and knowledge so that it can learn and adapt to the supervised data set in the field of power grid faster in subsequent tasks. In order to implement the pre-training process, a general data set for pre-training the initial large model can be obtained, and the data in the general data set can be text, image, audio, etc.
[0084] In addition, a preset specific vocabulary in the power grid field will also be obtained. The specific vocabulary contains specific technical terms related to the power grid field. For example, negative voltage curve, transformer, voltage stability, distribution network, etc. are all specific technical terms related to the power grid field. The specific technical terms can be added to the above-mentioned general data set to obtain a pre-trained data set, and the pre-trained data set can be used to pre-train the initial large model to obtain a pre-trained large model.
[0085] In an embodiment of the present invention, since specific technical terms in the power grid field are lacking in the general data set of the large model, by adding specific technical terms in the power grid field to the above-mentioned general data set, the specific technical terms in the power grid field can be embedded in the pre-training process of the large model, so that the obtained pre-trained large model has a better understanding ability of the text in the power grid field, which is the knowledge enhancement in this application.
[0086] It is understandable that the self-supervised learning method is adopted in the pre-training stage of the above-mentioned initial large model.
[0087] After pre-training the initial large model using a pre-training data set containing a general data set and a specific vocabulary, the pre-trained initial large model is obtained, and the pre-trained initial large model will be further fine-tuned using a supervised data set to obtain a fine-tuned initial large model. The fine-tuning process is a supervised fine-tuning stage. By using the supervised data set in the power grid field to fine-tune the pre-trained initial large model, the trained large model can not only further adapt to the understanding of the specific attributes of the power grid field, but also enhance the performance of the large model in the keyword extraction task. And because each supervised data in the supervised data set has a corresponding prompt template, the fine-tuned large model can better clarify the task and accurately locate the position of the keywords in the text. It is understandable that it is very important to accurately locate the position of the keywords in the text, because in the power grid field, the contextual position of the keywords often determines their actual significance in the operating process and fault analysis. By using keyword annotation identifiers such as " <key> "and"< / key>", to emphasize the position of keywords, so that the big model is more accurate and robust when processing data in the power grid field, and can effectively support subsequent analysis and decision-making processes. By using keyword annotations, generation constraints are set for keywords to ensure that the generated text conforms to the expected format, and further constrain the trained big model to pay attention to the position of the keywords that need to be extracted.
[0088] In an embodiment of the present invention, the supervised data set is divided into a training set, a test set and a validation set according to a preset ratio. The training set is used to train the initial large model to fine-tune the initial large model, the validation set is used to tune the parameters of the large model, and the test set is used to evaluate the performance of the trained large model. The performance of the large model can be determined by a series of evaluation indicators, such as accuracy, precision, recall, F1 score and confusion matrix.
[0089] Through fine-tuning training, the initial large model can learn a more accurate keyword extraction method under the guidance of pre-labeled data, thereby improving its initial performance.
[0090] In an embodiment of the present invention, after fine-tuning the initial large model using a supervised data set, human feedback reinforcement learning and a power grid domain knowledge constraint method can also be introduced to adjust and optimize the fine-tuned initial large model through a reward and penalty mechanism to obtain a trained large model, wherein the power grid domain knowledge constraint method is combined with human feedback reinforcement learning, and human preferences are used as reward signals to guide the adjustment and optimization of the initial large model, thereby enhancing the large model's understanding and satisfaction of human intentions, and enabling the large model to further improve its accuracy and robustness in application scenarios in the power grid field.
[0091] In a feasible embodiment of the present invention, the above-mentioned method of introducing human feedback reinforcement learning and power grid domain knowledge constraint is used to adjust and optimize the fine-tuned initial large model through a reward and penalty mechanism to obtain a large model, including:
[0092] Step 421. Use the manually input keyword data set to build a reinforcement learning preference data set.
[0093] In an embodiment of the present invention, keyword data of keywords to be extracted are manually input, and the keyword data are input into a fine-tuned initial large model, the initial large model extracts keywords from the keyword data, and further constructs a reinforcement learning preference data set.
[0094] In a feasible implementation, it is necessary to manually score and sort the keyword results generated based on the keyword data set to construct a reinforcement learning preference data set. It can be understood that the higher the correlation between the generated keywords and the target data, the higher the score, and the more in line with the ideal effect.
[0095] In a feasible embodiment of the present invention, Step 421, using the manually input keyword data set to construct a reinforcement learning preference data set, includes:
[0096] Step 4211: If manually inputted i-th keyword data is detected, the i-th keyword data is inputted into the fine-tuned initial large model to obtain the keyword corresponding to the i-th keyword data.
[0097] The keyword data set includes N keyword data, N represents the total number of keyword data in the keyword data set, and i and N are both positive integers.
[0098] In the embodiment of the present invention, a keyword data set may be manually obtained from a supervision data set or other channels, and the keyword data set is data from which keywords need to be extracted. After the i-th keyword data manually input is monitored, the i-th keyword data may be input into the initial large model for keyword extraction to obtain a keyword result.
[0099] Step 4212, construct a reinforcement learning preference data set based on the keywords corresponding to each keyword data in the manually input keyword data set.
[0100] In an embodiment of the present invention, the output sampling parameters of the large model are the key factors controlling the quality and diversity of keywords generated by the large model. By constructing an artificial reinforcement learning preference data set, the language understanding ability of the trained large model can be effectively enhanced, and the accuracy of its keyword extraction can be improved.
[0101] In an embodiment of the present invention, a reinforcement learning preference data set is constructed according to the keywords corresponding to each keyword data in the manually input keyword data set, including:
[0102] A. Output the keywords corresponding to each keyword data to the display screen so that the displayed keywords can be manually scored and sorted.
[0103] Specifically, the keywords corresponding to each keyword data are output to the display screen so that the displayed keywords can be scored and sorted manually. It is understood that after manual scoring, the system can automatically sort the keywords from high to low, or from low to high. Alternatively, the keyword data can be taken as a whole, and if there are multiple different keyword division methods, the scores can be manually scored for different keyword division methods.
[0104] B. Determine the reinforcement learning preference data set based on the results of manually scoring and sorting the keywords displayed on the display screen and the keyword data set. It can be understood that the reinforcement learning preference data set at least includes the keyword data and its corresponding scoring and sorting results.
[0105] By constructing a reinforcement learning preference dataset, human feedback reinforcement learning can be introduced so that the fine-tuned initial large model can be trained based on the reinforcement learning preference dataset. The large model trained based on the reinforcement learning preference dataset can better meet the actual needs and preferences of human users, as follows:
[0106] Step 422, based on the cosine similarity power grid domain knowledge constraint reward function and direct preference optimization DPO reinforcement learning algorithm, the initial large model is trained using the reinforcement learning preference data set to obtain the trained large model.
[0107] In the embodiment of the present application, the power grid domain knowledge constraint reward function of cosine similarity is as follows:
[0108]
[0109] Among them, R CTR (x i ,y i ) represents the power grid domain knowledge constraint reward function of cosine similarity, x i and i They respectively represent the i-th keyword data in the keyword dataset and the keywords output by the large model in the intensive training phase. This reward function can be used to increase the relevance of the keywords output by the large model to the keyword data, thereby enhancing the ability of the large model to generate keywords in the knowledge context of the power grid field, so as to further improve the accuracy of keyword extraction.
[0110] It should be noted that the above-mentioned reward function can be added to the loss function of the large model in the reinforcement training stage so that the reward function takes effect during the training process.
[0111] In the embodiment of the present invention, the power grid domain knowledge constraint reward function and the DPO (Decision Process Optimization) reinforcement learning algorithm are combined with the cosine similarity, and the reinforcement learning preference data set is used to continue training the initial large model. The reinforcement learning preference data set is input into the initial large model for reinforcement training. The trained large model can generate text that is more in line with human preferences and gradually optimize its keyword extraction ability. Based on the preset loss function in the DPO reinforcement learning algorithm, the possibility of human preference data is increased and the possibility of non-human preference data is reduced.
[0112] In one embodiment of the present invention, the method further includes:
[0113] Step 170: Save the trained large model as a file in a preset format to obtain a large model file.
[0114] Step 180: Use the Flask framework to load the large model file into the memory, and use the Flask framework to deploy the corresponding API interface for the large model file saved in the memory.
[0115] In one embodiment of the present invention, in order to avoid frequent model loading for each request and improve the running speed of the retrieval model, the trained large model is saved as a ".pth" file. The Flask framework is used to load the large model into the memory. By keeping the large model resident in the memory, the response time can be significantly reduced and the overall performance of the system can be improved.
[0116] The Flask framework is used to deploy the large model as an API interface to implement the multi-concurrent request function of the Web port. By defining and exposing the RESTful API, users can easily interact with the large model through HTTP requests to achieve automation and efficiency of keyword extraction services.
[0117] The large-scale model keyword extraction interface for the power grid field deployed on the server side is called on the Web side, and the actual data of the power grid field for the keywords to be extracted is input to obtain the keywords extracted by the large model, and the keyword results are displayed on the front-end interface. Through the intuitive front-end interface, users can easily view and use the keyword extraction results, improving the user experience and the practicality of the system.
[0118] The API interface deployment implemented by the embodiment of the present invention using the Flask framework ensures scalability and high concurrent processing capabilities in practical applications, and provides solid technical support for intelligent data processing and analysis in the power grid field.
[0119] In order to prove that the results of extracting keywords by the large model proposed in the present invention are more accurate, a set of self-constructed data sets is used to verify it. The self-constructed data sets are respectively input into other keyword extraction models and the large model of the present invention for accuracy evaluation. The accuracy of the keyword output results can be evaluated by the evaluation indicators P, R, and F1. It can be understood that the larger the value of the evaluation indicator, the higher its accuracy.
[0120] The experimental results can be specifically referred to Table 1, which is the experimental comparison results, among which TFIDF, TextRank, Maui, PROD, BLING-KPE and Span Extraction are all other keyword extraction models, and Our Method is the large model proposed by the present invention. According to the numerical values of the evaluation indicators P, R and F1, it can be seen that the evaluation index of the output result of the large model proposed by the present invention is greater than the evaluation index of other keyword extraction models, that is, the keyword extraction effect of the large model proposed by the present invention is better than that of other models, which effectively improves the accuracy of the output result of the large model.
[0121] Table 1 Experimental comparison results
[0122]
[0123]
[0124] The present invention also proposes a keyword extraction device for a large model of a power grid domain based on knowledge enhancement and domain knowledge constraints, which can be referred to Figure 3 , Figure 3 The structure diagram of the keyword extraction device of the large model of the power grid domain based on knowledge enhancement and domain knowledge constraint in the embodiment of the present invention includes:
[0125] The data acquisition module 301 is used to obtain supervisory data sets related to the power grid field.
[0126] The model training module 302 is used to train the initial large model for keyword extraction in the power grid field using a supervised data set based on knowledge enhancement and domain knowledge constraints to obtain a trained large model.
[0127] The keyword extraction module 303 inputs the target data of keywords to be extracted into the large model to extract keywords in the power grid field, and obtains keywords related to the power grid field contained in the target data output by the large model.
[0128] The large model keyword extraction device in the power grid field based on knowledge enhancement and domain knowledge constraints in the embodiment of the present invention can effectively save human resources and computing resources and improve the efficiency of keyword extraction by using a large model to extract keywords in the power grid field. Moreover, by introducing human feedback reinforcement learning, the accuracy and efficiency of keyword extraction can be effectively improved.
[0129] Figure 4 FIG. 1 shows an internal structure diagram of a computer device in one embodiment of the present invention. The computer device may be a terminal or a system. Figure 4As shown, the computer device includes a processor, a memory and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor may implement each step in the above method embodiment. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor may implement each step in the above method embodiment. Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0130] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes each step in the above method embodiment.
[0131] In one embodiment, a computer-readable storage medium is proposed, which stores a computer program. When the computer program is executed by a processor, the processor executes each step in the above method embodiment. A person of ordinary skill in the art can understand that all or part of the processes in the above embodiment method can be completed by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium, and the program can include the processes of the embodiments of the above methods when executed. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0132] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0133] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A keyword extraction method based on knowledge enhancement and domain knowledge constraints, characterized by: The method comprises: Acquire supervisory datasets related to the power grid sector; Based on knowledge enhancement and domain knowledge constraints, the supervised dataset is used to train an initial large model for keyword extraction in the power grid domain to obtain a trained large model; Target data of keywords to be extracted are input into the large model to extract keywords in the field of power grid, and keywords related to the field of power grid contained in the target data output by the large model are obtained.
2. The method according to claim 1, characterized in that The acquisition of supervisory data sets related to the power grid field includes: Collecting source data related to the power grid field, wherein the source data at least includes one or more of equipment data, equipment operation data, environmental data, and historical fault data in the power grid field; The source data is processed to obtain a supervision data set related to the power grid field, where the supervision data set is written using a natural language template.
3. The method according to claim 1, characterized in that The source data is processed to obtain a supervisory data set related to the power grid field, including: Preprocessing the source data to obtain candidate data, wherein the preprocessing includes one or more of cleaning, normalization, and format conversion; The candidate data are annotated by manual annotation, and the supervision data set is constructed. The supervision data set includes input content, prompt templates, and annotation results of keywords in the input content.
4. The method according to claim 1, wherein Based on the knowledge enhancement and domain knowledge constraint, the supervised data set is used to train the initial large model for extracting keywords in the power grid field to obtain the trained large model, including: Obtaining a general data set for pre-training an initial large model and a preset specific vocabulary in the field of power grids, adding the specific vocabulary to the general data set to obtain a pre-training data set, wherein the specific vocabulary includes specific technical terms related to the field of power grids; Pre-training the initial large model using the pre-training data set to obtain a pre-trained initial large model; Fine-tuning the pre-trained initial large model using the supervised dataset to obtain a fine-tuned initial large model; Human feedback reinforcement learning and power grid domain knowledge constraint methods are introduced, and the fine-tuned initial large model is adjusted and optimized through a reward and penalty mechanism to obtain a large model.
5. The method according to claim 4, characterized in that The method of introducing human feedback reinforcement learning and power grid domain knowledge constraint is used to adjust and optimize the fine-tuned initial large model through a reward and penalty mechanism to obtain a large model, including: Utilize manually input keyword data sets to build reinforcement learning preference datasets; Based on the cosine similarity-based power grid domain knowledge constraint reward function and direct preference optimization DPO reinforcement learning algorithm, the initial large model is trained using the reinforcement learning preference data set to obtain a trained large model.
6. The method according to claim 5, characterized in that The method of constructing a reinforcement learning preference dataset using a manually input keyword data set includes: If manually inputted keyword data i is detected, the i-th keyword data is inputted into the fine-tuned initial large model to obtain the keyword corresponding to the i-th keyword data, wherein the keyword data set includes N keyword data, i and N are positive integers; A reinforcement learning preference dataset is constructed based on the keywords corresponding to each keyword data in the manually input keyword dataset.
7. The method according to claim 6, characterized in that The step of constructing a reinforcement learning preference dataset based on keywords corresponding to each keyword data in the manually input keyword dataset includes: Output the keywords corresponding to each keyword data to the display screen so that the displayed keywords can be manually scored and sorted; The reinforcement learning preference dataset is determined based on the results of manually scoring and sorting the keywords displayed on the display screen and the keyword dataset.
8. The method according to claim 1, characterized in that The method further comprises: Saving the large model obtained through training as a file in a preset format to obtain a large model file; The large model file is loaded into the memory using the Flask framework, and the corresponding API interface is deployed for the large model file saved in the memory using the Flask framework.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 8.
10. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 8.