Emergency processing auxiliary question and answer method and system based on LangChain architecture

By combining the LangChain architecture with the Faiss vector database, the problem of insufficient response accuracy and efficiency of large language models in emergency response is solved, fast and accurate emergency response questions and answers are achieved, and user experience and system performance are improved.

CN120632018APending Publication Date: 2025-09-12SHANGHAI INSPUR CLOUD COMPUTING SERVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510648294.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

Existing large language models lack accuracy and efficiency in responding to emergency situations, especially in emergency situations, where it is difficult to answer users' questions quickly and accurately.

Method used

An emergency response assisted question-answering method based on the LangChain architecture is adopted. By obtaining emergency response knowledge documents, multi-dimensional summarization and organization are carried out and a secondary index is constructed. Vector matching is performed using the Faiss vector database, and the large language model LLM is combined to generate answers. The rationality of the answers is verified by setting rules.

Benefits of technology

It improves the accuracy and efficiency of answering emergency questions, can better understand user needs, provide flexible and personalized services, and enhance the overall performance of the knowledge base question-answering system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120632018A_ABST
    Figure CN120632018A_ABST
Patent Text Reader

Abstract

The invention provides an emergency processing auxiliary question answering method and system based on a LangChain framework, and the method comprises the steps: obtaining an emergency processing knowledge document; concluding and sorting the emergency processing knowledge document according to at least two dimensions so as to construct an auxiliary data set; the texts in the auxiliary data set are organized into secondary indexes, the first-level indexes are keywords, the second-level indexes are original texts, and the first-level indexes and the second-level indexes are in one-to-one correspondence; converting keywords in each text into numerical vectors and storing the numerical vectors in a vector database; the query problem of the user is converted into a problem vector, and the problem vector is used for searching and matching in the vector database; adding the matched keyword, an original text which corresponds to the keyword and is used as a second-level index, and a query problem into a prompt; and submitting the prompt to the LLM, and generating an answer by the LLM and outputting the answer. According to the invention, questions proposed by users can be answered more quickly and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present invention relate to network communication technology, and in particular to an emergency response auxiliary question-answering method and system based on the LangChain architecture. Background Art

[0002] Large language models (LLMs) excel at understanding and responding to human commands, significantly impacting natural language question answering. However, without domain-specific training, LLMs often underperform in specific verticals. Existing LLM-based methods for big data development and emergency response assistance have shortcomings in user interaction.

[0003] For emergency processing, since the issues are usually emergency situations such as equipment failure processing, LLM is required to answer the questions raised by users more quickly and accurately. Summary of the Invention

[0004] One or more embodiments of the present invention describe an emergency response assisted question-answering method and system based on the LangChain architecture, which can answer questions raised by users more quickly and accurately.

[0005] According to a first aspect, an emergency response auxiliary question-answering method based on the LangChain architecture is provided, the method comprising:

[0006] Obtaining an emergency response knowledge document; wherein the document includes emergency response knowledge;

[0007] Summarize and organize emergency response knowledge documents according to at least two dimensions to construct an auxiliary data set;

[0008] Organizing the text in the auxiliary data set into a secondary index, wherein the first-level index is the keyword, the second-level index is the original text, and the first-level index corresponds to the second-level index one-to-one;

[0009] Convert the keywords in each text segment into a numerical vector, where each dimension represents the semantics or features of the text segment, and then store the numerical vector in a vector database;

[0010] When receiving a user's query question regarding emergency handling, the user's query question is converted into a question vector, and the question vector is used to search and match in the vector database;

[0011] Add the matched keyword, the original text corresponding to the keyword as the second-level index, and the query question to the prompt;

[0012] Submit the prompt to the large language model LLM, which generates the answer and outputs it.

[0013] The at least two dimensions include: type dimension, theme dimension and author dimension.

[0014] After summarizing and arranging the emergency handling knowledge documents according to at least two dimensions and before organizing the text in the auxiliary data set into a secondary index, the method further includes:

[0015] The emergency response knowledge document is loaded, different parsing tools are used, and titles are added to the parsed content, and then saved in Markdown format to improve the recall rate.

