Data knowledge extraction method, system, device and storage medium based on large language model
By combining a large language model with a secondary retrieval optimization algorithm and feature matrix processing, the problems of low efficiency and insufficient accuracy in existing technologies are solved, achieving efficient and accurate knowledge extraction and integration, and constructing an entity relationship graph.
Patent Information
- Application Number
- CN202411555650.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-11-04
AI Technical Summary
Existing knowledge extraction technologies based on large-scale language models are inefficient, consume a lot of computing resources, and lack accuracy when processing massive amounts of text data. They are unable to meet real-time requirements, and the generated information may be inaccurate, requiring manual verification.
By understanding the relationships between texts through a large language model, a secondary retrieval optimization algorithm is adopted, redundant features are removed by combining the feature correlation coefficient matrix, information is integrated using the fine-tuned model, evaluation criteria are defined and model parameters are adjusted, and knowledge source information is extracted using a secondary block iteration method.
It improves the efficiency and accuracy of knowledge extraction by constructing a knowledge graph to display entity relationships, eliminating duplicate information and handling ambiguity, thus achieving efficient and accurate knowledge extraction.
Smart Images

Figure CN119646134B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of data knowledge, and particularly relates to a data knowledge extraction method, system, device and storage medium based on a large language model. BACKGROUND
[0002] With the rapid development of the Internet, a large amount of text data such as user comments on social media, news reports, forum posts and blog articles continues to emerge. These data contain rich information and knowledge, and how to effectively extract valuable knowledge from them has become a key research direction. The extracted knowledge not only helps enterprises make accurate market decisions and product optimization, but also provides strong data support for academic research, thereby promoting the progress of science and technology.
[0003] Currently, large language models exhibit excellent text understanding and generation capabilities due to their large number of parameters, which makes it possible to use such models to extract key information. However, existing knowledge extraction techniques still face many challenges: on the one hand, processing massive amounts of text data requires a large amount of time and computing resources; on the other hand, when processing data in specific fields, the efficiency of existing methods is low, making it difficult to meet real-time requirements. In addition, due to the diversity and complexity of text data itself, existing techniques still have deficiencies in accuracy, and are prone to errors and omissions. In particular, although large-scale language models have strong understanding and generation capabilities, they can also generate inaccurate information, which requires human verification to ensure the authenticity of the information.
[0004] Therefore, it is crucial to develop a method based on large language models that can improve the efficiency and accuracy of knowledge extraction for improving the current data analysis process. SUMMARY
[0005] The main purpose of the present application is to overcome the shortcomings and deficiencies of the prior art, and to provide a data knowledge extraction method, system, device and storage medium based on a large language model. The present application considers the relationship between texts through a large language model understanding model, and realizes the complementation between knowledge sources through a secondary retrieval optimization algorithm, thereby improving the efficiency and accuracy of the knowledge extraction method.
[0006] In order to achieve the above purpose, the present application adopts the following technical solutions:
[0007] In a first aspect, the present application provides a data knowledge extraction method based on a large language model, comprising the following steps:
[0008] Obtaining original data, and preprocessing the obtained original data;
[0009] Features are extracted from the preprocessed raw data, corresponding task features are selected, and high correlation features are removed by calculating the correlation coefficient matrix between the features;
[0010] A large language model for the task is selected, and the large language model is fine-tuned on the labeled data set of the corresponding task based on the large language model capturing general language and knowledge;
[0011] Based on the large language model inference and prompt word engineering, the information of the knowledge source is extracted in a secondary block iteration manner, and the context understanding ability of the large language model after fine-tuning training is used to integrate the information extracted from different data sources;
[0012] Define evaluation criteria, analyze error cases of the large language model, identify improvement direction, and adjust the parameters of the large language model and the training data according to the evaluation results and error analysis.
[0013] As a preferred technical solution, the obtained raw data is preprocessed, specifically:
[0014] Delete irrelevant information in the raw data, fill in missing data, or delete records with many missing values, correct spelling errors, format errors, and inconsistent data; design personalized prompt word templates, standardize date, time, and currency data in different formats to a unified format through data processing by the large language model, unify text data to lowercase, remove special characters and punctuation, convert data to a data type suitable for model processing, perform word segmentation and part-of-speech tagging on text data, and use word embedding technology to convert structured and unstructured text into word vector representation.
[0015] As a preferred technical solution, features are extracted from the preprocessed raw data, corresponding task features are selected, and high correlation features are removed by calculating the correlation coefficient matrix between the features, specifically:
[0016] Convert text data in the raw data into a word frequency vector to measure the importance of words and reduce the weight of common words, convert text data into a high-dimensional vector using a pre-trained word vector model, calculate the mean, standard deviation, maximum value, and minimum value, aggregate features in a time window in time series data, calculate the correlation coefficient between the features and the target variable, select features with high correlation, remove high correlation features by calculating the correlation coefficient matrix between the features, and project data to a lower-dimensional space by linear transformation to retain key information and remove redundant features. The key information includes semantic information and word frequency information.
[0017] As a preferred technical solution, in time series data, features are aggregated in a time window, and the correlation coefficient between the features and the target variable is calculated, specifically:
[0018] The time series data is arranged in chronological order and contains feature data and target variables, the size of the time window is selected to aggregate the features, the statistical features in each time window are calculated, and the aggregated features are aligned with the target variables. Since the sequence data is not normally distributed, the Spearman correlation coefficient is selected as the sequence analysis model to calculate the correlation parameters between each aggregated feature and the target variable.
[0019] As a preferred technical solution, the large language model is fine-tuned on the labeled data set corresponding to the task, which includes the following steps:
[0020] According to the requirements of the specific task, the structure of the large language model is modified, the output layer is adjusted, and the auxiliary loss function of the specific task is added, specifically:
[0021] First, the large language model is supervised fine-tuned to enable the large language model to have initial data knowledge extraction capability; the supervised fine-tuning is performed by collecting a supervised data set containing input prompts and required outputs to fine-tune the large language model;
[0022] Second, train a reward model, which is the model after removing the last embedding layer of the large language model after supervised fine-tuning; the reward model takes prompts and responses as input and calculates scalar reward values as output. The training of the reward model is achieved by fitting the human tendency for different responses. The difference between the reward values of the two responses in each sample is used to calculate the tendency probability to fit the human label, and then the training of the reward model is completed. The loss function of the reward model aims to maximize the difference between the responses preferred by the user and the responses not preferred by the user;
[0023] Third, generate a strategy optimization PPO model, which guides the SFT model after supervised fine-tuning to continue training through the reward model. Specifically, first, the current strategy samples a response according to the input query; then, the reward model calculates the reward for the quality of the response and feeds back to the current strategy for updating; when the SFT model continues to train, a penalty term is added to the loss function to ensure that the output of the PPO model and the output of the SFT model are as close as possible, and a general large language model is added to the training target to improve performance;
[0024] According to the preset fine-tuning strategy, some pre-trained model parameters are frozen to retain the learning of the large language model in general language and knowledge, and the large language model is fine-tuned and trained using the labeled data set. The model parameters are updated through the backpropagation algorithm.
[0025] As a preferred technical solution, the context understanding ability of the large language model trained by fine-tuning is used to integrate information extracted from different data sources, specifically:
[0026] In combination with information from different data sources, the data source information is divided into blocks, vectors are generated based on fine-tuned Chinese word embedding models, the similarity between each block of information is calculated based on the prompt words and the large language model, and the large language model itself generates the corresponding input question of the data source with high similarity, and the input question is re-searched through the large language model to retrieve different information sources. Again, the information source content is divided into blocks and word embedding is performed, and the block size in the second retrieval is twice that of the first time. The data information with high relevance after retrieval is considered in terms of text relationship through context understanding, the extracted entities and relationships are integrated into a knowledge graph, the relationship and connection between entities are displayed, repeated information is eliminated, and ambiguous information is processed based on the content similarity size after the retrieval result.
[0027] As a preferred technical solution, the error case of the analysis model is identified to improve the direction, specifically:
[0028] The trained model is evaluated using a validation set or test set to calculate the performance of the large language model on various evaluation indicators. For the samples predicted incorrectly by the large language model on the validation set or test set, the large language model performs self-error case analysis to identify patterns or characteristics that the model is prone to errors. Check if the model is missing key features, if more feature engineering is needed, check if the data set has class imbalance or data bias, use fusion retrieval enhancement technology or adjust class weights, adjust the training data according to the error case analysis results, increase or decrease the number of samples of certain classes, retrain the model using the adjusted model parameters and training data, and evaluate the adjusted model using the validation set or test set to check if the model's performance on the evaluation indicators has improved.
[0029] In a second aspect, the present application provides a data knowledge extraction system based on a large language model, which is applied to the data knowledge extraction method based on a large language model, and includes a data acquisition module, a feature extraction module, a model fine-tuning module, an information integration module, and a result evaluation module.
[0030] The data acquisition module is configured to acquire raw data and pre-process the acquired raw data.
[0031] The feature extraction module is configured to extract features from the pre-processed raw data, select corresponding task features, and remove highly correlated features by calculating a correlation coefficient matrix between the features.
[0032] The model fine-tuning module is configured to select a large language model for a task, fine-tune the large language model based on the large language model to capture general language and knowledge, and fine-tune the large language model on the labeled data set of the corresponding task.
[0033] The information integration module is configured to extract information from knowledge sources based on a large language model inference and prompt word engineering, and to integrate the information extracted from different data sources by using the context understanding capability of the large language model after fine-tuning training.
[0034] The result evaluation module is configured to define evaluation criteria, analyze error cases of the large language model, identify improvement directions, and adjust parameters of the large language model and training data according to the evaluation results and error analysis.
[0035] In a third aspect, the present application provides an electronic device, which comprises:
[0036] at least one processor; and,
[0037] a memory in communication with the at least one processor; wherein,
[0038] The memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to execute the large language model-based data knowledge extraction method.
[0039] In a fourth aspect, the present application provides a computer-readable storage medium storing a program, and the program is executed by a processor to implement the large language model-based data knowledge extraction method.
[0040] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0041] The data knowledge extraction method of the present application removes highly correlated features by calculating the correlation coefficient matrix between features, projects data to a lower dimensional space through linear transformation, retains main information, considers the relationship between texts through a large language understanding model, realizes the complementation between knowledge sources through a secondary search optimization algorithm, and realizes the depth merging of knowledge source information by changing the block size while retaining semantics, and realizes the extraction of entities and relationships into a knowledge graph by means of the powerful language understanding capability of the large model, displays the relationship and connection between entities, eliminates redundant information, and processes ambiguous information, thereby improving the efficiency and accuracy of the knowledge extraction method. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0043] Figure 1 This is a flowchart of a data knowledge extraction method based on a large language model, as described in an embodiment of the present invention.
[0044] Figure 2 This is a flowchart illustrating the reward model training method based on user backtesting data, as described in an embodiment of the present invention.
[0045] Figure 3 This is a block diagram of the data knowledge extraction system based on a large language model according to an embodiment of the present invention;
[0046] Figure 4 This is a structural diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0047] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.
[0048] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0049] like Figure 1 As shown in the figure, this embodiment provides a data knowledge extraction method based on a large language model, which includes the following steps:
[0050] S1. Collect raw data from multiple sources and preprocess the collected raw data;
[0051] Furthermore, in step S1, the collected raw data is preprocessed, specifically as follows:
[0052] Delete irrelevant information in raw data, fill in missing data, use mean, median or interpolation method, or delete records with more missing values, correct spelling errors, format errors and inconsistent data; design personalized prompt templates, process data through large language models to standardize data in different formats such as date, time and currency into a unified format, unify text data to lowercase, remove special characters and punctuation, convert data to a data type suitable for model processing, tokenize and part-of-speech tag text data, and use word embedding technology to convert structured and unstructured text into word vector representation.
[0053] S2, extract features from preprocessed raw data, select corresponding task features, and remove highly correlated features by calculating the correlation coefficient matrix between features.
[0054] Further, step S2 is specifically:
[0055] Convert text data to word frequency vectors to measure the importance of words and reduce the weight of common words, use pre-trained word vector models to convert text to high-dimensional vectors, calculate mean, standard deviation, maximum and minimum, aggregate features by time window in time series data, calculate the correlation coefficient between features and target variables, select highly correlated features, remove highly correlated features by calculating the correlation coefficient matrix between features, and project data to a lower dimensional space by linear transformation to retain key information and remove redundant features.
[0056] Further, in time series data, aggregate features by time window, calculate the correlation coefficient between features and target variables, specifically: arrange time series data in chronological order and include feature data and target variables, select time window size to aggregate features, calculate statistical features within each time window, align aggregated features with target variables, and calculate correlation parameters between each aggregated feature and target variables.
[0057] S3, select a large language model for the task, and fine-tune the large language model based on the large language model to capture general language and knowledge on the labeled data set corresponding to the task.
[0058] Step S3 is specifically:
[0059] S31, modify the structure of the large language model according to the requirements of the specific task, adjust the output layer and add auxiliary loss functions for specific tasks, specifically including the following steps:
[0060] The first step is supervised fine-tuning. In order to make the language model have the ability to extract data knowledge, it is usually necessary to collect a supervised data set containing input prompts (instructions) and required outputs to fine-tune the language model. These prompts and outputs can be written by human annotators for certain specific data knowledge extraction tasks while ensuring task diversity. Here we use historical labeled data. Supervised fine-tuning can utilize the parameters and structure of the pre-trained model, avoiding training the model from scratch, thereby speeding up the model training process and improving the model's performance on the target task. Generally speaking, only part of the layers of the pre-trained model will be fine-tuned. During the fine-tuning process, the model is optimized through the backpropagation algorithm, so that the model performs better on the task.
[0061] The second step is to train a reward model. This stage aims to obtain a reward model that fits human preference data knowledge extraction. The structure of the reward model is a model obtained by removing the last embedding layer of the model trained by supervised fine-tuning. The reward model takes prompts and responses as input and calculates a scalar reward value as output. The training process of the reward model is achieved by fitting human tendencies for different responses. Specifically, first, based on the model fine-tuned on human-written data, K different responses (4≤K≤9) are sampled for the same prompt. Then, the responses are combined two by two to form a reward model training sample, and the human gives a tendency label, that is, for each prompt, a total of responses are displayed, and then the user selects the output with better effect. During training, each prompt's response pair is taken as a batch. This batch-by-prompt training method is less prone to overfitting than the traditional sample-by-sample training method, because each prompt is input into the model only once. Finally, the reward model fits the human label by calculating the difference between the reward values of the two responses in each sample, and then completes the training of the reward model. The loss function of the reward model is shown in the following formula. The goal of this loss function is to maximize the difference between the response that the user prefers and the response that the user does not prefer.
[0062]
[0063] where r θ (x,y w ) is the reward value of prompt x and response y under the reward model with parameters θ, y w is the response result that the labeler prefers, and y l is the response result that the labeler does not prefer. D is the entire training data set.
[0064] The third step is to generate the policy optimization PPO. It guides the continued training of the SFT model through the reward model obtained in the second step. Given the learned data knowledge extraction reward model, the parameters of the pre-trained model will be considered as a strategy, and the training will be carried out in the framework of reinforcement learning. First, the current strategy samples the reply according to the input query. Then, the reward model calculates the reward for the quality of the reply, which is fed back to the current strategy for updating. In this step, the training target aims to solve the following two problems. The first problem is that as the model is updated, the data generated by the reinforcement learning model and the data used to train the reward model will become more different. A KL penalty term is added to the loss function to ensure that the output of the PPO model and the output of the SFT are not too different. The second problem is that if only the PPO model is trained, the performance of the model on general NLP tasks will be greatly reduced. A general language model objective can be added to the training target to solve this problem. In summary, the following objective function is maximized in the training of PPO.
[0065]
[0066] wherein, is the learned RL policy, π SFT is the SFT model, D pretain is the pre-training distribution, and β is the KL penalty term coefficient, and γ controls the KL penalty term and the pre-training gradient.
[0067] Further, after the data knowledge extraction large model has undergone the two fine-tuning steps of knowledge correction and variance elimination, it has basically met the requirements of humans for the model, and can output real information and rich opinions. However, the data knowledge extraction large model is designed to solve human problems in the data knowledge extraction vertical field, and users prefer to solve their problems in as few dialogue rounds as possible. Obviously, too many dialogue rounds are not what users want to see, so this phenomenon is one of the core problems that need to be solved in the data knowledge extraction vertical field large model. However, this low dialogue efficiency problem occurs relatively infrequently and is difficult to judge qualitatively, so if the current reinforcement learning method based on human feedback is used for targeted fine-tuning, the cost of manual annotation is very high, and it is difficult to form a good evaluation rule for human annotators to refer to.
[0068] Therefore, we make corresponding modifications to the traditional reward model training stage, and propose a reward model training method based on user backtest data. By setting a satisfaction survey after the user uses the model, we aim to use user evaluation data for reinforcement learning based on human feedback to optimize the dialogue efficiency of vertical domain large models. Moreover, this method can continuously optimize and improve the model according to other requirements of the later model, and complete different requirements. Figure 2 As shown in the figure, after the user and the vertical domain large model interact, the evaluation questions are designed manually, and the ability of the model is evaluated. In this patent, two evaluation questions are proposed: 1. Please score the accuracy of the model's answer to the question in this use process; 2. Please score the number of dialogue rounds spent by the model to solve the problem in this use process. These two questions describe the dialogue efficiency of the model from two angles. After the user-generated interaction data and evaluation data reach a certain scale, the data set is extracted, and the general large language model is used to merge the questions in the data set. The questions and the answers of the vertical domain large model are merged to obtain a human feedback data set containing two evaluation indicators. Obviously, it is difficult to train two evaluation indicators at the same time, so this study proposes a method of dynamically weighting and aggregating two evaluation indicators to form a human feedback data set that ranks answers according to scores.
[0069] Taking the two evaluation questions mentioned in this embodiment as an example, the comprehensive evaluation score of a certain answer is defined as follows:
[0070] Score[X]=α1β1Score1[X]+α2β2Score2[X]
[0071] Where α1 and α2 represent the initial weights of the two scores, reflecting the importance of the two evaluations measured by the researchers. If the importance is the same, then both are 0.5. β1 and β2 represent the dynamic weights of the two scores, which reflect the relative saturation degree between different scores. For example, when the average satisfaction of score 1 is very high and the average satisfaction of score 2 is relatively low, the weight of β1 should be much lower than β2, so that the model focuses more on learning and improving the unsatisfactory situation caused by score 2. Therefore, the dynamic weight is defined as follows:
[0072] β1=S2 / (S1+S2)
[0073] β2=S1 / (S1+S2)
[0074] In the formula, S1 represents the average score of all answers at score 1 under the question. After obtaining the comprehensive score of each answer, all answers under each question can be sorted to obtain a standard human feedback data set for training the reward model. The reward model is a model obtained by removing the last embedding layer in the network structure of the vertical field large model, the input is the question and the answer, and the output is a scalar reward value. During training, the answers corresponding to each question are taken as a batch, and this method of dividing the batch according to the question is less likely to cause overfitting than the traditional method of randomly dividing the batch, because each question data is input into the model only once. The loss learned by the model is as follows
[0075]
[0076] The objective of this loss function is to maximize the difference between the answers that the annotators like and the answers that the annotators do not like. Where r θ (x,y w ) represents the question x and the answer y w under the reward model with parameters θ. y w is the answer with a higher score, and r θ is the answer with a lower score. After training the reward model, the model can be fine-tuned through reinforcement learning using question and answer data to improve the dialogue efficiency of the vertical field large model. It is worth mentioning that the data used for reinforcement learning fine-tuning can be collected from the process of users using the product, achieving training while using, and gradually improving the performance of the model.
[0077] S32, according to the preset fine-tuning strategy, select to freeze part of the pre-training model parameters, retain the learning of the large language model on general language and knowledge, use the annotation data set to fine-tune and train the large language model, and update the model parameters through the back propagation algorithm.
[0078] S4, based on large language model inference and prompt word engineering, a twice block iteration method is used to extract knowledge source information, and the context understanding ability of the large language model after fine-tuning training is used to integrate the information extracted from different data sources.
[0079] Further, the information extracted from different data sources is integrated by using the context understanding ability of the model, specifically: combining information from different data sources, dividing the data source information into blocks, generating vectors based on the fine-tuned Chinese word embedding model, calculating the similarity between each block of information based on the prompt and the large language model, and generating the corresponding input question for retrieving the data source with high comprehensive similarity by the large language model itself, and then re-retrieving different information sources through the large language model, and again dividing and embedding the information source content, the block size in the second retrieval is twice that of the first time, and the data information with high relevance after retrieval is considered in the context understanding to consider the relationship between texts, the extracted entities and relationships are integrated into a knowledge graph, the relationship and connection between entities are displayed, repeated information is eliminated, and ambiguous information is processed based on the content similarity size after retrieval.
[0080] S5, define evaluation criteria, analyze error cases of the large language model, identify improvement direction, adjust model parameters and training data according to evaluation results and error analysis.
[0081] Further, step S5 specifically comprises:
[0082] The trained model is evaluated using the validation set or test set, the performance of the model on each evaluation index is calculated, error case analysis is performed on the samples predicted incorrectly by the model on the validation set or test set, the patterns or characteristics prone to errors of the model are identified, whether the model lacks key features or needs more feature engineering is checked, whether the data set has class imbalance or data bias is checked, data enhancement techniques or class weight adjustment are used, the training data is adjusted according to the error case analysis results, the number of samples of certain classes is increased or decreased, the model is retrained using the adjusted model parameters and training data, and the adjusted model is evaluated again using the validation set or test set to check whether the performance of the model on the evaluation index has improved.
[0083] The data knowledge extraction method of the present application screens out a low-redundancy feature set by constructing a correlation coefficient matrix between features; then uses linear transformation technology to map the data to a low-dimensional space to preserve key information; uses a large language model to analyze the relevance between texts; implements a secondary retrieval optimization algorithm to integrate the advantages of different knowledge sources; and by dynamically adjusting the block size, while maintaining the integrity of the semantics, the powerful understanding ability of the large language model is used to perform deep information integration. Finally, the extracted entities and their relationships are constructed into a knowledge graph to show the connection between entities, while eliminating duplicates and solving ambiguous information, significantly improving the efficiency and accuracy of the knowledge extraction process.
[0084] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a combination of a series of actions, but those skilled in the art should know that the present application is not limited by the order of the described actions, because according to the present application, certain steps can be performed in other order or simultaneously.
[0085] Based on the same idea as the data knowledge extraction method based on the large language model in the above embodiment, the present application also provides a data knowledge extraction system based on the large language model, which can be used to execute the above-mentioned data knowledge extraction method based on the large language model. For the sake of illustration, in the structural diagram of the embodiment of the data knowledge extraction system based on the large language model, only the parts related to the embodiment of the present application are shown, and those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and can include more or fewer components than the illustrated, or combine certain components, or different component arrangements.
[0086] Please refer to Figure 3 In another embodiment of the present application, a data knowledge extraction system based on a large language model 100 is provided, which comprises a data acquisition module 101, a feature extraction module 102, a model fine-tuning module 103, an information integration module 104 and a result evaluation module 105;
[0087] The data acquisition module 101 is configured to acquire raw data and pre-process the acquired raw data;
[0088] The feature extraction module 102 is configured to extract features from the pre-processed raw data, select corresponding task features, and remove highly correlated features by calculating a correlation coefficient matrix between the features;
[0089] The model fine-tuning module 103 is configured to select a large language model for a task, capture general language and knowledge based on the large language model, and fine-tune the large language model on a labeled data set corresponding to the task;
[0090] The information integration module 104 is configured to extract knowledge source information in a secondary block iteration manner based on large language model reasoning and prompt word engineering, and integrate information extracted from different data sources by using the context understanding ability of the large language model after fine-tuning training;
[0091] The result evaluation module 105 is configured to define evaluation criteria, analyze error cases of the large language model, identify improvement directions, and adjust parameters of the large language model and training data according to the evaluation results and error analysis.
[0092] It should be noted that the data knowledge extraction system based on the large language model of the present application corresponds to the data knowledge extraction method based on the large language model of the present application, and the technical features and advantages described in the above embodiment of the data knowledge extraction method based on the large language model are applicable to the embodiment of the data knowledge extraction based on the large language model, and the specific content can be referred to the description in the method embodiment of the present application. Here, no further description is given, and this is hereby declared.
[0093] In addition, in the implementation of the data knowledge extraction system based on the large language model of the above embodiment, the logical division of each program module is only illustrative, and in actual application, the above function allocation can be completed by different program modules according to needs, for example, for the configuration requirements of the corresponding hardware or the convenience of software implementation. The internal structure of the data knowledge extraction system based on the large language model is divided into different program modules to complete all or part of the functions described above.
[0094] Please refer to Figure 4 In one embodiment, an electronic device implementing a data knowledge extraction method based on a large language model is provided. The electronic device 200 can include a first processor 201, a first memory 202, and a bus, and can further include a computer program stored in the first memory 202 and executable on the first processor 201, such as a data knowledge extraction program based on a large language model 203.
[0095] The first memory 202 includes at least one type of readable storage medium, including flash memory, mobile hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The first memory 202 can be an internal storage unit of the electronic device 200 in some embodiments, such as the mobile hard disk of the electronic device 200. The first memory 202 can also be an external storage device of the electronic device 200 in other embodiments, such as the plug-in mobile hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on the electronic device 200. Further, the first memory 202 can include both the internal storage unit and the external storage device of the electronic device 200. The first memory 202 can be used not only to store application software and various data installed on the electronic device 200, such as the code of the data knowledge extraction program based on the large language model 203, but also to temporarily store data that has been output or will be output.
[0096] The first processor 201 may, in some embodiments, be composed of integrated circuits, for example, may be composed of a single packaged integrated circuit, or may be composed of multiple packaged integrated circuits of the same function or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, combinations of various control chips, etc. The first processor 201 is the control unit of the electronic device, connects various components of the entire electronic device through various interfaces and lines, and executes various functions and processes data of the electronic device 200 by running or executing programs or modules stored in the first memory 202 and calling data stored in the first memory 202.
[0097] Figure 4 Only the electronic device with components is shown, and those skilled in the art can understand that, Figure 4 The structure shown does not constitute a limitation on the electronic device 200, and can include fewer or more components than shown, or combine certain components, or different component arrangements.
[0098] The data knowledge extraction program 203 based on a large language model stored in the first memory 202 in the electronic device 200 is a combination of multiple instructions, which, when running in the first processor 201, can achieve:
[0099] Obtaining raw data, preprocessing the obtained raw data;
[0100] Extracting features from the preprocessed raw data, selecting corresponding task features, and removing highly correlated features by calculating the correlation coefficient matrix between the features;
[0101] Selecting a large language model for the task, capturing general language and knowledge based on the large language model, and fine-tuning the large language model on the corresponding task annotation data set;
[0102] Based on the large language model inference and prompt word engineering, the information of the knowledge source is extracted by using the method of twice block iteration, and the context understanding ability of the large language model after fine-tuning training is used to integrate the information extracted from different data sources;
[0103] Defining evaluation criteria, analyzing error cases of the large language model, identifying improvement directions, and adjusting the parameters of the large language model and the training data according to the evaluation results and error analysis.
[0104] Further, the modules / units integrated in the electronic device 200, if realized in the form of software function units and sold or used as independent products, can be stored in a nonvolatile computer-readable storage medium. The computer-readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0105] Those of ordinary skill in the related art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments of each method. In the embodiments provided in the present application, any reference to memory, storage, database or other medium can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), 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.
[0106] The technical features of the above embodiments can be combined in any way. To make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combinations of the technical features do not contradict, they should be considered within the scope of the present application.
[0107] The above embodiments are the preferred embodiments of the present application, but the embodiments of the present application are not limited to the above embodiments, and any changes, modifications, substitutions, combinations, simplifications made without departing from the spirit and principles of the present application should be considered as equivalent replacement modes and should be included in the protection scope of the present application.
Claims
1. A method for extracting data knowledge based on a large language model, characterized in that, The method comprises the following steps: Obtaining raw data, preprocessing the obtained raw data; Extracting features from the preprocessed raw data, selecting corresponding task features, and removing highly correlated features by calculating the correlation coefficient matrix between the features; Select a large language model for the task, capture general language and knowledge based on the large language model, and fine-tune the large language model on the labeled data set of the corresponding task; the fine-tuning of the large language model on the labeled data set of the corresponding task comprises the following steps: According to the requirements of the specific task, modify the structure of the large language model, adjust the output layer, and add auxiliary loss functions for specific tasks, specifically: First, fine-tune the large language model to enable the large language model to have initial data knowledge extraction capability; the supervised fine-tuning is performed by collecting a supervised data set containing input prompts and required outputs to fine-tune the large language model; Second, train a reward model, which is a model obtained by removing the last embedding layer of the large language model after supervised fine-tuning; the reward model takes prompts and responses as input and calculates scalar reward values as output; the reward model is trained by fitting the human tendency for different responses; the difference between the reward values of the two responses in each sample is used to calculate the tendency probability to fit the human label, and then the reward model is trained; the loss function of the reward model aims to maximize the difference between the responses preferred by the user and the responses not preferred by the user; Third, generate a strategy optimization PPO model, which guides the SFT model after supervised fine-tuning to continue training through the reward model, specifically: first, the current strategy samples a response according to the input query; Then, the reward model calculates the reward for the quality of the response and feeds back to the current strategy for updating; when the SFT model continues to train, a penalty term is added to the loss function to ensure that the output difference between the PPO model and the SFT model is as small as possible, and a general large language model target is added to the training target to improve performance; According to the preset fine-tuning strategy, select part of the pre-trained model parameters to be frozen, retain the learning of the large language model on general language and knowledge, fine-tune and train the large language model using the labeled data set, and update the model parameters through the back propagation algorithm; Based on the inference and prompt word engineering of the large language model, the information of the knowledge source is extracted in a secondary block iteration manner, and the information extracted from different data sources is integrated by using the context understanding ability of the large language model after fine-tuning training; Specifically: In combination with information from different data sources, the data source information is divided into blocks, a vector is generated based on a fine-tuned Chinese word embedding model, the similarity between each block of information is calculated based on the prompt word and the large language model, and the large language model itself generates an input question for retrieving the data source with high similarity, and the input question is re-retrieved by the large language model to different information sources. Again, the information source content is divided into blocks and word embedding is performed, and the size of the block in the second retrieval is twice that of the first time. The data information with high relevance after retrieval is considered in the context of the relationship between the text, the extracted entities and relationships are integrated into a knowledge graph, the relationship and connection between entities are displayed, and the redundant information is eliminated. Based on the content similarity size after the retrieval result, the ambiguous information is processed; Define evaluation criteria, analyze error cases of the large language model, identify improvement direction, adjust the parameters and training data of the large language model according to the evaluation results and error analysis. 2.The method of claim 1, wherein, The obtained original data is preprocessed, specifically: Delete irrelevant information in the original data, fill in missing data, or delete records with many missing values, correct spelling errors, format errors, and inconsistent data; Design a personalized prompt word template, standardize the data of different formats such as date, time, and currency into a unified format through data processing by the large language model, unify the text data to lowercase, remove special characters and punctuation, and convert the data to a data type suitable for model processing. Tokenize and part-of-speech tag the text data, and use word embedding technology to convert structured and unstructured text into word vector representation.
3. The data knowledge extraction method based on a large language model according to claim 1, characterized in that, The features are extracted from the preprocessed original data, and the corresponding task features are selected. The high correlation between the features is removed by calculating the correlation coefficient matrix, specifically: Convert the text data in the original data into a word frequency vector to measure the importance of the word and reduce the weight of common words. Use a pre-trained word vector model to convert the text data into a high-dimensional vector. Calculate the mean, standard deviation, maximum value, and minimum value. In time series data, aggregate features by time window, calculate the correlation coefficient between features and target variables, select features with high correlation, remove high correlation between features by calculating the correlation coefficient matrix, and project data to a lower-dimensional space by linear transformation. Preserve key information, remove redundant features, and the key information includes semantic information and word frequency information.
4. The data knowledge extraction method based on a large language model according to claim 3, characterized in that, In time series data, the features are aggregated by time window, and the correlation coefficient between the features and the target variables is calculated, specifically: Arrange the time series data in chronological order, and include feature data and target variables. Select the time window size to aggregate features, calculate the statistical features in each time window, and align the aggregated features with the target variables. Since the sequence data does not follow a normal distribution, select the Spearman correlation coefficient as the sequence analysis model to calculate the correlation parameter between each aggregated feature and the target variable. 5.The method of claim 1, wherein, The error cases of the large language model are analyzed, and the improvement direction is identified, specifically: The trained model is evaluated using the validation set or test set, the performance of the large language model on various evaluation indicators is calculated, the self-error case analysis of the large language model is performed for the samples predicted incorrectly by the large language model on the validation set or test set, the patterns or characteristics prone to errors of the model are identified, whether the model lacks key features is checked, whether more feature engineering is needed, whether there is class imbalance or data bias in the data set is checked, fusion retrieval enhancement technology or class weight adjustment is used, according to the error case analysis result, the training data is adjusted, the number of samples of certain classes is increased or decreased, the model is retrained using the adjusted model parameters and training data, the adjusted model is evaluated again using the validation set or test set, and whether the performance of the model on the evaluation indicators is improved is checked.
6. A data knowledge extraction system based on a large language model, characterized by, The large language model-based data knowledge extraction method is applied to any one of claims 1-5, comprising a data acquisition module, a feature extraction module, a model fine-tuning module, an information integration module, and a result evaluation module. The data acquisition module is configured to acquire raw data and preprocess the acquired raw data. The feature extraction module is configured to extract features from the preprocessed raw data, select corresponding task features, and remove highly correlated features by calculating a correlation coefficient matrix between the features. The model fine-tuning module is configured to select a large language model for a task, fine-tune the large language model on a labeled data set for the corresponding task based on the large language model to capture general language and knowledge. The information integration module is configured to use secondary block iteration to extract information from knowledge sources based on large language model reasoning and prompt word engineering, and integrate information extracted from different data sources using the context understanding ability of the large language model after fine-tuning. The result evaluation module is configured to define evaluation criteria, analyze error cases of the large language model, identify improvement directions, and adjust parameters of the large language model and training data according to evaluation results and error analysis.
7. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to perform the large language model-based data knowledge extraction method of any one of claims 1-5.
8. A computer-readable storage medium storing a program, characterized in that, The program is executed by the processor to implement the large language model-based data knowledge extraction method of any one of claims 1-5.
Citation Information
Patent Citations
Method and device for training generative large language model based on knowledge base feedback
CN117009490A
Intelligent legal question and answer method based on retrieval enhanced language model
CN118277538A
Intelligent intrusion detection method and system based on interpretable intrusion detection network
CN118337427A