Construction method of dam emergency response rule question-answering recommendation system based on large language model

By introducing dam emergency response knowledge base and prompt word injection technology, the problem of low quality answers to large language models in the field of dam emergency response is solved, the accuracy and comprehensiveness of the answers are improved, and the efficiency and output quality of the system are enhanced.

CN118332076BActive Publication Date: 2024-12-06HOHAI UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410345422.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-25
Publication Date
2024-12-06
Estimated Expiration
2044-03-25

AI Technical Summary

Technical Problem

The existing question-and-answer system based on large language models has problems such as information lag, corpus missing and model hallucinations in the field of dam emergency response, which affects the quality and efficiency of answers.

Method used

By introducing the Dam Emergency Response Knowledge Base to provide domain knowledge for large language models and using prompt word injection technology, helping the model understand user input and improve the accuracy and comprehensiveness of the answers. Specific steps include emergency response document encoding, user input verification, scene recognition and keyword extraction, emergency response rule matching and integration of prompt words to prevent user input attacks.

Benefits of technology

The accuracy and comprehensiveness of the large language model in the field of emergency response of dams is improved, information lag and corpus missing are avoided, and the efficiency and output quality of the system are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118332076B_ABST
    Figure CN118332076B_ABST
Patent Text Reader

Abstract

The present invention discloses a dam emergency response rule question-and-answer recommendation system based on a large language model and a construction method thereof. The system encodes the emergency response document uploaded by the user and then constructs a corresponding knowledge base; performs an aggressive tendency test on the user input; performs emergency scene recognition and question keyword extraction on the user input; matches the emergency response rules in the knowledge base according to the emergency scene and the question keyword; integrates the emergency response rule text into a prompt word template and outputs the result. The present invention is used for dam emergency response rule question-and-answer, and provides relevant information for the large language model according to the relevant professional field knowledge and expectations of the dam emergency response knowledge base, helps the model to better understand the problem, improves the accuracy and comprehensiveness of the answer, and enhances the performance of the dam emergency response rule question-and-answer system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method for constructing a dam emergency response rule question and answer recommendation system, and in particular to a method and system for constructing a dam emergency response rule question and answer recommendation system based on a large language model, belonging to the field of intelligent question and answer. Background Art

[0002] Dam emergency response refers to a series of measures taken to ensure the safety of the dam and the surrounding personnel and property when an emergency may occur at the dam. Its purpose is to minimize the losses caused by disasters and ensure the safe and stable operation of the dam. The focus of dam response is prevention and initiative. It requires the preparation of emergency plans in advance, predictions and warnings of possible dangerous situations, and the rapid and orderly organization of emergency responses after accidents. Dam emergency response is an important task to ensure the safe operation of dams. It requires comprehensive consideration of factors such as technology, management, and emergency materials to improve the ability of emergency response and reduce the risk of dam operation.

[0003] In question-answering applications based on large language models, large language models can generate answers based on user input. However, since these models cannot access the latest knowledge or expertise in a specific field, relying solely on large language models to generate answers still has problems such as information lag, missing corpus, and hallucinations, which seriously affect the quality of answers. There are currently some methods that use fine-tuning technology to inject specific domain knowledge into large language models, but these methods require a large amount of fine-tuning data. The model may forget domain knowledge and may still have problems such as model hallucinations, which seriously affects the efficiency and output quality of the question-answering system. Summary of the invention

[0004] Purpose of the invention: In view of the problems and deficiencies in the prior art, the present invention provides a dam emergency response rule question-answering recommendation system based on a large language model and a construction method thereof, aiming to use the dam emergency response knowledge base to provide domain knowledge and professional corpus for the large language model. In the question-answering task, by injecting prompt words, professional knowledge is used in the form of prompt word context to help the large language model understand the emergency response questions input by the user, improve the accuracy and comprehensiveness of the model's answers, and enhance the performance of the large language model in the dam emergency response rule question-answering.

