Construction Safety Q&A Method and Device Based on Large Language Model Technology

By building a safety Q&A system for the construction industry with vector library and knowledge graph, and using large language model technology, the complexity and professionalism of safety issues in the construction industry are solved, high-quality safety Q&A services are provided, and the accuracy and transparency of the Q&A are improved.

CN118332092BActive Publication Date: 2025-07-04TSINGHUA UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410733393.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2025-07-04
Estimated Expiration
2044-06-07

AI Technical Summary

Technical Problem

The safety issues in the construction industry are complex and highly professional. The existing large language models cannot provide accurate safety Q&A services, and it is difficult for staff to fully grasp safety standards and identify hidden dangers.

Method used

Build a safety Q&A system for the construction industry based on large language models, integrate building safety management documents and accident reports through vector libraries and knowledge graphs, and use vector similarity matching and knowledge graph retrieval to provide in-depth analysis of rule query and accident/hidden danger inquiry problems.

Benefits of technology

It improves the accuracy, inspiration and transparency of safety Q&A in the construction industry, supplements the experience shortcomings of managers and workers, improves safety awareness and ability, and avoids accident risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118332092B_ABST
    Figure CN118332092B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a method and device for construction safety question answering based on large language model technology. The method includes: obtaining a question to be answered and using a large language model to determine the type of the question; if the question belongs to a rule query type question: vectorize the question, retrieve the most similar knowledge fragment in the vector library, and prompt the large language model to answer according to the knowledge fragment; if the question belongs to an accident / hidden danger inquiry type question: vectorize the question, retrieve the most similar knowledge fragment in the vector library; extract the entities and entity relationships in the question, and retrieve the sub-graph related to the entities and entity relationships in the knowledge graph; prompt the large language model to answer according to the knowledge fragment and the sub-graph. This embodiment can provide high-quality question answering services for the characteristics of strong professionalism and high complexity in the field of construction safety.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of intelligent Q&A in the construction industry, and particularly to a construction safety Q&A method and device based on large language model technology. Background Art

[0002] With the increase in construction safety accidents, the construction safety issue faces many challenges, which are mainly manifested in the complexity caused by a large amount of information and diverse risk factors. The staff lack sufficient professional knowledge and experience, and it is difficult to comprehensively master safety specifications and deeply understand potential safety hazards, resulting in insufficient safety operations.

[0003] With the continuous development of intelligent technologies, the AI-driven Q&A mode represented by LLM (Large Language Model) has emerged, greatly simplifying the process for people to obtain knowledge. For example, Patent CN117493513A discloses a Q&A system and method based on vectors and large language models, and Patent CN116932708A discloses an open-domain natural language inference Q&A system and method driven by large language models. However, current large language models such as the ChatGLM series can provide basic Q&A services, but they usually cannot provide accurate answers in the face of the strong professionalism and complex situations in the construction industry. Summary of the Invention

[0004] The embodiments of the present invention provide a construction safety Q&A method and device based on large language model technology to solve the above technical problems.

[0005] In a first aspect, the embodiments of the present invention provide a construction safety Q&A method based on large language model technology, including:

[0006] Obtain the question to be answered, and use the large language model to judge the type of the question;

[0007] If the question belongs to the rule query type question: vectorize the question, and retrieve the most similar knowledge fragment in the vector library, and prompt the large language model to answer according to the knowledge fragment;

[0008] If the question belongs to the accident / hazard inquiry type question: vectorize the question, and retrieve the most similar knowledge fragment in the vector library; extract the entities and entity relationships in the question, and retrieve the sub-graph related to the entities and entity relationships in the knowledge graph; prompt the large language model to answer according to the knowledge fragment and sub-graph;

[0009] Wherein, the vector library is constructed according to construction safety management documents, and the knowledge graph is constructed according to historical construction safety accident reports.

[0010] Second aspect, embodiments of the present invention provide an electronic device, the electronic device comprising:

[0011] One or more processors;

[0012] A memory for storing one or more programs,

[0013] When the one or more programs are executed by the one or more processors, the one or more processors implement the construction industry safety Q&A method based on large language model technology described in any embodiment.

[0014] Third aspect, embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the construction industry safety Q&A method based on large language model technology described in any embodiment.

[0015] In view of the characteristics of strong professionalism and complex situations in construction industry safety construction and management, embodiments of the present invention provide a construction industry safety Q&A method based on large language model technology. A knowledge graph is constructed based on in-depth analysis of a large number of accident investigation reports, and the complex association relationships in the field of building safety are sorted out in a graph structure. The regulatory text data and the graph data of the knowledge graph are integrated into a professional knowledge base for the construction industry safety field, and the multi-source fusion data provides the ability to comprehensively and deeply analyze complex safety problems. In specific query problems, this embodiment uses a large language model to classify the problem categories, and customizes different data retrieval and matching rules according to the characteristics of rule query problems and accident / hidden danger inquiry problems: for the input rule-based queries, vector similarity matching is used for retrieval in the vector database, and the retrieved knowledge fragments are output as reference knowledge; for the input accident / hidden danger inquiry queries, multimodal matching is performed in both the vector space and the knowledge graph, and the reference knowledge is output by comprehensively combining the semantic matching fragments and the structure matching graph. Finally, the retrieved knowledge is combined with the user's original query, and comprehensive processing and answer generation are performed through the large language model, which plays a role in knowledge supplementation and problem explanation while maintaining the generation quality, greatly improving the accuracy, enlightenment and transparency of the Q&A. Description of the Drawings

[0016] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0017] Figure 1It is a flowchart of a construction safety Q&A method based on large language model technology provided by an embodiment of the present invention;

[0018] Figure 2 It is a flowchart of another construction safety Q&A method based on large language model technology provided by an embodiment of the present invention;

[0019] Figure 3 It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners

[0020] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the scope of protection of the present invention.

[0021] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus cannot be construed as a limitation of the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.

[0022] In the description of the present invention, it should also be noted that unless otherwise clearly defined and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, and it can be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.