[0016] Before converting the keywords in each paragraph of text into a numerical vector, the method further includes: extracting the relationship between the paragraphs in the text from the auxiliary data set, merging all paragraphs containing a master-slave relationship into one paragraph, so that after the article is segmented, each paragraph of text corresponds to the same event;

[0017] The second-level index corresponding to the first-level index is: the merged paragraph where the keyword of the first-level index is located.

[0018] Based on the LangChain architecture, the natural language processing (NLP) paragraph analysis tool is used to extract the relationship between paragraphs in the text from the auxiliary dataset;

[0019] Based on the LangChain architecture, the Chinese Recursive Text Splitter tool is used to split the text. At least one of the length of a single paragraph and the length of overlapping adjacent texts is restricted, so that each paragraph of the text corresponds to the same event after the article is split.

[0020] Based on the LangChain architecture, we use NLP's component syntax analysis tools to extract noun phrases and verb phrases;

[0021] Based on the LangChain architecture, we use NLP named entity recognition tools to extract currency names, personal names, and company names.

[0022] The converting of keywords in each text segment into a numerical vector includes: based on the LangChain architecture, using an embedding model to convert the extracted keywords into a numerical vector.

[0023] The vector database includes: Faiss;

[0024] The step of converting the user's query question into a question vector and using the question vector to search and match in a vector database includes:

[0025] Construct the set of all numeric vectors as Faiss index;

[0026] Convert the user's query question into a vector representation in the vector space that is the same as the numerical vector in the Faiss index;

[0027] Use the transformed query vector to perform similarity search in the Faiss index.

[0028] After the LLM generates and outputs the answer, the method further includes:

[0029] The rationality of the answers generated by LLM is verified by setting rules, constraints and secondary reasoning mechanisms. If the answer does not meet the prompt requirements, the prompt is reorganized or the query strategy is investigated based on the feedback information, and the answer is requested from LLM again until it meets the prompt requirements.

[0030] According to the second aspect, an emergency response auxiliary question-answering system based on the LangChain architecture is provided, including:

[0031] A document acquisition module configured to acquire an emergency response knowledge document; wherein the document includes emergency response knowledge;

[0032] The document processing module is configured to summarize and organize emergency response knowledge documents according to at least two dimensions to construct an auxiliary data set; organize the text in the auxiliary data set into a secondary index, wherein the first-level index is the keyword and the second-level index is the original text, and the first-level index and the second-level index have a one-to-one correspondence; convert the keywords in each text segment into a numerical vector, wherein each dimension represents the semantics or characteristics of the text segment, and then store the numerical vector in a vector database;

[0033] The large model processing module is configured to, when receiving a user's query question for emergency handling, convert the user's query question into a question vector, and use the question vector to search and match in the vector database; add the matched keyword, the original text corresponding to the keyword as a second-level index, and the query question to the prompt; submit the prompt to the large language model LLM, which generates and outputs the answer.

[0034] According to a third aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in any embodiment of the present invention is implemented.

[0035] It can be seen that each embodiment of the present invention has at least the following beneficial effects:

[0036] 1. By combining LLM technology with a local knowledge base, the accuracy and efficiency of question answering are improved. Leveraging the LangChain framework, the system is able to better understand the diverse needs of users and provide more flexible and personalized services. This approach not only improves the user experience but also significantly enhances the overall performance of the knowledge base question answering system.

[0037] 2. LangChain is a framework for developers to develop LLM (Large Language Model) applications. This embodiment of the present invention encapsulates and links the various components of LLM through the LangChain architecture. Linking LLM-related components together simplifies LLM application development and allows developers to quickly develop complex LLM applications.

[0038] 3. In this embodiment of the present invention, all text is organized into a two-level index. The first-level index represents key information, and the second-level represents the original text, with a one-to-one mapping between the two. The search component only vectorizes the keywords and participates in similarity matching. The original text mapped to the recall results is also submitted to the LLM, greatly improving efficiency.

[0039] 4. Effectively understand and analyze user needs to provide more accurate services. Provide personalized assistance and answers based on specific user needs and preferences. Collect and analyze user data to generate targeted solutions. Update local knowledge bases to timely adjust and optimize services to meet users' evolving needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0041] Figure 1 This is a flowchart of an emergency response auxiliary question-answering method based on the LangChain architecture in one embodiment of the present invention.

