Underground coal mine early warning data query method and system based on language large model

Through the method based on the large language model, the problem of insufficient intelligence and convenience in coal mine early warning data query is solved, and natural language query requests are quickly recognized and converted into SQL query statements, which improves query efficiency and accuracy and supports coal mines. Security management.

CN118733608APending Publication Date: 2024-10-01ZHENGZHOU HENGDA INTELLIGENT CONTROL TECHNOLOGY CO LTD +1

Patent Information

Application Number
CN202410722249.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

The traditional underground coal mine early warning data query method has problems such as low data structure, inflexible query methods, and reliance on professional skills, resulting in insufficient intelligence and convenience.

Method used

Using a method based on a large language model, natural language query requests are obtained through natural language processing technology to determine whether it is a data query problem. If so, match historical questions in the knowledge base or use a pre-trained language large model to generate SQL query statements and execute the query. and stores query results to enhance the knowledge base.

Benefits of technology

It improves the accuracy and efficiency of data query, reduces manual errors and time costs, enables non-technical personnel to easily query complex databases, improves data accessibility and system response time, enhances versatility, and supports coal mine safety monitoring and Accident prevention.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733608A_ABST
    Figure CN118733608A_ABST
Patent Text Reader

Abstract

The invention relates to a coal mine underground early warning data query method and system based on a language large model, and the system comprises a question receiving module which is used for receiving a query question of a user; the intention understanding module is used for analyzing the problem intention of the user; the SQL generation module is used for converting the natural language query input by the user into an SQL query statement; the early warning data query module is used for retrieving and screening early warning data corresponding to the SQL query statement from the database; the SQL statement storage module is used for storing query question-SQL data pairs; the knowledge base generation module is used for integrating the query problem-SQL data pairs in the SQL statement storage module to form a knowledge base; and iteratively training the language large model by a data set accumulated by the large model fine tuning module. All the modules cooperate with each other, so that the early warning data can be accurately queried through natural languages, and the intelligent level of coal mine underground early warning data query is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data query, and more specifically, to a method and system for querying underground coal mine warning data based on a large language model. Background Art

[0002] Today's society is in a stage of rapid advancement of artificial intelligence technology, with research and development in various fields deepening, especially focusing on several key technology branches, including but not limited to computer vision, natural language processing (NLP), robotics and automated control, etc. Among these branches, the core pursuit of natural language processing is to give machines the ability to understand and use natural language, so that they can communicate and process information effectively like humans.

[0003] Semantic parsing plays a vital role in the historical evolution of natural language processing. This technology is dedicated to converting the natural language used by people in daily life into a formalized logical expression that can be understood and executed by machines, that is, parsing natural language texts with complex meanings into a structured and unambiguous computer-readable form. This conversion process helps to eliminate the inherent ambiguity and ambiguity of natural language, allowing machines to accurately grasp the true intention of human language.

[0004] The practical application of semantic parsing technology is very extensive, covering not only traditional information retrieval and dialogue system construction, but also extending to intelligent decision-making, knowledge graph construction and query, etc. For example, in database management systems, SQL (Structured Query Language) is a standardized database operation language used to retrieve, update and manage information in the database. It is a specific form of natural language after semantic parsing, which can convert human query needs into computer-executable operation instructions, thereby achieving high interaction and intelligent management at the data level.

[0005] With the deepening of automation and informatization of coal mines, the real-time acquisition and accurate query of underground warning data have become an important part of coal mine safety management. However, traditional query methods have many limitations, such as low data structuring, inflexible query methods, and reliance on professional skills. Therefore, the present invention designs a coal mine underground warning data query method and system based on a language large model, aiming to solve the above problems and improve the intelligence and convenience of coal mine underground warning data query. Summary of the invention

[0006] The purpose of the present invention is to provide a method and system for querying coal mine underground early warning data based on a large language model, so as to solve the problem of insufficient intelligence and convenience of early warning data query in the prior art.

[0007] In order to solve the above problems, the coal mine underground early warning data query method based on the language large model involved in the present invention adopts the following technical solutions:

[0008] A method for querying coal mine underground warning data based on a language large model comprises the following steps:

[0009] Step S1: Obtain a natural language query request and standardize the original natural language text in the request;

[0010] Step S1: Obtain a natural language query request and standardize the original natural language text in the request;