[0023] In the construction industry, the challenges faced by workers are not limited to what can be covered by rule queries. That is, in addition to the safety operation and management problems caused by the difficulty of comprehensively mastering regulatory documents, the identification and handling of potential safety hazards at the construction site are also a crucial and challenging task. This is mainly manifested in the complex and changeable on-site conditions at construction sites. The causes of potential safety hazards are usually the result of the intertwining of multiple factors and are difficult to simply attribute to a single cause. This reality means that even experienced safety inspectors may miss key potential hazard points. In addition, the identification and handling of potential hazards largely depend on individual judgment, and the qualities and experiences of construction site managers vary, increasing the risk of incomplete hazard detection and improper handling. Based on an in-depth understanding of the actual needs of the construction industry, this embodiment provides a safety Q&A method for the construction industry based on large language model technology. Through the knowledge such as the regulatory knowledge, common operation hazards and countermeasures, and the connection between hazards and accidents covered by the vector library and knowledge graph, it can make up for the experience deficiencies of managers and workers, make up for the lack of subjective judgment, improve safety awareness and safety capabilities, and avoid accident risks. To illustrate this method, the vector library and knowledge graph are introduced first.

[0024] Since some safety accidents occur because workers have difficulty fully mastering a large number of regulatory requirement documents, the vector library can be constructed based on construction safety management documents, and the construction safety management documents include at least one of laws and regulations, national standards, industry codes, enterprise manuals, and expert guides. Generally speaking, through embedding technology, the above-mentioned construction safety management documents can be preprocessed and segmented, and then the Doc2Vec model of the embedding machine is used for text vectorization processing to obtain the vectorized representation of the text, which is stored in the distributed vector database Vecc (Vector Embeddings for Content Comparison). In a specific embodiment, this process may include the following steps:

[0025] Step 1: Prepare and store construction safety management document data. Construction safety management documents are the core data resources of this embodiment and can be roughly divided into the following categories: 1. Laws and regulations: including documents with the nature of laws and regulations such as the Regulations on the Quality Management of Construction Projects and the Regulations on Architectural Design Management. 2. National standards: such as GBT standard series, HJ standard series, etc. 3. Industry general codes: such as construction safety codes, fire protection design codes, etc. 4. Enterprise project manuals: detailed construction standards, safety management guidelines, and operation manuals issued for different enterprises and different types of engineering projects. 5. Expert guides: such as architectural intelligent design guides, etc.

[0026] A key advantage of a distributed system is its scalability. As the amount of data increases, the processing power and storage capacity of the system can be expanded by simply adding more computing nodes. Given the large volume and diverse categories of data, in this step, all text documents are loaded into a distributed document storage system in a distributed manner, aiming to support parallel processing of massive data and ensure that the system can efficiently process and access this data.

[0027] Step 2: Preprocess and segment the documents. Specifically, two strategies are adopted for each document to ensure effective processing: one is segmentation based on the topic title: this method is applicable to well-structured documents and can ensure that the text content within each paragraph has a certain internal consistency. The other is fixed-length sliding window segmentation: for cases where the structure is not obvious or the document is long, a fixed-length sliding window is used for text segmentation to ensure that each segment can be effectively processed.

[0028] Step 2: Vectorize the segmented text. To handle the complex features of the text, the PV-DM (Distributed Memory Model of Paragraph Vector) algorithm of the Doc2Vec model can be selected for text vectorization. Doc2Vec is a model based on statistical information. It not only considers the order information of words but also includes context information, thus being able to capture the subtle relationships between words. The core algorithm of PV-DM is: each paragraph of the input corpus is mapped to a vector as the column vector of matrix ; each word is mapped to a vector as the column vector of matrix . Given a sequence of words , and the paragraph is p, the goal of the PV-DM model is to maximize the average probability:

[0029]

[0030] where, T represents the number of words in the word sequence, k represents the context window size, which determines that when predicting the current word , the k words before and after it are considered as the context. k represents the conditional probability of the word appearing under the condition of a given context (composed of the current word and the k words before and after it) and the paragraph vector .

[0031] The prediction work is completed through a multi-class classifier (softmax function) to obtain:

[0032]

[0033] Among them, is the score of the target word and is the score of any word in the vocabulary (the vocabulary uses a publicly available corpus in the construction field).

[0034]

[0035] is the transpose of the vector of is the bias term of , and h is the hidden layer vector h generated by processing and combining the word vectors and paragraph vectors through the neural network.

[0036] By jointly training the word vectors and document vectors, the Doc2Vec model can effectively capture the context relationships inside and outside the document and learn high-quality document representations. This method not only enhances the model's ability to understand the text structure but also improves the quality of text embedding.

[0037] Step Four: Store vector data. The vector representations obtained by training each text segment through the Doc2Vec model can be stored in a distributed vector database for subsequent similarity matching retrieval. The distributed vector database selects the Vecc database, which is optimized for high-dimensional vector data and can quickly locate the vector most similar to the query vector, making it more efficient to perform similarity searches in a large-scale vector set; in addition, when dealing with large-scale data sets, the Vecc database can effectively perform approximate nearest neighbor searches. This search method balances search accuracy and speed and is suitable for real-time or quasi-real-time query responses; furthermore, the Vecc database can be deployed and extended in different hardware and distributed environments to adapt to different scales of data requirements, with high scalability and flexibility; and it provides guarantees for data security and consistency to ensure the accuracy and reliability of the data.

[0038] Combined with engineering practice, there is another type of safety accident that is caused by problems such as insufficient experience and inadequate training of staff, resulting in problems in aspects such as fact-checking and management of potential safety hazards at the construction site. To solve this type of complex problem, a large number of accident investigation reports can be deeply analyzed, the complex correlation relationships among accidents, potential hazards, operations, locations, and measures can be sorted out, and a knowledge graph in the field of building safety can be constructed. Generally speaking, by training the BiLSTM-CRF and Softmax classification layers, entity extraction and entity relationship recognition can be carried out on the accident investigation reports of the construction industry over the years to obtain the graph data structure (entity relationship triples) of the knowledge graph and store it in the graph database management system Neo4j. Specifically, the extracted entities include at least one of the following categories: accident type, accident location, operation link, responsible entity, accident cause, prevention and rectification measures; entity relationships include causal relationships and the mutual relationships among various entities. In a specific implementation manner, this process may include the following steps:

[0039] Step 1: Select training data and sample. 20% of the data in the building accident investigation reports in the past 10 years can be selected as training samples, and the selected samples should be able to represent a wide range of accident types and scenarios, so as to improve the coverage and practicability of the knowledge graph.

[0040] Step 2: Label the entity categories and entity relationships of the training samples. Optionally, the entity categories of accident types to be labeled include electrical accidents, mechanical injuries, object strikes, fires, etc.; the entity categories of accident locations include, for example, scaffolding, adjacent edges, etc.; the entity categories of operation links include hoisting operations, safety operations, lifting operations, etc.; the entity categories of prevention and rectification measures include, for example, strengthening supervision, equipment improvement, etc.; the entity categories of accident causes can be subdivided into the following categories: unsafe operation behaviors of the responsible entity, and this type of entity includes improper operation, non-compliance with rules, etc.; unsafe management behaviors of the responsible entity, and this type of entity includes insufficient safety education, ineffective supervision and management, etc.; unsafe states of machinery, materials, environment, etc., and this type of entity includes, for example, crane equipment failures, strong winds and heavy rains, etc. The entity relationships to be labeled include "A causes B", "A occurs at B", etc. Tables 1 and 2 respectively show the predefined ontology models in the field of building safety, including the set of entity categories and the set of relationships between entity categories in this field. The annotation can be completed with reference to this ontology model, where the relationship between entities is consistent with the relationship of the entity categories to which they belong.

[0041] Table 1 Set of Entity Categories

[0042]

[0043] Table 2 Set of Relationships between Entity Categories

[0044]

[0045]

[0046]

[0047]

[0048]

[0049] Step 3: Use the labeled data to train the BiLSTM-CRF framework. Among them, the BiLSTM layer can capture the context information of each word and output a sequence of hidden states. To implement the entity recognition task, a CRF layer can be added after the BiLSTM layer. The CRF layer itself considers the dependencies between labels in the word sequence and can well solve the sequence labeling problem, outputting the optimal entity type for each word. To implement the entity relationship prediction task, a classifier based on context information is added after the BiLSTM layer. Based on the word features output by the BiLSTM layer, this classifier fuses the features of two entities through a fully connected layer to achieve the transformation and fusion of different features. The fused features are used as the input for the Softmax classification layer operation to predict the probability distribution of the relationship types between two adjacent words. During the training process, both the entity recognition loss of the CRF layer and the relationship prediction loss of the relationship classifier should be considered to improve the effects of both. Loss function:

[0050]

[0051] Among them, is the CRF loss, is the relationship classification loss, is the balance parameter.

[0052] Optionally, first, based on the large-scale pre-trained BiLSTM-CRF model, the pre-trained model is fine-tuned using the annotated construction accident report data, enabling the model's parameters to gradually adapt to and learn the specific pragmatic features of text in professional field reports, such as industry jargon, event description methods, etc., so that the model can not only maintain its general understanding ability but also better process and understand construction report text, generating more accurate analysis results. The fine-tuned model is further applied to unannotated construction accident report data for predicting entities, entity categories, and entity relationships. The pseudo-labels generated in this process are used to expand the initial annotated dataset, forming a richer and more diverse training dataset. The pseudo-labels are merged with the initial annotated data to form the augmented annotated data, and a semi-supervised learning strategy is adopted to iteratively use the augmented annotated data to further train the model. Each round of training includes the utilization and fine-tuning of pseudo-labels (the specific process is the same as the above process). The core of this strategy is to make the model more robust by gradually introducing more information from the annotated data, while improving its accuracy in identifying various entities and relationships in construction accident reports. In each iteration, the model not only learns to identify new entity and relationship types but also adjusts its own parameters to better adapt to the characteristics and complexity of the dataset. After the iteration ends, the performance of the model is evaluated on an independent test set to ensure its good generalization performance on unseen data. The model at this time serves as the final entity extraction model. After a piece of text is input into this model, the model can output the key entities, entity categories, and relationships between entities in the text according to the logical relationships in the accident report. The following gives a specific input-output example:

[0053] 「Example Input 1 IN1」

[0054] On June 30, 2023, an electric shock accident occurred at No. 356, a certain village in a certain community of a certain street, with a direct economic loss of 1.5 million yuan.

[0055] I. Course of the accident

[0056] On June 30, 2023, the gas pipeline installation team where the workers of a construction company were located was carrying out the installation work of natural gas pipelines on the scaffolding on the outer wall of No. 356 in a certain village of a certain community on a certain street. There were natural gas pipelines to be installed on both the west and north sides of the house, and there was a low-voltage overhead line at the intersection of the west and north sides. Before the accident, the worker and his fellow workers were prefabricating natural gas pipelines above the scaffolding, and another fellow worker was assisting in delivering the pipelines on the ground. After delivering the pipelines, the fellow worker left the work area and went to other positions to continue working. The fellow worker who prefabricated the natural gas pipelines together then climbed down the scaffolding to collect the electric welding machine, leaving only this worker working on the scaffolding. At around 10:30, when the fellow worker returned to the accident location to get tools, he found that the worker had fallen to the ground below the scaffolding at the northwest corner of Building No. 356 involved, with the safety helmet rolled to one side, and there was also a folding ladder leaning against the first-floor scaffolding beside.

[0057] II. Analysis of Accident Causes