[0005] Technical solution: A method for constructing a dam emergency response rule question-answering recommendation system based on a large language model. The introduction of an additional dam emergency response knowledge base can provide the model with more comprehensive and accurate information and help the model better understand the problem. At the same time, the model can obtain the required professional knowledge, thereby helping the model to deal with problems in the specific field of knowledge such as dam emergency response, enhance the performance of the large language model in the field of dam emergency response, and improve the accuracy and comprehensiveness of the answers.

[0006] The following steps are involved:

[0007] (1) Emergency response document encoding: The dam emergency response rule question-and-answer recommendation system processes the emergency response documents uploaded by users, performs format standardization on the original documents, splits the documents into manageable segments through text preprocessing and text segmentation, and uses a semantic vector model to encode the segmented segments into vector form to capture semantic information. This vector representation is then stored in a vector database for vector similarity retrieval calculations.

[0008] (2) User input verification: Build a text compliance classification model to identify and filter user input, review the content of user input, and check whether the user input contains illegal content, hateful tendencies, and other violations. The output results of the text compliance classification model are used to comprehensively judge whether the user input contains illegal content and filter out illegal questions.

[0009] (3) User input scenario recognition and keyword extraction: Construct an emergency response scenario classification model to identify the emergency scenario corresponding to the user's question from the set emergency response scenario library, and use it to locate the emergency response scenario in the relational database to improve the matching accuracy of the emergency response rules. Construct a keyword extraction model to extract keywords from legitimate user question input and mine the key information in the question to more accurately locate the content of the emergency response document. For the extracted key information, use the semantic vector model to encode it into a vector form, which is used for similarity calculation and retrieval in the vector database.

[0010] (4) Emergency response rule matching: Construct an emergency response rule matching model, use the extracted emergency scenarios and user question keywords, calculate the semantic similarity based on the keywords, query the identification numbers of the first k emergency response rules with the highest matching semantic similarity from the vector database, and query the text content of the emergency response rules that match the emergency scenario from the relational database based on the identification numbers and emergency scenarios.

[0011] (5) Integrate prompt words and output results: Build a prompt word template library, select different prompt word templates according to the requirements of the emergency scenario, and after receiving the query results of the vector database, integrate the emergency response rules into the prompt template as supplementary knowledge according to the prompt word template requirements. At the same time, set preventive measures to prevent users from using question input to perform prompt word injection attacks. The integrated prompt words will eventually be input into the large language model for processing, and the system will then feed back the output results of the large model to the user as the final output.

[0012] Furthermore, the specific steps of emergency response document coding in step (1) are as follows:

[0013] (1.1) Document standardization. Given an input document and a corresponding emergency scenario, the document can be in various formats such as Word, TXT, and PDF. In order to enable the large language model to understand the document content, the document is standardized and the input document is converted into plain text data using a document loader.

[0014] (1.2) Document slicing. For a long text document, the document is sliced ​​and the long text is divided into multiple short text segments {p1, p2, ..., p m}, where each paragraph p i They all contain part of the complete semantics of the original long text to improve the accuracy of information retrieval, reduce the computational burden of the system in processing long texts, and improve computing efficiency.

[0015] (1.3) The text segment is encoded into a vector form. For the segmented short text segment {p1, p2, ..., p m}, using the pre-trained vector encoding model to capture the deep semantic relationship of the text segment and obtain the semantic vector represented in digital form As shown in the following formula:

[0016]

[0017] Among them, Embed(·) is the vector encoding model.

[0018] (1.4) The information is stored in the database. Each generated semantic vector and its corresponding paragraph p i A unique identifier is assigned, the semantic vector is stored in the vector database, and the text and emergency scenarios are stored in the relational database for similarity calculation and matching with emergency response rules.