[0011] Step S2: judging whether the natural language query request is a data query question from the standardized language text based on natural language processing technology, if so, executing step S3, if not, executing step S6;

[0012] Step S3: Match the input data query question with the historical questions in the knowledge base, and determine whether there are historical questions whose similarity with the input data query question exceeds a preset threshold. If so, sort the retrieved historical questions from high to low according to the similarity, select the historical question with the highest similarity, and obtain the SQL statement corresponding to it as the SQL query statement; if not, use the pre-trained language model and the basic table structure information of the database to generate the SQL query statement;

[0013] Step S4: Execute the SQL query statement, execute the SQL query statement, retrieve the relevant warning data corresponding to the SQL query statement from the coal mine underground warning database, if the query is successful through the SQL query statement and the expected result is obtained, then execute step S5, and filter and verify the validity of the query result;

[0014] Step S5: The SQL query statement and the corresponding original natural language query question are regarded as a valid data pair, i.e., a query question-SQL data pair, and the query question-SQL data pair is stored;

[0015] Step S6: Input the natural language request of non-data query into the open source conversational language big model, and output the result obtained from the open source conversational language big model to the user.

[0016] Preferably, in step S3, the input data query question is matched with the historical questions in the knowledge base to determine whether there are historical questions with a similarity exceeding a preset threshold with the input data query question. If there are historical questions, the retrieved historical questions are sorted from high to low according to the similarity, and the historical question with the highest similarity is selected to obtain the SQL statement corresponding to it as the SQL query statement; if there are no historical questions, a pre-trained language model is used to generate an SQL query statement in combination with the basic table structure information of the database, specifically including:

[0017] Step S31: converting the natural language text into a query question vector;

[0018] Step S32: Calculate the similarity between the query question vector and the question vector in the knowledge base. The calculation formula is as follows:

[0019]

[0020] Where a and b are two vectors of the problem, a·b represents the dot product of the vectors, and |a| and |b| are the norms of the vectors;

[0021] Step S33: Determine whether there are historical questions whose similarity to the input data query question exceeds a preset threshold. If so, sort the retrieved historical questions from high to low according to the similarity, and call the SQL statement corresponding to the question with the highest similarity in the knowledge base as the SQL query statement. If not, execute step S34;

[0022] Step S34: According to the user query request, combined with the basic configuration information of the database, the table structure in the database is obtained, and the prompt words of the language model are constructed using the obtained table structure. According to the user query question and the constructed prompt words, an SQL query statement is generated through the language model.

[0023] Preferably, the method further includes the step of constructing a knowledge base, specifically including:

[0024] The stored query question-SQL data pairs are obtained, the text is converted into vectors, the converted vectors and the corresponding SQL statements form a question vector-SQL data pair, which is verified, and the verified question vector-SQL data pairs are stored to form a knowledge base.

[0025] Preferably, the verification step of the question vector-SQL data pair specifically includes:

[0026] Provide a feedback mechanism in the user interface so that users can directly report problems with query results; the system automatically records the execution status of all SQL queries, including SQL statements that failed to execute, queries that took too long to execute, and the amount of data returned;

[0027] Classify the collected data into error types, including SQL mapping errors, unclear query intent, and inaccurate vector representation; use natural language processing tools to analyze the text of user feedback and extract key information, including query logic errors, incomplete data, and data update issues;

[0028] Use machine learning models to adjust the vector representation of question text and retrain the text vectorization model based on user feedback and the correct interpretation of query intent;

[0029] According to user feedback and correct query results, SQL query statements are regenerated, and the mapping relationship between relevant question vectors and SQL query statements in the knowledge base is updated.

[0030] Preferably, the method further includes a large language model training step, specifically including:

[0031] Perform data processing on the stored multiple query question-SQL data pairs, build a language model fine-tuning data set, convert the text of each query question into a vector, divide the data set into training set, validation set and test set in a ratio of 8:1:1, and when the data in the data set reaches the preset value, fine-tune the language model.

[0032] Preferably, data processing is performed on the stored multiple query question-SQL data pairs, and the data processing includes data cleaning, data correction and data enhancement, wherein the specific steps of data enhancement include:

[0033] Enhance the data by replacing synonyms, reorganizing sentences, or back-translating. Perform sample checks on the enhanced data to ensure that all generated query questions are semantically consistent with the original questions and grammatically correct. Use a small-scale validation set to compare the performance of the original model and the model trained with the enhanced data to ensure that data enhancement brings positive results.

[0034] Incorporate new query questions generated by data augmentation into the training dataset, update the distribution of the training set, validation set, and test set to ensure that they reflect the diversity of the augmented data, train the model using the augmented dataset, monitor various performance indicators during training, and evaluate the performance of the model trained with augmented data on an independent test set.

[0035] The present invention also provides a coal mine underground early warning data query system based on a language large model, comprising the following modules:

[0036] Question receiving module: obtains natural language query requests and standardizes the original natural language text in the request;

[0037] Intent understanding module: Based on natural language processing technology, it determines whether the natural language query request is a data query question from the standardized language text, and executes different dialogue query processes according to different results;

[0038] SQL generation module: uses a pre-trained large-scale language model to map natural language query questions into structured SQL query statements; there are two mapping methods, one is to call highly matched pre-stored SQL statements in the knowledge base, and the other is to use the language large model to automatically generate new SQL statements.

[0039] Early warning data query module: executes the SQL query statement generated by the SQL generation module, obtains early warning data from the database, and screens and verifies the query results;

[0040] SQL statement storage module: records and saves SQL statements that can be correctly executed and obtain the required warning data and their corresponding original query questions;

[0041] Knowledge base generation module: used to read and integrate the query question-SQL data pairs stored in the SQL statement storage module to create a knowledge base with self-learning capabilities;

[0042] Large model fine-tuning module: Regularly obtain query question-SQL data pairs in the SQL statement storage module to form a fine-tuning data set. When the data in the data set reaches the preset value, the language large model is fine-tuned and trained in stages based on the fine-tuning data set.

[0043] The beneficial effects of the present invention are as follows: the present invention uses natural language processing technology, and the method can quickly identify and process natural language query requests and convert them into valid SQL query statements. This not only reduces the errors and time costs of manual input, but also improves the accuracy and efficiency of queries. It enables non-technical personnel to easily query complex databases through natural language. Users do not need to understand SQL or the complex query syntax of the database to obtain the required information, which greatly improves the accessibility of data.

[0044] The system reuses valid queries by matching historical questions with corresponding SQL statements, reducing the consumption of computing resources. At the same time, the system's response time is optimized, improving the user experience. By storing query questions and SQL statements as valid data pairs, the system can continuously accumulate knowledge bases and improve the intelligence level of its problem handling and SQL generation. As the knowledge base expands, the accuracy of the model and problem handling capabilities will continue to improve.

[0045] For requests not related to data query, the system can use the open source dialogue language model to process, provide non-query information or conduct ordinary dialogue, which enhances the versatility of the system. By efficiently and accurately querying coal mine underground warning data, it helps to obtain key safety information in a timely manner, support coal mine safety monitoring and accident prevention work, thereby protecting worker safety and improving the management efficiency of mineral resources.

[0046] Overall, this method makes coal mine data query more intelligent, efficient and safe through technological innovation, greatly improving the company's operational efficiency and safety management level. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the following briefly introduces the drawings required for use in the embodiment:

[0048] Figure 1 It is a flow chart of a method for querying coal mine underground warning data based on a large language model according to a preferred embodiment of the present invention;

[0049] Figure 2 This is a flow chart of step S3 of a coal mine underground warning data query method based on a language large model in a preferred embodiment of the present invention;

[0050] Figure 3 It is a block diagram of the overall steps of a method for querying underground coal mine warning data based on a large language model according to a preferred embodiment of the present invention;

[0051] Figure 4 It is a structural block diagram of a coal mine underground early warning data query system based on a language large model according to a preferred embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the technical purpose, technical solution and beneficial effects of the present invention clearer, the technical solution of the present invention is further described below in conjunction with the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention, that is, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.

[0053] The coal mine underground warning data query method based on the language large model of the preferred embodiment of the present invention is as follows Figure 1 As shown, see Figure 2-3 , including the following steps:

[0054] Step S1: Obtain a natural language query request and standardize the original natural language text in the request;

[0055] Step S2: judging whether the natural language query request is a data query question from the standardized language text based on natural language processing technology, if so, executing step S3, if not, executing step S6;