[0042] Figure 2 This is a schematic diagram of the processing of text merging, segmentation, keyword extraction and text vectorization in one embodiment of the present invention.

[0043] Figure 3 This is a flowchart of an emergency response auxiliary question-answering method based on the LangChain architecture in another embodiment of the present invention.

[0044] Figure 4This is a schematic diagram of the structure of an emergency response auxiliary question-answering system based on the LangChain architecture in one embodiment of the present invention. DETAILED DESCRIPTION

[0045] The solution provided by the present invention is described below with reference to the accompanying drawings.

[0046] First, it should be noted that the terms used in the embodiments of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. As used in the embodiments of the present invention and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise.

[0047] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.

[0048] Figure 1 This is a flow chart of an emergency response auxiliary question-answering method based on the LangChain architecture in one embodiment of the present invention. Figure 1 , the method comprising:

[0049] Step 101: Acquire an emergency response knowledge document; wherein the document includes emergency response knowledge;

[0050] Step 103: Summarize and organize the emergency response knowledge documents according to at least two dimensions to construct an auxiliary data set;

[0051] Step 105: Organize the text in the auxiliary data set into a secondary index, wherein the first-level index is the keyword, the second-level index is the original text, and the first-level index corresponds to the second-level index one-to-one;

[0052] Step 107: Convert the keywords in each text segment into a numerical vector, where each dimension represents the semantics or features of the text segment, and then store the numerical vector in a vector database;

[0053] Step 109: When receiving a user's query question regarding emergency handling, convert the user's query question into a question vector, and use the question vector to perform a search and match in the vector database;

[0054] Step 111: Add the matched keyword, the original text corresponding to the keyword as the second-level index, and the query question to the prompt;

[0055] Step 113: Submit the prompt to the large language model LLM, which generates and outputs the answer.

[0056] according to Figure 1 It can be seen from the method shown that the method in the embodiment of the present invention has at least the following beneficial effects:

[0057] 1. By combining LLM technology with a local knowledge base, the accuracy and efficiency of question answering are improved. Leveraging the LangChain framework, the system is able to better understand the diverse needs of users and provide more flexible and personalized services. This approach not only improves the user experience but also significantly enhances the overall performance of the knowledge base question answering system.

[0058] 2. LangChain is a framework for developers to develop LLM (Large Language Model) applications. This embodiment of the present invention encapsulates and links the various components of LLM through the LangChain architecture. Linking LLM-related components together simplifies LLM application development and allows developers to quickly develop complex LLM applications.

[0059] 3. In this embodiment of the present invention, all text is organized into a two-level index. The first-level index represents key information, and the second-level represents the original text, with a one-to-one mapping between the two. The search component only vectorizes the keywords and participates in similarity matching. The original text mapped to the recall results is also submitted to the LLM, greatly improving efficiency.

[0060] 4. Effectively understand and analyze user needs to provide more accurate services. Provide personalized assistance and answers based on specific user needs and preferences. Collect and analyze user data to generate targeted solutions. Update local knowledge bases to timely adjust and optimize services to meet users' evolving needs.

[0061] The following combination Figure 1 The process shown is used to describe the method of the embodiment of the present invention in detail.

[0062] First, step 101 is performed: obtaining an emergency handling knowledge document; wherein the document includes emergency handling knowledge.

[0063] Next, step 103 is performed: the emergency handling knowledge documents are summarized and sorted according to at least two dimensions, thereby constructing an auxiliary data set.

[0064] In one embodiment of the present invention, the at least two dimensions include: a type dimension, a subject dimension, and an author dimension.

[0065] In one embodiment of the present invention, the steps between step 103 and step 105 further include:

[0066] Step 104: Load the emergency response knowledge document, use different parsing tools, add titles to the parsed content, and then save it in Markdown format to improve the recall rate.

[0067] In the above steps 101, 103 and 104, the embodiment of the present invention can summarize and organize the big data development and emergency response documents uploaded by users according to dimensions such as type, subject, and author, thereby constructing an auxiliary data set. Upload the documents to the data storage module to supplement the content that has not yet been covered by the data set. In addition, the recall rate needs to be improved when the document is loaded to improve the accuracy and stability of the LLM answer. The document may be parsed inaccurately, resulting in a low retrieval recall rate. On the one hand, different parsing tools can be tried to make the parsing more accurate. On the other hand, for documents that do not perform well with different parsing tools, try adding titles to the parsed content and save it in Markdown format to improve the recall rate.