[0019] Furthermore, the specific steps of the user input verification in step (2) are as follows: for the user input q, use the offensive language detection model to detect and identify whether the user input uses offensive language content or illegal content with a tendency, including content or tendency with hatred, and the output result is True or False. The recognition result of each type of content or tendency is recorded as {r1, r2, ..., r n}. The final test result r of the user input q is shown in the following formula:

[0020] r=r1∧r2∧...∧r n

[0021] For inputs containing illegal content, the dam emergency response rule question and answer recommendation system directly skips subsequent processing and returns an illegal prompt.

[0022] Furthermore, the specific steps of user input scene recognition and keyword extraction in step (3) are as follows:

[0023] (3.1) Emergency scenario identification. For user input q, the emergency scenario classification model is used to identify the emergency scenario s∈S corresponding to the user’s question, where S is an emergency scenario library containing various emergency scenarios such as earthquakes, mudslides, and floods.

[0024] (3.2) Question keyword extraction. For user input q, the keyword extraction model is used to identify the keywords {k1, k2, ..., k m}, use the pre-trained vector encoding model to encode the keywords and obtain the semantic vector represented in digital form As shown in the following formula:

[0025]

[0026] Among them, Embed(·) is the vector encoding model.

[0027] Furthermore, the specific steps of emergency response rule matching in step (4) are as follows:

[0028] (4.1) Similarity calculation. Given the semantic vector of the keyword in the user's question Semantic vector sets of regular text stored in vector databases Calculate the semantic vector of each rule text The similarity s between the input q and the user i , that is, the matching score between the emergency response rule text vector and the user input keyword vector, as shown in the following formula:

[0029]

[0030] Among them, Similarity(·) is the similarity score function between the two. Here, cosine similarity is used to compare the similarity between the two. is the average semantic vector of keywords, as shown in the following formula:

[0031]

[0032] (4.2) Database query. Select the calculated similarity score {s1, s2, ..., s m} The highest first k identification numbers. According to the identification number and the identified emergency scenario s, the corresponding matching emergency response rule text is queried from the relational database

[0033] Furthermore, the specific steps of integrating the prompt words and outputting the results in step (5) are as follows:

[0034] (5.1) Selecting a template from a prompt word template library. According to different emergency scenarios, a prompt word template corresponding to the emergency scenario is selected from a preset prompt word template library, wherein each prompt word template has reserved space for the emergency response rule text in the form of a placeholder.

[0035] (5.2) Perform prompt word injection prevention settings. Set the system message in the prompt word template, specify the role and function range of the large language model, and set the separator between the system message and the user message, such as "###". At the same time, filter the specific separators set in the user input to prevent users from injecting prompt words. Add a prefix message before the user input, requiring the large language model to output the reply strictly in accordance with the requirements of the system message.

[0036] (5.3) Inject emergency response rules. Match the placeholders in the prompt word template, format each emergency response rule text and integrate it into the prompt word template according to the template requirements as the prompt word input that is finally submitted to the large language model.

[0037] A dam emergency response rule question-answering recommendation system based on a large language model includes the following modules:

[0038] (1) Emergency response document encoding module: The dam emergency response rule question-and-answer recommendation system processes the emergency response documents uploaded by users, performs format standardization on the original documents, splits the documents into manageable segments through text preprocessing and text segmentation, and uses the semantic vector model to encode the divided segments into vector form to capture semantic information. This vector representation is then stored in the vector database for vector similarity retrieval calculation.

[0039] (2) User input verification module: Build a text compliance classification model to identify and filter user input, review the content of user input, and check whether the user input contains illegal content, hateful tendencies, and other violations. The output results of the text compliance classification model are used to comprehensively judge whether the user input contains illegal content and filter illegal questions.

[0040] (3) User input scenario recognition and keyword extraction module: Build an emergency response scenario classification model to identify the emergency scenario corresponding to the user's question from the set emergency response scenario library, and use it to locate the emergency response scenario in the relational database to improve the matching accuracy of the emergency response rules. Build a keyword extraction model to extract keywords from legitimate user question input and mine the key information in the question to more accurately locate the content of the emergency response document. For the extracted key information, use the semantic vector model to encode it into a vector form, which is used for similarity calculation and retrieval in the vector database.