[0056] Step S3: Match the input data query question with the historical questions in the knowledge base, and determine whether there are historical questions whose similarity with the input data query question exceeds a preset threshold. If so, sort the retrieved historical questions from high to low according to the similarity, select the historical question with the highest similarity, and obtain the SQL statement corresponding to it as the SQL query statement; if not, use the pre-trained language model and the basic table structure information of the database to generate the SQL query statement;

[0057] Step S4: Execute the SQL query statement, execute the SQL query statement, retrieve the relevant warning data corresponding to the SQL query statement from the coal mine underground warning database, if the query is successful through the SQL query statement and the expected result is obtained, then execute step S5, and filter and verify the validity of the query result;

[0058] Step S5: The SQL query statement and the corresponding original natural language query question are regarded as a valid data pair, i.e., a query question-SQL data pair, and the query question-SQL data pair is stored;

[0059] Step S6: Input the natural language request of non-data query into the open source conversational language big model, and output the result obtained from the open source conversational language big model to the user.

[0060] Through natural language processing technology, this method can quickly identify and process natural language query requests and convert them into valid SQL query statements. This not only reduces errors and time costs of manual input, but also improves the accuracy and efficiency of queries. It enables non-technical personnel to easily query complex databases through natural language. Users can obtain the required information without understanding SQL or the complex query syntax of the database, which greatly improves the accessibility of data.

[0061] The system reuses valid queries by matching historical questions with corresponding SQL statements, reducing the consumption of computing resources. At the same time, the system's response time is optimized, improving the user experience. By storing query questions and SQL statements as valid data pairs, the system can continuously accumulate knowledge bases and improve the intelligence level of its problem handling and SQL generation. As the knowledge base expands, the accuracy of the model and problem handling capabilities will continue to improve.

[0062] For requests not related to data query, the system can use the open source dialogue language model to process, provide non-query information or conduct ordinary dialogue, which enhances the versatility of the system. By efficiently and accurately querying coal mine underground warning data, it helps to obtain key safety information in a timely manner, support coal mine safety monitoring and accident prevention work, thereby protecting worker safety and improving the management efficiency of mineral resources.

[0063] Overall, this method makes coal mine data query more intelligent, efficient and safe through technological innovation, greatly improving the company's operational efficiency and safety management level.

[0064] like Figure 2 As shown, in step S3, the input data query question is matched with the historical questions in the knowledge base to determine whether there are historical questions with a similarity exceeding a preset threshold with the input data query question. If so, the retrieved historical questions are sorted from high to low according to the similarity, and the historical question with the highest similarity is selected to obtain the SQL statement corresponding to it as the SQL query statement; if not, the pre-trained language model is used to generate the SQL query statement in combination with the basic table structure information of the database, specifically including:

[0065] Step S31: Convert natural language text into query question vector; In this step, the input natural language text first needs to be converted into a mathematical expression, namely "query question vector". This is usually achieved through text embedding technology in natural language processing, such as using Word2Vec, BERT, or other deep learning models to extract text features and convert them into vector form. This step is necessary because computers process digital information. Through vectorization, the semantic information of the text can be encoded into numerical form for subsequent processing.

[0066] Step S32: Calculate the similarity between the query question vector and the question vector in the knowledge base. The calculation formula is as follows:

[0067]

[0068] Where a and b are the vectors of the two questions, a·b represents the dot product of the vectors, and |a| and |b| are the moduli of the vectors. This calculation method can measure the degree of proximity of the two vectors in direction, thereby determining the semantic similarity of the two questions.

[0069] In the present invention, the setting of the similarity threshold is obtained through multiple experimental tests and is finally set to 0.85. To improve the computational efficiency, the cosine_similarity function in the sklearn machine learning library is used to calculate the cosine similarity. In addition, as the knowledge base expands, Faiss (Facebook AI Similarity Search) is used to perform approximate nearest neighbor search to speed up the calculation.