[0058] Direct cause: The working surface of the scaffolding did not maintain a safe distance from the low-voltage overhead line involved and the 4 connectors, and no safety protection measures were set; the safety awareness of the natural gas pipeline installation workers was weak, and during the process of climbing and crossing the low-voltage overhead line illegally, the calf touched the exposed hexagonal bolt with dangerous voltage of the connector, and other limbs touched the scaffolding, resulting in an electric current forming a loop through his body, triggering this electric shock accident.

[0059] Indirect causes: 1. The safety production education and training of a certain construction company were not in place... 2. The project manager of a certain construction company did not earnestly perform his safety production work responsibilities. 3. The safety person in charge of a certain construction company did not earnestly perform the responsibilities of a safety production management personnel, and the daily inspections were not in place...

[0060] III. Accident Rectification and Prevention Measures

[0061] (1) A certain construction company should seriously learn from the profound lessons of this accident, further implement the main responsibility of enterprise safety production, prevent similar accidents from happening again, and meet the following requirements... (2) The consulting company should seriously learn from the profound lessons of this accident, strictly perform its supervision responsibilities, supervise and inspect the construction unit to implement construction safety guarantee measures, and discover and eliminate potential production safety accident hazards at the construction site in a timely manner. (3) The sub-district office should take this as a warning and carry out a rectification and investigation of potential safety hazards at the construction sites in the gas household installation projects within the whole sub-district... (4) The District Housing and Construction Bureau should strengthen accident warning education for gas household installation projects within the whole district, and coordinate with the district power supply department to carry out special inspections on projects under construction near low-voltage overhead lines.

[0062] 「Example Output 1 OUT1」

[0063] Entity Recognition List and Its Categories:

[0064] Accident type: [Electric shock accident]

[0065] Accident risk: [Direct economic loss of 1.5 million yuan]

[0066] Responsible parties: [Construction company, consulting company, sub-district office, district housing construction bureau, installation worker, safety supervisor, project manager]

[0067] Location of occurrence: [Scaffolding working surface, low-voltage overhead line]

[0068] Operation link: [Installation of natural gas pipeline]

[0069] Unsafe operation behavior: [Illegally climbing and crossing low-voltage overhead lines]

[0070] Unsafe state of objects: [The scaffolding working surface did not maintain a safe distance from the low-voltage overhead line and 4 connectors, no safety protection measures were set up, and exposed live bolts]

[0071] Unsafe management behavior: [Failure to implement safety production education and training, failure to perform safety production work responsibilities, and inadequate daily inspections]

[0072] Personal status: [Weak safety awareness]

[0073] Organizational safety culture: [Inadequate safety production education and training]

[0074] Accident prevention and rectification measures: [Comprehensive safety hazard investigation, strengthening the allocation and inspection of safety management personnel, safety education and training, safety production management at the construction site, strengthening safety supervision, and strengthening accident warning education for gas household construction projects]

[0075] List of relationship extraction:

[0076] (Installation worker, has weak safety awareness)

[0077] (Scaffolding working surface, has no safe distance from the low-voltage overhead line and 4 connectors)

[0078] (Scaffolding working surface, has no safety protection measures)

[0079] (Construction company, shapes inadequate safety production education and training)

[0080] (Construction company, should implement comprehensive safety hazard investigation and rectification)

[0081] It is worth mentioning that the text input into the model in the above example is a passage from an accident report. In actual applications, this model can perform entity extraction on any text related to construction safety in the construction industry, not limited to the text in accident reports.

[0082] Step 4: Apply the final BiLSTM-CRF model to new unlabeled text to identify entities, entity categories, and predict the relationships between entities (i.e., entity relationships) in the text. According to the categories of each identified entity, match the predicted entity relationships with the set of relationships between entity categories in the predefined construction accident domain. Optionally, form multiple triples from the identified entities and entity relationships, where each triple includes two entities and the relationship between the two entities. For each triple, first determine the categories to which the two entities within the group belong, and then perform a Standard Query Language (SPARQL) query on the above ontology model to obtain the possible association relationships between the categories to which the two entities belong. Then, compare the possible association relationships with the relationship between the two entities stored within the triple. If the semantics are consistent, the relationship is considered a match. Optionally, use the string matching algorithm, the Levenshtein distance algorithm, to calculate the text similarity between the two relationships. When the similarity exceeds a predetermined threshold, it is confirmed as a match with consistent semantics. Exemplarily, the categories to which the two entities in a triple belong are "personal status" and "organizational safety culture" respectively. From Table 2, the possible association relationships between these two categories include "reflect" and "influence". Then, calculate the text similarity between the relationship between the entities stored in the triple and "reflect" and "influence" respectively. If the text similarity between this relationship and "reflect" exceeds the set threshold, it is considered that this relationship matches "reflect", that is, this triple matches the entry {personal status, organizational safety culture, reflect} in the ontology model.

[0083] Step 5: Construct a knowledge graph for the construction accident domain based on the entities and relationships that can be matched. Optionally, use the graph database management system Neo4j to convert all the triples obtained in Step 4 that can match an entry in the ontology model into a graph structure. In this structure, entities are converted into nodes in the graph, and the relationships between entities are converted into edges in the graph. Quality assessment, indexing, and optimization can be performed on the knowledge graph to support efficient data retrieval and analysis. For triples that cannot match any entry in the ontology model, based on the frequency of occurrence of entities and relationships in the triples and expert judgment, add the triples with a frequency of occurrence greater than the set threshold and the triples considered important by experts to the above knowledge graph to improve the knowledge system.

[0084] The above process constructs a vector library and a knowledge graph in the construction safety field, converting huge amounts of text materials into a data format that can be understood and processed by machines, laying a foundation for in-depth analysis and information retrieval of subsequent intelligent questions and answers.

[0085] Based on the above vector library and knowledge graph, Figure 1 is a flowchart of a construction safety Q&A method based on large language model technology provided by an embodiment of the present invention. This method is applicable to the situation of professional Q&A in the construction safety field and is executed by an electronic device. As Figure 1 shown, the method specifically includes:

[0086] S110. Obtain the question to be answered and use the large language model to judge the type of the question.