[0041] (4) Emergency response rule matching module: Construct an emergency response rule matching model, use the extracted emergency scenarios and user question keywords, calculate the semantic similarity based on the keywords, query the identification numbers of the first k emergency response rules with the highest matching semantic similarity from the vector database, and query the text content of the emergency response rules that match the emergency scenario from the relational database based on the identification numbers and emergency scenarios.

[0042] (5) Prompt word integration and result output module: Build a prompt word template library, select different prompt word templates according to the requirements of the emergency scenario, and after receiving the query results of the vector database, integrate the emergency response rules into the prompt template as supplementary knowledge according to the prompt word template requirements. At the same time, set preventive measures to prevent users from using question input to perform prompt word injection attacks. The integrated prompt words will eventually be input into the large language model for processing, and the system will then feed back the output results of the large model to the user as the final output.

[0043] The system implementation process is the same as the above-mentioned construction method.

[0044] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for implementing the dam emergency response rule question-and-answer recommendation system based on a large language model as described above is implemented.

[0045] A computer-readable storage medium stores a computer program for executing the implementation method of the dam emergency response rule question-answering recommendation system based on a large language model as described above.

[0046] Beneficial effects: Compared with the prior art, the dam emergency response rule question-answering recommendation system based on the large language model and the construction method thereof provided by the present invention have the following advantages over the prior art: by directly inputting the emergency response document, it avoids the manual construction of a large number of fine-tuning data sets while being able to inject professional knowledge into the large language model, providing sufficient context for the model, and avoiding problems such as information lag, missing corpus, and model hallucination. In addition, by extracting the emergency scenarios and keywords asked by users to match the relevant emergency response rules, it is possible to locate the relevant emergency response rules more comprehensively and accurately, help the model better understand the problem, improve the accuracy and comprehensiveness of the answer, and enhance the performance of the large language model in the field of dam emergency response. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 is a flow chart of a method according to an embodiment of the present invention;

[0048] Figure 2 A framework diagram of emergency response document coding according to an embodiment of the present invention.

[0049] Figure 3 A framework diagram of user input scene recognition and keyword extraction according to an embodiment of the present invention.

[0050] Figure 4 A framework diagram of emergency response rule matching according to an embodiment of the present invention.

[0051] Figure 5 It is a framework diagram of prompt word integration and result output according to an embodiment of the present invention. DETAILED DESCRIPTION

[0052] The present invention is further explained below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.

[0053] like Figure 1 As shown, a method for constructing a dam emergency response rule question-answering recommendation system based on a large language model specifically includes the following steps:

[0054] Step (1) Emergency response document encoding: The dam emergency response rule question-and-answer recommendation system processes the emergency response documents uploaded by users, performs format standardization on the original documents, splits the documents into manageable segments through text preprocessing and text segmentation, and uses a semantic vector model to encode the divided segments into vector form to capture semantic information. This vector representation is then stored in a vector database for vector similarity retrieval calculations.

[0055] Input PDF documents, use OCR technology and PDF document loader to convert unformatted documents into text forms that can be understood by large language models. Then use document divider to divide long documents into short text segments with complete semantics. For each segment, use pre-trained semantic vector encoder to encode it into vector format, store the short text segment vector format in the vector database, and store (logo, short text segment text format, emergency scenario) in the relational database.

[0056] Step (2) User input verification: Build a text compliance classification model to identify and filter user input, review the content of user input, and check whether the user input contains offensive language or illegal content. The output of the text compliance classification model is used to comprehensively judge whether the user input contains illegal content and filter illegal questions.

[0057] For example, a user inputs the question "How should we deal with emergency situations under the red warning of heavy rain?" The text compliance classification model will output whether there is any violation content based on the user's text input, and the question will be identified as not having such a tendency and will be reviewed through question input.

