Risk early warning question answering method and device based on large language model
By chunking and vectorized matching of oil industry documents, combining downhole sensor data, optimized prompt data and training of Q&A models, the problem of traditional large language models lacking professional knowledge in the risk warning Q&A in the oil industry is solved, and high-precision risk warning Q&A is achieved.
Patent Information
- Application Number
- CN202510820908.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-06-19
AI Technical Summary
Traditional large language models lack professional knowledge and experience in the oil industry, and it is difficult to provide high-precision responses in risk warning questions and answers.
By converting professional documents into plain text data and processing them in blocks, combining vectorized processing and similarity matching of downhole sensor data, optimized prompt data is built, and training question-and-answer models are lightweight fine-tuned to integrate industry knowledge and real-time monitoring of data.
It has achieved accurate analysis and high-quality response to risk warning issues in the oil industry, improved the accuracy and adaptability of risk warnings, and was able to understand complex working conditions and provide answers that comply with industry standards.
Smart Images

Figure CN120336495A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and specifically relates to a risk warning question - answering method and device based on a large - language model. Background Art
[0002] A large - language model is an advanced natural - language processing system constructed using a vast amount of corpus and deep neural networks. It realizes high - quality text generation and precise understanding through multi - level semantic understanding and context - association capabilities. Its pre - training and fine - tuning techniques continuously improve its generalization ability and professional adaptability in multi - task scenarios. It not only performs excellently in traditional tasks such as question - answering, summarization, and translation, but also demonstrates innovative advantages in cross - modal information fusion, knowledge reasoning, and situation prediction, providing strong technical support for intelligent decision - making and information services in various industries.
[0003] Risk warning questions and answers in the oil industry mostly involve professional knowledge such as drilling, geological exploration, and equipment monitoring. The question - answering not only requires text information but also needs to combine multi - variable data analysis. For example, when abnormal situations such as well leakage and well collapse occur, the system needs to reason by combining parameters such as the current well depth, drilling pressure, and formation lithology. However, traditional large - language models lack direct processing experience of professional knowledge in the oil industry, resulting in the reply content being unable to meet user needs. Summary of the Invention
[0004] This application provides a risk warning question - answering method and device based on a large - language model, which can accurately reply to users' risk warning questions by combining industry - specific professional knowledge and variable data.
[0005] In the first aspect of this application, a risk warning question - answering method based on a large - language model is provided. The method includes: Converting different types of specialized documents into pure text data and performing text chunking to obtain multiple knowledge data chunks; Vectorizing the risk warning question input by the user, performing similarity matching with the stored vector database, retrieving knowledge data chunks in multiple said knowledge data chunks whose similarity meets a preset condition, and constructing optimized prompt data in combination with the risk warning question; Inputting the prompt data into a preset first model to obtain the reply output of the preset first model; Using the prompt data and the reply output, and combining with the existing question - answering data set, training a preset second model, and obtaining a question - answering model for risk warning after the training is completed.
[0006] Based on the above technical solutions, preferably, the vectorizing the risk warning question input by the user and performing similarity matching with the stored vector database specifically includes: Separate the real-time monitoring data collected by downhole sensors included in the risk warning problem; Perform semantic processing on the numerical information of the real-time monitoring data to generate a numerical description text; Perform vectorization processing on the numerical description text to obtain a first sub-vector; Perform vector processing on the description text content included in the risk warning problem to obtain a second sub-vector; Fuse the first sub-vector and the second sub-vector to obtain a first vector; Calculate the similarity between the first vector and the second vector of the knowledge data block, so as to perform similarity matching between the knowledge data block and the risk warning problem.
[0007] Based on the above technical solutions, preferably, before performing semantic processing on the numerical information of the real-time monitoring data to generate a numerical description text, the method further includes: By analyzing historical downhole monitoring data and industry standards of the petroleum industry, calculate the relative deviation of the historical downhole monitoring data according to the process parameters and warning thresholds corresponding to the downhole operation of the historical downhole monitoring data to obtain a deviation rate; Extract the change trend, fluctuation range and mutation points of the historical downhole monitoring data through statistical methods to obtain the trend characteristics of the historical downhole monitoring data; Construct a text generation template, and generate a descriptive text according to the deviation rate and the trend characteristics; Establish a mapping relationship between the historical downhole monitoring data and the descriptive text to obtain a numerical conversion rule.
[0008] Based on the above technical solutions, preferably, the performing semantic processing on the numerical information of the real-time monitoring data to generate a numerical description text specifically includes: Match the real-time monitoring data with the historical downhole monitoring data to determine the target historical monitoring data that the real-time monitoring data is closest to among the multiple historical downhole monitoring data; According to the numerical conversion rule, determine the descriptive text corresponding to the target historical monitoring data to obtain the numerical description text corresponding to the real-time monitoring data.
[0009] Based on the above technical solutions, preferably, the retrieving knowledge data blocks with similarity meeting preset conditions among the multiple knowledge data blocks and constructing optimized prompt data in combination with context information specifically includes: Perform structured parsing on the risk warning problem, and extract multiple first modules through named entity recognition and dependency syntax analysis. The first module includes at least one of key entities, abnormal descriptions, time information, and core parameters; Performing structural analysis on the target knowledge block to obtain multiple second modules, wherein the second modules include at least one of a key entity, an abnormality description, time information, and a core parameter, and the target knowledge block is a knowledge data block whose similarity meets a preset condition when searching for multiple knowledge data blocks; Aligning the plurality of the first modules with the plurality of the second modules, and using a templated construction method to generate initial prompt data through the aligned plurality of the first modules and the plurality of the second modules; The thinking chain reasoning strategy is introduced to obtain the prompt data by adding step-by-step reasoning guidance sentences to the initial prompt data.
[0010] On the basis of the above technical solution, preferably, the prompt data and the reply output are used, and combined with the existing question and answer data set, to train the preset second model, and after the training is completed, a question and answer model for risk warning is obtained, which specifically includes: Constructing a question-answering dataset according to the prompt data, the reply output, and the question-answering dataset; Preprocessing the question-answer data set to obtain a processed data set; A lightweight fine-tuning method is adopted to train the preselected parameter matrix of the preset second model during the training of the preset second model through the processed data set. At the same time, the reply output is used as a soft label to train the question-answering model.
[0011] On the basis of the above technical solution, preferably, the lightweight fine-tuning method is used to train the preselected parameter matrix of the preset second model during the training of the preset second model by the processed data set, specifically including: Setting the pre-selected parameter matrix, the pre-selected parameter matrix includes a query matrix, a key matrix and a value matrix; A matrix decomposition layer is added to the preselected parameter matrix to obtain a low-rank matrix, so as to train the low-rank matrix during the training process.
[0012] In a second aspect of the present application, a risk warning question-answering device based on a large language model is provided, the device being used to execute a risk warning question-answering method based on a large language model as described in any one of the above, the device comprising an acquisition module, a processing module and an output module, wherein: The processing module is used to convert different types of specialized documents into plain text data and perform text block processing to obtain multiple knowledge data blocks; The processing module is used to vectorize the risk warning problems input by the user, perform similarity matching with the stored vector database, retrieve knowledge data blocks whose similarity meets the preset conditions from multiple said knowledge data blocks, and construct optimized prompt data in combination with the risk warning problems; The obtaining module is used to input the prompt data into a preset first model and obtain the reply output of the preset first model; The output module is used to adopt the prompt data and the reply output, and in combination with the existing Q&A data set, train a preset second model, and after the training is completed, obtain a Q&A model for risk warning.
[0013] Based on the above technical solutions, preferably, the processing module is used to separate the real-time monitoring data collected by downhole sensors included in the risk warning problems; The processing module is used to perform semantic processing on the numerical information of the real-time monitoring data to generate a numerical description text; The processing module is used to perform vectorization processing on the numerical description text to obtain a first sub-vector; The processing module is used to perform vector processing on the descriptive text content included in the risk warning problems to obtain a second sub-vector; The processing module is used to fuse the first sub-vector and the second sub-vector to obtain a first vector; The processing module is used to calculate the similarity between the first vector and the second vector of the knowledge data block, so as to perform similarity matching between the knowledge data block and the risk warning problem.
[0014] Based on the above technical solutions, preferably, the processing module is used to analyze the historical downhole monitoring data and the industry standards of the petroleum industry, calculate the relative deviation of the historical downhole monitoring data according to the downhole operation process parameters and warning thresholds corresponding to the historical downhole monitoring data, and obtain a deviation rate; The processing module is used to extract the change trend, fluctuation range and mutation points of the historical downhole monitoring data through statistical methods to obtain the trend characteristics of the historical downhole monitoring data; The processing module is used to construct a text generation template and generate a descriptive text according to the deviation rate and the trend characteristics; The processing module is used to establish a mapping relationship between the historical downhole monitoring data and the descriptive text to obtain a numerical conversion rule.
[0015] On the basis of the above technical solution, preferably, the processing module is used to match the real-time monitoring data with the historical downhole monitoring data, and determine the target historical monitoring data that is closest to the real-time monitoring data among the multiple historical downhole monitoring data; The processing module is used to determine the descriptive text corresponding to the target historical monitoring data according to the numerical conversion rule, and obtain the numerical description text corresponding to the real-time monitoring data.
[0016] On the basis of the above technical solution, preferably, the processing module is used to perform structured analysis on the risk warning problem, and extract multiple first modules through named entity recognition and dependency syntax analysis, wherein the first modules include at least one of key entities, abnormal descriptions, time information and core parameters; The processing module is used to perform structured analysis on the target knowledge block to obtain multiple second modules, wherein the second modules include at least one of key entities, anomaly descriptions, time information, and core parameters, and the target knowledge block is a knowledge data block whose similarity meets a preset condition when searching for multiple knowledge data blocks; The processing module is used to align the plurality of the first modules with the plurality of the second modules, and generate initial prompt data through the aligned plurality of the first modules and the plurality of the second modules in a templated construction manner; The acquisition module is used to introduce a thought chain reasoning strategy, and obtain the prompt data by adding a step-by-step reasoning guidance sentence to the initial prompt data.
[0017] On the basis of the above technical solution, preferably, the processing module is used to construct a question-answering dataset according to the prompt data and the reply output, and the question-answering dataset; The processing module is used to preprocess the question and answer data set to obtain a processed data set; The processing module is used to adopt a lightweight fine-tuning method to train the pre-selected parameter matrix of the preset second model during the training of the preset second model through the processing data set. At the same time, the reply output is used as a soft label to train the question-answering model.
[0018] On the basis of the above technical solution, preferably, the output module is used to set the pre-selected parameter matrix, and the pre-selected parameter matrix includes a query matrix, a key matrix and a value matrix; The output module is used to add a matrix decomposition layer to the pre-selected parameter matrix to obtain a low-rank matrix, so as to train the low-rank matrix during the training process.
[0019] In a third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface, and a network interface. The memory is used to store instructions. Both the user interface and the network interface are used to communicate with other devices. The processor is used to execute the instructions stored in the memory, so that the electronic device executes the method described in any one of the above.
[0020] In a fourth aspect of the present application, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions, and when the instructions are executed, the method described in any one of the above is executed.
[0021] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. By constructing a knowledge database based on professional documents, the present application uses text chunking and vector retrieval to ensure accurate acquisition of knowledge data chunks related to the user's risk warning problem from the industry knowledge base. At the same time, the input variable data of the user is combined to optimize the prompt data, enabling the preset first model to understand the professional background and perform reasoning analysis in combination with real-time monitoring data, and then generating high-quality responses. Through lightweight fine-tuning training of the preset second model, the existing Q&A dataset, industry cases, and model response outputs are further integrated to improve the learning ability of professional terms, variable correlation analysis, and risk warning models, enabling it to more accurately understand complex working conditions and give accurate answers that conform to industry specifications.
[0022] 2. By separating the downhole sensor data and text description information, the accurate analysis of risk warning problems is realized, and the monitoring data is converted into an understandable text description through the semanticization of numerical information to enhance the semantic expression ability. Vectorization processing is adopted to generate numerical description vectors and text description vectors respectively, and a complete risk warning problem vector is constructed through vector fusion, making it contain both industry professional semantic information and key parameter features. Subsequently, through vector database retrieval, the similarity between the risk warning problem vector and the knowledge data chunk is calculated to achieve efficient and accurate matching, and the most relevant historical cases and industry experiences can be quickly extracted from the professional knowledge base to provide accurate knowledge support for subsequent intelligent Q&A, thereby improving the accuracy, adaptability, and decision-making reliability of risk warning.
[0023] 3. Structurally analyze the risk warning problems and target knowledge chunks, accurately extract key entities, abnormal descriptions, time information, and core parameters, and perform semantic alignment so that the retrieved knowledge data chunks can deeply match the risk problems input by the user. Adopt a templated construction method to convert the aligned information into structured initial prompt data to ensure that the large language model can accurately understand the industry background and variable data during processing. Further introduce the chain of thought reasoning strategy, add step-by-step reasoning guidelines to the prompt data, so that the model can perform multi-step reasoning in a logical deduction manner, rather than simply matching answers, thereby improving the accuracy, interpretability, and reasoning ability of the answers. Description of the Drawings
[0024] Figure 1 is a schematic flowchart of a risk warning Q&A method based on a large language model disclosed in an embodiment of the present application; Figure 2 is a schematic block diagram of a risk warning Q&A device based on a large language model disclosed in an embodiment of the present application; Figure 3 is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application.
[0025] Description of the reference numerals: 201, acquisition module; 202, processing module; 203, output module; 301, processor; 302, communication bus; 303, user interface; 304, network interface; 305, memory. Detailed Embodiments
[0026] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments.
[0027] In the description of the embodiments of the present application, words such as "for example" or "for illustration" are used to indicate examples, illustrations, or explanations. Any embodiment or design solution described as "for example" or "for illustration" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "for example" or "for illustration" is intended to present relevant concepts in a specific manner.
[0028] In the description of the embodiments of the present application, the term "plural" means two or more. For example, plural systems refer to two or more systems, and plural screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly specifying the technical features indicated. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0029] Large language models are built on the basis of massive corpora and deep neural networks, and have the capabilities of multi-level semantic understanding and context association. They demonstrate excellent generalization capabilities and professional adaptability in tasks such as question answering, summarization, translation, cross-modal information fusion, knowledge reasoning, and situation prediction, providing strong support for intelligent decision-making in all walks of life; however, risk warning question answering in the oil industry involves highly specialized fields such as drilling, geological exploration, and equipment monitoring, and requires precise reasoning by combining multi-variable real-time data such as well depth, drilling pressure, and formation lithology. Traditional large language models are difficult to meet the requirements of high-precision risk warning due to the lack of experience in directly processing such professional knowledge.
[0030] This embodiment discloses a risk warning question answering method based on a large language model, referring to Figure 1 , and includes the following steps S110-S140: S110, converting different types of specialized documents into plain text data, and performing text chunking processing to obtain a plurality of knowledge data chunks.
[0031] A risk warning question answering method based on a large language model disclosed in the embodiments of the present application is applied to a server. The server includes, but is not limited to, electronic devices such as mobile phones, tablet computers, wearable devices, and PCs (Personal Computers), and may also be a background server running a risk warning question answering method based on a large language model. The server can be implemented by an independent server or a server cluster composed of multiple servers.
[0032] Professional documents in the oil industry usually consist of structured data and unstructured text. The structured part covers various real-time monitoring parameters during the drilling process, such as the current well depth, drilling fluid density, total pit volume, flow rate at the outlet, pump pressure, etc. These parameters are collected by sensors to form detailed numerical records. At the same time, the document also contains formation data, lithology data, adjacent well operation data, as well as various charts and picture information such as well logging and seismic profiles. The unstructured part is composed of professional text descriptions written by engineering and technical personnel, including drilling accident analysis, determination of abnormal causes, adjustment of construction plans, and risk warning suggestions. For example, in a well leakage accident report, the document may record that "when drilling to 3670.62 meters, the pump pressure dropped from the normal 28.4 MPa to 28 MPa, and at the same time, the well fluid density changed abnormally and was accompanied by a decrease in the flow rate at the outlet. After preliminary judgment by on-site technical personnel, it is suspected that a formation fracture caused the well leakage." Such documents combine digital data, image information, and professional descriptions to provide rich context information and professional backgrounds for risk warning Q&A, enabling data-driven anomaly detection and accurate warning.
[0033] First, deploy a complete set of multi-format document parsing solutions to uniformly process various data sources such as Word documents, TXT files, CSV data tables, Excel spreadsheets, PDF files, pictures, and videos. Use a dedicated document loader to directly read text files and extract text from PDF files. At the same time, utilize optical character recognition technology to extract text information from pictures and videos, thereby converting various unstructured and semi-structured data into plain text data that can be understood by large language models. Then, in the text preprocessing module, clean, format-unify, and filter noise from the extracted content. Combining the understanding of professional document content in the field, use a semantic-based document slicing algorithm and a sliding window strategy to divide long documents into chunks, divide continuous text into multiple knowledge data chunks with complete context according to logic and theme, and embed document titles, abstracts, and key metadata in each data chunk to enhance the accuracy and efficiency of subsequent vector retrieval.
[0034] S120, vectorize the risk warning question input by the user, perform similarity matching with the stored vector database, retrieve knowledge data chunks with similarity meeting the preset conditions in multiple knowledge data chunks, and construct optimized prompt data in combination with context information.
[0035] In a possible implementation, the risk warning problems input by the user are vectorized and matched for similarity with the stored vector database, which specifically includes: separating the real-time monitoring data collected by downhole sensors included in the risk warning problems; performing semantic processing on the numerical information of the real-time monitoring data to generate numerical description texts; performing vectorization processing on the numerical description texts to obtain first sub-vectors; performing vector processing on the descriptive text content included in the risk warning problems to obtain second sub-vectors; fusing the first sub-vectors and the second sub-vectors to obtain first vectors; calculating the similarity between the first vectors and the second vectors of the knowledge data blocks, so as to perform similarity matching between the knowledge data blocks and the risk warning problems.
[0036] Specifically, first, through natural language processing and rule matching techniques, the risk warning problems input by the user are preprocessed. For example, the risk warning problem can be: On June 27, 2024, at 8:31, well JHW22-12 drilled to 3670.62 m and lost circulation occurred. The density of the lost drilling fluid was 1.47 g / cm³. The total pit volume decreased from 79.7 m³ to 179.02 m³, with a loss of 0.68 m³ and a loss rate of 40.8 m³ / h. The outlet flow rate decreased from the normal 19.6% to 13.3%, and the pump pressure decreased from the normal 28.4 MPa to 28 MPa. No abnormalities were found in other parameters. Please analyze the reasons for the lost circulation based on the above information.
[0037] Preprocess the risk warning problems input by the user, and use named entity recognition and regular expressions to accurately separate the real-time monitoring data collected by downhole sensors from the mixed text, such as numerical information such as the current well depth, drilling fluid density, total pit volume, outlet flow rate, and pump pressure, to ensure that these data can be independently extracted and accurately reflect the monitoring status. Assume the risk warning problem input by the user is:
[0038] where q i represents the text unit input by the user. Use the sensor data extraction function f s to separate:
[0039] where S represents the real-time monitoring data extracted from the user input, such as well depth, pump pressure, drilling fluid density, etc.
[0040] Secondly, for the extracted real-time monitoring data, based on the knowledge in the field of oil drilling technology and risk warning, the original numbers are converted into descriptive texts through predefined rules and comparison methods. For example, numerical description texts such as "the current well depth is in the critical area" or "the pump pressure is lower than the normal working range" are generated to intuitively express the risk information hidden in the data in a semantic way.
[0041] Next, use the pre-trained embedding model to vectorize the generated numerical description text, convert the text into a high-dimensional semantic feature representation, and obtain the first sub-vector reflecting the semantics of numerical information, so as to capture the key risk indicators and abnormal trends in the description. Define the numerical semantic conversion function f t , which is used to convert numerical data into an interpretable text description:
[0042] Among them, T is the numerical description text generated based on threshold judgment rules, trend analysis, etc., for example:
[0043] Among them, θ low , θ high are preset thresholds.
[0044] The numerical description text T is vectorized through the pre-trained embedding model E to obtain the first sub-vector:
[0045] Among them, E(t i ) is converted into a high-dimensional vector through a large language model or a domain-specific embedding model:
[0046] Meanwhile, the description text part other than the sensor data in the risk warning problem is also vectorized, and a second sub-vector reflecting the background information and context semantics is generated through a language model adapted to the professional field to ensure that the semantic needs of the user can be fully expressed.
[0047]
[0048] Subsequently, use vector fusion techniques (such as vector concatenation or weighted average) to merge the first sub-vector and the second sub-vector to generate a comprehensive first vector, which simultaneously integrates the semantic features of real-time monitoring data and the background information of the user's description text, providing a complete and accurate semantic representation for subsequent matching. Finally, calculate the cosine similarity between the comprehensive first vector and the second vector corresponding to each knowledge data block stored in the vector database, specifically calculated through the following formula:
[0049] Among them, α t is the weight corresponding to the text similarity, α s is the weight corresponding to the numerical similarity, α ts is the weight corresponding to the text-numerical cross-modal similarity, α stis the weight corresponding to the numerical-text cross-modal similarity. Among them, the text similarity is calculated by the following formula:
[0050] Among them, d t is the dimension of the text vector or the first sub-vector. The text vector is the vector obtained by vectorizing the descriptive text of the knowledge data block security. w ti is the weight of the i-th dimension in the text vector or the first sub-vector, which is used to enhance the influence of professional terms in the similarity calculation. For example, the weights of "lost circulation" and "fracture" are higher.
[0051] The numerical similarity is calculated by the following formula:
[0052] Among them: d s is the dimension of the numerical description vector or the second sub-vector. w si is the weight of the i-th dimension in the numerical description vector or the second sub-vector, which can be set according to the importance of the drilling parameters. For example, the key parameters such as pump pressure and well depth have higher weights.
[0053] Among them, the text-numerical cross-modal similarity and the numerical-text cross-modal similarity are specifically calculated by the following formula:
[0054]
[0055] Among them, and are the cross-modal cross weights, which are used to measure the influence of numerical information on text reasoning and the supplementary role of text description on numerical data.
[0056]
[0057] Among them, is the first sub-vector of the first vector, is the second sub-vector of the first vector, is the numerical description vector part of the second vector, is the text vector part of the second vector.
[0058] Screen out the knowledge data blocks that meet the preset similarity threshold, so as to achieve an accurate match with the risk warning problem and provide high-quality context support for subsequent intelligent questions and answers.
[0059] In a possible implementation, before semantic processing of numerical information in real-time monitoring data to generate numerical description text, the method further includes: analyzing historical downhole monitoring data and industry standards of the petroleum industry, calculating the relative deviation of the historical downhole monitoring data according to the process parameters and warning thresholds of downhole operation corresponding to the historical downhole monitoring data to obtain a deviation rate; extracting the change trend, fluctuation amplitude, and mutation points of the historical downhole monitoring data through statistical methods to obtain the trend characteristics of the historical downhole monitoring data; constructing a text generation template, and generating descriptive text according to the deviation rate and trend characteristics; establishing a mapping relationship between the historical downhole monitoring data and the descriptive text to obtain a numerical conversion rule.
[0060] Specifically, first, for historical downhole monitoring data, key process parameters are extracted from the industry standards of the petroleum industry and historical drilling data, including well depth, drilling pressure, pump pressure, drilling fluid density, outlet flow, etc., and the warning threshold range is defined. Through the relative deviation calculation formula, the deviation rate of the current measured value from the normal working range is calculated. For example, for a certain process parameter X, the relative deviation rate is calculated as follows:
[0061] where X normal represents the average normal value of this parameter in historical data, and it will automatically determine whether the parameter is abnormal according to the size of this deviation rate, and mark it as slight deviation, significant deviation, or severe deviation.
[0062] Next, the time series change trend of historical data is analyzed through statistical methods, including calculating the fluctuation amplitude, trend slope, and mutation points of the parameter. The fluctuation amplitude can be calculated using the standard deviation:
[0063] where is the mean value of historical data. If the standard deviation is too large, it indicates that the parameter has violent fluctuations and there may be potential risks. In addition, the trend slope m is calculated through linear regression:
[0064] When m exceeds the set threshold, it means that the parameter has an obvious upward or downward trend, and it is marked with different trend types such as "steady state", "slow growth", "rapid rise", etc. In addition, the mutation point detection adopts the Z-score method based on the standard deviation:
[0065] When |Z i | exceeds the set threshold, this point is regarded as a mutation point. For example, a sudden drop in drilling pressure may mean a risk of well collapse.
[0066] After obtaining the deviation rate and trend characteristics, a text generation template is constructed based on this numerical information. For example, when the relative deviation of the drilling fluid density is detected to be 8% and the trend analysis shows a continuous decrease, descriptive text can be generated according to the template: \The current drilling fluid density is 8% lower than the normal level and shows a downward trend, and there may be a risk of well leakage.\ By combining industry terms, numerical calculation results, and trend analysis results, this text makes the description more in line with the cognitive habits of engineers and can be used as input for large language models to improve the understanding ability of risk in question and answer.
[0067] Finally, a mapping relationship between historical downhole monitoring data and descriptive text is established, mapping the deviation rate, fluctuation characteristics, and trend characteristics in different numerical intervals to corresponding text descriptions, enabling quick matching and generation of corresponding text descriptions after future real-time data input. For example: Deviation rate 0 - 5% corresponds to "The parameter has a slight deviation and the operation is stable" Deviation rate 5 - 15% + downward trend corresponds to "The parameter has a significant decrease and there may be risks" Deviation rate > 15% + increasing fluctuation corresponds to "The parameter changes violently and a serious failure may occur" This mapping relationship is optimized through multiple iterations, enabling more accurate conversion of numerical data into readable text information and providing precise input for risk warning question and answer.
[0068] In a possible implementation, semantic processing of numerical information is performed on real-time monitoring data to generate numerical description text, specifically including: matching the real-time monitoring data with historical downhole monitoring data to determine the target historical monitoring data closest to the real-time monitoring data among multiple historical downhole monitoring data; according to the numerical conversion rule, determining the descriptive text corresponding to the target historical monitoring data to obtain the numerical description text corresponding to the real-time monitoring data.
[0069] Specifically, first, through a real-time monitoring data matching algorithm, the target historical data closest to the current real-time data is searched for in the historical downhole monitoring dataset. During the matching process, based on multivariate similarity calculation, key parameters such as well depth, weight on bit, pump pressure, drilling fluid density, and outlet flow rate are comprehensively considered, and the Euclidean distance between each historical data point and the real-time data is calculated:
[0070] Where: H i represents the i-th historical data, R represents the real-time data, H i,j and R j are the numerical values of the historical data and the real-time data on the j-th parameter respectively, and w jis the weighting coefficient of each parameter, ensuring a greater impact on the similarity matching of key parameters such as drilling fluid density and pump pressure).
[0071] Traverse all historical data and select the H with the minimum Euclidean distance * as the target historical monitoring data:
[0072] Next, according to the numerical conversion rules, obtain the corresponding descriptive text of the target historical data from the historical database. The numerical conversion rules are based on the pre-established mapping relationship, which converts the deviation rate, fluctuation characteristics, trend characteristics, etc. in different numerical ranges into engineering term descriptions. For example: The well depth change < 2% and the drilling pressure is normal correspond to "The bottom of the well is stable and the drilling pressure remains within the normal range." The drilling fluid density drops by 10% and the outlet flow rate is abnormal correspond to "There may be a well leakage. It is recommended to check the mud pump and the wellbore stability." The pump pressure fluctuation > 15% and the historical data shows a similar trend correspond to "The pump pressure fluctuates violently. Well collapse or sticking may occur." Based on the matched target historical data H directly look up the corresponding descriptive text T(H * ) * :
[0073] Thus, obtain the numerical description text of the real-time monitoring data.
[0074] Finally, automatically complete and format the descriptive text with the specific numerical information of the real-time data to ensure that the generated text conforms to the cognitive mode of engineering personnel. For example: Real-time data R: Well depth 3670.62m, pump pressure drops by 1.5MPa, outlet flow rate drops by 19.6%; Target historical data H * : Matched the historical record at a depth of 3675m, pump pressure drops by 1.4MPa, outlet flow rate drops by 18%; The finally generated numerical description text: "The current drilling depth is 3670.62m. It is detected that the pump pressure drops by 1.5MPa and the outlet flow rate drops by 19.6%. Historical data shows that there may be a well leakage risk in similar situations. It is recommended to check the drilling fluid density and the wellbore stability." This method ensures that the generated descriptive text has both industry knowledge background and can be personalized according to real-time data by matching the most similar historical data and combining the preset numerical conversion rules, providing more accurate risk warning input for the large language model.
[0075] In a possible implementation, retrieve knowledge data blocks whose similarity among multiple knowledge data blocks meets a preset condition, and construct optimized prompt data in combination with context information. Specifically, it includes: performing structured parsing on the risk warning problem, and extracting multiple first modules through named entity recognition and dependency syntax analysis. The first module includes at least one of a key entity, an abnormal description, time information, and a core parameter; performing structured parsing on the target knowledge block to obtain multiple second modules. The second module includes at least one of a key entity, an abnormal description, time information, and a core parameter, and the target knowledge block is a knowledge data block whose similarity among multiple knowledge data blocks meets a preset condition; aligning the multiple first modules with the multiple second modules, and adopting a templated construction method to generate initial prompt data through the aligned multiple first modules and multiple second modules; introducing a chain-of-thought reasoning strategy to obtain prompt data by adding guiding statements for step-by-step reasoning to the initial prompt data.
[0076] Specifically, first perform structured parsing on the risk warning problem input by the user. Using named entity recognition (NER) and dependency syntax analysis (Dependency Parsing) techniques, extract multiple first modules from the problem text, including key entities (such as well numbers, well areas, operation types), abnormal descriptions (such as well leakage, well collapse, stuck pipe), time information (such as occurrence time, duration), and core parameters (such as well depth, drilling pressure, pump pressure, outlet flow rate). First, use a pre-trained NER model to perform entity annotation on the text, and combine a rule-based parsing algorithm to extract key parameters in a specific domain. At the same time, use dependency syntax analysis to identify syntactic relationships and extract the subject-predicate-object structure of abnormal behaviors from the sentence for effective matching with knowledge data blocks.
[0077] Next, perform structured parsing on the target knowledge block, that is, perform the same entity extraction and dependency syntax analysis on the retrieved multiple knowledge data blocks to obtain the second module, which also includes key entities, abnormal descriptions, time information, and core parameters. Since the knowledge data blocks may contain different industry standards, historical cases, and experience summaries, the knowledge blocks will be denoised and summarized first to ensure that the extracted information is logically consistent with the user's input problem. In addition, text semantic similarity will be calculated, the knowledge blocks most relevant to the problem will be screened out, and they will be sorted in descending order of relevance to ensure the quality of the aligned data.
[0078] Then, align the first module with the second module. Based on semantic matching and feature mapping algorithms, find the structurally closest corresponding items. For example, if the user's question involves a specific well number and abnormal drilling pressure, and the knowledge data block contains historical well leakage cases with the same well number, then preferentially match the corresponding historical data. Adopt a templated construction method. After aligning the first module and the second module, generate initial prompt data according to the preset prompt word structure, which usually adopts the "role - goal - input format - output format" framework to ensure that the large language model can accurately understand the question. For example, the input format may adopt "well number + current abnormal parameters + historical matching cases", and the output format requires the model to perform reasoning based on the case data.
[0079] Finally, introduce the Chain-of-Thought (CoT) reasoning strategy. Add guiding statements for step-by-step reasoning to the initial prompt data to guide the large language model to perform hierarchical reasoning. For example, first guide the model to analyze the influencing factors of the current abnormal data in the prompt data, then perform pattern matching in combination with historical cases, and finally generate a reasonable conclusion based on the existing treatment suggestions. This strategy can significantly improve the professionalism and logical coherence of the answer, enabling it not only to provide a direct answer but also to explain the reasoning process, thereby enhancing the credibility and interpretability of the Q&A.
[0080] For example, the risk warning question input by the user is: Well JHW22 - 12 had a well leakage at 8:31 on June 27, 2024, when drilling to 3670.62m. The drilling fluid density was 1.47g / cm³, the total pit volume decreased from 79.7m³ to 179.02m³, the leakage was 0.68m³, the leakage rate was 40.8m³ / h, the outlet flow rate decreased from the normal 19.6% to 13.3%, and the pump pressure decreased from the normal 28.4MPa to 28MPa. Please analyze the cause of the well leakage in combination with historical data.
[0081] Parse the text input by the user and extract key entities, abnormal descriptions, time information, and core parameters to form the first module: Key entities: well number JHW22 - 12, time 2024 - 06 - 27 8:31; Abnormal description: well leakage; Time information: 2024 - 06 - 27 8:31; Core parameters: well depth 3670.62m, drilling fluid density 1.47g / cm³, total pit volume decreased by 0.68m³, leakage rate 40.8m³ / h, outlet flow rate decreased from 19.6% to 13.3%, pump pressure decreased from 28.4MPa to 28MPa Retrieve the historical knowledge data block with the highest similarity in the vector database, match the historical drilling records, and parse out the second module. Retrieve knowledge data block 1 (matching degree 92%): Well JHW22-11 had a lost circulation at a well depth of 3700m, the pump pressure dropped by 27-31MPa, the seismic profile superposition curvature attribute showed that fractures developed near the bottom of the well, and there were 3 lost circulation risk points in the Jurassic and Triassic systems. Historical cases indicate that similar formations are prone to lost circulation. Retrieve knowledge data block 2 (matching degree 88%): Similar lost circulation occurred within a well depth range of 3680m in a certain oilfield. Cause analysis shows that the drilling passed through a high-porosity fracture zone, resulting in a large-scale loss of drilling fluid.
[0082] Structurally analyze the knowledge data block and extract the second module: ; Key entities: Well number JHW22;11, well depth 3700m; Abnormal description: Lost circulation; Time information: Historical cases; Core parameters: Pump pressure dropped by 27-31MPa, fractures developed at the bottom of the well, there are 3 lost circulation risk points in the Jurassic and Triassic systems, and lost circulation caused by a high-porosity fracture zone.
[0083] Align the first module with the second module to generate initial prompt data: 1. Well number matching: JHW22-12 (user input) and JHW22-11 (historical knowledge), the well numbers are different, but the well depths are similar (3670.62m and 3700m), and they may belong to the same geological structure 2. Abnormal matching: Based on the lost circulation input by the user and the lost circulation in the historical data (formation fractures, high-porosity zone), the alignment conclusion is that the lost circulation input by the user may be related to formation fractures 3. Pump pressure and flow matching: According to the pump pressure drop from 28.4MPa to 28MPa and the outlet flow rate drop from 19.6% to 13.3% input by the user, and the pump pressure of 27-31MPa and abnormal flow rate in the historical data, the alignment conclusion is that the flow rate drop trend is consistent with historical cases Then construct the initial prompt data: Well JHW22-12 had a lost circulation at 3670.62m, the drilling fluid density was 1.47g / cm³, the pump pressure dropped from 28.4MPa to 28MPa, and the outlet flow rate dropped from 19.6% to 13.3%. Well JHW22-11 had a lost circulation at 3700m, and historical data shows that the seismic profile shows fractures developed at the bottom of the well. Please analyze the cause of this lost circulation.
[0084] Finally, introduce the chain of thought reasoning strategy. To improve the reasoning ability of the large language model, introduce step-by-step reasoning guidance and optimize the prompt data: First step: Analyze whether the current abnormal data conforms to historical cases. For the current well depth of 3670.62m, the pump pressure dropped by 0.4MPa, and the outlet flow rate dropped by 6.3%, does it conform to historical lost circulation cases? Step 2: Analyze the bottom-hole formation characteristics in combination with historical cases. Historical data shows that bottom-hole fractures are developed at 3700 m. Is it possible to affect the position at 3670.62 m? Step 3: Comprehensively analyze the possible causes of lost circulation. Combine the current drilling parameters and historical cases to determine the main cause of lost circulation.
[0085] Final optimized prompt data: You are a drilling engineering expert and need to analyze the lost circulation phenomenon that occurred at 3670.62 m in Well JHW22-12. The following are the drilling parameters: mud density: 1.47 g / cm³, pump pressure: 28.4 MPa to 28 MPa, outlet flow rate: 19.6% to 13.3%, well depth: 3670.62 m; historical data: lost circulation occurred at 3700 m in Well JHW22-11; there are 3 lost circulation risk points in the Jurassic and Triassic systems; bottom-hole fractures are developed, and the high-porosity fracture zone leads to fluid loss. Please analyze the cause of lost circulation according to the following steps: 1. Combine the current drilling parameters to judge the trend of lost circulation; 2. Analyze whether the bottom-hole formation structure may cause fluid loss; 3. Combine historical cases and drilling parameters to obtain the possible causes of lost circulation and give preventive measures.
[0086] S130, input the prompt data into the preset first model to obtain the reply output of the preset first model.
[0087] After constructing the optimized prompt data, input it into the preset first model to generate the reply output of the risk warning Q&A. The specific implementation process includes model adaptation, input format conversion, context management, inference optimization, and result parsing. Among them, the preset first model uses a conventional commercial large model.
[0088] First, the prompt data will be formatted according to the input requirements of the selected large language model to ensure that the input text structure conforms to the model's parsing ability. For example, complex parameters will be JSONified or key variables will be marked to enable the model to accurately understand the input. Then, the context management mechanism is used to ensure the consistency of information such as the user's historical interactions, retrieved knowledge data blocks, and real-time monitoring data in multi-round conversations, so as to enhance the model's reasoning ability and coherence. Subsequently, through dynamic inference optimization strategies, such as Chain-of-Thought (CoT) reasoning and ReAct (Reason+Act) strategies, the model is guided to gradually analyze the risk causes, match historical cases, and propose reasonable preventive measures according to logical steps. Finally, the original output of the model is subjected to result parsing and structuring, such as extracting core viewpoints, checking unit conversions, ensuring that the output conforms to industry terminology specifications, and judging the reliability of the answer through confidence scoring. If the confidence is insufficient, the input prompt data will be re-optimized and re-inferred to generate an accurate risk warning Q&A reply to ensure that the result can be used for actual engineering decisions.
[0089] After the optimized prompt data is input into the large language model, the expected output may be: Combining the current drilling parameters with historical data, the well leakage of JHW22-12 well may be caused by the development of bottom hole fractures. The pump pressure dropped by 0.4MPa and the outlet flow rate decreased by 6.3%, indicating that there may be a high porosity zone at the bottom of the well, resulting in fluid loss. Historical data show that a similar situation occurred at 3700m in the adjacent well JHW22-11. Combined with the seismic profile analysis, the bottom hole fracture may extend to 3670.62m. It is recommended to adjust the drilling fluid density and use plugging agents to improve the stability of the wellbore.
[0090] S140, using the prompt data and the response output, and combining with the existing question and answer data set, the preset second model is trained, and after the training is completed, a question and answer model for risk warning is obtained.
[0091] In a possible implementation, the preset second model is trained using prompt data and reply output in combination with an existing question-and-answer data set, and a question-and-answer model for risk warning is obtained after the training is completed, specifically including: constructing a question-and-answer data set based on the prompt data and reply output, and the question-and-answer data set; preprocessing the question-and-answer data set to obtain a processed data set; using a lightweight fine-tuning method, in the process of training the preset second model using the processed data set, training the preselected parameter matrix of the preset second model, and at the same time, using the reply output as a soft label to train the question-and-answer model.
[0092] Specifically, first, a high-quality question-answering dataset is constructed based on the prompt data, model response output, and existing question-answering datasets to enhance the understanding and reasoning ability of the preset second model for risk warning tasks. During the data construction process, the prompt data is paired with the response output, and combined with the existing expert-annotated question-answering data to form a multi-level question-answering dataset containing input questions, knowledge background, historical cases, reasoning process, and final answers to ensure that the model can learn the complete decision logic during the training process. At the same time, in order to improve the generalization ability of the data, data enhancement techniques such as synonymous substitution, sentence reconstruction, and random missing of some input information are used to construct more diverse question-answering samples to avoid overfitting the model to certain specific expressions.
[0093] Next, perform data preprocessing on the Q&A dataset to ensure the quality and consistency of the training data. First, standardize the text by unifying the expression of professional terms (e.g., "pump pressure drop" and "pump pressure reduction" are kept consistent) and converting different units to reduce training errors caused by inconsistent data formats. Second, adopt text cleaning techniques to remove redundant information, formatting errors, and low-quality data that may affect the training effect. Then, perform hierarchical annotation on the data, classifying the data according to question types (such as lost circulation analysis, abnormal WOB, equipment fault prediction) and difficulty levels (such as direct matching vs. complex reasoning) so that a phased learning strategy can be used during training, enabling the model to gradually adapt from simple tasks to complex reasoning tasks.
[0094] In the model training stage, adopt lightweight fine-tuning methods (LoRA or Adapter), and only train the preselected parameter matrices in the preset second model to avoid the high computational cost brought by full-parameter fine-tuning.
[0095] In a possible implementation, adopt a lightweight fine-tuning method. During the training of the preset second model by processing the dataset, train the preselected parameter matrices of the preset second model, specifically including: setting the preselected parameter matrices, where the preselected parameter matrices include a query matrix, a key matrix, and a value matrix; adding a matrix factorization layer to the preselected parameter matrices to obtain low-rank matrices, so as to train the low-rank matrices during the training process.
[0096] Specifically, first set the preselected parameter matrices, that is, determine the parameter parts that need to be fine-tuned in the preset second model (such as a large language model with a Transformer structure). Since full-parameter fine-tuning has high computational resource requirements and is prone to model overfitting, this solution only selectively trains the query matrix (Query Matrix, W Q ), the key matrix (KeyMatrix, W K ), and the value matrix (ValueMatrix, W V ). These matrices are located in the attention mechanism (Self-AttentionLayer) of the Transformer model and are mainly used to calculate the relationships between input tokens. By optimizing these matrices, the specialization of the model in the risk warning task can be enhanced without modifying the entire network structure. In addition, when setting the preselected parameter matrices, other model parameters such as the feed-forward network will be frozen to ensure that the training only optimizes the most critical attention weights.
[0097] Next, add a matrix factorization layer to the preselected parameter matrix to obtain a low-rank matrix. Specifically, the LoRA (Low-Rank Adaptation) low-rank adaptation method is adopted. LoRA inserts a trainable low-rank factorization layer on the W Q , W K , W V matrices, while the original parameters remain frozen, thereby reducing the training computational amount and improving the generalization ability of the model. Under the LoRA structure, each original weight matrix W is replaced by:
[0098] where: A and B are trainable low-rank matrices, satisfying , where r is much smaller than d (for example, r = 4, d = 1024). Only A and B are trained, while W remains frozen, thus effectively reducing the computational resources required for training.
[0099] Finally, during the training process, only the low-rank matrices are optimized. The adaptive gradient optimization algorithm (such as AdamW) is used to update the gradients of A and B. At the same time, knowledge distillation is combined, and the response of the first model is used as a soft label to calculate the KL divergence loss:
[0100] In addition, the cross-entropy loss is used to calculate the hard label error:
[0101] The final optimization objective function is:
[0102] where λ1 and λ2 are used to control the weight ratio of the hard label and the soft label, ensuring that the model can learn both the true answer and the inference mode of the first model. After training, the low-rank matrices A and B are optimized, enabling the fine-tuned question-answering model to provide more professional answers in the risk warning task. At the same time, since only the low-rank part is trained, the overall computational cost of the model is significantly reduced, making it suitable for practical application scenarios.
[0103] To improve the training efficiency and effect, optimization strategies such as gradient accumulation, adaptive learning rate adjustment (CosineAnnealing), and mixed-precision training (FP16) are adopted to ensure the stable convergence of the model. In addition, to enhance the robustness of the model in different environments, adversarial training (AdversarialTraining) is used. By artificially introducing input perturbations (such as spelling mistakes and different format inputs), the adaptability of the model is tested, and the training strategy is adjusted through error feedback. Finally, after the training is completed, the model is evaluated. Metrics such as BLEU score, cosine similarity calculation, and professional term matching rate are used to measure the performance of the question-answering model, and it is tested in the actual risk warning scenario to ensure that the model can accurately answer risk questions, and finally an intelligent question-answering model for oil industry risk warning is obtained.
[0104] This embodiment also discloses a risk warning question-answering device based on a large language model. The device is used to execute a risk warning question-answering method based on a large language model as described in any one of the above, referring to Figure 2 , the device includes an acquisition module 201, a processing module 202, and an output module 203, where: The processing module 202 is used to convert different types of specialized documents into plain text data and perform text chunking processing to obtain multiple knowledge data chunks.
[0105] The processing module 202 is used to vectorize the risk warning question input by the user, perform similarity matching with the stored vector database, retrieve knowledge data chunks whose similarity meets the preset conditions from multiple knowledge data chunks, and construct optimized prompt data in combination with the risk warning question.
[0106] The acquisition module 201 is used to input the prompt data into a preset first model and obtain the reply output of the preset first model.
[0107] The output module 203 is used to adopt the prompt data and the reply output, and in combination with the existing question-answering data set, train a preset second model, and after the training is completed, obtain a question-answering model for risk warning.
[0108] In a possible implementation manner, the processing module 202 is used to separate the real-time monitoring data collected by downhole sensors included in the risk warning question.
[0109] The processing module 202 is used to perform numerical information semantic processing on the real-time monitoring data to generate numerical description text.
[0110] The processing module 202 is used to perform vectorization processing on the numerical description text to obtain a first sub-vector.
[0111] The processing module 202 is configured to perform vector processing on the descriptive text content included in the risk warning problem to obtain a second sub-vector.
[0112] The processing module 202 is configured to fuse the first sub-vector and the second sub-vector to obtain a first vector.
[0113] The processing module 202 is configured to calculate the similarity between the first vector and the second vector of the knowledge data block, so as to perform similarity matching between the knowledge data block and the risk warning problem.
[0114] In a possible implementation manner, the processing module 202 is configured to analyze the historical downhole monitoring data and the industry standards of the petroleum industry, and calculate the relative deviation of the historical downhole monitoring data according to the process parameters and warning thresholds corresponding to the historical downhole monitoring data during downhole operation to obtain a deviation rate.
[0115] The processing module 202 is configured to extract the change trend, fluctuation range, and mutation points of the historical downhole monitoring data through statistical methods to obtain the trend characteristics of the historical downhole monitoring data.
[0116] The processing module 202 is configured to construct a text generation template and generate descriptive text according to the deviation rate and trend characteristics.
[0117] The processing module 202 is configured to establish a mapping relationship between the historical downhole monitoring data and the descriptive text to obtain a numerical conversion rule.
[0118] In a possible implementation manner, the processing module 202 is configured to match the real-time monitoring data with the historical downhole monitoring data to determine the target historical monitoring data that the real-time monitoring data is closest to among multiple historical downhole monitoring data.
[0119] The processing module 202 is configured to determine the descriptive text corresponding to the target historical monitoring data according to the numerical conversion rule to obtain the numerical descriptive text corresponding to the real-time monitoring data.
[0120] In a possible implementation manner, the processing module 202 is configured to perform structured parsing on the risk warning problem, and extract multiple first modules through named entity recognition and dependency syntax analysis. The first module includes at least one of a key entity, an abnormal description, time information, and a core parameter.
[0121] The processing module 202 is configured to perform structured parsing on the target knowledge block to obtain multiple second modules. The second module includes at least one of a key entity, an abnormal description, time information, and a core parameter. The target knowledge block is a knowledge data block whose retrieval similarity among multiple knowledge data blocks meets a preset condition.
[0122] The processing module 202 is used to align the plurality of first modules with the plurality of second modules, and generate initial prompt data through the aligned plurality of first modules and the plurality of second modules in a templated construction manner.
[0123] The acquisition module 201 is used to introduce the thinking chain reasoning strategy, and obtain the prompt data by adding a step-by-step reasoning guidance sentence to the initial prompt data.
[0124] In a possible implementation, the processing module 202 is used to construct a question-and-answer dataset based on the prompt data and the response output, as well as the question-and-answer dataset.
[0125] The processing module 202 is used to pre-process the question and answer data set to obtain a processed data set.
[0126] The processing module 202 is used to adopt a lightweight fine-tuning method to train the pre-selected parameter matrix of the preset second model in the process of training the preset second model by processing the data set. At the same time, the reply output is used as a soft label to train the question-answering model.
[0127] In a possible implementation, the output module 203 is used to set a pre-selected parameter matrix, where the pre-selected parameter matrix includes a query matrix, a key matrix, and a value matrix.
[0128] The output module 203 is used to add a matrix decomposition layer to the pre-selected parameter matrix to obtain a low-rank matrix, so as to train the low-rank matrix during the training process.
[0129] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0130] This embodiment also discloses an electronic device, referring to Figure 3 The electronic device may include: at least one processor 301 , at least one communication bus 302 , a user interface 303 , a network interface 304 , and at least one memory 305 .
[0131] The communication bus 302 is used to realize the connection and communication between these components.
[0132] The user interface 303 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.
[0133] Among them, the network interface 304 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface).
[0134] Among them, the processor 301 may include one or more processing cores. The processor 301 connects various parts within the entire server using various interfaces and lines. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 305, and by calling the data stored in the memory 305, it performs various functions of the server and processes data. Optionally, the processor 301 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 301 may integrate a combination of one or several of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, and application programs, etc.; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 301 and may be implemented separately by a single chip.
[0135] Among them, the memory 305 may include random access memory (RAM) and may also include read-only memory. Optionally, the memory includes a non-transitory computer-readable storage medium. The memory 305 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 305 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-mentioned method embodiments, etc.; the data storage area may store the data involved in the above-mentioned method embodiments. The memory 305 may optionally also be at least one storage device located far from the aforementioned processor 301. The memory 305, as a computer storage medium, may include an operating system, a network communication module, a user interface 303 module, and an application program for a risk warning Q&A method based on a large language model.
[0136] InFigure 3 In the electronic device shown, the user interface 303 is mainly used to provide an interface for the user to input and obtain the data input by the user; and the processor 301 can be used to call the application program stored in the memory 305 for a risk warning Q&A method based on a large language model. When executed by one or more processors 301, the electronic device is caused to execute the method as described in one or more of the above embodiments.
[0137] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, certain steps can be adopted in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0138] In the above embodiments, the descriptions of the respective embodiments have their own focuses. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0139] In the several embodiments provided by this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some service interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical or other form.
[0140] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0141] In addition, the functional units in the respective embodiments of this application can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0142] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory 305 and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present application. And the aforementioned memory 305 includes: various media such as USB flash drives, mobile hard disks, magnetic disks, or optical discs that can store program codes.
[0143] The present application also discloses a computer-readable storage medium that stores instructions. When executed by one or more processors 301, it causes the electronic device to execute the method as described in one or more of the above embodiments.
[0144] The above are only exemplary embodiments of the present disclosure, and the scope of the present disclosure cannot be limited thereby. That is, any equivalent changes and modifications made in accordance with the teachings of the present disclosure still fall within the scope covered by the present disclosure. After considering the specification and the disclosure of the practical truth, those skilled in the art will easily think of other implementation schemes of the present disclosure. The present application aims to cover any variations, uses, or adaptive changes of the present disclosure, and these variations, uses, or adaptive changes follow the general principles of the present disclosure and include the common general knowledge or conventional technical means in the technical field not recorded in the present disclosure. The specification and the embodiments are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A risk warning Q&A method based on a large language model, characterized in that, The method includes: Converting different types of specialized documents into plain text data and performing text chunking to obtain multiple knowledge data chunks; Vectorizing the risk warning problem input by the user, performing similarity matching with the stored vector database, retrieving knowledge data chunks in multiple said knowledge data chunks whose similarity meets the preset conditions, and constructing optimized prompt data in combination with the risk warning problem; Inputting the prompt data into a preset first model to obtain the reply output of the preset first model; Using the prompt data and the reply output, and combining with the existing Q&A dataset, training a preset second model, and obtaining a Q&A model for risk warning after the training is completed.
2. The risk warning Q&A method based on a large language model according to claim 1, wherein The vectorizing the risk warning problem input by the user and performing similarity matching with the stored vector database specifically includes: Separating the real-time monitoring data collected by downhole sensors included in the risk warning problem; Performing semantic processing on the numerical information of the real-time monitoring data to generate a numerical description text; Performing vectorization processing on the numerical description text to obtain a first sub-vector; Performing vector processing on the descriptive text content included in the risk warning problem to obtain a second sub-vector; Fusing the first sub-vector and the second sub-vector to obtain a first vector; Calculating the similarity between the first vector and the second vector of the knowledge data chunk, so as to perform similarity matching between the knowledge data chunk and the risk warning problem.
3. The risk warning Q&A method based on a large language model according to claim 2, wherein, Before the performing semantic processing on the numerical information of the real-time monitoring data to generate a numerical description text, the method further includes: Analyzing the historical downhole monitoring data and the industry standards of the petroleum industry, calculating the relative deviation of the historical downhole monitoring data according to the downhole operation process parameters and warning thresholds corresponding to the historical downhole monitoring data to obtain a deviation rate; Extracting the change trend, fluctuation range and mutation points of the historical downhole monitoring data through statistical methods to obtain the trend characteristics of the historical downhole monitoring data; Constructing a text generation template and generating a descriptive text according to the deviation rate and the trend characteristics; Establishing a mapping relationship between the historical downhole monitoring data and the descriptive text to obtain a numerical conversion rule.
4. The risk warning Q&A method based on a large language model according to claim 3, characterized in that, The performing semantic processing on the numerical information of the real-time monitoring data to generate a numerical description text specifically includes: Matching the real-time monitoring data with the historical downhole monitoring data to determine the target historical monitoring data closest to the real-time monitoring data among multiple said historical downhole monitoring data; According to the numerical conversion rule, determining the descriptive text corresponding to the target historical monitoring data to obtain the numerical description text corresponding to the real-time monitoring data.
5. The risk warning Q&A method based on a large language model according to claim 1, wherein The retrieving knowledge data chunks in multiple said knowledge data chunks whose similarity meets the preset conditions and constructing optimized prompt data in combination with context information specifically includes: Performing structured parsing on the risk warning problem, and extracting multiple first modules through named entity recognition and dependency syntax analysis, where the first module includes at least one of a key entity, an abnormal description, time information, and a core parameter; Performing structural analysis on the target knowledge block to obtain multiple second modules, wherein the second modules include at least one of a key entity, an abnormality description, time information, and a core parameter, and the target knowledge block is a knowledge data block whose similarity meets a preset condition when searching for multiple knowledge data blocks; Aligning the plurality of the first modules with the plurality of the second modules, and using a templated construction method to generate initial prompt data through the aligned plurality of the first modules and the plurality of the second modules; The thinking chain reasoning strategy is introduced to obtain the prompt data by adding step-by-step reasoning guidance sentences to the initial prompt data.
6. The risk warning Q&A method based on a large language model according to claim 1, wherein The prompt data and the reply output are used, and combined with the existing question-answer data set, to train the preset second model. After the training is completed, a question-answer model for risk warning is obtained, which specifically includes: Constructing a question-answering dataset according to the prompt data, the reply output, and the question-answering dataset; Preprocessing the question-answer data set to obtain a processed data set; A lightweight fine-tuning method is adopted to train the preselected parameter matrix of the preset second model during the training of the preset second model through the processed data set. At the same time, the reply output is used as a soft label to train the question-answering model.
7. The risk warning Q&A method based on a large language model according to claim 6, characterized in that, The lightweight fine-tuning method is used to train the preselected parameter matrix of the preset second model during the training of the preset second model by the processed data set, specifically including: Setting the preselected parameter matrix, the preselected parameter matrix includes a query matrix, a key matrix and a value matrix; A matrix decomposition layer is added to the preselected parameter matrix to obtain a low-rank matrix, so as to train the low-rank matrix during the training process.
8. A risk warning Q&A device based on a large language model, characterized in that, The device is used to execute a risk warning question-answering method based on a large language model as described in any one of claims 1 to 7, and the device includes an acquisition module, a processing module, and an output module, wherein: The processing module is used to convert different types of specialized documents into plain text data and perform text block processing to obtain multiple knowledge data blocks; The processing module is used to vectorize the risk warning question input by the user, perform similarity matching with the stored vector database, retrieve the knowledge data blocks whose similarity meets the preset conditions from the plurality of knowledge data blocks, and construct optimized prompt data in combination with the risk warning question; The acquisition module is used to input the prompt data into the preset first model and obtain the reply output of the preset first model; The output module is used to adopt the prompt data and the reply output, and combine with the existing question and answer data set to train the preset second model, and obtain the question and answer model for risk warning after the training is completed.
9. An electronic device, characterized in that, It includes a processor, a communication bus, a user interface, a network interface, and a memory. The memory is used to store instructions. Both the user interface and the network interface are used to communicate with other devices. The communication bus is used to implement connection and communication between components within the electronic device. The processor is used to execute the instructions stored in the memory, so that the electronic device executes the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1-7 is executed.
Citation Information
Patent Citations
Intelligent question answering system based on large language model and knowledge graph black soil protection and utilization
CN118690851A
Multi-modal knowledge question and answer retrieval method and system for specific professional field
CN119621921A
Document data structured storage and retrieval method based on AI drive
CN119829723A
Data preprocessing method involving graph database, and a computer program recorded on a recording medium for executing the same
KR102732142B1
Apparatus, method and storage medium for data query
US20240330341A1
Cited By
Method and device for business risk processing, medium, equipment and program product
CN121071118A