[0087] The question specifically refers to related questions in the construction safety field. In this embodiment, according to engineering practice, these questions are divided into two types. One type is the specified query type question, that is, the question clearly stated in documents such as regulations, systems, and manuals; the other type is the accident / hidden danger inquiry type question, that is, a complex query that cannot be fully reflected in the regulations and systems documents and requires analyzing accident report texts. Different methods will be used to give answers according to the question type in subsequent operations.

[0088] Optionally, the large language model can be used to judge the type of the question. Exemplarily, ChatGLM is a dialogue robot developed by Zhipu AI that supports Chinese-English bilingual, supports interaction with users through natural language dialogue, has multi-domain knowledge, code ability, common sense reasoning and application ability, and performs well in the Chinese context. The ChatGLM model can be used to classify user queries. To improve the classification accuracy, the characteristics of the rule query type questions and the accident / hidden danger inquiry type questions can be explained to the large language model, and the large language model can be prompted to judge the type of the question according to the characteristics. Exemplarily, the following prompt can be designed:

[0089] Which of the following two categories does the current user query belong to: 1. Rule type query (questions clearly stated in documents such as regulations, systems, and manuals); 2. Accident / hidden danger inquiry type query (complex queries that cannot be fully reflected in the regulations and systems documents and require analyzing accident report texts).

[0090] Then for the following two questions, the large language model will predict the following two types:

[0091] Question: When working, a crane needs to be used. What are the safety precautions for the passenger dropping operation?

[0092] Model prediction: 1

[0093] Question: After discovering hidden danger A, what other hidden dangers should I pay attention to?

[0094] Model prediction: 2

[0095] S120. Retrieve knowledge related to the question in the vector library and knowledge graph according to the question type, and use it to provide answers for the large language model.

[0096] Generally speaking, for rule query questions (questions clearly stated in documents such as regulations, systems, manuals, etc., for example, what are the operating rules of a specific device, what personal protective equipment do I need for this work, how to arrange safety training for new workers, etc.), in this embodiment, vectorization technology is used to convert the user's natural language query into a machine-readable vector form, and the vector library and large language model are used to provide answers. For complex queries that cannot be fully reflected in the regulations documents, combined with engineering practice feedback, mainly accident / hidden danger exploration questions (for example, what other hidden dangers are worthy of my attention after discovering hidden danger A, what accidents may hidden danger A cause, what hidden dangers are likely to occur in operation link B, etc.), in addition to vectorization processing, it is also necessary to identify and map the key entities in the query and the relationships between them, and use the vector library, knowledge graph and large language model to jointly provide answers. Through classification processing and data conversion, this embodiment can select the most appropriate processing path according to the nature of the query, so as to ensure effective response to both standard rule queries and more complex accident hidden danger explorations. Specifically, for different question types, S120 includes the following two optional implementation methods:

[0097] The first optional implementation method is that when the question belongs to the rule query type, vectorize the question and retrieve the most similar knowledge fragments in the vector library for the large language model to provide answers. In a specific implementation, first, preprocess the query question, including text cleaning (removing irrelevant characters in the question, such as extra spaces, special symbols, etc.), standardization processing (unifying case, converting common abbreviations, etc.), word segmentation, etc. Secondly, convert the preprocessed text into a numerical vector and match it with the knowledge chunks in the vector database. In this link, the Doc2Vec model, the same embedding model as the vector database, is used for text vectorization processing, and the vector representation of the user query is sent to the Vecc vector library constructed in the above embodiment, and the query method is specified as similarity calculation. The Vecc database will adopt a local index mechanism to quickly locate the text segment vector that is most similar to the query vector dimension. The similarity algorithm uses cosine similarity, and the calculation formula is:

[0098]

[0099] where and are the query vector and the vector of a certain text segment in the database respectively.

[0100] Sort the documents by similarity score from high to low, and return the TopK document vectors, their IDs, the corresponding similarity scores, and the document contents for the large language model to answer. Example: Query "Key points for crane operation safety", the title of the Top1 document is "Safety Manual for Lifting Operations", and the similarity is 0.92.

[0101] In the second optional implementation manner, when the question belongs to the accident / hidden danger inquiry type, vectorize the question and retrieve the most similar knowledge fragments in the vector library; extract the entities and entity relationships in the question, and retrieve the sub-graphs related to the entities and entity relationships in the knowledge graph; use the knowledge fragments and sub-graphs together as relevant knowledge for the large language model to answer. For inquiry type questions, the answers that can be given by the rules and regulations documents are limited, while the knowledge graph constructed based on the study of accident reports can provide knowledge about the correlations between accidents and causes, hidden dangers and links, and hidden dangers. Therefore, this embodiment performs double retrieval on the vector library and the knowledge graph to provide deeper knowledge for the large language model, enabling the large language model to comprehensively understand and respond to complex safety accident and hidden danger related queries, and providing more in-depth and comprehensive analysis and answers.

[0102] In a specific implementation manner, first preprocess the query question, including text cleaning (removing irrelevant characters in the question, such as extra spaces, special symbols, etc.), normalization processing (unifying case, converting common abbreviations, etc.), word segmentation, etc. Secondly, convert the preprocessed text into a numerical vector and match it with the knowledge chunks in the vector database to quickly locate the knowledge fragments related to the user's question. The specific process is as described in the first optional implementation manner and will not be elaborated here.

[0103] At the same time, perform entity extraction on the query question to obtain the entities and entity relationships in the question, and retrieve the sub-graphs related to the entities and entity relationships in the knowledge graph. Optionally, use the final BiLSTM-CRF model in knowledge graph construction to extract entities and entity relationships, and use the Cypher query language to convert the identified entities and relationships into query instructions for the Neo4j graph database. In Cypher, a node can be represented as '(node)' and a relationship as '-[rel]->'. Suppose the query is "Find other hidden dangers related to hidden danger A"; "hidden danger A" is a node in the graph database with the attribute name; the relationship is marked as RELATED_TO in the database. The query instruction first needs to match this node; then the query needs to find other nodes that have a specific relationship with "hidden danger A"; finally, the RETURN statement is used to specify the return content of the query. The specific statement is as follows:

[0104] MATCH (hazard:Hazard {name: 'Hidden Danger A'})-[:RELATED_TO]->(relatedHazard)

[0105] RETURN relatedHazard

[0106] Neo4j executes a query in the graph database according to the Cypher statement to search for directly matching nodes and relationships. For entities or relationships that cannot be directly matched, a combination degree calculation is used for approximate matching measurement. The specific steps are as follows:

[0107] Step 1: Vectorize the entities and entity relationships in the question, as well as each node and edge of the knowledge graph. Optionally, convert the entity or relationship description in the query into a text vector. Among them, the vector of the query entity is , and the vector of the query relationship (here referring to the relationship predicate) is ; for each entity or relationship node in the graph library, extract its attribute description and convert it into a vector respectively .

[0108] Step 2: Calculate the first vector similarity between the entity and each node, and select the nodes with the top-ranked similarities as candidate nodes. Optionally, calculate the Pearson correlation coefficient similarity between the query entity and each node entity :

[0109]

[0110] Among them, is the covariance, is the standard deviation.

[0111] Step 3: Calculate the second vector similarity between the edges of each candidate node and the entity relationship, and select the edges with the top-ranked similarities as candidate edges. Optionally, calculate the cosine similarity between the query relationship and each candidate relationship :

[0112]

[0113] Step 4: Generate a sub-graph related to the entity and entity relationship according to the candidate nodes and candidate edges. Optionally, match from the candidate nodes and / or candidate edges with similarities greater than a given threshold to obtain an approximate matching result. If all are below the threshold, it is judged as a non-matching result.

[0114] Finally, integrate the direct matching results and the approximate matching results based on similarity calculation, and perform the retrieval. The retrieval results are evaluated by experts (including the types and quantities of nodes and edges, their structural positions in the graph, etc.), and the relevance between the retrieval output and the user query is continuously optimized. The output results can be roughly divided into three categories, and the corresponding output form can be selected according to the characteristics of the question:

[0115] The first category: If the question requires understanding the direct connection between specific entities, the retrieval results are output as a list of relationships of the specific entities. In this case, specific relationship instances are returned, usually including the relationship type and the start and end nodes of the relationship. This return type focuses on showing the specific association methods between entities and is applicable to situations where the direct connection between specific nodes needs to be understood, such as understanding the direct association between a certain safety hazard and specific measures.

[0116] The second category: If the question requires understanding the indirect connection between two entities, the retrieval results are output as the connection path between the two entities. In this case, the complete path from one node to another is returned, including all the nodes and relationships passed through. This type emphasizes the connection sequence between nodes and is applicable when understanding the indirect connection and interaction path between two entities. For example, understanding how a series of safety measures are interconnected to prevent a certain type of accident.

[0117] The third category: If the question requires analyzing the complex interactions between multiple entities and relationships, the retrieval results are output as a graph structure composed of multiple nodes and edges. In this case, a larger set of nodes and relationships that meet specific conditions or patterns is returned, which usually constitutes a subgraph. This return type provides a broader perspective to understand the complex network between entities and is applicable to exploring and analyzing the complex interactions between entities and relationships in a larger scope, such as studying the overall network and impact of a certain type of safety hazard.

[0118] Optionally, a large language model can also be used to determine which of the above three categories the question belongs to. Specifically, first explain the characteristics of the three types of questions to the large language model, and then prompt the large language model to judge the type of the question based on the characteristics. The following prompt can be designed:

[0119] To which of the following three categories does the current user query belong: The first category: The query question requires understanding the direct connection between specific entities, such as understanding the direct association between a certain safety hazard and specific measures. The second category: The query question requires understanding the indirect connection and interaction path between two entities. For example, understanding how a series of safety measures are interconnected to prevent a certain type of accident. The third category: The query question requires analyzing the complex interactions between multiple entities and relationships, such as studying the overall network and impact of a certain type of safety hazard.

[0120] S130. Prompt the large language model to answer based on the knowledge obtained in S120.

[0121] In this step, the large language model processes and understands the query raised by the user, and based on the knowledge matching results provided by S120, gives a sufficient answer in combination with the context. Specifically, after obtaining the strongest knowledge fragment and knowledge sub-graph (if any) related to the query question, the knowledge fragment and sub-graph (if any) are fused with the user's original query and provided to the LLM for processing. The model learns, integrates and generates a structured and accurate answer on this basis, so as to achieve a comprehensive response to the user's query. Optionally, first, set the role of the large language model as an expert in answering construction safety questions, and set the task scope and expected behavior pattern for the LLM; then, provide the input information to the large language model, including the user's question, knowledge fragment and sub-graph (if any); finally, prompt the large language model to act as the set role, and give the answer to the question according to the knowledge fragment and sub-graph, and indicate the directly cited text.

[0122] Exemplarily, define the role of the LLM as "a professional expert in answering safety questions, specifically used to answer specific knowledge points related to construction safety in the questions". Then, fill the user's question into the {question} field to clarify the user's query or doubt, providing the starting point for the LLM to generate an answer; fill the knowledge fragment into the {textData} field, and fill the sub-graph into the {graphData} field to provide relevant knowledge as a reference for the answer. Finally, assemble the role, {question} field and {textData} into the following prompt to guide the LLM to generate a structured answer according to the provided information, and emphasize the clarification of the citation to increase the transparency and traceability of the answer.

[0123] 「Example of prompt」

[0124] You are a professional expert in answering safety questions, specifically used to answer specific knowledge points related to construction safety in the questions. Please summarize and answer according to the user's question question, referring to the text data textData and graph data graphData (if there is no graph data graphData, please ignore), and indicate the directly cited text and graph.

[0125] - {question}

[0126] - {textData

[0127] Data 1: Source "…"

[0128] Data 2: Source: 《…》

[0129] …}