[0070] Step S33: Determine whether there are historical questions whose similarity with the input data query question exceeds the preset threshold. If so, the retrieved historical questions are sorted from high to low according to the similarity, and the SQL statement corresponding to the question with the highest similarity in the knowledge base is called as the SQL query statement. If not, execute step S34; if one or more historical questions are found in the knowledge base and their similarity exceeds the preset threshold, this means that these historical questions are similar enough to the current question and their solutions can be used. The system sorts the retrieved historical questions from high to low according to the similarity, and calls the SQL statement corresponding to the question with the highest similarity as the SQL query statement for this query. If no sufficiently similar historical questions are found, the system will go to step S34.

[0071] Step S34: According to the user query request, combined with the basic configuration information of the database, the table structure in the database is obtained, and the prompt words of the language model are constructed using the obtained table structure. According to the user query question and the constructed prompt words, the SQL query statement is generated through the language model. In the case that there is no ready-made historical question available, the system needs to generate a new SQL query statement to respond to the user's query request. This step involves obtaining the table structure information in the database according to the basic configuration information of the database. Then, the prompt words of the language model are constructed using these table structure information. These prompt words help the large model understand how to generate effective SQL query statements from the structure of the database. For example, if the user's query is about the number of accidents in a certain period of time, the prompt words may include "time", "accident", and table names and field names related to these concepts. Then, in combination with the user's natural language query and the constructed prompt words, a logical SQL query statement is generated through the large model. In particular, the prompt words are mainly used to guide the model to generate output with specific content, style, structure or purpose by designing and constructing input prompts when interacting with a large language model.

[0072] The advantage of the SQL query statement method of the present invention is that it combines the use of historical data with the innovative application of new technologies, can respond quickly to known problems, and can also flexibly deal with new problems that have not been encountered before.

[0073] like Figure 3As shown, it also includes the steps of building a knowledge base, including:

[0074] The stored query question-SQL data pairs are obtained, the text is converted into vectors, the converted vectors and the corresponding SQL statements form a question vector-SQL data pair, which is verified, and the verified question vector-SQL data pairs are stored to form a knowledge base.

[0075] The process of obtaining stored query-SQL pairs involves collecting all verified query questions and their corresponding SQL query statements from the system's history. These pairs usually come from past user interactions, and each pair is a combination of an actual question and a SQL statement that was successfully executed and returned the correct result.

[0076] The collected query text is converted into a numerical vector through text vectorization technology. It is usually processed using open source models such as moka-ai / m3e-base, with the aim of capturing the semantic features of the text and converting it into a machine-processable form. After text vectorization, each question can be represented as a point in a high-dimensional space.

[0077] Pair each query vector with its corresponding SQL statement to form a new query vector-SQL data pair. This step actually creates a mapping relationship, which makes it easier for the system to quickly find and decide whether there are sufficiently similar historical queries to reuse their SQL statements when facing new queries.

[0078] Finally, these question vector-SQL data pairs are stored in the system's knowledge base. This knowledge base can be implemented using traditional database management systems such as MySQL, PostgreSQL, or more modern solutions such as NoSQL databases (such as MongoDB). The key is to ensure fast retrieval and efficient management of data.

[0079] Therefore, the knowledge base of the present invention can not only provide powerful support for the query system, but also continuously evolve and optimize over time to better serve the needs of coal mine underground warning data query.

[0080] In this embodiment, the verification step of the question vector-SQL data pair specifically includes:

[0081] Provide a feedback mechanism in the user interface so that users can directly report problems with query results; the system automatically records the execution status of all SQL queries, including SQL statements that failed to execute, queries that took too long to execute, and the amount of data returned;

[0082] Classify the collected data into error types, including SQL mapping errors, unclear query intent, and inaccurate vector representation; use natural language processing tools to analyze the text of user feedback and extract key information, including query logic errors, incomplete data, and data update issues;

[0083] Use machine learning models to adjust the vector representation of question texts, retrain the text vectorization model based on user feedback and the correct interpretation of query intent, and optimize the performance of the text vectorization model by adding more training samples;

[0084] According to user feedback and correct query results, SQL query statements are regenerated, and the mapping relationship between relevant question vectors and SQL query statements in the knowledge base is updated.

[0085] Once verified, deploy the adjusted model and SQL mapping to the production environment. Monitor the performance after deployment to ensure that the improvements are effective in actual applications.

[0086] Continuously monitor system performance and user feedback, and iterate and optimize vector representations and SQL mappings using newly collected data. Regularly evaluate and adjust machine learning models and query processing strategies to respond to data changes or new user needs.