[0068] Next, step 105 is performed: organizing the text in the auxiliary data set into a secondary index, wherein the first-level index is the keyword, the second-level index is the original text, and the first-level index corresponds to the second-level index one-to-one.

[0069] In this embodiment of the present invention, the granularity of text segmentation is difficult to control, leading to concerns about excessive noise and loss of semantic information. To maximize recall, reduce irrelevant information, and increase speed, this embodiment organizes all text into a two-level index. The first-level index represents key information, and the second-level represents the original text, with a one-to-one mapping between the two. The search component only embeds the key information and participates in similarity calculations. The original text mapped to the recall results is then passed to the LLM.

[0070] In one embodiment of the present invention, the following steps are further included between step 105 and step 107:

[0071] Step 106: Before converting the keywords in each paragraph of text into a numerical vector, extract the relationship between the paragraphs in the text from the auxiliary data set, merge all paragraphs containing master-slave relationships into one paragraph, so that after the article is segmented, each paragraph of text corresponds to the same thing; wherein, the second-level index corresponding to the first-level index is: the merged paragraph where the keyword of the first-level index is located.

[0072] In one embodiment of the present invention, the processing of step 106 may be implemented in the following manner:

[0073] Based on the LangChain architecture, the natural language processing (NLP) paragraph analysis tool is used to extract the relationship between paragraphs in the text from the auxiliary dataset;

[0074] Based on the LangChain architecture, the Chinese Recursive Text Splitter tool is used to split the text. At least one of the length of a single paragraph and the length of overlapping adjacent texts is restricted, so that each paragraph of the text corresponds to the same event after the article is split.

[0075] Based on the LangChain architecture, we use NLP's component syntax analysis tools to extract noun phrases and verb phrases;

[0076] Based on the LangChain architecture, we use NLP named entity recognition tools to extract currency names, personal names, and company names.

[0077] It can be seen that in the embodiment of the present invention, the main relationships between paragraphs, such as subordinate relationships, are extracted by using the natural language processing (NLP) paragraph analysis tool. Figure 2 Merge paragraphs A and B into one paragraph, for example Figure 2 Fragment D in the text. Secondly, use the ChineseRecursiveTextSplitter tool to split the text, and set limits on the length of a single paragraph of text, the length of overlapping adjacent texts, etc., to improve the rationality of text segmentation and ensure that each text has relatively complete independent semantics. The granularity of different chunk_sizes is different. If the granularity is set too small, information will be lost; if the granularity is set too large, it may cause too much noise, resulting in obvious errors in the model output results, so targeted optimization of the data is required. In this way, after the article is segmented, it is ensured that each paragraph is talking about the same thing. Finally, use the component syntactic analysis tool and named entity recognition tool in NLP to extract. The former can extract the core part, such as noun phrases and verb phrases, and the latter can extract important entities, such as currency names, personal names, and company names.

[0078] Next, step 107 is performed: the keywords in each text segment are converted into a numerical vector, where each dimension represents the semantics or features of the text segment, and then the numerical vector is stored in a vector database.

[0079] In one embodiment of the present invention, based on the LangChain architecture, an embedding model such as bge-m3:latest is used to convert the extracted keywords into numerical vectors. The embedding model bge-m3:latest is used to convert the extracted keywords into numerical vectors, where each dimension represents a certain semantic meaning or feature of the text block. The vectorized text is then stored in a vector database such as Faiss.

[0080] The process of the above steps 106 and 107 can be found in Figure 2 shown.

[0081] Next, step 109 is executed: when a user's query question regarding emergency handling is received, the user's query question is converted into a question vector, and the question vector is used to perform a search and match in a vector database.

[0082] When converting the user's query question into a vector, the same method as the text vectorization method in step 107 is used so as to make comparisons in the same space.

[0083] In one embodiment of the present invention, the process of converting the user's query question into a question vector and using the question vector to search and match in a vector database in step 109 includes:

[0084] Construct the set of all numeric vectors as Faiss index;

[0085] Convert the user's query question into a vector representation in the vector space that is the same as the numerical vector in the Faiss index;