[0130] - {Graph data of the atlas

[0131] Relationship list: <Entity 1, Relationship, Entity 2>, <Entity 1, Relationship, Entity 3>,...

[0132] Paths between nodes: <Entity 1, Relationship 1, Entity 2, Relationship 2, Entity 3,...>,...

[0133] Nodes and relationships that make up a specific sub - atlas: <Entity 1, Relationship 1, Entity 2>, <Entity 3, Relationship 3, Entity 4>,...}

[0134] 「Answer example」

[0135] Point - by - point question | Answer | Based on text | Based on atlas

[0136] Question 1 | Reply 1 | Text 1 | Matching sub - atlas in the atlas

[0137] Question 2 | Reply 2 | Text 2 | Related nodes A, B and path A - leads to - B ...

[0138] Furthermore, after answering, text quality evaluation can also be carried out using BLEU scores, New Relic, etc. to control the quality of Q&A and optimize and improve the Q&A level. Optionally, the BLEU (Bilingual Evaluation Understudy) evaluation system can be used to monitor and control the quality of the answer text to ensure the accuracy and integrity of the answer. The quality of the answer is judged by setting a BLEU score threshold. Low - score answers need to be re - optimized and generated, thus improving the overall Q&A quality in real - time. This scoring method is mainly used to judge the correctness of the generated text and is evaluated by calculating the similarity between the candidate translation and a set of reference translations. The specific steps are as follows:

[0139] Step 1: Calculate the n - gram accuracy. An n - gram is a sequence of n consecutive items in the text. For each n - gram size (such as 1 - gram, 2 - gram, etc.), calculate the number of n - grams that appear in the candidate answer and match the n - grams in the reference text ( ), and the total number of n - grams in the candidate answer ( ).

[0140]

[0141] Step 2: Calculate the Brevity Penalty (BP). In automatic text generation, a common problem is that the generated text may be shorter than the reference text. Short texts sometimes wrongly get high BLEU scores because they are literally easier to match with the reference text. To solve this problem, the BLEU scoring introduces a penalty factor, Brevity Penalty, to reduce the scores of overly short answers. The calculation formula of BP is:

[0142]

[0143] where is the length of the candidate answer, is the length of the reference text that is closest to the length of the candidate answer. When the length of the candidate answer is equal to or greater than the length of the reference text, the BP value is 1, which has no impact on the BLEU score. When the candidate answer is shorter, the BP value is less than 1, thus reducing the BLEU score.

[0144] Step 3: Calculate the overall BLEU score. After calculating the overlap degree of N-grams and obtaining a preliminary BLEU score, apply the Brevity Penalty to adjust this score to get the final BLEU score. In this way, the Brevity Penalty ensures that the BLEU scoring not only focuses on the accuracy of the machine-generated text but also considers its integrity to provide a more comprehensive evaluation.

[0145] For common rule-based Q&A, if BLEU is lower than 0.6, the answer needs to be regenerated; for complex accident / hidden danger inquiry Q&A, if BLEU is lower than 0.7, the answer needs to be regenerated.

[0146] In addition, the performance of the entire Q&A method can be continuously monitored, including evaluating key indicators such as Q&A accuracy, response time, and user satisfaction. Optionally, when evaluating Q&A accuracy, some historical Q&A can be automatically sampled and compared with the standard answers to calculate the BLEU value; for difficult samples, combined with manual review, an accuracy score can be given. In addition, design an error reporting mechanism that allows users to report errors or inaccurate answers, and the system extracts the query content, answer, and user feedback to generate an error report for analysis.

[0147] When tracking the response time, the performance monitoring tool New Relic can be used to monitor the processing time of each query, and the running information, including query content, query processing start time, system response time, answer content, and other relevant running parameters, is automatically logged and stored. Regularly analyze the response time of abnormal queries and the response changes during the peak daily access traffic.

[0148] When evaluating user satisfaction, an online questionnaire can be used for satisfaction evaluation, including content such as answer accuracy and usage experience. At the same time, an open text box is set up to collect direct feedback, and sentiment analysis is applied to the user feedback to evaluate user satisfaction. The user satisfaction is comprehensively evaluated by combining the questionnaire scores and user feedback.

[0149] Figure 2 It is a flowchart of another construction safety Q&A method based on large language model technology provided by an embodiment of the present invention, which closed-loop shows the whole process from the construction of the vector library and knowledge graph to text quality evaluation and performance monitoring. The whole method can be understood with reference to this figure.

[0150] In summary, in order to effectively solve the complex problems in construction safety construction and management, this embodiment provides a construction safety Q&A method based on large language model technology. A knowledge graph is constructed based on in-depth analysis of a large number of accident investigation reports, and the complex correlation relationships among accidents, hidden dangers, operations, locations, and measures are sorted out in a graph structure. The regulatory text data and the graph data of the knowledge graph are integrated into a professional knowledge base in the construction safety field, providing the ability to comprehensively and deeply analyze complex safety problems through multi-source fusion data. In specific query problems, this embodiment uses a large language model to classify the problem categories, and customizes different data retrieval and matching rules according to the characteristics of rule-based query problems and accident / hidden danger inquiry problems: for the input rule-based queries, vector similarity matching is used for retrieval in the vector database, and the retrieved knowledge fragments are output as reference knowledge; for the input accident / hidden danger inquiry queries, multimodal matching is performed in both the vector space and the knowledge graph, and the reference knowledge is output by integrating the semantic matching fragments and the structure matching graph. Finally, the retrieved knowledge is combined with the user's original query, and comprehensive processing and answer generation are performed through the large language model, playing a role in knowledge supplementation and problem explanation while maintaining the generation quality, greatly improving the accuracy, enlightenment, and transparency of the Q&A.

[0151] Figure 3 It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention, as Figure 3 shown, the device includes a processor 60, a memory 61, an input device 62, and an output device 63; the number of processors 60 in the device can be one or more, Figure 3 taking one processor 60 as an example; the processor 60, memory 61, input device 62, and output device 63 in the device can be connected through a bus or other means, Figure 3 taking connection through a bus as an example.