[0058] Step (3) User input scene recognition and keyword extraction: Construct an emergency response scene classification model to identify the emergency scene corresponding to the user's question from the set emergency response scene library, and use it to locate the emergency response scene in the relational database to improve the matching accuracy of the emergency response rules. Construct a keyword extraction model to extract keywords from legitimate user question input and mine the key information in the question to more accurately locate the content of the emergency response document. For the extracted key information, use the semantic vector model to encode it into a vector form, which is used for similarity calculation and retrieval in the vector database.

[0059] In the above user input question, the emergency response scenario classification model will recognize that the question is about a rainstorm scenario, and the keyword extraction model will extract the keywords (rainstorm, red alert, how to deal with it). These keywords are encoded into vector format through the pre-trained semantic vector encoder.

[0060] Step (4) Emergency response rule matching module: Construct an emergency response rule matching model, use the extracted emergency scenarios and user question keywords, calculate semantic similarity based on the keywords, query the identification numbers of the first k emergency response rules with the highest matching semantic similarity from the vector database, and query the text content of the emergency response rules that match the emergency scenario from the relational database based on the identification numbers and emergency scenarios.

[0061] For the keywords (heavy rain, red alert, how to deal with it), similarity calculation is performed in the vector database in the form of vectors to obtain the identification numbers of the most matching k emergency response rules. According to the identification numbers and the emergency response scenario "heavy rain", the corresponding emergency response rule texts are queried in the relational database: {"When a red alert is issued, the following measures are taken: (1) Issue the alert information according to the prescribed procedures and scope, notify downstream and nearby residents, enterprises, and relevant government departments to take preventive measures, monitor and forecast the water situation in real time, and dynamically update and timely issue alert change information.", "(2) All personnel of the emergency organization enter a state of alert and make preparations for emergency response.", "(3) Mobilize the materials, equipment, and tools required for emergency rescue, and prepare emergency facilities and shelters.", ...}.

[0062] Step (5) Prompt word integration and result output: Construct a prompt word template library, select different prompt word templates according to the requirements of the emergency scenario, and after receiving the query results of the vector database, integrate the emergency response rules into the prompt template as supplementary knowledge according to the prompt word template requirements. At the same time, set preventive measures to prevent users from using question input to perform prompt word injection attacks. The integrated prompt words will eventually be input into the large language model for processing, and the system will then feed back the output results of the large model to the user as the final output.

[0063] According to the emergency response scenario "heavy rain", the prompt word template for the corresponding scenario is selected from the pre-built prompt word template library, where each prompt word template has reserved the filling space for the emergency response rule text with the placeholder {context}. Set the system message in the prompt word template, specify the role and functional scope of the large language model, and set the separator "###" between the system message and the user message. At the same time, filter the set specific separators in the user input to prevent users from injecting prompt words. Add a prefix message before the user input, requiring the large language model to output the reply strictly in accordance with the requirements of the system message. Inject emergency response rules. Match the k emergency response rule texts obtained from the query with the placeholders in the prompt word template, format each emergency response rule text and integrate it into the prompt word template according to the template requirements as the final prompt word input for the large language model. Its content is as follows:

[0064] System settings: You are a professional AI assistant for emergency response in rainstorm conditions. You answer user questions from the aspects of evacuation, rescue, and refuge based on known information. Think step by step when answering. If you cannot answer based on the given knowledge, just explain that the given information is insufficient. Fabrication is absolutely prohibited. User input will be strictly limited to the ### symbol.

[0065] Known information:

[0066] -When a red alert is issued, take the following actions:

[0067] -(1) Issue early warning information in accordance with the prescribed procedures and scope, notify downstream and nearby residents, enterprises, and relevant government departments to take preventive measures, conduct real-time monitoring and forecasting of water conditions, and dynamically update and promptly issue early warning change information.