[0086] Use the transformed query vector to perform similarity search in the Faiss index.

[0087] It can be seen that in the embodiment of the present invention, the vector database uses the Faiss vector database. Faiss can quickly process large-scale data sets, improve retrieval efficiency by encapsulating the vector library into an index database, and use the algorithm on the GUP to accelerate the retrieval of vectors, which helps to speed up the query process. When using Faiss for relevance matching, first, the set of vectors to be matched is constructed as a Faiss index result; then the vector to be queried (the vector representation of the user's question or query) is converted into a vector representation that is the same as the vector in the index; then the converted query vector is used to perform a similarity search in the Faiss index; finally, based on the results of the similarity search, similar vectors or text blocks are returned as the results of the relevance matching. Faiss's relevance matching can help the system perform similarity searches in the knowledge base, thereby finding the most relevant k pieces of information, as well as related information in the knowledge base, which helps to provide accurate, comprehensive and personalized answers, and improve the effectiveness of the question-answering system and user experience.

[0088] Step 111: Add the matched keyword, the original text corresponding to the keyword as the second-level index, and the query question to a prompt template (prompt).

[0089] Step 113: Submit the prompt to the large language model LLM, which generates and outputs the answer.

[0090] In one embodiment of the present invention, after the LLM generates and outputs the answer, the method further includes:

[0091] The rationality of the LLM-generated answers is verified by setting rules, constraints, and a secondary reasoning mechanism. If the answer does not meet the prompt requirements, the prompt is reorganized or the query strategy is investigated based on feedback information, and the answer is requested again from the LLM until the prompt requirements are met. As can be seen, in one embodiment of the present invention, to ensure the efficiency and accuracy of task execution, it is necessary to determine the rationality of the answer and conduct loop optimization: the rationality of the LLM-generated answers is verified by setting a series of rules, constraints, and a secondary reasoning mechanism. If the answer does not meet the prompt requirements, the prompt is reorganized or the query strategy is investigated based on feedback information, and the answer is requested again from the large model until a satisfactory result is obtained. This process involves continuous optimization of decision logic and dialogue strategies through methods such as reinforcement learning.

[0092] In one embodiment of the present invention, when relevant content is retrieved but the LLM does not provide an answer based on the content, an optimization model can be selected, prioritizing the latest model; if resources permit, a model with more parameters is selected. After comparing efficiency and accuracy, the qwen2:latest LLM is selected. The prompt is submitted to the LLM, which summarizes and generates an answer.

[0093] The method of one embodiment of the present invention can also be a method for building an auxiliary question-answering robot based on big data-related questions. First, through data capture, cleaning and integration technology, big data-related questions and their answers are collected, and then NLP technology is used to perform entity recognition and relationship extraction to build a vector database. Then, through the intelligent agent robot, the dialogue process and strategy are set according to different knowledge categories. At the same time, the knowledge content is converted into unstructured text data, and word segmentation, keyword extraction and embedding are performed to store and match user questions. When the user asks a question, the agent robot will vectorize the question and match it with the knowledge base vector to find the closest knowledge point. Then, LLM is used to generate the answer, and the agent robot judges the rationality of the answer and performs cyclic optimization until a satisfactory result is obtained. The whole process involves a large amount of data processing, text analysis and artificial intelligence technology to achieve the goal of the intelligent question-answering system, and this whole process is used to realize auxiliary question-answering of big data-related questions.

[0094] In summary, see Figure 3, an embodiment of the present invention is a big data development and emergency processing auxiliary answering method based on the LangChain architecture, which utilizes the reasoning ability of LLM and integrates the local knowledge base through the LangChain framework to make it more suitable for big data related problems. In response to the problems existing in the knowledge base question and answer system in the prior art, such as low accuracy, low efficiency and poor flexibility, the present invention provides a big data development and emergency processing auxiliary answering method based on the LangChain architecture to solve the above technical problems. This method improves the accuracy and efficiency of question answering by combining advanced LLM technology with the local knowledge base. Using the LangChain framework, the system can better understand the diverse needs of users and provide more flexible and personalized services. This method not only improves the user experience, but also significantly enhances the overall performance of the knowledge base question and answer system.

[0095] One embodiment of the present invention also proposes an emergency response auxiliary question-answering system based on the LangChain architecture, see Figure 4 , the system comprises:

[0096] The document acquisition module 401 is configured to acquire an emergency handling knowledge document; wherein the document includes emergency handling knowledge;

[0097] The document processing module 402 is configured to summarize and organize the emergency response knowledge documents according to at least two dimensions to construct an auxiliary data set; organize the text in the auxiliary data set into a secondary index, wherein the first-level index is the keyword and the second-level index is the original text, and the first-level index and the second-level index have a one-to-one correspondence; convert the keywords in each text segment into a numerical vector, wherein each dimension represents the semantics or characteristics of the text segment, and then store the numerical vector in a vector database;

[0098] The large model processing module 403 is configured to, when receiving a user's query question for emergency handling, convert the user's query question into a question vector, and use the question vector to search and match in the vector database; add the matched keyword, the original text corresponding to the keyword as a second-level index, and the query question to the prompt; submit the prompt to the large language model LLM, and the LLM generates and outputs an answer.

[0099] In one embodiment of the system of the present invention, the document processing module 402 is further configured to: after summarizing and organizing the emergency handling knowledge documents according to at least two dimensions, and before organizing the text in the auxiliary data set into a secondary index, load the emergency handling knowledge documents, use different parsing tools, add titles to the parsed content, and then save it in Markdown format to improve the recall rate.

[0100] In one embodiment of the system of the present invention, the document processing module 402 is further configured to: before converting the keywords in each paragraph of text into a numerical vector, extract the relationship between the paragraphs in the text from the auxiliary dataset, merge all paragraphs containing a master-slave relationship into one paragraph, so that after the article is segmented, each paragraph of text corresponds to the same event;

[0101] The second-level index corresponding to the first-level index is: the merged paragraph where the keyword of the first-level index is located.

[0102] In one embodiment of the system of the present invention, the document processing module 402 is further configured to:

[0103] Based on the LangChain architecture, the natural language processing (NLP) paragraph analysis tool is used to extract the relationship between paragraphs in the text from the auxiliary dataset;

[0104] Based on the LangChain architecture, the Chinese Recursive Text Splitter tool is used to split the text. At least one of the length of a single paragraph and the length of overlapping adjacent texts is restricted, so that each paragraph of the text corresponds to the same event after the article is split.

[0105] Based on the LangChain architecture, we use NLP's component syntax analysis tools to extract noun phrases and verb phrases;

[0106] Based on the LangChain architecture, we use NLP named entity recognition tools to extract currency names, personal names, and company names.

[0107] In one embodiment of the system of the present invention, the document processing module 402 is further configured to: based on the LangChain architecture, use the embedding model to convert the extracted keywords into numerical vectors.

[0108] In one embodiment of the system of the present invention, the vector database includes: Faiss;

[0109] When the large model processing module 403 converts the user's query question into a question vector and uses the question vector to search and match in the vector database, it specifically performs the following steps:

[0110] Construct the set of all numeric vectors as Faiss index;

[0111] Convert the user's query question into a vector representation in the vector space that is the same as the numerical vector in the Faiss index;

[0112] Use the transformed query vector to perform similarity search in the Faiss index.

[0113] In one embodiment of the system of the present invention, the large model processing module 403 is further configured to perform:

[0114] The rationality of the answers generated by LLM is verified by setting rules, constraints and secondary reasoning mechanisms. If the answer does not meet the prompt requirements, the prompt is reorganized or the query strategy is investigated based on the feedback information, and the answer is requested from LLM again until it meets the prompt requirements.

[0115] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the method in any one of the embodiments in the specification.

[0116] An embodiment of the present invention provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method in any embodiment of the specification is implemented.

[0117] It should be understood that the structures illustrated in the embodiments of the present invention do not constitute specific limitations on the apparatus of the embodiments of the present invention. In other embodiments of the present invention, the apparatus may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0118] The various embodiments of the present invention are described in a progressive manner. Similar portions between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the device embodiments are generally similar to the method embodiments, so their description is relatively simple. For relevant portions, refer to the description of the method embodiments.

