A graph-structure-based enhanced question-answering retrieval system and method for the construction industry safety.
By constructing a graph-based question-and-answer retrieval enhancement generation system for the construction industry, and utilizing large language models and knowledge graph technology, the problem of difficulty in finding construction safety management regulations was solved. This system enables fast and accurate retrieval of safety management regulations and SQL queries, thereby improving the efficiency and reliability of safety management results at construction sites.
Patent Information
- Application Number
- CN202510121892.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2045-01-26
AI Technical Summary
Existing construction safety management standards are presented in the form of unstructured text data, which makes it difficult to search and cannot meet the timeliness and diversity of construction site safety management. Existing technologies cannot quickly and accurately retrieve standards and measures related to specific safety management issues.
A graph-based question-and-answer retrieval enhancement generation system for construction safety is constructed. Entity and relation information is extracted from historical construction safety management data using a large language model, a knowledge graph is built and communities are divided, a summary is generated, similarity is calculated and ranked using vector representation, SQL query statements are generated for retrieval and reasoning, and consistency voting is combined to improve accuracy and robustness.
It enables rapid and accurate retrieval of construction safety management standards, improves the efficiency of safety management at construction sites, ensures the timely detection and handling of safety hazards, reduces the error rate, and improves the reliability and diversity of results.
Smart Images

