Intelligent question answering method and system based on large mine safety model
By applying intelligent Q&A method based on the big mine safety model in the mining field, we process complex mine document data and generate similar questions, and solve the problem of accuracy and efficiency in processing highly professional and complex data, and achieve more efficient mine risk hazard question and answer.
Patent Information
- Application Number
- CN202411714978.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
AI Technical Summary
Data in the mining field is characterized by strong professionalism, complex format, unstructured, and diverse sources, which makes it difficult for the Q&A system to accurately extract key information related to the problem, which in turn affects the accuracy and efficiency of mine risk hazards.
The intelligent question-and-answer method based on the mine safety model is adopted to process mine document data through preprocessing, text segmentation, keyword extraction and title extraction, and similar questions are generated to cover more possible query intentions and expression methods, so as to improve the accuracy and efficiency of question-and-answer.
By effectively handling mining document data and generating similar questions, the accuracy and efficiency of mining risk hazard questions and answers are improved, and the accuracy and timeliness of information are ensured, thereby improving the management level and competitiveness of the entire mining industry.
Smart Images

Figure CN119646150A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet big data and mine management, and in particular to an intelligent question-answering method and system based on a mine safety big model. Background Art
[0002] With the development of the times, the status and role of energy resources in social development have become more prominent. Mines are the main source of mineral resources in my country. The core content of safety management of coal mine enterprises mainly includes risk classification control and hidden danger investigation and treatment.
[0003] In daily work at mines, workers usually need to manually retrieve relevant information from massive files, or conduct relevant data analysis to support management decisions, or train new employees on basic mining knowledge and skills. Mining work involves a large amount of knowledge and data, including policies, regulations, geological exploration reports, risk analysis, equipment maintenance, etc. Therefore, it is necessary to develop an intelligent question-and-answer system to effectively manage and share massive data, assist workers in retrieving and providing scientific advice in production scheduling, safety management, and cost control, improve work efficiency, and ensure the accuracy and timeliness of information, thereby improving the management level and competitiveness of the entire mining industry.
[0004] However, due to the particularity of the mining field, this work faces many challenges: 1) Data in the mining field are usually highly professional, complex in format, unstructured, and have diverse sources. Therefore, it is difficult to process and organize mining documents, which makes it difficult for the question-and-answer system to accurately extract key information related to the questions when answering user questions, which ultimately leads to poor accuracy and efficiency in answering questions about mining risks and hidden dangers. 2) The cultural level of mining practitioners is relatively low, and the questions they ask are more colloquial. The question-and-answer system may not be able to accurately understand the semantic needs of users when understanding and processing their questions, and it is easy to be unable to answer them, which also leads to poor accuracy in answering questions about mining risks and hidden dangers. Therefore, how to improve the accuracy and efficiency of questions and answers about mining risks and hidden dangers is a technical problem that needs to be solved urgently. Summary of the invention
[0005] In view of the above-mentioned deficiencies in the prior art, the technical problem to be solved by the present invention is: how to provide an intelligent question-answering method and system based on a large mine safety model, effectively process mine document data through preprocessing, text segmentation, keyword extraction and title extraction, and generate related questions based on user questions to cover more possible query intentions and expressions, thereby improving the accuracy and efficiency of mine risk and hidden danger questions and answers.
[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0007] An intelligent question-answering method based on a mine safety big model, comprising:
[0008] S1: construct a vector database based on the mine document dataset;
[0009] S2: Get the input user question and generate corresponding similar questions based on the user question;
[0010] S3: After combining similar questions and user questions, vectorization is performed to generate a user question vector;
[0011] S4: Based on the user question vector, the relevance of the text block is retrieved in the vector database to obtain the corresponding preliminary screening text block set;
[0012] S5: re-sorting the initially screened text block set to obtain a refined text block set;
[0013] S6: Input the user question and the re-ranked text block set into the large model for correlation analysis, output the text block most relevant to the user question and sort it by similarity to form a data set as the retrieval result.
[0014] Preferably, in step S1, a vector database is constructed by the following steps:
[0015] S101: reading a mine document in a mine document data set;
[0016] S102: pre-processing the mine documents;
[0017] S103: performing text segmentation on the preprocessed mine document to obtain a plurality of text blocks;
[0018] S104: extract keywords from the text block to obtain keyword metadata;
[0019] S105: extracting titles from the mine documents to obtain title metadata;
[0020] S106: Establishing an association relationship between the text block and the keyword metadata and the title metadata;
[0021] S107: Perform vectorization processing on the text block to obtain a text block vector; store the text block vector, keyword metadata and title metadata in a vector database.
[0022] Preferably, in step S103, the specific steps of text segmentation are as follows:
[0023] S1031: Determine the target length of the text block;
[0024] S1032: Preliminarily segment the mine document according to the target length to generate a series of text blocks;
[0025] S1033: For each text block that is initially segmented, if its character length exceeds the target length, recursively segment the text block: segment the current text block again according to the target length until all text blocks meet the length requirement;
[0026] S1034: Obtain all text blocks obtained after recursive segmentation; merge adjacent text blocks that are closer to the target length but not longer than the target length after merging;
[0027] S1035: Output all text blocks.
[0028] Preferably, in step S104, keyword extraction is achieved through the following steps:
[0029] S1041: Calculate the frequency of each word in the mine document to which it belongs;
[0030] The formula is:
[0031]
[0032] Where: TF(t,d) represents the word frequency of word t in mine document d; n represents the number of times word t appears; N represents the number of words in mine document d;
[0033] S1042: Calculate the inverse document frequency of each word in all mine documents;
[0034] The formula is:
[0035]
[0036] Where: IDF(t) represents the inverse document frequency of word t; D represents the total number of mine documents; df t represents the number of mine documents containing word t;
[0037] S1043: Multiply the word frequency and the inverse document frequency of each word to obtain the final score of the word;
[0038] The formula is:
[0039] TF-IDF(t,d)=TF(t,d)*IDF(t);
[0040] Where: TF-IDF(t,d) represents the final score of word t;
[0041] S1044: Use the words whose final scores exceed the threshold as keyword metadata.
[0042] Preferably, in step S105, title extraction is achieved through the following steps:
[0043] S1051: Determine whether the mine document is of Word type: if so, execute step S1052; otherwise, execute step S1053;
[0044] S1052: Read the XML information of each line of text in the mine document line by line; determine whether each line is a paragraph format or a title of a custom style according to the XML information; if it is determined to be a title and meets the length condition, use it as title metadata;
[0045] S1053: Segment the mine document to form multiple text segments; further segment each text segment into phrases according to line breaks; determine whether the phrase is a title; if determined to be a title, use the phrase as title metadata.
[0046] Preferably, in step S107, a pre-trained model is selected; a fine-tuning data set is constructed through a mine document data set; the pre-trained model is fine-tuned through the fine-tuning data set combined with a contrastive learning loss function to obtain a vector representation model suitable for mine document data; a text block is vectorized through the vector representation model to generate a text block vector;
[0047] The steps to construct a fine-tuning dataset are as follows:
[0048] S1061: Read the mine document in the mine document data set;
[0049] S1062: performing text segmentation on the mine document to obtain a plurality of text segments;
[0050] S1063: Generate a corresponding question query for each text segment using the large model;
[0051] S1064: Construct corresponding positive and negative sample pairs for each question query and true label as fine-tuning dataset;
[0052] The calculation formula of contrastive learning loss function is as follows:
[0053]
[0054] Where: (x i ,y i ) represents a positive sample pair, (x i ,y j ) represents a negative sample pair, x i For the problem, i The correct answer to the question is y j is the wrong answer to the question; K represents the number of sample pairs; S represents the distance function.
[0055] Preferably, in step S3, the user question is input into the large model, and a hypothetical answer is output; the user question and the hypothetical answer are combined in one prompt and input into the large model again, and several similar questions are output.
[0056] Preferably, in step S4, the specific steps of correlation retrieval are as follows:
[0057] S401: Preliminarily screening keyword metadata and title metadata according to the user question vector, and retaining the text block vector corresponding to the screened metadata;
[0058] S402: Calculate the similarity between the user question vector and the retained text block vector;
[0059] S403: taking the text blocks whose similarity exceeds the threshold as a set of pre-screened text blocks.
[0060] Preferably, in step S5, the specific steps of reordering are as follows:
[0061] S501: Selecting a text block corresponding to a text block vector having the largest inner product similarity with the user question vector from the initial screening text block set as the first text and adding it to the re-ranking set;
[0062] S502: For the remaining text blocks in the initial screening text block set, calculate the MMR value between each text block and the user question vector;
[0063] S503: Select the text block with the largest MMR value to add to the re-ranking set, and delete the text block from the initial screening text block set;
[0064] S504: repeating steps S502 to S503 until the initial screening text block set is empty;
[0065] S505: taking the user question vector and each text in the re-ranking set as the input of the Reranker model, and outputting the corresponding similarity score; re-ranking each text in the re-ranking set according to the similarity score to form a refined text block set.
[0066] The present invention also discloses an intelligent question-answering system based on a mine safety big model, which is implemented based on the intelligent question-answering method based on a mine safety big model in the present invention, and includes:
[0067] Vector database, used to store text block vectors, keyword metadata, and title metadata;
[0068] Question input module, used to obtain input user questions;
[0069] A similar question generation module is used to generate corresponding similar questions based on user questions;
[0070] The text block retrieval module is used to combine similar questions and user questions, and then perform vectorization processing to generate a user question vector; based on the user question vector, the relevance of the text block is retrieved in the vector database to obtain the corresponding preliminary screening text block set;
[0071] A reordering module is used to reorder the initially screened text block set to obtain a refined text block set;
[0072] The result output module is used to input the user question and the re-ranked text block set into the large model for correlation analysis, output the text block most relevant to the user question and sort it by similarity to form a data set as the retrieval result.
[0073] Compared with the prior art, the intelligent question-answering system based on the mine safety model in the present invention has the following beneficial effects:
[0074] The present invention can efficiently process mining data from different sources and in different formats by preprocessing mining documents such as data format conversion, OCR recognition and data cleaning, ensuring the neatness, integrity and accuracy of the data, thereby providing reliable support for subsequent data analysis and decision-making. The present invention proposes a string segmentation method, which uses a recursive segmentation and merging strategy to segment text into small blocks that meet the specified length limit without losing the original text characters; at the same time, the present invention uses metadata extraction algorithms for title extraction and keyword extraction to enhance the relevance to the target question, so as to improve the accuracy of subsequent questions and answers on mining risk hazards.
[0075] The present invention obtains user questions related to hidden risks in mines, and then generates corresponding similar questions based on the user questions, and then combines and vectorizes the similar questions and user questions. First, by generating multiple questions similar to the user questions and combining these questions with the user's original questions, more possible query intentions and expressions can be covered, thereby increasing the probability of retrieving relevant information. Secondly, the combined question set contains richer semantic information, which can more accurately capture the characteristics of this information during vectorization processing, and generate more accurate user question vectors, thereby improving the accuracy of subsequent questions and answers about hidden risks in mines. Finally, through vectorization processing, the text information is converted into a mathematical vector, and an efficient vector operation algorithm can be used for rapid retrieval, significantly improving the efficiency of retrieval and question answering.
[0076] On the basis of combining similar questions and user questions, the present invention further performs a relevance search of text blocks in a vector database based on user question vectors, and reorders the pre-screened text block set to obtain a refined text block set. First, the text blocks in the vector database are also vectorized, so the text block set related to the user question can be quickly screened out as the pre-screening result by calculating the similarity between the user question vector and the text block vector. Secondly, the reordering process can further screen and optimize the pre-screened text block set, and sort the text blocks according to factors such as the relevance and importance of the text blocks to the user questions, so as to obtain more accurate retrieval results, which is conducive to improving the accuracy of subsequent mine risk hidden danger questions and answers. Finally, through reordering, the most relevant and valuable text blocks are placed in the front, so that the large model can determine the required importance more quickly, thereby improving the accuracy and efficiency of subsequent mine risk hidden danger questions and answers.
[0077] On the basis of reordering the search results, the present invention further inputs the user questions and the reordered finely sorted text block set into the big model for correlation analysis, and finally outputs the text blocks most relevant to the user questions and sorts them by similarity to form a data set as the search results. First, the big model has a strong semantic understanding ability, which can accurately capture the deep semantic connection between the user questions and the text blocks, so as to more accurately judge the correlation between the text blocks and the user questions. Secondly, the big model can optimize and adjust the search results in a personalized way according to the specific expression and context information of the user questions, so that the results are more in line with the user's expectations and needs; and through the correlation analysis of the big model, the search results can be further verified and screened to ensure that the text block set finally output is highly relevant to the user questions and has reliable quality. Finally, the big model can sort the text blocks according to the similarity between the text blocks and the user questions. This sorting algorithm is more intelligent and accurate, and can ensure that the user sees the most relevant information first. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] In order to make the purpose, technical solution and advantages of the invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings, in which:
[0079] Figure 1 The network structure diagram of the intelligent question-answering method and system based on the mine safety big model;
[0080] Figure 2 Schematic diagram for metadata extraction;
[0081] Figure 3 Flowchart extracted for the title;
[0082] Figure 4 Schematic diagram of the prompt word;
[0083] Figure 5 A schematic diagram of a label;
[0084] Figure 6 This is the network structure diagram of the BGE model;
[0085] Figure 7 A schematic diagram for checking and marking the sorting results. DETAILED DESCRIPTION
[0086] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but only represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.
[0087] The following is a further detailed description through specific implementation methods:
[0088] Embodiment 1:
[0089] This embodiment discloses an intelligent question-answering method based on a large mine safety model.
[0090] like Figure 1 As shown in the figure, the intelligent question-answering method based on the mine safety big model includes:
[0091] S1: construct a vector database based on the mine document dataset;
[0092] S2: Obtain input user questions related to mine risk hazards, and generate corresponding similar questions based on the user questions;
[0093] S3: After combining similar questions and user questions, vectorization is performed to generate a user question vector;
[0094] S4: Based on the user question vector, the relevance of the text block is retrieved in the vector database to obtain the corresponding preliminary screening text block set;
[0095] S5: re-sorting the initially screened text block set to obtain a refined text block set;
[0096] S6: Input the user question and the re-ranked text block set into the Large Language Model (LLM) for correlation analysis, output the text block most relevant to the user question and sort it by similarity to form a data set as the retrieval result.
[0097] The present invention obtains user questions related to hidden risks in mines, and then generates corresponding similar questions based on the user questions, and then combines and vectorizes the similar questions and user questions. First, by generating multiple questions similar to the user questions and combining these questions with the user's original questions, more possible query intentions and expressions can be covered, thereby increasing the probability of retrieving relevant information. Secondly, the combined question set contains richer semantic information, which can more accurately capture the characteristics of this information during vectorization processing, and generate more accurate user question vectors, thereby improving the accuracy of subsequent questions and answers about hidden risks in mines. Finally, through vectorization processing, the text information is converted into a mathematical vector, and an efficient vector operation algorithm can be used for rapid retrieval, significantly improving the efficiency of retrieval and question answering.
[0098] On the basis of combining similar questions and user questions, the present invention further performs a relevance search of text blocks in a vector database based on user question vectors, and reorders the pre-screened text block set to obtain a refined text block set. First, the text blocks in the vector database are also vectorized, so the text block set related to the user question can be quickly screened out as the pre-screening result by calculating the similarity between the user question vector and the text block vector. Secondly, the reordering process can further screen and optimize the pre-screened text block set, and sort the text blocks according to factors such as the relevance and importance of the text blocks to the user questions, so as to obtain more accurate retrieval results, which is conducive to improving the accuracy of subsequent mine risk hidden danger questions and answers. Finally, through reordering, the most relevant and valuable text blocks are placed in the front, so that the large model can determine the required importance more quickly, thereby improving the accuracy and efficiency of subsequent mine risk hidden danger questions and answers.
[0099] On the basis of reordering the search results, the present invention further inputs the user questions and the reordered finely sorted text block set into the big model for correlation analysis, and finally outputs the text blocks most relevant to the user questions and sorts them by similarity to form a data set as the search results. First, the big model has a strong semantic understanding ability, which can accurately capture the deep semantic connection between the user questions and the text blocks, so as to more accurately judge the correlation between the text blocks and the user questions. Secondly, the big model can optimize and adjust the search results in a personalized way according to the specific expression and context information of the user questions, so that the results are more in line with the user's expectations and needs; and through the correlation analysis of the big model, the search results can be further verified and screened to ensure that the text block set finally output is highly relevant to the user questions and has reliable quality. Finally, the big model can sort the text blocks according to the similarity between the text blocks and the user questions. This sorting algorithm is more intelligent and accurate, and can ensure that the user sees the most relevant information first.
[0100] In order to better introduce the technical aspects of the present invention, this embodiment is described through the following parts.
[0101] 1. Vector Database
[0102] In this embodiment, the vector database is constructed through the following steps:
[0103] S101: reading a mine document in a mine document data set;
[0104] S102: pre-processing the mine documents;
[0105] In this embodiment, the preprocessing of the mine document includes data format conversion, OCR recognition and data cleaning.
[0106] S103: Text segmentation is performed on the preprocessed mining document to obtain a number of text blocks; through text segmentation, accurate matching is achieved during analysis, making the problem more accurate and more relevant.
[0107] S104: extract keywords from the text block to obtain keyword metadata;
[0108] S105: extracting titles from the mine documents to obtain title metadata;
[0109] S106: Establishing an association relationship between the text block and the keyword metadata and the title metadata;
[0110] S107: Perform vectorization processing on the text block to obtain a text block vector; store the text block vector, keyword metadata and title metadata in a vector database.
[0111] The present invention can efficiently process mining data from different sources and in different formats by preprocessing mining documents such as data format conversion, OCR recognition and data cleaning, ensuring the neatness, integrity and accuracy of the data, thereby providing reliable support for subsequent data analysis and decision-making. The present invention proposes a string segmentation method, which uses a recursive segmentation and merging strategy to segment text into small blocks that meet the specified length limit without losing the original text characters; at the same time, the present invention uses metadata extraction algorithms for title extraction and keyword extraction to enhance the relevance to the target question, so as to improve the accuracy of subsequent questions and answers on mining risk hazards.
[0112] 1. Data preprocessing
[0113] The sources of mine data are diverse and complex, including data from various sensors, monitoring equipment, manual records, and external databases. Therefore, the formats are different, such as text files, spreadsheets, images, scans, and PDFs, which brings many challenges to data loading and processing.
[0114] When loading data, ordinary text readers cannot recognize and process some data in scanned formats. In order to meet this challenge, the system of the present invention has built-in advanced optical character recognition (OCR) technology, which can be compatible with and process data in scanned formats, and convert it into editable text, thereby improving the availability and accuracy of the data. In addition, since most documents in mining companies are stored in the earlier doc format, and the doc format has some problems in data segmentation and processing. In order to solve this problem, an efficient format converter is built into this embodiment, which can seamlessly convert files in doc format to docx format. This conversion not only improves the compatibility of files, but also meets the requirements of data segmentation, making subsequent data processing smoother and more efficient.
[0115] After successfully reading the text data, some data contains a lot of useless information or noise due to irregular manual recording or inaccurate scan conversion, which affects the subsequent segmentation and vectorization. Therefore, data cleaning is required, including simplified and traditional Chinese font conversion, typo correction, special symbol processing, missing data processing, duplicate data deletion, etc.
[0116] Through the integration of these functions, the present invention can efficiently process mining data from different sources and in different formats, ensuring the neatness, completeness and accuracy of the data, thereby providing reliable support for subsequent data analysis and decision-making.
[0117] 2. Text segmentation
[0118] When processing large amounts of text data, especially for natural language processing (NLP) tasks, it is usually necessary to split long text into smaller chunks for subsequent processing and analysis. This embodiment provides an efficient string segmentation method that uses a recursive segmentation and merging strategy to segment text into small chunks that meet a specified length limit without losing the original text characters. This method is particularly suitable for processing large amounts of text data, ensuring data integrity and segmentation efficiency.
[0119] Specific, combined Figure 2 As shown, the specific steps of text segmentation are as follows:
[0120] S1031: Determine the target length of the text block, i.e., the maximum length limit (e.g., each small block does not exceed 200 characters);
[0121] S1032: Preliminarily segment the mine document according to the target length to generate a series of text blocks;
[0122] In this embodiment, a string slicing operation may be used to implement preliminary segmentation, such as text[i:i+target_length]. The character length of the text block may exceed or be exactly equal to the target length.
[0123] S1033: For each text block that is initially segmented, if its character length exceeds the target length, recursively segment the text block: segment the current text block again according to the target length until all text blocks meet the length requirement;
[0124] In this embodiment, the recursive termination condition is: the current block length is less than or equal to the target length.
[0125] S1034: Obtain all text blocks obtained after recursive segmentation; merge adjacent text blocks that are closer to the target length but not longer than the target length after merging;
[0126] In this embodiment, the purpose of merging is to optimize the length distribution of text blocks and reduce the problem of excessive length differences caused by preliminary segmentation. If the length of some blocks is still much smaller than the target length after merging, and the total length of these blocks does not exceed twice the target length, they can be considered to be merged into one block. For extremely small blocks that cannot be merged (for example, a single word or phrase), they can be retained as independent blocks because they may have specific semantics or format requirements.
[0127] S1035: Output all text blocks.
[0128] The present invention adopts a recursive segmentation strategy to ensure that each small block does not exceed the specified length and retains the integrity of the original text to the maximum extent. It supports multiple segmentation strategies, from paragraphs, sentences to single characters, to ensure the adaptability of various types of text. Through the merging strategy, it ensures that the segmented text blocks are as close to the specified length as possible, improving processing efficiency.
[0129] 3. Keyword extraction
[0130] In this embodiment, an effective keyword extraction scheme is adopted, which combines term frequency (TF) and inverse document frequency (IDF) to calculate the importance of a certain word in a document set.
[0131] Specific, combined Figure 2 As shown in the figure, keyword extraction is achieved through the following steps:
[0132] S1041: Calculate the frequency of each word in the mine document to which it belongs;
[0133] The formula is:
[0134]
[0135] Where: TF(t,d) represents the word frequency of word t in mine document d; n represents the number of times word t appears; N represents the number of words in mine document d; a high TF value means that the word appears more frequently in the document and may contribute more to the topic of the document.
[0136] S1042: Calculate the inverse document frequency of each word in all mine documents;
[0137] The formula is:
[0138]
[0139] Where: IDF(t) represents the inverse document frequency of word t; D represents the total number of mine documents; df t It indicates the number of mine documents containing word t. IDF is used to measure the prevalence of a word in the entire corpus. The higher the IDF, the more unique the word is and the greater its value in distinguishing documents.
[0140] S1043: Multiply the word frequency and the inverse document frequency of each word to obtain the final score of the word;
[0141] The formula is:
[0142] TF-IDF(t,d)=TF(t,d)*IDF(t);
[0143] Where: TF-IDF(t,d) represents the final score of word t;
[0144] S1044: The words whose final scores exceed the threshold are used as keyword metadata. Words with high scores usually appear frequently in the current document, but rarely appear in the entire corpus, and thus can be considered as keywords of the document.
[0145] The keyword extraction scheme of the present invention is simple and easy to understand, does not require complex calculations or a large amount of training data, and can be applied to various types of text data. In addition, by adjusting the inverse document frequency, the present invention can effectively reduce the weight of common words that frequently appear in the entire corpus, reducing interference with keyword extraction results. The present invention can effectively identify important words in a document, providing strong support for subsequent text processing and analysis.
[0146] 4. Title extraction
[0147] In this embodiment, combined with Figure 3 As shown, title extraction is achieved through the following steps:
[0148] S1051: Determine whether the mine document is of Word type: if so, execute step S1052; otherwise, execute step S1053;
[0149] S1052: Read the XML information of each line of text in the mine document line by line; determine whether each line is a paragraph format or a title of a custom style according to the XML information; if it is determined to be a title and meets the length condition, add it as title metadata to the title set of the corresponding segment;
[0150] S1053: Segment the mining document to form multiple text segments; further segment each text segment into phrases according to line breaks; determine whether the phrase is a title based on relevant algorithms (checking the length of the phrase, whether there is punctuation at the end of the phrase, the proportion of non-alphabetic characters in the phrase, etc.) or whether it is in the set S; if it is determined to be a title, add the phrase as title metadata to the title set of the corresponding segment.
[0151] The present invention adds the title information extracted from the fragment to the meta-information to enhance the relevance to the target question, so as to improve the accuracy of question and answer.
[0152] 2. Vector Representation Model
[0153] In this embodiment, after the text is segmented, each segment needs to be vectorized and stored. Vectorization in RAG refers to a method of using a pre-trained vectorization model (such as the Chinese vector representation model bge-large-zh) to achieve dynamic vectorization according to contextual semantics. When representing words by vectors, the model can understand polysemous words in combination with the current context, and achieve different contexts, and its vector will change. However, since such models are usually trained on large-scale general corpora, but in specific fields such as coal mining, there are some professional terms and concepts that are not common in general corpora, so it is necessary to fine-tune the general vectorization model according to the mine data to improve the recall accuracy.
[0154] Specifically, a pre-trained model is selected; a fine-tuning dataset is constructed through a mine document dataset; the pre-trained model is fine-tuned through the fine-tuning dataset combined with a contrastive learning loss function to obtain a vector representation model suitable for mine document data; the text block is vectorized through the vector representation model to generate a text block vector;
[0155] The steps to construct a fine-tuning dataset are as follows:
[0156] S1061: Read the mine document in the mine document data set;
[0157] S1062: performing text segmentation on the mine document to obtain a plurality of text segments;
[0158] S1063: Through the large model (hereinafter also referred to as LLM) and the prompting project, guide the LLM to generate corresponding question queries for each text segment; prompt words such as Figure 4 The question-answer pair generated in the above steps contains two fields: query anchor and related corpus positive. The related corpus field is used as a label in the form of Figure 5 shown.
[0159] S1064: Construct corresponding positive and negative sample pairs for each question query and true label as fine-tuning dataset;
[0160] The calculation formula of contrastive learning loss function is as follows:
[0161]
[0162] Where: (x i ,y i ) represents a positive sample pair, (x i ,y j ) represents a negative sample pair, x i For the problem, i The correct answer to the question is y j is the wrong answer to the question; K represents the number of sample pairs; S represents the distance function.
[0163] In this embodiment, an adapter is constructed for the Bert-like bge model, and its structure is as follows: Figure 6 As shown in the figure, it consists of a down-projection layer, two Transformer encoders, and an up-projection layer. When selecting a vector database, it is necessary to consider the accuracy and speed of the recall information as well as the complexity and unstructured characteristics of mining enterprise data. Select PG or Milvus vector database to achieve efficient processing of complex data types.
[0164] The present invention constructs a positive and negative sample pair for each query and true label, and calculates the contrastive learning loss based on the contrastive learning loss function as shown in the following formula, thereby fine-tuning the pre-trained vectorization model to obtain a vector representation model that is more suitable for mining data.
[0165] 3. User Question Input
[0166] In view of the relatively low cultural level of mining workers, in order to ensure that the intelligent question-answering system is easy to operate and understands the questions input by users as much as possible, the system should support voice and text input. First, the interface design should be simple and intuitive, and the operation steps should be simplified as much as possible. Secondly, through advanced natural language processing technology, the system can understand the user's intentions, correct input errors, and provide instant feedback. Support for multi-language and dialect recognition is also key to ensure that users of different languages and dialects can use it easily. In addition, the system should establish a comprehensive knowledge base of frequently asked questions and update it regularly to ensure the timeliness and accuracy of the content.
[0167] 4. User Question Conversion
[0168] In this embodiment, given an input query, the LLM may not understand its semantic requirements and may not be able to answer. In order to minimize such problems, the present invention optimizes through two methods: similar question generation and query routing. Similar question generation means that the LLM first provides a hypothetical answer (regardless of whether it is correct or not), and then combines the query and the generated answer in a prompt and sends it to the retrieval system, instructing the LLM to generate N questions related to the original query, and then sends them (+ the original query) all to the retrieval system. That is, the user's question is input into the large model, and a hypothetical answer is output; the user's question and the hypothetical answer are combined in a prompt and input into the large model again, and several similar questions are output. In this way, more documents can be retrieved from the vector database, and duplicate results can be deduplicated and other post-processing operations can be performed.
[0169] Query routing means that for complex questions, LLM will analyze the structure of the question, decompose the question, and select specified query tools for the decomposed sub-questions to retrieve more accurate answers.
[0170] 5. Similarity retrieval
[0171] In this embodiment, during the knowledge base search process, metadata is first screened. Metadata includes information such as the file name, title, and keywords of the document. By screening the metadata, obviously irrelevant or low-quality text blocks are quickly eliminated to ensure that the screened data is more relevant and accurate. Then, the screened text blocks are used for similarity retrieval, and the similarity between the text blocks and the query is calculated to further filter and sort. The similarity calculation can use Euclidean distance or cosine distance to measure the relevance between the text blocks and the query.
[0172] Specifically, the specific steps of relevance retrieval are as follows:
[0173] S401: Preliminarily screening keyword metadata and title metadata according to the user question vector, and retaining the text block vector corresponding to the screened metadata;
[0174] S402: Calculate the similarity between the user question vector and the retained text block vector;
[0175] In this embodiment, the similarity calculation may use Euclidean distance or cosine distance to measure the relevance between the text block and the query question.
[0176] S403: taking the text blocks whose similarity exceeds the threshold as a set of pre-screened text blocks.
[0177] The present invention adopts a two-step screening method, which not only improves the recall rate of data, but also ensures a high similarity between the retrieval results and the query questions, and ultimately improves the accuracy and efficiency of knowledge base retrieval.
[0178] 6. Reorder
[0179] In this embodiment, when the retriever retrieves multiple contexts from the indexed documents or data sets, these contexts may be very relevant to the query sent by the user, while others may be only less relevant or even completely irrelevant. The task of re-ranking is to evaluate the relevance of these contexts and give priority to the contexts that are most likely to help the model respond more accurately and relevantly, so that the language model can give priority to these top-ranked contexts when generating answers, thereby improving the accuracy and quality of the final response.
[0180] In order to enhance LLM's understanding of the mining field, the present invention labels some user query and recall data, trains a re-ranking model, calculates similarity scores, and realizes re-ranking of the recall fragments.
[0181] During use, experts check and mark the sorting results according to the re-sorting results, and construct data pairs with correct user questions and sorting results (related / irrelevant). Each constructed data pair mainly contains three parts: question, correct answer, and wrong answer, such as Figure 7 The re-ranking model is further fine-tuned to improve the retrieval accuracy of the mining domain knowledge base.
[0182] Specifically, the specific steps of reordering are as follows:
[0183] S501: Selecting a text block corresponding to a text block vector having the largest inner product similarity with the user question vector from the initial screening text block set as the first text and adding it to the re-ranking set;
[0184] S502: For the remaining text blocks in the initial screening text block set, calculate the MMR value between each text block and the user question vector;
[0185] S503: Select the text block with the largest MMR value to add to the re-ranking set, and delete the text block from the initial screening text block set;
[0186] S504: repeating steps S502 to S503 until the initial screening text block set is empty;
[0187] S505: taking the user question vector and each text in the re-ranking set as the input of the Reranker model, and outputting the corresponding similarity score; re-ranking each text in the re-ranking set according to the similarity score to form a refined text block set.
[0188] 7. Data Annotation Feedback
[0189] According to the question-answering results, with the help of domain experts, the data is annotated and feedback is given, and the correctly annotated question-answer pairs are added to the fine-tuning training samples. When the number of samples reaches a certain level, the Lora fine-tuning technology in parameter efficient fine-tuning (PEFT) is used to fine-tune the large model to make the model better adapt to the characteristics of mining data.
[0190] Embodiment 2:
[0191] This embodiment discloses an intelligent question-answering system based on a large mine safety model, which is implemented based on the intelligent question-answering method based on a large mine safety model described in the embodiment.
[0192] like Figure 1 As shown in the figure, the intelligent question-answering system based on the mine safety model includes:
[0193] Vector database, used to store text block vectors, keyword metadata, and title metadata;
[0194] Question input module, used to obtain input user questions;
[0195] A similar question generation module is used to generate corresponding similar questions based on user questions;
[0196] The text block retrieval module is used to combine similar questions and user questions, and then perform vectorization processing to generate a user question vector; based on the user question vector, the relevance of the text block is retrieved in the vector database to obtain the corresponding preliminary screening text block set;
[0197] A reordering module is used to reorder the initially screened text block set to obtain a refined text block set;
[0198] The result output module is used to input the user question and the re-ranked text block set into the large model for correlation analysis, output the text block most relevant to the user question and sort it by similarity to form a data set as the retrieval result.
[0199] The present invention obtains user questions related to hidden risks in mines, and then generates corresponding similar questions based on the user questions, and then combines and vectorizes the similar questions and user questions. First, by generating multiple questions similar to the user questions and combining these questions with the user's original questions, more possible query intentions and expressions can be covered, thereby increasing the probability of retrieving relevant information. Secondly, the combined question set contains richer semantic information, which can more accurately capture the characteristics of this information during vectorization processing, and generate more accurate user question vectors, thereby improving the accuracy of subsequent questions and answers about hidden risks in mines. Finally, through vectorization processing, the text information is converted into a mathematical vector, and an efficient vector operation algorithm can be used for rapid retrieval, significantly improving the efficiency of retrieval and question answering.
[0200] On the basis of combining similar questions and user questions, the present invention further performs a relevance search of text blocks in a vector database based on user question vectors, and reorders the pre-screened text block set to obtain a refined text block set. First, the text blocks in the vector database are also vectorized, so the text block set related to the user question can be quickly screened out as the pre-screening result by calculating the similarity between the user question vector and the text block vector. Secondly, the reordering process can further screen and optimize the pre-screened text block set, and sort the text blocks according to factors such as the relevance and importance of the text blocks to the user questions, so as to obtain more accurate retrieval results, which is conducive to improving the accuracy of subsequent mine risk hidden danger questions and answers. Finally, through reordering, the most relevant and valuable text blocks are placed in the front, so that the large model can determine the required importance more quickly, thereby improving the accuracy and efficiency of subsequent mine risk hidden danger questions and answers.
[0201] On the basis of reordering the search results, the present invention further inputs the user questions and the reordered finely sorted text block set into the big model for correlation analysis, and finally outputs the text blocks most relevant to the user questions and sorts them by similarity to form a data set as the search results. First, the big model has a strong semantic understanding ability, which can accurately capture the deep semantic connection between the user questions and the text blocks, so as to more accurately judge the correlation between the text blocks and the user questions. Secondly, the big model can optimize and adjust the search results in a personalized way according to the specific expression and context information of the user questions, so that the results are more in line with the user's expectations and needs; and through the correlation analysis of the big model, the search results can be further verified and screened to ensure that the text block set finally output is highly relevant to the user questions and has reliable quality. Finally, the big model can sort the text blocks according to the similarity between the text blocks and the user questions. This sorting algorithm is more intelligent and accurate, and can ensure that the user sees the most relevant information first.
[0202] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit the technical solution. Those skilled in the art should understand that those modifications or equivalent substitutions of the technical solution of the present invention that do not depart from the purpose and scope of the technical solution should be included in the scope of the claims of the present invention.
Claims
1. An intelligent question-answering method based on a mine safety big model, characterized in that: include: S1: construct a vector database based on the mine document dataset; S2: Get the input user question and generate corresponding similar questions based on the user question; S3: After combining similar questions and user questions, vectorization is performed to generate a user question vector; S4: Based on the user question vector, the relevance of the text block is retrieved in the vector database to obtain the corresponding preliminary screening text block set; S5: re-sorting the initially screened text block set to obtain a refined text block set; S6: Input the user question and the re-ranked text block set into the large model for correlation analysis, output the text block most relevant to the user question and sort it by similarity to form a data set as the retrieval result.
2. The intelligent question-answering method based on the mine safety big model according to claim 1, characterized in that: In step S1, a vector database is constructed by the following steps: S101: reading a mine document in a mine document data set; S102: pre-processing the mine documents; S103: performing text segmentation on the preprocessed mine document to obtain a plurality of text blocks; S104: extract keywords from the text block to obtain keyword metadata; S105: extracting titles from the mine documents to obtain title metadata; S106: Establishing an association relationship between the text block and the keyword metadata and the title metadata; S107: Perform vectorization processing on the text block to obtain a text block vector; store the text block vector, keyword metadata and title metadata in a vector database.
3. The intelligent question-answering method based on the mine safety big model as claimed in claim 2 is characterized by: In step S103, the specific steps of text segmentation are as follows: S1031: Determine the target length of the text block; S1032: Preliminarily segment the mine document according to the target length to generate a series of text blocks; S1033: For each text block that is initially segmented, if its character length exceeds the target length, recursively segment the text block: segment the current text block again according to the target length until all text blocks meet the length requirement; S1034: Obtain all text blocks obtained after recursive segmentation; merge adjacent text blocks that are closer to the target length but not longer than the target length after merging; S1035: Output all text blocks.
4. The intelligent question-answering method based on the mine safety big model as claimed in claim 2, characterized in that: In step S104, keyword extraction is achieved through the following steps: S1041: Calculate the frequency of each word in the mine document to which it belongs; The formula is: Where: TF(t,d) represents the word frequency of word t in mine document d; n represents the number of times word t appears; N represents the number of words in mine document d; S1042: Calculate the inverse document frequency of each word in all mine documents; The formula is: Where: IDF(t) represents the inverse document frequency of word t; D represents the total number of mine documents; df t represents the number of mine documents containing word t; S1043: Multiply the word frequency and the inverse document frequency of each word to obtain the final score of the word; The formula is: TF-IDF(t,d)=TF(t,t)*IDF(t); Where: TF-IDF(t,d) represents the final score of word t; S1044: Use the words whose final scores exceed the threshold as keyword metadata.
5. The intelligent question-answering method based on the mine safety big model as claimed in claim 2, characterized in that: In step S105, title extraction is achieved through the following steps: S1051: Determine whether the mine document is of Word type: if so, execute step S1052; otherwise, execute step S1053; S1052: Read the XML information of each line of text in the mine document line by line; determine whether each line is a paragraph format or a title of a custom style according to the XML information; if it is determined to be a title and meets the length condition, use it as title metadata; S1053: Segment the mine document to form multiple text segments; further segment each text segment into phrases according to line breaks; determine whether the phrase is a title; if determined to be a title, use the phrase as title metadata.
6. The intelligent question-answering method based on the mine safety big model as claimed in claim 5, characterized in that: In step S107, a pre-trained model is selected; a fine-tuning data set is constructed through the mine document data set; the pre-trained model is fine-tuned through the fine-tuning data set combined with the contrastive learning loss function to obtain a vector representation model suitable for the mine document data; the text block is vectorized through the vector representation model to generate a text block vector; The steps to construct a fine-tuning dataset are as follows: S1061: Read the mine document in the mine document data set; S1062: performing text segmentation on the mine document to obtain a plurality of text segments; S1063: Generate a corresponding question-answer pair for each text segment through the large model; the question-answer pair includes two fields, a query and a related corpus, and the related corpus field is used as a label; S1064: Construct corresponding positive and negative sample pairs for each query and true label as fine-tuning datasets; The calculation formula of contrastive learning loss function is as follows: Where: (x i ,y i ) represents a positive sample pair, (x i ,y j ) represents a negative sample pair, x i For the problem, i The correct answer to the question is y j is the wrong answer to the question; K represents the number of sample pairs; S represents the distance function.
7. The intelligent question-answering method based on the mine safety big model according to claim 1 is characterized in that: In step S3, the user question is input into the large model, and a hypothetical answer is output; the user question and the hypothetical answer are combined in a prompt and input into the large model again, and several similar questions are output.
8. The intelligent question-answering method based on the mine safety big model according to claim 1, characterized in that: In step S4, the specific steps of correlation retrieval are as follows: S401: Preliminarily screening keyword metadata and title metadata according to the user question vector, and retaining the text block vector corresponding to the screened metadata; S402: Calculate the similarity between the user question vector and the retained text block vector; S403: taking the text blocks whose similarity exceeds the threshold as a set of pre-screened text blocks.
9. The intelligent question-answering method based on the mine safety big model according to claim 1, characterized in that: In step S5, the specific steps of reordering are as follows: S501: Selecting a text block corresponding to a text block vector having the largest inner product similarity with the user question vector from the initial screening text block set as the first text and adding it to the re-ranking set; S502: For the remaining text blocks in the initial screening text block set, calculate the MMR value between each text block and the user question vector; S503: Select the text block with the largest MMR value to add to the re-ranking set, and delete the text block from the initial screening text block set; S504: repeating steps S502 to S503 until the initial screening text block set is empty; S505: taking the user question vector and each text in the re-ranking set as the input of the Reranker model, and outputting the corresponding similarity score; re-ranking each text in the re-ranking set according to the similarity score to form a refined text block set.
10. An intelligent question-answering system based on a mine safety big model, characterized by: The intelligent question-answering method based on the mine safety big model described in claim 1 is implemented, comprising: Vector database, used to store text block vectors, keyword metadata, and title metadata; Question input module, used to obtain input user questions; A similar question generation module is used to generate corresponding similar questions based on user questions; The text block retrieval module is used to combine similar questions and user questions, and then perform vectorization processing to generate a user question vector; based on the user question vector, the relevance of the text block is retrieved in the vector database to obtain the corresponding preliminary screening text block set; A reordering module is used to reorder the initially screened text block set to obtain a refined text block set; The result output module is used to input the user question and the re-ranked text block set into the large model for correlation analysis, output the text block most relevant to the user question and sort it by similarity to form a data set as the retrieval result.
Citation Information
Cited By
RAG retrieval method and device based on document block attribute tag and computer readable storage medium
CN120705335A
Fine tuning data set construction method for large question and answer model in aerospace control software field
CN121029926A
Knowledge base document intention recognition method based on layout recognition
CN121072695A
Cryptography intelligent question and answer method based on maximum marginal correlation retrieval
CN121958487A