[0119] Those skilled in the art will appreciate that in one or more of the above examples, the functions described in the present invention may be implemented using hardware, software, widgets, or any combination thereof. When implemented using software, these functions may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.

[0120] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.

Claims

1. The emergency response auxiliary question-answering method based on the LangChain architecture is characterized by: The method includes: Obtaining an emergency response knowledge document; wherein the document includes emergency response knowledge; Summarize and organize emergency response knowledge documents according to at least two dimensions to construct an auxiliary data set; Organizing the text in the auxiliary data set into a secondary index, wherein the first-level index is the keyword, the second-level index is the original text, and the first-level index corresponds to the second-level index one-to-one; Convert the keywords in each text segment into a numerical vector, where each dimension represents the semantics or features of the text segment, and then store the numerical vector in a vector database; When receiving a user's query question regarding emergency handling, the user's query question is converted into a question vector, and the question vector is used to search and match in the vector database; Add the matched keyword, the original text corresponding to the keyword as the second-level index, and the query question to the prompt; Submit the prompt to the large language model LLM, which generates the answer and outputs it.

2. The method according to claim 1, characterized in that The at least two dimensions include: type dimension, theme dimension and author dimension.

3. The method according to claim 1, wherein: After summarizing and arranging the emergency handling knowledge documents according to at least two dimensions and before organizing the text in the auxiliary data set into a secondary index, the method further includes: The emergency response knowledge document is loaded, different parsing tools are used, and titles are added to the parsed content, and then saved in Markdown format to improve the recall rate.