[0087] Through this detailed step-by-step approach, the system can effectively learn and adapt to changes in user needs, continuously improve the accuracy and efficiency of queries, and thus provide more reliable and efficient services.

[0088] In this embodiment, a language large model training step is also included, specifically including:

[0089] Data processing is performed on the stored multiple query-SQL data pairs (standard text preprocessing is performed on the query questions, including removal of stop words, punctuation, stem extraction or word form restoration, and other cleaning measures to improve data quality), and a language large model fine-tuning dataset is constructed. The text of each query question is converted into a vector using existing text vectorization technology (such as moka-ai / m3e-base, etc.), and the dataset is divided into training set, validation set, and test set in a ratio of 8:1:1. When the data in the dataset reaches the preset value (such as adding 500 query-SQL data pairs for each data processing), the language large model is fine-tuned and trained, and the model is fine-tuned using the training set. When fine-tuning, a transfer learning strategy can be adopted, that is, on the basis of a pre-trained large model (such as GPT or BERT), it is adapted to the specific task of underground coal mine warning by continuing training. This includes adjusting the last few layers of the model or adding new layers to better handle the SQL generation task.

[0090] The fine-tuning parameters of the large model in the present invention are set as follows:

[0091] 1. The number of iterations is set to 100.

[0092] 2. Select Adam as the optimizer.

[0093] 3. The initial learning rate range is set to [0.01, 0.03, 0.06, 0.1, 0.3, 0.6], which is determined by the grid search method, and the final initial learning rate is 0.06. During the training process, a dynamic learning rate adjustment strategy is used to decay the learning rate, which can slow down the update speed of model parameters in the later stage of training and help the model converge to a better solution.

[0094] 4. To prevent overfitting, L2 regularization and Dropout mechanism are introduced during the training process.

[0095] 5. Use the early stopping strategy to monitor the performance of the validation set. When the performance of the validation set no longer improves after 10 consecutive epochs, terminate the training early to prevent overfitting.

[0096] 6. The k-fold cross validation method is used to ensure the stability of the model performance evaluation. In this patent, k is taken as 10.

[0097] The coal mine underground early warning data query system based on the language large model described in the patent of this invention can be deployed on different servers through detailed functional module division, which greatly optimizes the structural design and development process of the system. Using a standard data transmission interface, each functional module is connected in series, and each functional module has clear responsibilities and is independent of each other, which greatly improves the flexibility and scalability of the system. In addition, in the actual operation and maintenance stage, each module can be independently upgraded, tested and maintained, which also helps to reduce the time cost of system troubleshooting.

[0098] After each stage of model training, use the validation set to test the performance of the model. Adjust model parameters such as learning rate, batch size, etc. according to the validation results to optimize model performance. If the model performance does not improve significantly in several consecutive validation cycles, stop training to prevent overfitting.

[0099] In this embodiment, data processing is performed on the stored multiple query question-SQL data pairs, and the data processing includes data cleaning, data correction and data enhancement, wherein the specific steps of data enhancement include:

[0100] Enhance the data by replacing synonyms, reorganizing sentences, or back-translating. Perform sample checks on the enhanced data to ensure that all generated query questions are semantically consistent with the original questions and grammatically correct. Use a small-scale validation set to compare the performance of the original model and the model trained with the enhanced data to ensure that data enhancement brings positive results.

[0101] Incorporate new query questions generated by data augmentation into the training dataset, update the distribution of the training set, validation set, and test set to ensure that they reflect the diversity of the augmented data, train the model using the augmented dataset, monitor various performance indicators during training, and evaluate the performance of the model trained with augmented data on an independent test set.

[0102] The language model can use model integration technology, including BERT, GPT-3 and a custom model based on Transformer. When training the language model, each model is trained and predicted independently. Using the soft voting integration strategy, the probability output of the SQL conversion of each model prediction query will be weighted and summed, and the weight can be determined based on the performance on the validation set. Finally, the SQL query with the highest probability is selected as the output result.

[0103] In this way, model integration can effectively utilize the advantages of different models and improve the overall performance and robustness of the system, which is particularly suitable for handling complex and changeable coal mine underground data query tasks.

[0104] The present invention also provides an embodiment of a coal mine underground early warning data query system based on a language large model, comprising the following modules:

[0105] Question receiving module: obtains natural language query requests and standardizes the original natural language text in the request;

[0106] Intent understanding module: Based on natural language processing technology, it determines whether the natural language query request is a data query question from the standardized language text, and executes different dialogue query processes according to different results;

[0107] SQL generation module: uses a pre-trained large-scale language model to map natural language query questions into structured SQL query statements; there are two mapping methods, one is to call highly matched pre-stored SQL statements in the knowledge base, and the other is to use the language large model to automatically generate new SQL statements.

[0108] Early warning data query module: executes the SQL query statement generated by the SQL generation module, obtains early warning data from the database, and screens and verifies the query results;

[0109] SQL statement storage module: records and saves SQL statements that can be correctly executed and obtain the required warning data and their corresponding original query questions;

[0110] Knowledge base generation module: used to read and integrate the query question-SQL data pairs stored in the SQL statement storage module to create a knowledge base with self-learning capabilities;

[0111] Large model fine-tuning module: Regularly obtain query question-SQL data pairs in the SQL statement storage module to form a fine-tuning data set. When the data in the data set reaches the preset value, the language large model is fine-tuned and trained in stages based on the fine-tuning data set.

[0112] On the basis of the above embodiments, the present invention also discloses a coal mine underground early warning data query system based on a language large model. As an implementable method, the system needs to display the data query results more intuitively through an interface. In addition, some security protection measures are required to ensure the security and stability of the system. Therefore, the system includes the following functions:

[0113] (1) Login authorization function: users need to enter the authorized account and password to log in to the system. Only users with corresponding permissions can enter the system to operate, preventing illegal personnel from performing malicious operations.

[0114] (2) Enter the query question. Enter the question the user wants to query in the input box.

[0115] (3) Display the query results. Display the query results on the dialogue interface, including text information and warning picture information.

[0116] (4) Quick query question setting: users can set frequently used query questions in advance according to their query preferences. When they need to query data, they can directly click on the preset query questions to conduct the query.

[0117] (5) The system has a complete log recording function to record the system's operating behaviors, including login, query, etc., to detect abnormal operations in a timely manner and ensure the safe and stable operation of the system.

[0118] Users can enter the questions they want to query in the input box at the bottom of the system interface and click the send button to query the question.

[0119] The coal mine underground early warning data query system based on the language large model described in the patent of this invention can be deployed on different servers through detailed functional module division, which greatly optimizes the structural design and development process of the system. Using a standard data transmission interface, each functional module is connected in series, and each functional module has clear responsibilities and is independent of each other, which greatly improves the flexibility and scalability of the system. In addition, in the actual operation and maintenance stage, each module can be independently upgraded, tested and maintained, which also helps to reduce the time cost of system troubleshooting.

[0120] Finally, it should be noted that the above embodiments are only used to illustrate but not limit the technical solutions of the present invention, and any equivalent substitutions of the present invention and any modifications or partial substitutions that do not depart from the spirit and scope of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. A method for querying underground coal mine warning data based on a large language model, characterized in that: The following steps are involved: Step S1: Obtain a natural language query request and standardize the original natural language text in the request; Step S2: judging whether the natural language query request is a data query question from the standardized language text based on natural language processing technology, if so, executing step S3, if not, executing step S6; Step S3: Match the input data query question with the historical questions in the knowledge base, and determine whether there are historical questions whose similarity with the input data query question exceeds a preset threshold. If so, sort the retrieved historical questions from high to low according to the similarity, select the historical question with the highest similarity, and obtain the SQL statement corresponding to it as the SQL query statement; if not, use the pre-trained language model and the basic table structure information of the database to generate the SQL query statement; Step S4: Execute the SQL query statement, execute the SQL query statement, retrieve the relevant warning data corresponding to the SQL query statement from the coal mine underground warning database, if the query is successful through the SQL query statement and the expected result is obtained, then execute step S5, and filter and verify the validity of the query result; Step S5: The SQL query statement and the corresponding original natural language query question are regarded as a valid data pair, i.e., a query question-SQL data pair, and the query question-SQL data pair is stored; Step S6: Input the natural language request of non-data query into the open source conversational language big model, and output the result obtained from the open source conversational language big model to the user.