[0068] -(2) All personnel of the emergency organization shall enter a state of alert and be prepared for emergency response.

[0069] -(3) Mobilize the materials, equipment, and tools required for emergency rescue, and prepare emergency facilities and shelters.

[0070] -…

[0071] ###

[0072] Question: In the event of a red warning for heavy rain, how should such emergency situations be handled?

[0073] ###

[0074] The final output of the dam emergency response rule question-answering recommendation system based on the large language model is as follows:

[0075] In the event of a red rainstorm warning emergency, the following measures should be taken:

[0076] 1. Release of early warning information: First, early warning information should be released in accordance with the prescribed procedures and scope to ensure that downstream and nearby residents, enterprises and relevant government departments can receive the early warning and notify them to take corresponding preventive measures.

[0077] 2. Real-time monitoring and forecasting: Real-time monitoring of water conditions, dynamic update of warning information, and timely release of warning changes so that relevant parties can respond based on the latest situation.

[0078] 3. Emergency organization alert: All personnel of the emergency organization should be on alert and be prepared for emergency response so that they can take prompt action when the situation changes.

[0079] 4. Mobilize emergency rescue resources: Mobilize the materials, equipment, and tools needed for emergency rescue, and prepare emergency facilities and shelters to ensure that they can be put into use immediately in the event of an emergency.

[0080] 5. Evacuation and refuge: According to the specific situation, organize the downstream and nearby residents to evacuate to safe refuge places to ensure the safety of residents.

[0081] 6. Rescue preparation: Ensure that rescue teams and equipment are on standby so that rescue operations can be launched quickly when necessary.

[0082] The above measures are based on known information and are the disposal methods that should be taken according to the emergency conditions of the red warning for heavy rain.

[0083] The dam emergency response rule question-answering recommendation system based on a large language model includes the following modules:

[0084] (1) Emergency response document encoding module: The dam emergency response rule question-and-answer recommendation system processes the emergency response documents uploaded by users, performs format standardization on the original documents, splits the documents into manageable segments through text preprocessing and text segmentation, and uses the semantic vector model to encode the divided segments into vector form to capture semantic information. This vector representation is then stored in the vector database for vector similarity retrieval calculation.

[0085] (2) User input verification module: Build a text compliance classification model to identify and filter user input, review the content of user input, and check whether the user input contains any illegal content. The output of the text compliance classification model is used to comprehensively judge whether the user input contains any illegal content, and illegal questions are filtered out.

[0086] (3) User input scenario recognition and keyword extraction module: Build an emergency response scenario classification model to identify the emergency scenario corresponding to the user's question from the set emergency response scenario library, and use it to locate the emergency response scenario in the relational database to improve the matching accuracy of the emergency response rules. Build a keyword extraction model to extract keywords from legitimate user question input and mine the key information in the question to more accurately locate the content of the emergency response document. For the extracted key information, use the semantic vector model to encode it into a vector form, which is used for similarity calculation and retrieval in the vector database.

[0087] (4) Emergency response rule matching module: Construct an emergency response rule matching model, use the extracted emergency scenarios and user question keywords, calculate the semantic similarity based on the keywords, query the identification numbers of the first k emergency response rules with the highest matching semantic similarity from the vector database, and query the text content of the emergency response rules that match the emergency scenario from the relational database based on the identification numbers and emergency scenarios.

[0088] (5) Prompt word integration and result output module: Build a prompt word template library, select different prompt word templates according to the requirements of the emergency scenario, and after receiving the query results of the vector database, integrate the emergency response rules into the prompt template as supplementary knowledge according to the prompt word template requirements. At the same time, set preventive measures to prevent users from using question input to perform prompt word injection attacks. The integrated prompt words will eventually be input into the large language model for processing, and the system will then feed back the output results of the large model to the user as the final output.