4. The method according to claim 1, wherein: Before converting the keywords in each paragraph of text into a numerical vector, the method further includes: extracting the relationship between the paragraphs in the text from the auxiliary data set, merging all paragraphs containing a master-slave relationship into one paragraph, so that after the article is segmented, each paragraph of text corresponds to the same event; The second-level index corresponding to the first-level index is: the merged paragraph where the keyword of the first-level index is located.

5. The method according to claim 4, characterized in that Based on the LangChain architecture, the natural language processing (NLP) paragraph analysis tool is used to extract the relationship between paragraphs in the text from the auxiliary dataset; Based on the LangChain architecture, the Chinese Recursive Text Splitter tool is used to split the text. At least one of the length of a single paragraph and the length of overlapping adjacent texts is restricted, so that each paragraph of the text corresponds to the same event after the article is split. Based on the LangChain architecture, we use NLP's component syntax analysis tools to extract noun phrases and verb phrases; Based on the LangChain architecture, we use NLP named entity recognition tools to extract currency names, personal names, and company names.

6. The method according to claim 1, characterized in that The converting of keywords in each text segment into a numerical vector includes: based on the LangChain architecture, using an embedding model to convert the extracted keywords into a numerical vector.

7. The method according to claim 1, characterized in that The vector database includes: Faiss; The step of converting the user's query question into a question vector and using the question vector to search and match in a vector database includes: Construct the set of all numeric vectors as Faiss index; Convert the user's query question into a vector representation in the vector space that is the same as the numerical vector in the Faiss index; Use the transformed query vector to perform similarity search in the Faiss index.

8. The method according to claim 1, wherein: After the LLM generates and outputs the answer, the method further includes: The rationality of the answers generated by LLM is verified by setting rules, constraints and secondary reasoning mechanisms. If the answer does not meet the prompt requirements, the prompt is reorganized or the query strategy is investigated based on the feedback information, and the answer is requested from LLM again until it meets the prompt requirements.

9. The emergency response auxiliary question-answering system based on the LangChain architecture is characterized by: A document acquisition module configured to acquire an emergency response knowledge document; wherein the document includes emergency response knowledge; The document processing module is configured to summarize and organize emergency response knowledge documents according to at least two dimensions to construct an auxiliary data set; organize the text in the auxiliary data set into a secondary index, wherein the first-level index is the keyword and the second-level index is the original text, and the first-level index and the second-level index have a one-to-one correspondence; convert the keywords in each text segment into a numerical vector, wherein each dimension represents the semantics or characteristics of the text segment, and then store the numerical vector in a vector database; The large model processing module is configured to, when receiving a user's query question for emergency handling, convert the user's query question into a question vector, and use the question vector to search and match in the vector database; add the matched keyword, the original text corresponding to the keyword as a second-level index, and the query question to the prompt; submit the prompt to the large language model LLM, which generates and outputs the answer.

10. A computing device comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 8 is implemented.