Construction industry safety question and answer retrieval enhancement generation system and method based on graph structure
By constructing a construction safety management knowledge graph and using graph structure search technology, the problem of difficulty in finding safety management specifications on construction site is solved, and fast and accurate safety management information retrieval and intelligent database query are achieved, which improves the efficiency and timeliness of construction safety management.
Patent Information
- Application Number
- CN202510121892.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-01-26
AI Technical Summary
During the construction of large-scale infrastructure projects, there are sudden and high-risk safety hazards and safety management problems. The existing construction safety management specifications are difficult to find, which cannot meet the timeliness of safety management on the construction site.
The construction industry safety Q&A search and enhancement generation system is adopted based on graph structure. By constructing a construction safety management knowledge graph, entity information and relationship information are extracted, community division and abstract generation are carried out, and converted into vector representations to achieve fast and accurate retrieval and query.
The efficiency of construction safety management information and data utilization has been improved, and the standards and measures related to specific safety management issues have been quickly and accurately retrieved, meeting the needs of rapid response to safety management specifications during construction.
Smart Images

Figure CN120067250A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of construction safety management, and specifically refers to a construction safety question-answering retrieval enhanced generation system and method based on a graph structure. Background Art
[0002] In the field of construction engineering, as the requirements of all sectors of society for the construction safety of construction projects are getting higher and higher, the importance of construction project safety management has become increasingly prominent. Construction project construction is a multi-category comprehensive production activity, which has the characteristics of a long construction period and many uncertain factors during the construction process, resulting in great difficulty in on-site safety management. For a long time, construction safety issues have always been a matter of concern in engineering project construction. At present, construction safety specifications and construction safety accident reports are continuously accumulating, generating a large amount of information and data on construction safety management, recording the construction safety management situation, and containing a lot of safety management experience. At the same time, in order to standardize the on-site safety management process, relevant national departments and the industry have promulgated a large number of safety management specifications and standards related to this industry, including many new ideas and new methods of safety management, which can effectively and accurately guide the on-site safety management process.
[0003] In the actual application process, the utilization rate of information and data on construction safety management is relatively low, and a large number of hidden key information has not been mined. In order to improve the utilization efficiency of information and data on construction safety management, managers have established an information database for the systematic management of text data. With the development of artificial intelligence technology, information and data on construction safety management have begun to deviate from the original manual processing method, using intelligent methods and technologies to achieve in-depth mining of content, improving the acquisition efficiency of information and data on construction safety management, and ensuring the real-time nature of safety management work.
[0004] At the present stage, during the construction process of large-scale infrastructure projects, there are many sudden and high-risk safety hazards and safety management problems, which need to be discovered in time and corresponding solutions given. Existing construction safety management specifications give a large number of safety management measures, which can effectively guide on-site safety management tasks. Since safety management specifications are mostly presented in the form of unstructured text data and are huge in number, for specific safety management problems, the manual search method is time-consuming and laborious, and cannot meet the timeliness of on-site construction safety management. At the same time, construction site safety management problems are diverse and need to be considered and analyzed comprehensively in all aspects, which further increases the difficulty of finding safety management specifications.
[0005] In order to avoid the difficulty in finding safety management specifications during the engineering construction process, which may lead to the failure to timely discover and handle potential safety hazards, resulting in huge economic losses and safety accidents, technical personnel in this field have been seeking a method for intelligent safety Q&A in the construction industry enhanced by graph structure retrieval, so as to be able to quickly and accurately retrieve the specifications and measures related to specific safety management issues, improve the efficiency and level of construction safety management, and meet the need for rapid response to safety management specifications during the construction process. Summary of the Invention
[0006] The object of the present invention is to provide a graph-structure-based enhanced generation system and method for safety Q&A retrieval in the construction industry, which can quickly and accurately retrieve the specifications and measures related to specific safety management issues, and provide an effective guarantee for the rapid response to safety management specifications during the construction process.
[0007] The graph-structure-based enhanced generation system for safety Q&A retrieval in the construction industry designed by the present invention for achieving one of the above objects is characterized in that it includes:
[0008] A construction module, which is used to extract entity information and relationship information from the historical data of construction safety management through a large language model, construct a construction safety management knowledge graph based on the extracted entity information and relationship information, perform community partitioning on the construction safety management knowledge graph to obtain a hierarchical community structure of the construction safety management knowledge graph, generate abstracts corresponding to each community in the hierarchical community structure through the large language model, and add the abstracts 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] An extraction module, which is used to convert a 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 hierarchical construction safety management knowledge graph, sort the vector representation of the hierarchical construction safety management knowledge graph by using the similarity calculation result, and screen the sorted vector representation of the hierarchical construction safety management knowledge graph based on the similarity calculation result to obtain multiple communities of the hierarchical construction safety management knowledge graph that meet the similarity requirements; perform reverse index mapping on multiple communities of the hierarchical construction safety management knowledge graph, and recall entity information and relationship information of multiple hierarchical construction safety management knowledge graphs that meet the similarity requirements from multiple communities of the hierarchical construction safety management knowledge graph;
[0010] The inference module is used to combine the entity information and relationship information of multiple construction safety management hierarchical knowledge graphs, as well as the construction safety management query statement, to obtain a construction safety management question statement. It reasons about the construction safety management question statement through a large language model and generates corresponding multiple construction safety management SQL query statements according to different temperature coefficients of the large language model. Each construction safety management SQL query statement is executed 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 a consistency voting process on multiple construction safety management SQL query results to obtain a construction safety management SQL target query result.
[0012] Furthermore, the inference module performing a consistency voting process on multiple construction safety management SQL query results includes: traversing the construction safety management SQL query results, counting the number of occurrences of each construction safety management SQL query result, sorting them in descending order according to 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 above system also includes: a feedback module; the feedback module is used to judge the correctness of the construction safety management SQL target query result according to the user's needs. 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 wrong, 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.
[0014] Furthermore, the above system also includes: a processing module; the processing module is used to generate construction safety management questions through a large language model for the collected construction safety management historical data, write corresponding construction safety management SQL query statements according to the construction safety management questions, match the construction safety management questions and the construction safety management SQL query statements to obtain construction safety management Q&A pair sample data; perform text block segmentation on the construction safety management historical data and the construction safety management Q&A pair sample data based on a text block segmentation strategy to obtain preprocessed construction safety management historical data.
[0015] Furthermore, the construction module constructs a construction safety management knowledge graph based on the extracted entity information and relationship information, including: taking the entities as the nodes of the knowledge graph, the relationships between the entities as the edges of the knowledge graph, mapping the entities and relationships into the knowledge graph, and constructing a construction safety management knowledge graph.
[0016] Further, the construction module partitions 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 one community, and decomposing the community multiple times according to the granularity of the decomposed community to form a multi-level community, obtaining a hierarchical community structure of the construction safety management knowledge graph; the construction module generates abstracts corresponding to each community in the hierarchical community structure through a large language model, including: combining the entity information and relationship information within each community, generating abstracts corresponding to each community through the large language model, and adding them to the information of each community.
[0017] Further, the extraction module calculates 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 described by the following formula:
[0018]
[0019] Among them, 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 norm of the vector representation of the construction safety management query statement, and ||B|| represents the norm of the vector representation of the construction safety management hierarchical knowledge graph.
[0020] The graph structure-based construction industry safety Q&A retrieval enhancement generation method designed for the second object of the present invention is characterized in that it includes the following steps:
[0021] Extract entity information and relationship information from the construction safety management historical data through a large language model, construct a construction safety management knowledge graph based on the extracted entity information and relationship information, partition the construction safety management knowledge graph into communities, obtain a hierarchical community structure of the construction safety management knowledge graph, generate abstracts corresponding to each community in the hierarchical community structure through a large language model, and add the abstracts to the information of each community to obtain a construction safety management hierarchical knowledge graph, and convert the construction safety management hierarchical knowledge graph into a vector representation of the construction safety management hierarchical knowledge graph;
[0022] 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 hierarchical knowledge graph of construction safety management, use the similarity calculation result to sort the vector representation of the hierarchical knowledge graph of construction safety management, and filter the sorted vector representation of the hierarchical knowledge graph of construction safety management based on the similarity calculation result to obtain multiple communities of the hierarchical knowledge graph of construction safety management that meet the similarity requirements; perform reverse index mapping on multiple communities of the hierarchical knowledge graph of construction safety management, and recall the entity information and relationship information of multiple hierarchical knowledge graphs of construction safety management that meet the similarity requirements from multiple communities of the hierarchical knowledge graph of construction safety management;
[0023] Combine the entity information and relationship information of multiple hierarchical knowledge graphs of construction safety management, and the construction safety management query statement to obtain a construction safety management question statement, perform reasoning on the construction safety management question statement through a large language model, and generate corresponding multiple construction safety management SQL query statements according to different temperature coefficients of the large language model, and execute each construction safety management SQL query statement in the construction safety management historical database to obtain multiple construction safety management SQL query results.
[0024] A computer program product designed for the third object of the present invention includes computer instructions for causing a computer to execute the above-mentioned graph structure-based construction safety Q&A retrieval enhancement generation method.
[0025] The present invention has the following beneficial effects:
[0026] (1) The graph structure-based construction safety Q&A retrieval enhancement generation system and method construct a hierarchical knowledge graph of construction safety management, extract entity and relationship information through a large language model, and perform community division and summary generation, so that the retrieval process is no longer a blind global search, but first locates the community semantically related to the user's query statement, and then performs fine-grained entity information recall within the community, which can capture semantic similarity and not just rely on keyword matching, thereby improving the accuracy of retrieval and being able to better understand the context of the query.
[0027] (2) The graph-structure-based construction safety Q&A retrieval enhanced generation system and method use a large language model for reasoning and generation. It combines the retrieved entity information and the user's query statement into a question statement, then generates multiple SQL query statements through the large language model, and conducts a consistency vote, and finally returns to the user. It can convert the user's natural language query into an accurate SQL query statement, thereby realizing intelligent query of the database. Further, by setting different temperature coefficients to generate multiple SQL query statements, the diversity and robustness of the results can be improved, and the consistency vote effectively reduces the error rate of the generated results and ensures the reliability of the results. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 FIG. shows a schematic module diagram of a specific embodiment of a graph-structure-based construction safety Q&A retrieval enhanced generation system of the present invention.
[0029] Figure 2 FIG. shows a schematic flowchart of a specific embodiment of a graph-structure-based construction safety Q&A retrieval enhanced generation method of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0030] Hereinafter, exemplary embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.
[0031] As Figure 1 and Figure 2 shown, an embodiment of the present invention discloses a graph-structure-based construction safety Q&A retrieval enhanced generation system and method, which can meet the demand for rapid response to safety management specifications during the construction process.
[0032] Embodiment 1
[0033] This embodiment discloses a graph-structure-based construction safety Q&A retrieval enhanced generation system, which includes:
[0034] A construction module is used to extract entity information and relationship information from the historical data of construction safety management through a large language model, construct a knowledge graph of construction safety management based on the extracted entity information and relationship information, perform community division on the knowledge graph of construction safety management to obtain a hierarchical community structure of the knowledge graph of construction safety management, generate abstracts corresponding to each community in the hierarchical community structure through the large language model, and add the abstracts to the information of each community to obtain a hierarchical knowledge graph of construction safety management, and convert the hierarchical knowledge graph of construction safety management into a vector representation of the hierarchical knowledge graph of construction safety management;
[0035] In this embodiment, the historical data of construction safety management includes 22 database tables related to risk grading management and hidden danger investigation and control, such as "General Organization Table", "Random Shooting Business Table", "Safety Inspection Business Table", "Hidden Danger Work Order Task List", "Risk Dynamic List Table", "General Attachment Mapping Table", etc.
[0036] It should be noted that the conversion vector representation algorithm can be an Embedding model.
[0037] An extraction module is used to convert a construction safety management query statement into a vector representation of the construction safety management query statement; it should be noted that the construction safety management query statement can be input by the user, calculate 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, sort the vector representation of the hierarchical knowledge graph of construction safety management using the similarity calculation result, and filter the sorted vector representation of the hierarchical knowledge graph of construction safety management based on the similarity calculation result to obtain multiple communities of the hierarchical knowledge graph of construction safety management that meet the similarity requirements; perform reverse index mapping on the multiple communities of the hierarchical knowledge graph of construction safety management to recall the entity information and relationship information of multiple hierarchical knowledge graphs of construction safety management that meet the similarity requirements;
[0038] The inference module is used to combine the entity information and relationship information of multiple construction safety management hierarchical knowledge graphs, as well as the construction safety management query statement, to obtain a construction safety management question statement. The large language model is used to reason about the construction safety management question statement, and multiple corresponding construction safety management SQL query statements are generated according to different temperature coefficients of the large language model. It should be noted that in order to ensure the diversity and stability of SQL generation, the temperature coefficient can be set between 0.1 and 0.3. Each construction safety management SQL query statement is executed separately in the construction safety management historical database. For example, the generated SQL statement can be "SELECT COUNT(*) FROM Hidden Danger Work Order Task Order WHERE Hidden Danger Type = 'High Fall Hidden Danger' AND Item Name = 'A Certain Construction Project' AND Unit = 'A Certain Construction Team' AND Discovery Time >= CURDATE() - INTERVAL 3 MONTH;", and multiple construction safety management SQL query results are obtained.
[0039] In this embodiment, the inference module is further used to perform a consistency voting process on multiple construction safety management SQL query results to obtain a construction safety management SQL target query result.
[0040] In this embodiment, the inference module performs a consistency voting process on multiple construction safety management SQL query results, including: traversing the construction safety management SQL query results, counting the number of occurrences of each construction safety management SQL query result, sorting them in descending order according to 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] Based on the above system, optionally, 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, where the user requirements can be the evaluation made by the user on the construction safety management SQL target query result. 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 wrong, 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.
[0042] Based on the above system, optionally, the system further includes: a processing module; the processing module is used to generate questions about construction safety management from the collected historical data of construction safety management through a large language model, write corresponding construction safety management SQL query statements according to the questions about construction safety management, match the questions about construction safety management with the construction safety management SQL query statements to obtain sample data of question-and-answer pairs for construction safety management. For example, the sample data of question-and-answer pairs is "Query the number of inspection sheets of the monthly inspection type completed in the last 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 1 MONTH;". Perform text chunking on the historical data of construction safety management and the sample data of question-and-answer pairs for construction safety management based on the text chunking strategy. For example, for the sample data of question-and-answer pairs, it is chunked with a group of sample data of question-and-answer pairs as a chunk unit to maintain the coherence of question-and-answer semantics. For the historical data of construction safety management, it is chunked with a text paragraph as a chunk unit. It should be noted that when a text paragraph expounds on a construction safety management theme, it is divided into a chunk 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 information and relationship information, including: taking entities as nodes of the knowledge graph and the relationships between entities as edges of the knowledge graph. For example, tools such as "safety rope" and "construction elevator" will be marked as entities, and at the same time, the corresponding description information of the entities is captured, such as "The safety rope is made of high-strength fiber and has a maximum load of a certain kilogram", and the relationship of "use" is marked for "Construction workers use the safety rope", and the two entities of "construction workers" and "safety rope" are associated. Map the entities and relationships to the knowledge graph. For example, a text chunk about "regular inspection of fire extinguishers" will be associated with entity IDs such as "fire extinguisher" and "inspection" and the relationship ID of "regular execution" to construct a construction safety management knowledge graph.
[0044] In this embodiment, the following examples in the construction safety field are added to the entity extraction prompt template:
[0045] "Construction worker Zhang San correctly wears a safety helmet at the construction site. The manufacturer of the safety helmet is a certain company, and the production date is May 1, 2023. The safety helmet meets the GB2811-2019 standard."
[0046] Please extract entity information from the input text that meets the following requirements:
[0047] Entity name, such as "safety helmet", "Zhang San".
[0048] Entity type, select from the following types: [personnel, construction equipment, protective equipment, safety standards, date, location, manufacturer].
[0049] Entity description, covering comprehensive information related to the entity such as attributes, behaviors, etc., such as "safety helmet, manufacturer is a certain company, production date is 2023-05-01, meets the GB2811-2019 standard", "Zhang San, wears 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, examples in the construction safety field are added to the relationship modeling prompt template as follows:
[0052] "Construction personnel operate construction equipment", "Protective equipment protects construction personnel", "Construction equipment meets safety standards".
[0053] Please identify the significantly related (source entity, target entity) from the input entity information and extract the following relationship information:
[0054] Source entity name, such as "construction personnel".
[0055] Target entity name, such as "construction equipment".
[0056] Relationship description, explaining the reason for the mutual association between the source entity and the target entity, for example, "Construction personnel operate construction equipment to complete construction tasks".
[0057] Relationship strength, represented by a numerical score, with a value range of 0-10, where 10 indicates a strong association and 0 indicates no association. For example, the relationship strength between "construction personnel" and "construction equipment" may be 8.
[0058] Format each relationship as ("relationship"{tuple_delimiter}<source_entity>{tuple_delimiter}<target_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 through a graph clustering algorithm. For example, by analyzing the connection relationships between nodes, nodes with close connections are divided into the same community, and nodes with the same representative meaning are classified into one community. The community is decomposed multiple times according to the granularity of the decomposed community to form a multi-level community. For example, a larger community can be decomposed into smaller and more specific sub-communities. For example, "high-altitude operation safety" can be further decomposed into "high-altitude operation protection measures", "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, including: combining the 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 to cluster all nodes in the construction safety management knowledge graph.
[0061] Add examples in the construction safety field to the community summary prompt template as follows:
[0062] In the "High-altitude Operation Safety Community", the core themes revolve around "safety belt specifications", "guardrail setting standards", etc. The entities include "safety belts", "guardrails", "high-altitude operation personnel", etc. The relationships are "high-altitude operation personnel wear safety belts", "guardrails protect high-altitude operation personnel", etc.
[0063] Please summarize according to the input knowledge graph information, including the entity list, relationships, and related descriptions of the community:
[0064] Determine the core theme of the community and summarize it in a short sentence, such as "Set of entities and relationships related to high-altitude operation safety measures".
[0065] Clarify the boundary scope of the community, that is, which main entities and relationships are included, such as "including high-altitude operation protection tools such as safety belts and guardrails, as well as high-altitude operation personnel, and the relationships of wearing and protecting between them".
[0066] Write an abstract highlighting the key features and importance of the community, such as "This community focuses on the safety of working at heights, and the correct use and standard setting of safety belts and guardrails are crucial for ensuring the safety of workers at heights."
[0067] Generate a detailed report further elaborating on the specific situations of entities and relationships within the community and their impact on construction safety. For example, "As a key protective equipment, the quality and wearing method of safety belts affect the lives of workers at heights. The setting standards of guardrails ensure the safety boundaries of the working area and prevent accidents such as personnel falling. These entities and relationships together constitute an important part of the working-at-heights safety community and play an important 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 construction safety management hierarchical knowledge graph, as described by the following formula:
[0069]
[0070] Among them, 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 norm of the vector representation of the construction safety management query statement, and ‖B‖ represents the norm 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] Embodiment 2
[0073] This embodiment discloses a graph-structure-based method for retrieving, enhancing, and generating answers to construction safety questions. The method includes the following steps:
[0074] Step 1: Extract entity information and relationship information from the historical data of construction safety management through a large language model, construct a construction safety management knowledge graph based on the extracted entity information and relationship information, perform community partitioning on the construction safety management knowledge graph to obtain a hierarchical community structure of the construction safety management knowledge graph, generate summaries corresponding to each community in the hierarchical community structure through the large language model, and add the summaries to the information of each community to obtain a construction safety management hierarchical knowledge graph, and convert the construction safety management hierarchical knowledge graph into a vector representation of the construction safety management hierarchical 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, use the similarity calculation result to sort the vector representation of the construction safety management hierarchical knowledge graph, and filter the sorted vector representation of the construction safety management hierarchical knowledge graph based on the similarity calculation result to obtain multiple communities of the construction safety management hierarchical knowledge graph that meet the similarity requirements; perform reverse index mapping on multiple communities of the construction safety management hierarchical knowledge graph, and recall the entity information and relationship information of multiple construction safety management hierarchical knowledge graphs that meet the similarity requirements from multiple communities of the construction safety management hierarchical knowledge graph;
[0076] Step 3: Combine the entity information and relationship information of multiple construction safety management hierarchical knowledge graphs, and the construction safety management query statement to obtain a construction safety management question statement, perform reasoning on the construction safety management question statement through a large language model, and generate corresponding multiple construction safety management SQL query statements according to different temperature coefficients of the large language model, and execute each construction safety management SQL query statement in the construction safety management historical database respectively to obtain multiple construction safety management SQL query results.
[0077] Example 3
[0078] This embodiment discloses a computer program product, such as computer program instructions, which when executed by a computer, can call or provide the methods and / or technical solutions according to the present invention through the operations of the computer. Those skilled in the art should understand that the forms of existence of computer program instructions 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 executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer. Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above-described programs and modules can refer 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 apparatus. Various general purpose systems may also be used in conjunction with the teachings based hereon. The required structure for constructing such systems will be apparent from the above description. In addition, the present invention is not directed to any particular programming language. It should be appreciated that the teachings of the present invention can be implemented in a variety of programming languages, and the description of specific languages above is provided to disclose the best mode of the present invention.
[0080] In the specification provided herein, numerous specific details are set forth. It is, however, 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 an understanding of the present specification.
[0081] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the foregoing description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, the inventive aspects lie in less than all of the features of a single foregoing disclosed embodiment, as reflected in the claims. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the present invention.
Claims
1. A graph-based construction industry safety question-answer retrieval enhancement generation system, characterized by: include: A construction module is used to extract entity information and relationship information from historical data of construction safety management through a large language model, construct a knowledge graph of construction safety management based on the extracted entity information and relationship information, divide the knowledge graph of construction safety management into communities, obtain a hierarchical community structure of the knowledge graph of construction safety management, generate a summary corresponding to each community in the hierarchical community structure through a large language model, add the summary to the information of each community, obtain a hierarchical knowledge graph of construction safety management, and convert the hierarchical knowledge graph of construction safety management into a vector representation of the hierarchical knowledge graph of construction safety management; An extraction module is used to convert a 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 representation of the construction safety management hierarchical knowledge graph using the similarity calculation result, and screen the sorted vector representation of the construction safety management hierarchical knowledge graph based on the similarity calculation result to obtain multiple communities of construction safety management hierarchical knowledge graphs that meet the similarity requirements; perform reverse index mapping on the communities of the multiple construction safety management hierarchical knowledge graphs, and recall 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; The reasoning module is used to combine the entity information and relationship information of multiple construction safety management hierarchical knowledge graphs and construction safety management query statements to obtain construction safety management question statements, reason the construction safety management question statements through the large language model, and generate corresponding multiple construction safety management SQL query statements according to different temperature coefficients of the large language model, and execute each construction safety management SQL query statement in the construction safety management history database to obtain multiple construction safety management SQL query results.
2. The graph-based construction industry safety question-answer retrieval enhancement generation system according to claim 1 is characterized in that: The reasoning module is also used to perform consistency voting on multiple construction safety management SQL query results to obtain construction safety management SQL target query results.
3. The graph-based construction industry safety question-answer retrieval enhancement generation system according to claim 2 is characterized in that: The reasoning 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 in descending order according to the number of occurrences, and taking the construction safety management SQL query result with the largest number of occurrences as the construction safety management SQL target query result.
4. The graph-structured construction industry safety question-answer retrieval enhancement generation system according to claim 3 is characterized in that: Also includes: Feedback module; The feedback module is used to judge the correctness of the construction safety management SQL target query results according to user needs. When it is judged to be 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 it is judged to be wrong, 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-based construction industry safety question-answer retrieval enhancement generation system according to claim 2 is characterized in that: Also includes: Processing module; The processing module is used to generate construction safety management questions for the collected construction safety management historical data through a large language model, write corresponding construction safety management SQL query statements according to the construction safety management questions, match the construction safety management questions with the construction safety management SQL query statements, and obtain sample data of question and answer pairs for construction safety management; perform text block segmentation on the construction safety management historical data and the sample data of question and answer pairs for construction safety management based on a text block segmentation strategy to obtain pre-processed construction safety management historical data.
6. The graph-structured construction industry safety question-answer retrieval enhancement generation system according to claim 1 is characterized in that: The construction module constructs a construction safety management knowledge graph based on the extracted entity information and relationship information, including: taking entities as nodes of the knowledge graph, the relationships between entities as edges of the knowledge graph, mapping entities and relationships into the knowledge graph, and constructing a construction safety management knowledge graph.
7. The graph-based construction industry safety question-answer retrieval enhancement generation system according to claim 1 is characterized in that: The construction module divides 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, decomposing the community multiple times according to the granularity of the decomposition community to form a multi-level community, and obtaining a hierarchical community structure of the construction safety management knowledge graph; the construction module generates 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 a large language model, and adding it to the information of each community.
8. The graph-based construction industry safety question-answer retrieval enhancement generation system according to claim 1 is characterized in that: The extraction module calculates 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 described in the following formula: Among them, 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 modulus length of the vector representation of the construction safety management query statement, and ‖B‖ represents the modulus length of the vector representation of the construction safety management hierarchical knowledge graph.
9. A graph-based construction industry safety question-answer retrieval enhancement generation method, characterized in that: The steps include: The entity information and relationship information in the historical data of construction safety management are extracted through a large language model, and 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 to obtain a hierarchical community structure of the construction safety management knowledge graph, and the corresponding summary of each community in the hierarchical community structure is generated through a large language model, and the summary is added to the information of each community to obtain a hierarchical knowledge graph of construction safety management, and the hierarchical knowledge graph of construction safety management is converted into a vector representation of the hierarchical knowledge graph of construction safety management; 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 representation of the construction safety management hierarchical knowledge graph using the similarity calculation result, and screen the sorted vector representation of the construction safety management hierarchical knowledge graph based on the similarity calculation result to obtain multiple communities of construction safety management hierarchical knowledge graphs that meet the similarity requirements; perform reverse index mapping on the communities of the multiple construction safety management hierarchical knowledge graphs, and recall the 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; The entity information and relationship information of multiple construction safety management hierarchical knowledge graphs and construction safety management query statements are combined to obtain construction safety management question statements. The construction safety management question statements are inferred through a large language model, and multiple corresponding construction safety management SQL query statements are generated according to different temperature coefficients of the large language model. Each construction safety management SQL query statement is executed separately in the construction safety management history database to obtain multiple construction safety management SQL query results.
10. A computer program product, characterized in that It includes computer instructions, which are used to enable a computer to execute the graph-structured construction industry safety question and answer retrieval enhancement generation method described in claim 9.
Citation Information
Patent Citations
SQL (Structured Query Language) generation method and device based on background knowledge enhancement, equipment and medium
CN117312372A
Construction method of RAG system based on Graph
CN118503407A
RAG question and answer method and system based on knowledge graph and medium
CN118673126A
Network security operation and maintenance recommendation method for shore power system
CN119359284A
User-customized question-answering system based on knowledge graph
WO2021054514A1
Cited By
Search sorting method based on knowledge community discovery
CN120950562A
Large language model illusion suppression method, product and equipment based on multi-order detection
CN120975246A
Subway construction safety report automatic generation method and system
CN121599132A