Figure CN120067250B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of construction industry safety management technology, specifically to a graph-based construction industry safety question-and-answer retrieval enhancement generation system and method. Background Technology
[0002] In the field of construction engineering, as society places increasingly higher demands on the safety of construction projects, the importance of construction safety management has become increasingly prominent. Construction engineering is a comprehensive production activity involving multiple disciplines, characterized by long construction cycles and numerous uncertainties during the construction process, leading to significant challenges in on-site safety management. Construction safety has long been a major concern in engineering projects. Currently, construction safety regulations and accident reports are continuously accumulating, generating a vast amount of information and data on construction safety management, recording the situation and containing a wealth of safety management experience. Simultaneously, to standardize on-site safety management processes, relevant national departments and industry organizations have promulgated numerous industry-specific safety management regulations and standards, incorporating many new ideas and methods for safety management, which can effectively and accurately guide the on-site safety management process.
[0003] In practical applications, the utilization rate of information and data in construction safety management is low, and a large amount of hidden critical information remains untapped. To improve the efficiency of information and data utilization in construction safety management, managers have established information databases for the systematic management of text data. With the development of artificial intelligence technology, information and data in construction safety management are beginning to move away from traditional manual processing methods. Intelligent methods and technologies are being used to deeply mine the content, improving the efficiency of information and data acquisition in construction safety management and ensuring the real-time nature of safety management work.
[0004] Currently, during the construction of large-scale infrastructure projects, numerous sudden and high-risk safety hazards and management issues arise, requiring timely identification and corresponding solutions. Existing construction safety management standards provide a large number of safety management measures, effectively guiding on-site safety management tasks. However, because these standards are mostly presented in unstructured text data and are numerous, manual searching for specific safety management issues is time-consuming and laborious, failing to meet the timeliness requirements of on-site safety management. Furthermore, the diversity of on-site safety management issues requires comprehensive and multi-faceted analysis, further increasing the difficulty of finding relevant safety management standards.
[0005] To avoid the difficulty in finding safety management regulations during construction, which could lead to the failure to promptly identify and address safety hazards and cause significant economic losses and safety accidents, those skilled in the art have been seeking a method for intelligent question answering in the construction industry based on graph structure retrieval enhancement. This method would enable the rapid and accurate retrieval of regulations and measures related to specific safety management issues, thereby improving the efficiency and level of construction safety management and meeting the need for rapid response to safety management regulations during construction. Summary of the Invention
[0006] The purpose of this invention is to provide a graph-based construction industry safety question-and-answer retrieval enhancement generation system and method, which can quickly and accurately retrieve regulations and measures related to specific safety management issues, providing an effective guarantee for rapid response to safety management regulations during construction.
[0007] The graph-based construction industry safety question-answering retrieval enhancement generation system designed by this invention to achieve one of the above objectives is characterized by including:
[0008] The construction module is used to extract entity and relation information from historical construction safety management data through a large language model, construct a construction safety management knowledge graph based on the extracted entity and relation information, divide the construction safety management knowledge graph into communities to obtain a hierarchical community structure of the construction safety management knowledge graph, generate a summary corresponding to each community in the hierarchical community structure through the large language model, and add the summary to the information of each community to obtain a hierarchical construction safety management knowledge graph, and convert the hierarchical construction safety management knowledge graph into a vector representation of the hierarchical construction safety management knowledge graph;
[0009] The extraction module is used to convert construction safety management queries into vector representations of construction safety management queries; calculate the similarity between the vector representations of the construction safety management queries and the vector representations of the hierarchical knowledge graph of construction safety management; sort the vector representations of the hierarchical knowledge graph of construction safety management based on the similarity calculation results; and filter the sorted vector representations of the hierarchical knowledge graph of construction safety management based on the similarity calculation results to obtain multiple communities of the hierarchical knowledge graph of construction safety management that meet the similarity requirements; perform reverse index mapping on the communities of the multiple hierarchical knowledge graphs of construction safety management, and retrieve entity information and relationship information of the multiple hierarchical knowledge graphs of construction safety management that meet the similarity requirements from the communities of the multiple hierarchical knowledge graphs of construction safety management.
[0010] The reasoning module combines entity and relation information from multiple hierarchical knowledge graphs of construction safety management with construction safety management query statements to obtain construction safety management question statements. It then uses a large language model to reason about these question statements and generates multiple corresponding construction safety management SQL query statements based on different temperature coefficients of the large language model. Finally, it executes each construction safety management SQL query statement in the construction safety management historical database to obtain multiple construction safety management SQL query results.
[0011] Furthermore, the inference module is also used to perform consistency voting on multiple construction safety management SQL query results to obtain the construction safety management SQL target query result.
[0012] Furthermore, the inference module performs consistency voting on multiple construction safety management SQL query results, including: traversing the construction safety management SQL query results, counting the number of times each construction safety management SQL query result appears, sorting them in descending order of the number of occurrences, and taking the construction safety management SQL query result with the most occurrences as the construction safety management SQL target query result.
[0013] Furthermore, the aforementioned system also includes a feedback module; the feedback module is used to determine the correctness of the construction safety management SQL target query result according to user requirements. When the determination is correct, the corresponding construction safety management SQL query statement and construction safety management query statement are added to the construction safety management historical data; when the determination is incorrect, the corresponding construction safety management SQL query statement and construction safety management query statement are not added to the construction safety management historical data, and a new construction safety management SQL query statement is generated.
[0014] Furthermore, the aforementioned system also includes: a processing module; the processing module is used to generate construction safety management questions from the collected historical construction safety management data using a large language model, write corresponding construction safety management SQL query statements based on the construction safety management questions, match the construction safety management questions and construction safety management SQL query statements to obtain construction safety management question-answer pair sample data; and perform text block segmentation on the historical construction safety management data and the construction safety management question-answer pair sample data based on a text block segmentation strategy to obtain preprocessed historical construction safety management data.
[0015] Furthermore, the construction module constructs a construction safety management knowledge graph based on the extracted entity information and relationship information, including: using entities as nodes of the knowledge graph, using the relationships between entities as edges of the knowledge graph, mapping entities and relationships to the knowledge graph, and constructing the construction safety management knowledge graph.
[0016] Furthermore, the construction module divides the construction safety management knowledge graph into communities, including: clustering all nodes in the construction safety management knowledge graph using a graph clustering algorithm, grouping nodes with the same representative meaning into a community, and decomposing the communities multiple times according to the granularity of the community decomposition to form multi-level communities, thus obtaining a hierarchical community structure of the construction safety management knowledge graph; the construction module generates summaries corresponding to each community in the hierarchical community structure through a large language model, including: combining entity information and relational information within each community, generating summaries corresponding to each community through a large language model, and adding them to the information of each community.
[0017] Furthermore, the extraction module calculates the similarity between the vector representation of the construction safety management query statement and the vector representation of the hierarchical knowledge graph of construction safety management, as shown in the following formula:
[0018]
[0019] Wherein, similarity(A,B) represents the similarity between the vector representation of the construction safety management query statement and the vector representation of the construction safety management hierarchical knowledge graph, A represents the vector representation of the construction safety management query statement, B represents the vector representation of the construction safety management hierarchical knowledge graph, ||A|| represents the magnitude of the vector representation of the construction safety management query statement, and ||B|| represents the magnitude of the vector representation of the construction safety management hierarchical knowledge graph.
[0020] The graph-based question-answering retrieval enhancement generation method for the construction industry, designed to achieve the second objective mentioned above, is characterized by the following steps:
[0021] Entity and relation information is extracted from historical data on construction safety management using a large language model. Based on the extracted entity and relation information, a construction safety management knowledge graph is constructed. The knowledge graph is then divided into communities to obtain a hierarchical community structure. A summary corresponding to each community in the hierarchical community structure is generated using the large language model, and the summary is added to the information of each community to obtain a hierarchical knowledge graph of construction safety management. Finally, the hierarchical knowledge graph of construction safety management is converted into a vector representation of the hierarchical knowledge graph of construction safety management.
[0022] The process involves converting construction safety management queries into vector representations; calculating the similarity between these vector representations and the vector representations of the hierarchical knowledge graph of construction safety management; ranking the vector representations of the hierarchical knowledge graph of construction safety management based on the similarity calculation results; filtering the ranked vector representations of the hierarchical knowledge graph of construction safety management based on the similarity calculation results to obtain multiple communities of the hierarchical knowledge graph of construction safety management that meet the similarity requirements; and performing reverse index mapping on the communities of the multiple hierarchical knowledge graphs of construction safety management to retrieve entity information and relationship information of the multiple hierarchical knowledge graphs of construction safety management that meet the similarity requirements from the communities of the multiple hierarchical knowledge graphs of construction safety management.
[0023] The entity and relation information of multiple hierarchical knowledge graphs for construction safety management, along with construction safety management query statements, are combined to obtain construction safety management question statements. The construction safety management question statements are then inferred using a large language model, and multiple corresponding construction safety management SQL query statements are generated based on different temperature coefficients of the large language model. Each construction safety management SQL query statement is then executed in the construction safety management historical database to obtain multiple construction safety management SQL query results.
[0024] To achieve the third objective mentioned above, the present invention provides a computer program product comprising computer instructions for causing a computer to execute the aforementioned graph-based construction industry safety question-answering retrieval enhancement generation method.
[0025] The present invention has the following beneficial effects:
[0026] (1) The graph-based construction industry safety question-answering retrieval enhancement generation system and method constructs a hierarchical knowledge graph for construction safety management. It extracts entity and relation information through a large language model and performs community division and summary generation. This makes the retrieval process no longer a blind global search, but first locates the community that is semantically related to the user's query statement, and then performs fine-grained entity information retrieval within the community. It can capture semantic similarity rather than just relying on keyword matching, thereby improving the accuracy of retrieval and better understanding the context of the query.
[0027] (2) The graph-based construction industry safety question-answering retrieval enhancement generation system and method utilizes a large language model for reasoning and generation. It combines the retrieved entity information and user query statements into question statements, then generates multiple SQL query statements through the large language model, performs consistency voting, and finally returns them to the user. This can transform the user's natural language query into an accurate SQL query statement, thereby realizing intelligent querying of the database. Furthermore, by setting different temperature coefficients to generate multiple SQL query statements, the diversity and robustness of the results can be improved, while consistency voting effectively reduces the error rate of the generated results and ensures the reliability of the results. Attached Figure Description
[0028] Figure 1 This diagram illustrates a module schematic of a specific embodiment of a graph-based construction industry safety question-answering retrieval enhancement generation system according to the present invention.
[0029] Figure 2 This diagram illustrates a specific embodiment of the graph-based construction industry safety question-answering retrieval enhancement generation method of the present invention. Detailed Implementation
[0030] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0031] like Figure 1 and Figure 2 As shown in the figure, this invention discloses a graph-based construction industry safety question-and-answer retrieval enhancement generation system and method, which can meet the needs of rapid response to safety management regulations during construction.
[0032] Example 1
[0033] This embodiment discloses a graph-structure-based enhanced question-answering retrieval and generation system for the construction industry safety system, which includes:
[0034] The construction module is used to extract entity and relation information from historical construction safety management data through a large language model, construct a construction safety management knowledge graph based on the extracted entity and relation information, divide the construction safety management knowledge graph into communities to obtain a hierarchical community structure of the construction safety management knowledge graph, generate a summary corresponding to each community in the hierarchical community structure through the large language model, and add the summary to the information of each community to obtain a hierarchical construction safety management knowledge graph, and convert the hierarchical construction safety management knowledge graph into a vector representation of the hierarchical construction safety management knowledge graph;
[0035] In this embodiment, the historical data for construction safety management includes 22 database tables related to risk classification management and hidden danger investigation and control, such as the "General Organizational Structure Table", "Snap and Report Business Table", "Safety Inspection Business Table", "Hidden Danger Work Order Task Sheet", "Dynamic Risk List Table", and "General Attachment Mapping Table".
[0036] It should be noted that the transformation vector representation algorithm can be an embedding model.
[0037] The extraction module converts construction safety management queries into vector representations of those queries. Note that these queries can be user-inputted. The module calculates the similarity between the vector representations of the construction safety management queries and the vector representations of the hierarchical knowledge graphs for construction safety management. The similarity results are used to rank the vector representations of the hierarchical knowledge graphs, and then the ranked vector representations are filtered based on the similarity results to obtain multiple communities within the hierarchical knowledge graphs that meet the similarity requirements. A reverse index mapping is then performed on these communities to retrieve entity and relationship information for the hierarchical knowledge graphs that meet the similarity requirements.
[0038] The reasoning module combines entity and relational information from multiple hierarchical knowledge graphs of construction safety management with construction safety management query statements to generate construction safety management question statements. It then uses a large language model to reason about these question statements and generates multiple corresponding construction safety management SQL query statements based on different temperature coefficients of the large language model. It should be noted that to ensure the diversity and stability of the generated SQL, the temperature coefficient can be set between 0.1 and 0.3. Each construction safety management SQL query statement is executed in the historical construction safety management database. For example, the generated SQL statement could be "SELECT COUNT(*) FROM Hazard Work Order Task Order WHERE Hazard Type = 'Fall from Height Hazard' AND Item Name = 'A Certain Construction Project' AND Unit = 'A Certain Construction Team' AND Discovery Time >= CURDATE() - INTERVAL 3 MONTH;", yielding multiple construction safety management SQL query results.
[0039] In this embodiment, the inference module is also used to perform consistency voting on multiple construction safety management SQL query results to obtain the construction safety management SQL target query result.
[0040] In this embodiment, the inference module performs consistency voting on multiple construction safety management SQL query results, including: traversing the construction safety management SQL query results, counting the number of times each construction safety management SQL query result appears, sorting them in descending order of the number of occurrences, and taking the construction safety management SQL query result with the most occurrences as the construction safety management SQL target query result.
[0041] Optionally, based on the above system, the system further includes a feedback module; the feedback module is used to judge the correctness of the construction safety management SQL target query result according to user requirements, wherein the user requirements can be the user's evaluation of the construction safety management SQL target query result. When the judgment is correct, the construction safety management SQL query statement and construction safety management query statement corresponding to the construction safety management SQL target query result are added to the construction safety management historical data; when the judgment is incorrect, the construction safety management SQL query statement and construction safety query statement corresponding to the construction safety management SQL target query result are not added to the construction safety management historical data, and a new construction safety management SQL query statement is generated.
[0042] Based on the above system, optionally, the system further includes: a processing module; the processing module is used to generate construction safety management questions from the collected historical construction safety management data using a large language model, write corresponding construction safety management SQL query statements based on the construction safety management questions, match the construction safety management questions and the construction safety management SQL query statements to obtain question-answer pair sample data for construction safety management. For example, if the question-answer pair sample data is "Query the number of monthly inspection type inspection orders completed in the most recent month?", the corresponding SQL query statement is "SELECT COUNT(*) AS completed_monthly_inspections FROM sneb_base.safe_order WHERE order_type_text='monthly inspection' AND state_text='completed' AND order_time>=NOW()-INTERVAL". 1MONTH;”; The historical data of construction safety management and the question-and-answer pair sample data of construction safety management are segmented into text blocks based on the text block segmentation strategy. For example, the question-and-answer pair sample data is segmented into a block unit according to a set of question-and-answer pair sample data, so as to maintain the semantic coherence of the questions and answers; the historical data of construction safety management is segmented into a block unit according to the text paragraph. It should be noted that when a text is about a construction safety management topic, it is divided into a block to obtain the preprocessed historical data of construction safety management.
[0043] In this embodiment, the construction module constructs a construction safety management knowledge graph based on the extracted entity and relationship information. This includes: treating entities as nodes in the knowledge graph and relationships between entities as edges. For example, tools such as "safety rope" and "construction elevator" are marked as entities. At the same time, the module captures the corresponding descriptive information of the entities, such as "safety rope, made of high-strength fiber, maximum load capacity of a certain kilogram" and "construction workers use safety ropes," marking the relationship "use" and associating it with the entities "construction workers" and "safety rope." The modules map the entities and relationships into the knowledge graph. For example, a text block about "regular inspection of fire extinguishers" will be associated with entity IDs such as "fire extinguisher" and "inspection," as well as the relationship ID "regularly performed," thus constructing the construction safety management knowledge graph.
[0044] In this embodiment, an example of adding the construction safety domain to the entity extraction prompt template is as follows:
[0045] "Construction worker Zhang San was wearing a safety helmet correctly at the construction site. The safety helmet was manufactured by a certain company, and the production date was 2023-05-01. The safety helmet complies with the GB2811-2019 standard."
[0046] Please extract entity information from the input text that meets the following requirements:
[0047] Entity names, such as "safety helmet" or "Zhang San".
[0048] Entity type, select from the following types: [Personnel, Construction Equipment, Protective Equipment, Safety Standards, Date, Location, Manufacturer].
[0049] Entity descriptions encompass comprehensive information about the entity's attributes and behaviors, such as "Safety helmet, manufactured by [Company Name], production date 2023-05-01, conforms to GB2811-2019 standard," and "Zhang San is wearing a safety helmet correctly at the construction site."
[0050] Format each entity as ("entity"{tuple_delimiter})<entity_name> {tuple_delimiter}<entity_type> {tuple_delimiter}<entity_description> ).
[0051] In this embodiment, an example of adding the construction safety domain to the relationship modeling prompt template is as follows:
[0052] “Construction personnel operate construction equipment,” “Protective equipment protects construction personnel,” and “Construction equipment meets safety standards.”
[0053] From the input entity information, identify the clearly related (source entity, target entity) entities and extract the following relationship information:
[0054] Source entity name, such as "construction workers".
[0055] The name of the target entity, such as "construction equipment".
[0056] Relationship descriptions explain why the source and target entities are related, such as "construction workers operate construction equipment to complete construction tasks".
[0057] Relationship strength is represented by a numerical fraction, ranging from 0 to 10, where 10 indicates a strong association and 0 indicates no association. For example, the relationship strength between "construction workers" and "construction equipment" might be 8.
[0058] Format each relation as ("relationship"{tuple_delimiter})<source_entity> {tuple_delimiter}<targe t_entity> {tuple_delimiter}<relationship_description> {tuple_delimiter}<relationship_strength> ).
[0059] In this embodiment, the construction module divides the construction safety management knowledge graph into communities, including: clustering all nodes in the construction safety management knowledge graph using a graph clustering algorithm. For example, by analyzing the connection relationships between nodes, closely connected nodes are grouped into the same community, and nodes with the same representative meaning are grouped into one community. The communities are decomposed multiple times according to the granularity of the decomposition to form multi-level communities. For example, a larger community can be decomposed into smaller, more specific sub-communities. For example, "high-altitude operation safety" can be further decomposed into "high-altitude operation protection measures" and "high-altitude operation personnel training," etc., to obtain a hierarchical community structure of the construction safety management knowledge graph. The construction module generates summaries corresponding to each community in the hierarchical community structure through a large language model, including: combining entity information and relationship information within each community to improve the efficiency of knowledge retrieval and utilization; generating summaries corresponding to each community through a large language model and adding them to the information of each community.
[0060] It should be noted that the graph clustering algorithm can be the Leiden algorithm used to cluster all nodes in the construction safety management knowledge graph.
[0061] Here's an example of adding the construction safety category to a community summary prompt template:
[0062] In the "High-Altitude Operation Safety Community," the core themes revolve around "Safety Belt Standards" and "Guardrail Installation Standards," with entities including "Safety Belts," "Guardrails," and "High-Altitude Workers," and relationships such as "High-Altitude Workers Wearing Safety Belts" and "Guardrails Protecting High-Altitude Workers."
[0063] Based on the input knowledge graph information, including the community's entity list, relationships, and related descriptions, please summarize as follows:
[0064] Identify the core theme of the community and summarize it in a concise statement, such as "the set of entities and relationships related to safety measures for working at heights".
[0065] Define the boundaries of the community, including the main entities and relationships it encompasses, such as "safety belts, guardrails and other protective equipment for working at heights, as well as workers working at heights, and the relationships among them regarding their wearing and protection."
[0066] Write a summary highlighting the community’s key features and importance, such as “This community focuses on safety at heights, where the correct use and proper installation of safety belts and guardrails are crucial to ensuring the safety of workers at heights.”
[0067] Detailed reports are generated to further elaborate on the specific circumstances of entities and relationships within the community, as well as their impact on construction safety. For example, "Safety belts, as critical protective equipment, affect the life safety of workers at heights through their quality and wearing methods. The standards for setting up guardrails ensure the safety boundaries of the work area and prevent accidents such as falls. These entities and relationships together constitute an important part of the safety community for working at heights and play an indispensable role in the overall construction safety management."
[0068] In this embodiment, the extraction module calculates the similarity between the vector representation of the construction safety management query statement and the vector representation of the hierarchical knowledge graph of construction safety management, as shown in the following formula:
[0069]
[0070] Wherein, similarity(A,B) represents the similarity between the vector representation of the construction safety management query statement and the vector representation of the construction safety management hierarchical knowledge graph, A represents the vector representation of the construction safety management query statement, B represents the vector representation of the construction safety management hierarchical knowledge graph, ||A|| represents the magnitude of the vector representation of the construction safety management query statement, and ||B|| represents the magnitude of the vector representation of the construction safety management hierarchical knowledge graph.
[0071] In this embodiment, the large language model adopts one or more of the following: QwenLM, ChatGLM, Llama.
[0072] Example 2
[0073] This embodiment discloses a graph-based method for enhancing the generation of question-and-answer retrieval in the construction industry, which includes the following steps:
[0074] Step 1: Extract entity and relation information from historical construction safety management data using a large language model. Construct a construction safety management knowledge graph based on the extracted entity and relation information. Divide the construction safety management knowledge graph into communities to obtain a hierarchical community structure. Generate summaries for each community in the hierarchical community structure using a large language model and add the summaries to the information of each community to obtain a hierarchical construction safety management knowledge graph. Convert the hierarchical construction safety management knowledge graph into a vector representation of the hierarchical construction safety management knowledge graph.
[0075] Step 2: Convert the construction safety management query statement into a vector representation of the construction safety management query statement; calculate the similarity between the vector representation of the construction safety management query statement and the vector representation of the construction safety management hierarchical knowledge graph; sort the vector representations of the construction safety management hierarchical knowledge graph using the similarity calculation results; filter the sorted vector representations of the construction safety management hierarchical knowledge graph based on the similarity calculation results to obtain multiple communities of the construction safety management hierarchical knowledge graph that meet the similarity requirements; perform reverse index mapping on the communities of the multiple construction safety management hierarchical knowledge graphs to retrieve entity information and relationship information of the multiple construction safety management hierarchical knowledge graphs that meet the similarity requirements from the communities of the multiple construction safety management hierarchical knowledge graphs;
[0076] Step 3: Combine the entity information and relational information of multiple hierarchical knowledge graphs for construction safety management with the query statements for construction safety management to obtain the question statements for construction safety management. Reason about the question statements for construction safety management through a large language model, and generate multiple corresponding SQL query statements for construction safety management based on different temperature coefficients of the large language model. Execute each SQL query statement for construction safety management in the historical database for construction safety management to obtain multiple SQL query results for construction safety management.
[0077] Example 3
[0078] This embodiment discloses a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the present invention through the operation of the computer. Those skilled in the art should understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instruction, or the computer compiling the instruction and then executing the corresponding compiled program, or the computer reading and executing the instruction, or the computer reading and installing the instruction and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the programs and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and will not be repeated here.
[0079] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0080] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0081] Similarly, it should be understood that, in order to streamline this disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into that detailed description, wherein each claim itself is a separate embodiment of the invention.
Claims
1. A graph structure based construction industry safety question and answer retrieval augmentation generation system, characterized by, The method comprises the following steps: The construction module is used for extracting entity information and relationship information in construction safety management historical data by a large language model, constructing a construction safety management knowledge graph based on the extracted entity information and relationship information, performing community division on the construction safety management knowledge graph to obtain a hierarchical community structure of the construction safety management knowledge graph, generating a summary corresponding to each community in the hierarchical community structure by the large language model, adding the summary to information of each community, obtaining a construction safety management hierarchical knowledge graph, and converting the construction safety management hierarchical knowledge graph into a vector representation of the construction safety management hierarchical knowledge graph; The extraction module is used for converting a construction safety management query sentence into a vector representation of the construction safety management query sentence, calculating a similarity between the vector representation of the construction safety management query sentence and the vector representation of the construction safety management hierarchical knowledge graph, sorting the vector representation of the construction safety management hierarchical knowledge graph according to a similarity calculation result, screening the sorted vector representation of the construction safety management hierarchical knowledge graph based on the similarity calculation result, and obtaining multiple communities of the construction safety management hierarchical knowledge graph that meet a similarity requirement; The reasoning module is used for combining entity information and relationship information of the multiple communities of the construction safety management hierarchical knowledge graph and the construction safety management query sentence to obtain a construction safety management question sentence, reasoning the construction safety management question sentence by the large language model, generating multiple construction safety management SQL query sentences corresponding to different temperature coefficients of the large language model, and executing each construction safety management SQL query sentence in a construction safety management historical database to obtain multiple construction safety management SQL query results.
2. The graph structure based construction industry safety question and answer retrieval augmentation generation system of claim 1, wherein, The reasoning module is also used for performing consistency voting processing on the multiple construction safety management SQL query results to obtain a construction safety management SQL target query result.
3. The graph structure based construction industry safety question-answer retrieval augmentation generation system of claim 2, wherein, The reasoning module performs consistency voting processing on the multiple construction safety management SQL query results, which comprises the following steps: traversing the construction safety management SQL query results, counting a number of times each construction safety management SQL query result appears, sorting the construction safety management SQL query results in descending order according to the number of times, and taking the construction safety management SQL query result with the largest number of times as the construction safety management SQL target query result.
4. The graph structure based construction industry safety question-answer retrieval augmentation generation system of claim 3, wherein, The method further comprises the following steps: The feedback module is used for receiving a feedback of the construction safety management SQL target query result, and feeding back the feedback to the construction safety management historical database. The feedback module is configured to judge the correctness of the construction safety management SQL target query result according to user demand, and when the judgment is correct, the construction safety management SQL query statement and the construction safety management query statement corresponding to the construction safety management SQL target query result are added to the construction safety management historical data; when the judgment is incorrect, the construction safety management SQL query statement and the construction safety management query statement corresponding to the construction safety management SQL target query result are not added to the construction safety management historical data, and the construction safety management SQL query statement is regenerated.
5. The graph structure based construction industry safety question-answer retrieval augmentation generation system of claim 2, wherein, Further comprising: The processing module is configured to generate a construction safety management question for the collected construction safety management historical data through a large language model, compile a corresponding construction safety management SQL query statement according to the construction safety management question, match the construction safety management question and the construction safety management SQL query statement to obtain a construction safety management question and answer pair sample data, and perform text block segmentation on the construction safety management historical data and the construction safety management question and answer pair sample data based on a text block segmentation strategy to obtain preprocessed construction safety management historical data. The construction module is configured to construct a construction safety management knowledge graph based on the extracted entity information and relationship information, including: taking an entity as a node of the knowledge graph, taking a relationship between entities as an edge of the knowledge graph, mapping the entity and the relationship to the knowledge graph, and constructing the construction safety management knowledge graph.
6. The graph structure based construction industry safety question-answer retrieval augmentation generation system of claim 1, wherein, The construction module is configured to divide the construction safety management knowledge graph into communities, including: clustering all nodes in the construction safety management knowledge graph through a graph clustering algorithm, classifying nodes with the same representative meaning into a community, and decomposing the community multiple times according to a decomposition community granularity to form a multi-level community and obtain a hierarchical community structure of the construction safety management knowledge graph; and the construction module is configured to generate a summary corresponding to each community in the hierarchical community structure through a large language model, including: combining entity information and relationship information in each community, generating a summary corresponding to each community through the large language model, and adding the summary to information in each community.
7. The graph structure based construction industry safety question-answer retrieval augmentation generation system of claim 1, wherein, The extraction module is configured to calculate the similarity between the vector representation of the construction safety management query statement and the vector representation of the construction safety management hierarchical knowledge graph, as shown in the following formula:
8. The graph structure based construction industry safety question-answer retrieval augmentation generation system of claim 1, wherein, Wherein, similarity(A,B) represents the similarity between the vector representation of the construction safety management query statement and the vector representation of the construction safety management hierarchical knowledge graph, A represents the vector representation of the construction safety management query statement, B represents the vector representation of the construction safety management hierarchical knowledge graph, ‖A‖ represents the length of the vector representation of the construction safety management query statement, and ‖B‖ represents the length of the vector representation of the construction safety management hierarchical knowledge graph. The method comprises the following steps:
9. A method for generating a graph structure based construction industry safety question and answer retrieval augmentation, the method comprising: The method comprises the following steps: The entity information and relationship information in the construction safety management historical data are extracted by the large language model, a construction safety management knowledge graph is constructed based on the extracted entity information and relationship information, the construction safety management knowledge graph is divided into communities, a hierarchical community structure of the construction safety management knowledge graph is obtained, and summaries corresponding to each community in the hierarchical community structure are generated by the large language model, and the summaries are added to the information of each community to obtain a construction safety management hierarchical knowledge graph, and the construction safety management hierarchical knowledge graph is converted into a vector representation of the construction safety management hierarchical knowledge graph; The construction safety management query statement is converted into a vector representation of the construction safety management query statement, the similarity between the vector representation of the construction safety management query statement and the vector representation of the construction safety management hierarchical knowledge graph is calculated, the vector representation of the construction safety management hierarchical knowledge graph is sorted based on the similarity calculation result, the sorted vector representation of the construction safety management hierarchical knowledge graph is filtered based on the similarity calculation result, and a plurality of communities of the construction safety management hierarchical knowledge graph satisfying the similarity requirement are obtained; the plurality of communities of the construction safety management hierarchical knowledge graph are mapped by reverse indexing, and entity information and relationship information of a plurality of construction safety management hierarchical knowledge graphs satisfying the similarity requirement are recalled from the plurality of communities of the construction safety management hierarchical knowledge graph; The entity information and relationship information of the plurality of construction safety management hierarchical knowledge graphs and the construction safety management query statement are combined to obtain a construction safety management question statement, the construction safety management question statement is reasoned by the large language model, a plurality of construction safety management SQL query statements corresponding to different temperature coefficients of the large language model are generated, each construction safety management SQL query statement is executed in the construction safety management historical database, and a plurality of construction safety management SQL query results are obtained.
10. A computer program product, comprising computer instructions for causing a computer to execute the construction safety question and answer retrieval enhancement generation method based on a graph structure in claim 9.
Citation Information
Patent Citations
SQL (Structured Query Language) generation method and device based on background knowledge enhancement, equipment and medium
CN117312372A
RAG question and answer method and system based on knowledge graph and medium
CN118673126A