[0089] Obviously, those skilled in the art should understand that the various steps of the dam emergency response rule question-answering recommendation system based on a large language model or the various modules of the dam emergency response rule question-answering recommendation system based on a large language model of the above-mentioned embodiment of the present invention can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the examples of the present invention are not limited to any specific combination of hardware and software.

Claims

1. A method for constructing a dam emergency response rule question-answering recommendation system based on a large language model, characterized in that: The following steps are involved: (1) Emergency response document encoding: The dam emergency response rule question-answering recommendation system processes emergency response documents uploaded by users, performs format standardization on the original documents, splits the documents into segments through text preprocessing and text segmentation, and uses a semantic vector model to encode the segmented segments into vector form to capture semantic information. This vector representation is then stored in a vector database for vector similarity retrieval calculation; (2) User input verification: Build a text compliance classification model to identify and filter user input, review the content of user input, and use the output of the text compliance classification model to comprehensively determine whether the user input contains illegal content and filter out illegal questions; (3) User input scenario recognition and keyword extraction: Construct an emergency response scenario classification model to identify the emergency scenario corresponding to the user's question from the set emergency response scenario library, and use it to define the emergency response scenario in the relational database; construct a keyword extraction model to extract keywords from legitimate user question input and mine the key information in the question; for the extracted key information, use the semantic vector model to encode it into a vector form, and use it to calculate similarity and search in the vector database; (4) Emergency response rule matching: Construct an emergency response rule matching model, use the extracted emergency scenarios and user question keywords, calculate semantic similarity based on keywords, query the identification numbers of the first k emergency response rules with the highest matching semantic similarity from the vector database, and query the text content of the emergency response rules that match the emergency scenario from the relational database based on the identification numbers and emergency scenarios; (5) Integrate prompt words and output results: Build a prompt word template library, select different prompt word templates according to the requirements of the emergency scenario, and after receiving the query results of the vector database, integrate the emergency response rules as supplementary knowledge into the prompt template according to the requirements of the prompt word template; Set up preventive measures to prevent users from using question input to perform prompt word injection attacks; The integrated prompt words will be finally input into the large language model for processing, and the system will then feed back the output of the large model to the user as the final output; The specific steps of emergency response document coding in step (1) are as follows: (1.1) Document standardization: Given an input document and a corresponding emergency scenario, the document is standardized and converted into plain text data using a document loader; (1.2) Document slicing: Slice the document and divide the long text into multiple short text segments {p1, p2, ..., p m }, where each text segment p i They all contain a part of the complete semantics of the original long text; (1.3) Encoding the text segment into a vector form: For the segmented short text segment {p1, p2, ..., p m }, using the pre-trained vector encoding model to capture the deep semantic relationship of the text segment and obtain the semantic vector represented in digital form As shown in the following formula: Among them, Embed(·) is the vector encoding model; (1.4) Information is stored in the database: Each generated semantic vector and its corresponding paragraph p i A unique identifier is assigned, the semantic vector is stored in the vector database, and the text and emergency scenarios are stored in the relational database for similarity calculation and matching with emergency response rules. The specific steps of user input scene recognition and keyword extraction in step (3) are as follows: (3.1) Emergency scenario identification: For user input q, the emergency scenario classification model is used to identify the emergency scenario s∈S corresponding to the user’s question, where S is the emergency scenario library; (3.2) Question keyword extraction: For user input q, use the keyword extraction model to identify the keywords {k1, k2, ..., k m }, use the pre-trained vector encoding model to encode the keywords and obtain the semantic vector represented in digital form As shown in the following formula: Among them, Embed(·) is the vector encoding model; The specific steps of emergency response rule matching in step (4) are as follows: (4.1) Similarity calculation: Given the semantic vector of the keywords in the user's question Semantic vector sets of regular text stored in vector databases Calculate the semantic vector of each rule text The similarity s between the input q and the user i , which is the matching score between the emergency response rule text vector and the user input keyword vector, as shown in the following formula: Among them, Similarity(·) is the similarity score function between the two. Here, cosine similarity is used to compare the similarity between the two. is the average semantic vector of keywords, as shown in the following formula: (4.2) Database query: Select the calculated similarity score {s1, s2, ..., s m } The highest first k identification numbers; query the corresponding matching emergency response rule text from the relational database based on the identification number and the identified emergency scenario s The specific steps of integrating prompt words and outputting results in step (5) are as follows: (5.1) Selecting a template from a prompt word template library: According to different emergency scenarios, a prompt word template corresponding to the emergency scenario is selected from a preset prompt word template library, wherein each prompt word template has reserved space for the emergency response rule text in the form of a placeholder; (5.2) Perform prompt word injection prevention settings: Set the system message in the prompt word template, specify the role and function range of the large language model, and set the separator between the system message and the user message; filter the specific separators set in the user input to prevent the user from injecting prompt words; add a prefix message before the user input, requiring the large language model to output the reply strictly in accordance with the requirements of the system message; (5.3) Inject emergency response rules: inject the k emergency response rule texts obtained by query Match the placeholders in the prompt word template, format each emergency response rule text and integrate it into the prompt word template according to the template requirements as the prompt word input that is finally submitted to the large language model.