2. The method for querying underground coal mine warning data based on a language large model according to claim 1 is characterized in that: In step S3, the input data query question is matched with the historical questions in the knowledge base to determine whether there are historical questions with a similarity exceeding a preset threshold with the input data query question. If there are historical questions, the retrieved historical questions are sorted from high to low according to the similarity, and the historical question with the highest similarity is selected to obtain the SQL statement corresponding to it as the SQL query statement; if there are no historical questions, the pre-trained language model is used to generate the SQL query statement in combination with the basic table structure information of the database, which specifically includes: Step S31: converting the natural language text into a query question vector; Step S32: Calculate the similarity between the query question vector and the question vector in the knowledge base. The calculation formula is as follows: Where a and b are two vectors of the problem, a·b represents the dot product of the vectors, and |a| and |b| are the norms of the vectors; Step S33: Determine whether there are historical questions whose similarity to the input data query question exceeds a preset threshold. If so, sort the retrieved historical questions from high to low according to the similarity, and call the SQL statement corresponding to the question with the highest similarity in the knowledge base as the SQL query statement. If not, execute step S34; Step S34: According to the user query request, combined with the basic configuration information of the database, the table structure in the database is obtained, and the prompt words of the language model are constructed using the obtained table structure. According to the user query question and the constructed prompt words, an SQL query statement is generated through the language model.

3. The method for querying underground coal mine warning data based on a language large model according to claim 1 is characterized in that: It also includes the steps of building a knowledge base, including: The stored query question-SQL data pairs are obtained, the text is converted into vectors, the converted vectors and the corresponding SQL statements form a question vector-SQL data pair, which is verified, and the verified question vector-SQL data pairs are stored to form a knowledge base.

4. The method for querying underground coal mine warning data based on a language large model according to claim 1 is characterized in that: It also includes the steps of training a large language model, including: Perform data processing on the stored multiple query question-SQL data pairs, build a language model fine-tuning data set, convert the text of each query question into a vector, divide the data set into training set, validation set and test set in a ratio of 8:1:1, and when the data in the data set reaches the preset value, fine-tune the language model.

5. The method for querying underground coal mine warning data based on a language large model according to claim 1 is characterized in that: The preset threshold for the similarity between historical questions and input data query questions is 0.

85.

6. A coal mine underground early warning data query system based on a language large model, based on the coal mine underground early warning data query method based on a language large model according to any one of claims 1 to 5, characterized in that: Includes the following modules: Question receiving module: obtains natural language query requests and standardizes the original natural language text in the request; Intent understanding module: Based on natural language processing technology, it determines whether the natural language query request is a data query question from the standardized language text, and executes different dialogue query processes according to different results; SQL generation module: uses a pre-trained large-scale language model to map natural language query questions into structured SQL query statements; there are two mapping methods, one is to call highly matched pre-stored SQL statements in the knowledge base, and the other is to use the language large model to automatically generate new SQL statements. Early warning data query module: executes the SQL query statement generated by the SQL generation module, obtains early warning data from the database, and screens and verifies the query results; SQL statement storage module: records and saves SQL statements that can be correctly executed and obtain the required warning data and their corresponding original query questions; Knowledge base generation module: used to read and integrate the query question-SQL data pairs stored in the SQL statement storage module to create a knowledge base with self-learning capabilities; Large model fine-tuning module: Regularly obtain query question-SQL data pairs in the SQL statement storage module to form a fine-tuning data set. When the data in the data set reaches the preset value, the language large model is fine-tuned and trained in stages based on the fine-tuning data set.

Citation Information

Patent Citations

  • Intelligent coal mine method based on local knowledge base and natural language processing large model

    CN117891956A

  • Natural language intelligent query method and device based on multi-agent interaction

    CN118012900A

  • Automatic opening and shutting system for ventilation window according to state change of outdoor room

    KR1020220003244A

  • KR20220109179A

Cited By

  • Materialized view selection method and system based on large model

    CN118916385A

  • A materialized view selection method and system based on large model

    CN118916385B

  • Intelligent query method and system based on large model and retrieval enhancement technology

    CN119003743A

  • Method for automatically analyzing zero sample text to SQL (Structured Query Language) based on large language model

    CN119248817A

  • A zero-shot text-to-SQL automatic parsing method based on large language model

    CN119248817B