[0152] The memory 61, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the construction industry safety Q&A method based on large language model technology in the embodiments of the present invention. The processor 60 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 61, that is, implements the above-mentioned construction industry safety Q&A method based on large language model technology.

[0153] The memory 61 may mainly include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory 61 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some instances, the memory 61 may further include a memory remotely provided relative to the processor 60, and these remote memories can be connected to the device through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.

[0154] The input device 62 can be used to receive input digital or character information, and generate key signal inputs related to the user settings and function controls of the device. The output device 63 may include a display device such as a display screen.

[0155] The embodiments of the present invention also provide a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the construction industry safety Q&A method based on large language model technology in any embodiment.

[0156] The computer storage medium of the embodiments of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device.

[0157] A computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which computer-readable program code is carried. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.

[0158] The program code contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0159] The computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the C language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the technical solutions of the embodiments of the present invention.

Claims

1. A safety Q&A method for the construction industry based on large language model technology, characterized in that, Including: Obtain the question to be answered, and use a large language model to judge the type of the question; The question types include rule query questions and accident / hidden danger inquiry questions. Among them, rule query questions refer to questions clearly stated in regulations, systems, and manual documents, and accident / hidden danger inquiry questions refer to complex queries that cannot be fully reflected in the regulations and systems documents and require analyzing accident report texts; If the question belongs to a rule query question: Vectorize the question, and retrieve the most similar knowledge fragment in the vector library, and prompt the large language model to answer according to the knowledge fragment; If the question belongs to an accident / hidden danger inquiry question: Vectorize the question, and retrieve the most similar knowledge fragment in the vector library; at the same time, extract the entities and entity relationships in the question, and retrieve the sub-graph related to the entities and entity relationships in the knowledge graph; prompt the large language model to answer according to the knowledge fragment and the sub-graph; Among them, the vector library is constructed according to the building safety management documents, and the knowledge graph is constructed according to the historical building safety accident reports; The steps of constructing the vector library according to the building safety management documents include: preparing and storing the building safety management document data, preprocessing and segmenting the document, vectorizing the segmented text segments, and storing the vector data; correspondingly, the knowledge fragment retrieved in the vector library is a certain text segment in the building safety management document.

2. The method according to claim 1, wherein The using the large language model to judge the type of the question includes: Explaining the characteristics of rule query questions and accident / hidden danger inquiry questions to the large language model; Prompting the large language model to judge the type of the question according to the characteristics.

3. The method according to claim 1, characterized in that, The building safety management documents include at least one of laws and regulations, national standards, industry specifications, enterprise manuals, and expert guides; Entities include at least one of accident types, accident locations, operation links, responsible parties, accident causes, prevention and rectification measures; Entity relationships include causal relationships.

4. The method according to claim 1, wherein Before extracting the entities and entity relationships in the question, it also includes: Labeling entities and entity relationships for some data in the historical building safety accident reports, where the labeled entities include at least one of accident types, accident locations, operation links, responsible parties, accident causes, prevention and rectification measures; the labeled entity relationships include causal relationships; Using the labeled data to train the BiLSTM-CRF model so that the trained model can identify the entities and entity relationships in the input text; Using the trained model to identify the unlabeled data to obtain the pseudo-labels of the unlabeled data; Combining the labeled data and the data with pseudo-labels into a new training set, and performing secondary training on the trained model to obtain the final BiLSTM-CRF model.

5. The method according to claim 1, characterized in that, Before retrieving the sub-graph related to the entities and entity relationships in the knowledge graph, it also includes: Extract multiple entities and entity relationships from historical construction accident reports, where the extracted entities include at least one of accident type, accident location, operation link, responsible entity, accident cause, preventive and corrective measures; the extracted entity relationships include causal relationships. Match the entity relationships with the set of relationships between the entity categories in the predefined construction accident domain according to the categories of each entity. Construct a knowledge graph of the construction accident domain based on the entities and entity relationships that can be matched.

6. The method according to claim 1, wherein The retrieving sub-graphs related to the entities and entity relationships in the knowledge graph includes: Vectorize the entities and entity relationships, as well as each node and edge of the knowledge graph. Calculate the first vector similarity between the entity and each node, and select the nodes with the top-ranked similarities as candidate nodes. Calculate the second vector similarity between the edges of each candidate node and the entity relationship, and select the edges with the top-ranked similarities as candidate edges. Generate a sub-graph related to the entities and entity relationships based on the candidate nodes and candidate edges.

7. The method according to claim 1, wherein The sub-graph is represented as a relationship list, a connection path, or a graph structure. The retrieving sub-graphs related to the entities and entity relationships in the knowledge graph includes: Retrieve the nodes and edges related to the entities and entity relationships in the knowledge graph. If the question needs to understand the direct connection between specific entities, output the retrieval result as a relationship list of the specific entities. If the question needs to understand the indirect connection between two entities, output the retrieval result as a connection path between the two entities. If the question needs to analyze the complex interaction between multiple entities and relationships, output the retrieval result as a graph structure composed of multiple nodes and edges.

8. The method according to claim 1, wherein The prompting the large language model to give the answer to the question based on the knowledge fragment and the sub-graph includes: Set the role of the large language model as an expert in answering construction safety questions. Provide the knowledge fragment, the sub-graph, and the question to the large language model. Prompt the large language model to act as the set role, give the answer to the question based on the knowledge fragment and the sub-graph, and indicate the directly cited text and graph.

9. An electronic device, characterized in that, Includes: One or more processors; A memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the construction safety Q&A method based on the large language model technology according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the program is executed by a processor, it implements the construction safety Q&A method based on the large language model technology according to any one of claims 1-8.

Citation Information

Patent Citations

  • Auxiliary retrieval method fusing knowledge graph and large language model

    CN117633252A