2. The method for constructing a dam emergency response rule question-answering recommendation system based on a large language model according to claim 1, characterized in that: The specific steps of the user input verification in step (2) are as follows: for the user input q, use the offensive language detection model to detect and identify whether the user input uses offensive language content or illegal content with a tendency, and the recognition result of each type of content or tendency is recorded as {r1, r2, ..., r n }; The final test result r of the user input q is shown in the following formula: r=r1∧r2∧...∧r n For inputs containing illegal content, the dam emergency response rule question and answer recommendation system directly skips subsequent processing and returns an illegal prompt.

3. A dam emergency response rule question-answering recommendation system based on a large language model that implements the method described in any one of claims 1-2, characterized in that: Includes the following modules: (1) Emergency response document encoding module: The dam emergency response rule question-answering recommendation system processes the emergency response documents uploaded by users, performs format standardization on the original documents, splits the documents into segments through text preprocessing and text segmentation, and uses the semantic vector model to encode the segmented segments into vector form to capture semantic information. This vector representation is then stored in the vector database for vector similarity retrieval calculation; (2) User input verification module: Build a text compliance classification model to identify and filter user input, review the content of user input, and comprehensively judge whether the user input contains illegal content based on the output of the text compliance classification model, and filter illegal questions; (3) User input scenario recognition and keyword extraction module: Construct an emergency response scenario classification model to identify the emergency scenario corresponding to the user's question from the set emergency response scenario library, and use it to identify the emergency response scenario in the relational database; construct a keyword extraction model to extract keywords from legitimate user question input and mine the key information in the question; for the extracted key information, use the semantic vector model to encode it into a vector form, and use it to calculate similarity and search in the vector database; (4) Emergency response rule matching module: Construct an emergency response rule matching model, use the extracted emergency scenarios and user question keywords, calculate semantic similarity based on the keywords, query the identification numbers of the first k emergency response rules with the highest matching semantic similarity from the vector database, and query the text content of the emergency response rules that match the emergency scenario from the relational database based on the identification numbers and emergency scenarios; (5) Prompt word integration and result output module: Build a prompt word template library, select different prompt word templates according to the requirements of the emergency scenario, and after receiving the query results of the vector database, integrate the emergency response rules as supplementary knowledge into the prompt template according to the requirements of the prompt word template; Set up preventive measures to prevent users from using question input to perform prompt word injection attacks; The integrated prompt words will eventually be input into the large language model for processing, and the system will then feed back the output results of the large model to the user as the final output.

4. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for constructing a dam emergency response rule question-and-answer recommendation system based on a large language model as described in any one of claims 1 to 2 is implemented.

5. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the method for constructing a dam emergency response rule question-answering recommendation system based on a large language model as described in any one of claims 1-2.