Question and answer enhancement method, device and equipment for operation and maintenance question and answer robot and medium
By constructing and enhancing the corpus vector database, using large language models and prompt engineering technology to enhance operation and maintenance problems, the problems of insufficient semantic understanding of traditional operation and maintenance question-and-answer robots are solved, and higher search accuracy and response speed are achieved.
Patent Information
- Application Number
- CN202411630183.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-04-18
AI Technical Summary
Traditional operation and maintenance Q&A robots are based on keyword matching or vector model search, and there are problems of insufficient semantic understanding and mismatch in search, which affects the search accuracy.
By building a corpus vector database, using large language models and prompt engineering technology to enhance operation and maintenance problems, and correlate corresponding solutions to form an enhanced vector database. Receive the question text to be answered, convert it into a vector representation, and match it with the enhanced vector database to get the corresponding solution to the question text.
It improves the semantic coverage of the corpus vector database, reduces search error matching, improves search accuracy, and enhances operation and maintenance problems through offline batch processing, improving the response speed of operation and maintenance robots.
Smart Images

Figure CN119848185A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a question-and-answer enhancement method, device, equipment and medium for an operation and maintenance question-and-answer robot. Background Art
[0002] The operation and maintenance Q&A robot can respond to relevant troubleshooting instructions or solutions based on the fault phenomenon entered by the user. Traditional operation and maintenance Q&A robots use keyword matching to query the questions entered by users. The search results mainly rely on the similarity of text expressions and the data quality of the corpus, and lack semantic understanding. The search results of traditional search solutions that support semantic understanding rely heavily on the quality of the vector model. A high-quality vector model can embed sentences with similar meanings into similar vector spaces, and better match questions and answers. However, it is still inevitable that the vector representations of sentences with large semantic differences are very similar, which affects the search accuracy.
[0003] In addition, in the use scenario of the operation and maintenance question-answering robot, after the initial search results are obtained using the traditional keyword matching method or the Embedding (text vector embedding) method, how to exclude questions that are not in the corpus has always been a difficult problem. For example, "Cannot access the Internet in the cloud computer" and "The cloud computer cannot be connected", whether using the keyword matching or Embedding search method, the matching degree of both is very high, but the former means that the cloud computer cannot connect to the Internet, and the latter means that the cloud computer cannot log in, and the semantics of the two are inconsistent. How to solve such mismatching problems has always been a difficult problem. Summary of the invention
[0004] In view of this, the present invention provides a question-answering enhancement method, device, equipment and medium for an operation and maintenance question-answering robot to solve the problem that the quality of the vector model affects the search accuracy.
[0005] In the first aspect, the present invention provides a question and answer enhancement method for an operation and maintenance question and answer robot, the method comprising: using a corpus text including operation and maintenance problems and corresponding solutions to construct a corpus vector database; using a large language model and prompt engineering technology to enhance the operation and maintenance problems in the corpus vector database, and associating corresponding solutions to obtain an enhanced vector database; receiving a question text to be answered, and converting the question text into a vector representation; matching the vector representation with the enhanced vector database to obtain a solution corresponding to the question text.
[0006] In the present invention, by constructing a corpus vector database and enhancing the operation and maintenance problems in the corpus vector database, the coverage of the corpus in the corpus vector database is improved, and it is easier to match various questions input by users, thereby solving the problem that the operation and maintenance question-answering robot's vector-based search depends on the quality of the vector model and the inevitable search mismatch, and improving the search accuracy. At the same time, the enhancement of the operation and maintenance problems is processed before the user asks questions, and can be batch processed offline, rather than enhancing the prompt words during the search, which effectively improves the response speed of the operation and maintenance robot.
[0007] In an optional embodiment, a corpus vector database is constructed using a corpus text including operation and maintenance problems and corresponding solutions, including: obtaining a corpus text including operation and maintenance problems and corresponding solutions; converting the corpus text into vector data using a vector embedding model; and using the operation and maintenance problems in the corpus text as an index to construct a corpus vector database based on the vector data and a pre-constructed FAISS database.
[0008] In the present invention, the operation and maintenance problems are used as indexes, and a corpus vector database is constructed based on the FAISS database. Therefore, when the question text is subsequently matched, the efficient similarity search function of FAISS can be used to achieve rapid matching of the question text.
[0009] In an optional embodiment, a large language model and prompt engineering technology are used to enhance the operation and maintenance problems in the corpus vector database, and the corresponding solutions are associated to obtain an enhanced vector database, including: converting each corpus in the corpus vector database into structured data, each corpus including an operation and maintenance problem and a corresponding solution; using a large language model and prompt engineering technology to obtain synonymous expressions and related questioning methods of the operation and maintenance problem in each corpus, and associating the synonymous expressions and related questioning methods with corresponding solutions to generate new corpus; converting the new corpus into a vector, and adding it to the corpus vector database to obtain an enhanced vector database.
[0010] In the present invention, the operation and maintenance questions are enhanced by obtaining synonymous expressions and related questioning methods of the operation and maintenance questions in each corpus, thereby allowing users to ask questions in a variety of different expressions, while enriching the diversity and coverage of the operation and maintenance question-answering robot and reducing dependence on manually labeled data.
[0011] In an optional embodiment, the vector representation and the enhanced vector database are matched to obtain a solution corresponding to the question text, including: calculating the similarity scores of the vector representation and the corpus in the enhanced vector database, and determining the maximum similarity score; determining the solution corresponding to the question text based on the relationship between the maximum similarity score and a preset threshold.
[0012] In an optional embodiment, the preset threshold includes a high threshold and a low threshold, and the solution corresponding to the question text is determined according to the relationship between the maximum similarity score and the preset threshold, including: when the maximum similarity score is greater than the high threshold, the corresponding corpus is output; when the maximum similarity score is less than the low threshold, it is prompted that the question text is not in the enhanced vector database.
[0013] In the present invention, two thresholds, a high threshold and a low threshold, are set, and the maximum similarity score is compared with the two thresholds respectively, thereby further improving the accuracy of matching.
[0014] In an optional embodiment, determining a solution corresponding to the question text based on the relationship between the maximum similarity score and a preset threshold value also includes: when the maximum similarity score is greater than the low threshold value and less than the high threshold value, based on a preset prompt word, using a large language model to determine whether the question text and the corpus text corresponding to the maximum similarity score match; when they match, outputting the corpus text corresponding to the maximum similarity score; when they do not match, prompting that the question text is not in the enhanced vector database.
[0015] In the present invention, Prompt Engineering technology is adopted, and the semantic reasoning ability of LLM is fully utilized. When the maximum similarity score is greater than the low threshold and less than the high threshold, the search answer and the user question are paired. Only a small amount of GPU hardware resources are consumed to filter out unmatched answers, thereby avoiding misleading users.
[0016] In an optional implementation, the preset prompt words include whether the question text and the corpus text match, and the response is 1 if they match, and 0 if they do not match.
[0017] In the present invention, by setting the prompt word of matching reply 1 and unmatching reply 0, the large language model can be guided to output only one token, so the response time can be controlled at the millisecond level, which will not cause a significant impact on the response speed of the operation and maintenance question-and-answer robot, and the GPU occupancy time is extremely short, effectively saving computing resources.
[0018] In the second aspect, the present invention provides a question and answer enhancement device for an operation and maintenance question and answer robot, the device comprising: a database construction module, used to construct a corpus vector database using a corpus text including operation and maintenance problems and corresponding solutions; a database enhancement module, used to enhance the operation and maintenance problems in the corpus vector database using a large language model and prompt engineering technology, and associate the corresponding solutions to obtain an enhanced vector database; a question receiving module, used to receive a question text to be answered, and convert the question text into a vector representation; a matching module, used to match the vector representation with the enhanced vector database to obtain a solution corresponding to the question text.
[0019] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the question and answer enhancement method of the operation and maintenance question and answer robot of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0020] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the question and answer enhancement method of an operation and maintenance question and answer robot according to the first aspect or any corresponding embodiment thereof.
[0021] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, which are used to enable a computer to execute the question and answer enhancement method of an operation and maintenance question and answer robot according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 is a flow chart of a question-answering enhancement method for an operation and maintenance question-answering robot according to an embodiment of the present invention;
[0024] Figure 2 is a flow chart of another question-answering enhancement method for an operation and maintenance question-answering robot according to an embodiment of the present invention;
[0025] Figure 3 is a schematic diagram of a process of index enhancement according to an embodiment of the present invention;
[0026] Figure 4is a structural block diagram of a question-answering enhancement device of an operation and maintenance question-answering robot according to an embodiment of the present invention;
[0027] Figure 5 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0029] According to an embodiment of the present invention, an embodiment of a question and answer enhancement method for an operation and maintenance question and answer robot is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0030] In this embodiment, a question-answering enhancement method for an operation and maintenance question-answering robot is provided, which can be used in electronic devices such as computers, mobile phones, tablet computers, etc. Figure 1 is a flow chart of a question-answering enhancement method according to an operation and maintenance question-answering robot according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0031] Step S101, construct a corpus vector database using corpus texts including operation and maintenance problems and corresponding solutions. The operation and maintenance problems can be determined according to the application field of the operation and maintenance question-and-answer robot. For example, if the operation and maintenance question-and-answer robot is a cloud computer failure operation and maintenance robot, the operation and maintenance problems can be problems related to cloud computer failures. Specifically, the corpus text can be written by the operation and maintenance personnel based on the problems encountered in the actual operation and maintenance scenarios and the corresponding solutions. At the same time, common operation and maintenance problems and corresponding solutions can also be obtained from the Internet. This embodiment does not specifically limit the source of the corpus text.
[0032] When constructing a corpus vector database based on corpus text, the corpus text is converted into a vector that can express the corresponding semantics, thereby facilitating various text processing tasks. Among them, when converting the corpus text into a vector, relevant technologies such as an embedding model and a bag-of-words model can be used. In addition, for the constructed corpus vector database, the vector converted from each operation and maintenance problem and the corresponding solution can be stored as a piece of data, that is, multiple pieces of data are stored in the corpus vector database.
[0033] Step S102, using a large language model and prompt engineering technology to enhance the operation and maintenance problems in the corpus vector database, and associate corresponding solutions to obtain an enhanced vector database.
[0034] Specifically, a Large Language Model (LLM) is an AI model that can recognize, summarize, translate, predict, and generate text and other forms of content based on knowledge gained from large data sets. These models are artificial neural networks that can contain tens of millions or even billions of weights and are (pre)trained using self-supervised learning and semi-supervised learning. Prompt Engineering is an AI (Artificial Intelligence, AI) technology that improves AI performance by designing and improving its prompts. The goal of Prompt Engineering is to create highly effective and controllable AI systems that can perform specific tasks accurately and reliably.
[0035] Specifically, prompt engineering can guide the large language model to output specific results by designing precise natural language prompts. Before using the large language model and prompt engineering to enhance the operation and maintenance problem, the large language model can be fine-tuned and appropriate prompts can be designed for the task of enhancing the operation and maintenance problem. In addition, the prompts can be continuously adjusted and optimized according to the output of the large language model, and a feedback loop can be performed until the output of the model can achieve a satisfactory effect, thereby determining the prompts for the task.
[0036] In the related art, the basic search process of the question-answering robot is to match the user's questions with the problem phenomena in the corpus. The matching degree measurement standard is the Embedding similarity between the question and the corpus. The problem is that the search quality depends largely on the quality of the Embedding model and the coverage breadth of the corpus-related corpus. In order to cope with the various questioning methods of users, this embodiment uses a large language model and prompt engineering to enhance the operation and maintenance problems in the corpus vector database, that is, to expand the operation and maintenance problems and increase the coverage breadth of the operation and maintenance problems, so as to achieve a better matching effect. Among them, when enhancing the operation and maintenance problems, the above-mentioned prompts for the operation and maintenance problem enhancement task can be used to guide the large language model to expand each operation and maintenance problem, so as to obtain more operation and maintenance problems.
[0037] In addition, since the enhancement of operation and maintenance problems is performed on the basis of each original operation and maintenance problem, the solutions corresponding to the enhanced operation and maintenance problems and the original operation and maintenance problems are the same, the enhanced operation and maintenance problems and the solutions corresponding to the original operation and maintenance problems can be associated to form a new piece of data, and each new piece of data is converted into a vector and stored in the corpus vector database to obtain an enhanced vector database. The enhanced vector database can be saved in the operation and maintenance question robot so that the operation and maintenance question-answering robot can answer the user input questions according to the enhanced vector library.
[0038] Step S103, receiving the question text to be answered, and converting the question text into a vector representation. Specifically, the question text to be answered can be a question text input by a user, wherein the user can input the question text to the operation and maintenance question answering robot to obtain a solution from the operation and maintenance question answering robot. After the operation and maintenance question answering robot receives the prompt text, it first converts it into a vector representation so as to match it with the enhanced vector database.
[0039] Step S104, matching the vector representation with the enhanced vector database to obtain the solution corresponding to the question text. Specifically, when matching the vector representation with the enhanced vector database, a keyword matching method or an embedding method can be used. When matching, the question text is mainly matched with the operation and maintenance problems in the enhanced vector database, and then the solution corresponding to the matched operation and maintenance problem is output as the solution corresponding to the question text.
[0040] The question-answering enhancement method of the operation and maintenance question-answering robot provided in the embodiment of the present invention improves the coverage of the corpus in the corpus vector database by constructing a corpus vector database and enhancing the operation and maintenance questions in the corpus vector database, making it easier to match various questions input by users, thereby solving the problem that the vector-based search of the operation and maintenance question-answering robot depends on the quality of the vector model and the inevitable search mismatch, and improving the search accuracy. At the same time, the enhancement of the operation and maintenance questions is processed before the user asks the question, and can be processed offline in batches, rather than enhancing the prompt words during the search, which effectively improves the response speed of the operation and maintenance robot.
[0041] In this embodiment, a question-answering enhancement method for an operation and maintenance question-answering robot is provided, and the process includes the following steps:
[0042] Step S201, constructing a corpus vector database using corpus text including operation and maintenance problems and corresponding solutions.
[0043] Specifically, the above step S201 includes:
[0044] Step S2011, obtain a corpus text including operation and maintenance problems and corresponding solutions; specifically, the obtained corpus text can be written and stored in the format of an unstructured txt file, where each line represents a corpus data, including information such as operation and maintenance problem phenomena and problem solutions. In addition, after obtaining the corpus text, a Python tool script can be used to read the corpus txt file, and regular expressions can be used to extract the problem phenomena and solutions for each corpus.
[0045] At the same time, in order to improve the accuracy of subsequent matching, data preprocessing operations can also be performed on the extracted problem phenomena. In this embodiment, the preprocessing operation includes stop word filtering and synonym replacement processing. Among them, stop words refer to some insignificant words, and stop word filtering processing can be performed based on a commonly used stop word library during specific processing. Synonym replacement refers to building a fuzzy dictionary for specific businesses and unifying the expression of synonymous nouns, such as converting "cloud desktop" into "cloud computer" and so on. The preprocessed problem phenomena and corresponding solutions can be saved in JSON format.
[0046] Step S2012, using a vector embedding model to convert the corpus text into vector data. In this embodiment, a vector embedding model is used to perform text vectorization processing. During the specific processing, a pre-trained Embedding model can be loaded. For example, the m3e-base model can be used as the Embedding model for text vectorization processing. The m3e-base model is a text embedding model that supports Chinese and English and is open sourced by MokaAI, and can effectively capture the semantic information of the text. Among them, when using the m3e-base model for text vectorization processing, each corpus data in the corpus text can be input into the model by downloading the m3e-base model package and installing the sentence_transformers library to obtain the corresponding vector data.
[0047] Step S2013, using the operation and maintenance problems in the corpus text as indexes, constructing a corpus vector database based on the vector data and the pre-built FAISS database. Among them, FAISS (Facebook AI Similarity Search) is a library for efficient similarity search and dense vector clustering open sourced by the Facebook AI team. FAISS provides an efficient and reliable retrieval method for massive data in high-dimensional space. It contains algorithms for searching in vector groups of any size, until vector groups that may not fit in RAM. In this embodiment, FAISS, an efficient vector similarity search library, is used to construct a corpus vector database. Before construction, the FAISS library is installed first, and then an empty database object is created to specify the dimension and distance measurement method of the vector. In this embodiment, 768 is used as the vector dimension, and cosine similarity is used as the similarity measurement method. When constructing a corpus vector database based on the FAISS library, each problem phenomenon is used as an index, and each corpus data is saved therein, thereby obtaining a corpus vector database.
[0048] Step S202, using a large language model and prompt engineering technology to enhance the operation and maintenance problems in the corpus vector database, and associate corresponding solutions to obtain an enhanced vector database.
[0049] Specifically, the above step S202 includes:
[0050] Step S2021, convert each corpus in the corpus vector database into structured data, each corpus includes operation and maintenance problems and corresponding solutions; specifically, in order to manage and query each corpus data in the corpus vector database, each corpus data is first converted into structured data before operation and maintenance problem enhancement. For example, a unique id can be assigned to the problem phenomenon and solution in each corpus and saved as a structured database table. When applied to cloud computer failure scenarios, the structured database tables are shown in Tables 1 and 2 below:
[0051] Table 1 Problem phenomenon table
[0052] Id Problem phenomenon Solution ID 1 Cloud computer usage is slow 1 2 Cloud computer black screen 2 … … …
[0053] Table 2 Solution table
[0054] Id Workaround 1 The solution to the problem of stuck is xxx 2 The solution to the black screen problem is xxx … …
[0055] Step S2022, using a large language model and prompt engineering technology to obtain synonymous expressions and related questioning methods of the operation and maintenance problem in each corpus, and associating the synonymous expressions and related questioning methods with corresponding solutions respectively to generate new corpus.
[0056] Specifically, in the application scenario of the operation and maintenance question-answering robot, there are two main ways for users to ask questions, namely, directly describing the problem phenomenon and asking questions about the problem phenomenon. The Embedding representations of these two situations are somewhat different. In order to achieve the best index enhancement effect, this embodiment handles these two situations separately. That is, for the questioning method of directly describing the problem phenomenon, the processing method of obtaining synonymous expressions is adopted for enhancement; for the questioning method of asking questions about the problem phenomenon, the processing method of obtaining related questioning methods is adopted for enhancement.
[0057] Among them, when adopting the processing method of obtaining synonymous expressions, prompts can be used to guide the large language model to output as many synonymous expressions as possible, and these synonymous expressions can be associated with the solution to the original problem. For example, for the cloud computer application scenario, the prompt can include the following content:
[0058] -<|system|>
[0059] You are a helpful assistant who answer questions as best as you can.Auser will input a cloud computer related issue,find as many synonymousexpressions as possible and output a comma separated list.
[0060] -<|user|>
[0061] {issue}
[0062] -<|assistant>
[0063] The above prompts will guide the large language model to find as many synonymous expressions of the problem phenomenon as possible, and output the results as a comma-separated list. The answers of the large language model are sorted and associated with the solutions corresponding to the original problems, and inserted into the above structured database table. For example, when applied to the cloud computer failure scenario, the structured database table after the synonymous expressions are inserted is shown in Table 3 below:
[0064] Table 3
[0065] Id Problem phenomenon Solution ID 1 Cloud computer usage is slow 1 2 Cloud computer black screen 2 … … … 101 Computer is slow to respond 1 102 Cloud computer freezes 2 … … …
[0066] As shown in Table 3 above, the large language model found two synonymous expressions of "cloud computer usage lag" and "cloud computer black screen", namely "cloud computer slow response" and "cloud computer crashes", and associated them with the corresponding solution IDs.
[0067] When obtaining the processing methods of related questioning methods, prompts can be used to guide the large language model to output as many questioning methods as possible for each operation and maintenance problem, and associate these questioning methods with the solution to the original problem. For example, for the cloud computer application scenario, the prompt can include the following content:
[0068] –<|system|>
[0069] You are a helpful assistant who answer questions as best as you can.Auser will input a cloud computer related issue,Find as many ways to ask the question as possible and output a comma separated list.
[0070] -<|user|>
[0071] {issue}
[0072] -<|assistant>
[0073] The above prompts will guide the large language model to find as many questioning methods as possible for the problem phenomenon, and output the results as a comma-separated list. The answers of the large language model are sorted and associated with the solutions corresponding to the original problems, and inserted into the above structured database table. For example, when applied to cloud computer failure scenarios, the structured database table after the questioning methods are inserted is shown in Table 4 below:
[0074] Table 4
[0075]
[0076] As shown in Table 4 above, the large language model found two possible questioning methods, "cloud computer usage is slow" and "cloud computer screen is black", and associated them with the corresponding solution IDs.
[0077] Step S2023, convert the new corpus into a vector and add it to the corpus vector database to obtain an enhanced vector database. Specifically, after obtaining the synonymous expressions and related questioning methods of the operation and maintenance problems in each corpus to obtain new operation and maintenance problems, the m3e-base model can be used to convert the new operation and maintenance problems into Embedding vectors as indexes, and the corresponding solution id is stored as data persistence in FAISS.
[0078] Step S203, receiving the question text to be answered, and converting the question text into a vector representation; specifically, after receiving the question text, the question text can be preprocessed by filtering stop words and replacing synonyms in a similar manner to the corpus text. Then, an Embedding model such as the m3e-base model is used to convert the question text into a vector representation.
[0079] Step S204, matching the vector representation with the enhanced vector database to obtain a solution corresponding to the question text.
[0080] Specifically, the above step S204 includes:
[0081] Step S2041, calculate the similarity score between the vector representation and the corpus in the enhanced vector database, and determine the maximum similarity score; in this embodiment, since the corpus vector database is constructed using FAISS, when matching the vector representation and the enhanced vector database, similar vector retrieval can be implemented based on the FAISS efficient similarity search function. Among them, when performing similar vector retrieval, according to step S2013, FAISS will perform similarity calculation by calculating the cosine similarity between the vector representation and the corpus in the enhanced vector database, and determine the corpus data that best matches the question text through the similarity calculation result, i.e., the maximum value in the similarity score, and then return the id corresponding to the best matching corpus data and the corresponding maximum similarity score.
[0082] Step S2042, determining the solution corresponding to the question text according to the relationship between the maximum similarity score and the preset threshold. Specifically, the maximum similarity score can be compared with the preset threshold. If it is greater than the preset threshold, it means that the matching result is relatively accurate. At this time, the best matching corpus data determined in step S2041 can be output. However, in order to balance the search accuracy and efficiency, the preset threshold can be further set to two thresholds, a high threshold and a low threshold, and determine whether the best matching corpus data obtained in step S2041 is accurate according to the relationship between the maximum similarity score and the two thresholds.
[0083] In an optional implementation, the above step S2042 includes:
[0084] Step a1, when the maximum similarity score is greater than the high threshold, the corresponding corpus is output; specifically, when the maximum similarity score is greater than the high threshold, it can be considered that the question text and the corpus corresponding to the maximum similarity score are highly matched, and the corresponding original corpus is queried from the database based on the returned unique ID, and the corresponding problem phenomenon and solution are returned to the user.
[0085] Step a2: When the maximum similarity score is less than the lower threshold, it is prompted that the question text is not in the enhanced vector database. Specifically, when the maximum similarity score is less than the lower threshold, it can be considered that the question text input by the user is not related to the content in the enhanced vector database. At this time, the user is directly prompted that the current question is not in the knowledge base, and the three most similar questions are recommended to the user.
[0086] Step a3, when the maximum similarity score is greater than the lower threshold and less than the upper threshold, based on the preset prompt word, a large language model is used to determine whether the question text and the corpus text corresponding to the maximum similarity score match; when they match, the corpus text corresponding to the maximum similarity score is output; when they do not match, it is prompted that the question text is not in the enhanced vector database.
[0087] Specifically, when the maximum similarity score is greater than the low threshold and less than the high threshold, it may be that the user's questioning method is not covered in the enhanced index or the user's question does not match the answer. At this time, further search and matching judgment is required. That is, other methods can be further used to determine whether the question text and the most matching corpus text match. The essential task of this matching judgment is to determine the semantic similarity between the question statement entered by the user and the search result. The solution can be to use an open source semantic similarity model or design and train an NLP (Natural Language Processing) model by yourself. Considering that the open source semantic similarity model has insufficient generalization ability and the training model lacks the corresponding high-quality data set, and the large model has a strong semantic understanding ability after unsupervised pre-training on a large data set, this embodiment uses a large language model to solve this problem. Since the reasoning process of the large language model requires a large amount of GPU hardware resources, in order to save resources and improve efficiency, this embodiment designs a prompt word that guides LLM to determine whether the user's question and answer match and only returns one token. The prompt word includes whether the question text and the corpus text match, a matching reply 1, and a non-matching reply 0. For example, the prompt word can be expressed as follows:
[0088] <instruction>
[0089] Determine whether the query and response have similar semantics.Ifthey are similar,reply 1,otherwise reply 0.Nothing more.
[0090] < / instruction>
[0091] <query> {query}< / query>
[0092] <response> {response}< / response>
[0093] The above prompt words will guide the large language model to determine whether the question entered by the user matches the result returned by the FAISS search. When the search and the returned results match, LLM outputs 1, otherwise it outputs 0. Since LLM reasoning only needs to output one token, the response time of this step can be controlled in milliseconds, so it will not have a significant impact on the response speed of the business robot, and the GPU occupancy time is extremely short, effectively saving computing resources. In actual business, using this method greatly reduces the frequency of the question-and-answer robot returning irrelevant results, effectively avoiding the interference of irrelevant answers to users.
[0094] The question-answering enhancement method of the operation and maintenance question-answering robot provided in the embodiment of the present invention utilizes the Prompt Engineering technology to give full play to the powerful text generation ability of LLM, automatically generates synonymous question phenomena and possible questioning methods of users, and uses them as an enhanced index of the corpus, allowing users to ask questions in a variety of different ways of expression. This method overcomes the problem that the search results of traditional keyword-based indexes mainly rely on the similarity of text expressions and lack semantic understanding ability, and realizes semantic matching and sorting; at the same time, this method also solves the problem that vector-based searches rely on the quality of vector models and the inevitable search mismatches, thereby improving the search accuracy.
[0095] In the present invention, the index of the FAISS vector retrieval library is expanded from the perspective of corpus synonym sentence enhancement and question mode enhancement, thereby directly matching the user input question with the corpus, avoiding the extraction of search keywords and the subsequent logical matching steps based on keywords, and improving the response speed of the question-answering robot. In addition, index enhancement can also enrich the diversity and coverage of the question-answering system and reduce the reliance on manually labeled data.
[0096] The present invention is based on Prompt Engineering technology and makes full use of the semantic reasoning ability of LLM to pair search answers and user questions when the FAISS search confidence is low. It only consumes a small amount of GPU hardware resources to filter out mismatched answers, avoiding misleading users.
[0097] As a specific application example of the embodiment of the present invention, Figure 2 As shown, the question-answering enhancement method of the operation and maintenance question-answering robot includes the following process:
[0098] Step 11: Corpus data analysis: Read the corpus text written by business personnel to solve operation and maintenance problems, extract the problem phenomena and corresponding solutions after data preprocessing, and save them in JSON format.
[0099] Step 12: Build a corpus vector database. Based on the parsed JSON corpus data and the problem phenomenon as the index, build a corpus vector database based on the Embedding model and FAISS.
[0100] Step 13: Index enhancement. For each piece of data in the corpus, based on LLM and Prompt Engineering technology, find as many similar expressions of corpus problem phenomena and possible user questioning methods as possible, use these similar expressions and possible questioning methods as enhanced indexes, associate them with the solutions in the original corpus, and write them into the FAISS vector database.
[0101] Step 14, user request processing. Receive the question text input by the user, convert the text into a vector representation, and find the most matching corpus and the corresponding relevance score from the corpus based on FAISS. In order to take into account both search accuracy and efficiency, the present invention sets two thresholds, high_threshold and low_threshold. If the similarity score is higher than the high_threshold, the problem phenomenon and solution contained in the corpus are directly returned to the user; if the score is lower than the low_threshold, it is prompted that the question content is not in the knowledge base; otherwise, execute step 15.
[0102] Step 15: Search match judgment: Use LLM and Prompt Engineering to judge whether the user's question matches the problem phenomenon returned by the search. If so, return the corpus. Otherwise, prompt that the current question is not in the knowledge base.
[0103] like Figure 3 As shown, the index enhancement in step S13 specifically includes the following steps:
[0104] Step S31, structured data conversion: assign a unique id to each problem phenomenon and solution in the corpus and save it as a structured database table.
[0105] Step S32: Synonymous sentence index enhancement: Prompts are used to guide the large language model to output as many synonymous expressions of the problem phenomenon as possible, and these synonymous expressions are associated with the solution to the original problem.
[0106] Step S33, questioning method index enhancement: Prompts are used to guide the large language model to output as many questioning methods as possible for each question, and these questioning methods are associated with the solutions to the original question.
[0107] Step S34, FAISS data persistence. The synonymous sentences and questioning methods after index enhancement are converted into Embedding vectors as indexes, and the corresponding solution IDs are stored as data persistence in FAISS.
[0108] In this embodiment, a question-answering enhancement device for an operation and maintenance question-answering robot is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0109] This embodiment provides a question-answering enhancement device for an operation and maintenance question-answering robot, such as Figure 4 As shown, including:
[0110] A database construction module 41, used to construct a corpus vector database using corpus text including operation and maintenance problems and corresponding solutions;
[0111] A database enhancement module 42, for enhancing the operation and maintenance problems in the corpus vector database by using a large language model and prompt engineering technology, and associating corresponding solutions to obtain an enhanced vector database;
[0112] A question receiving module 43, used for receiving a question text to be answered and converting the question text into a vector representation;
[0113] The matching module 44 is used to match the vector representation with the enhanced vector database to obtain a solution corresponding to the question text.
[0114] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0115] The embodiment of the present invention also provides a computer device having the above Figure 4 The question and answer enhancement device of the operation and maintenance question and answer robot shown.
[0116] See also Figure 5 , Figure 5 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 5As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 10 is taken as an example.
[0117] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0118] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0119] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the use of a computer device based on the presentation of a small program landing page, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0120] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0121] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0122] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0123] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0124] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A question-answering enhancement method for an operation and maintenance question-answering robot, characterized in that: The method comprises: Construct a corpus vector database using corpus texts including operation and maintenance problems and corresponding solutions; Using a large language model and prompt engineering technology to enhance the operation and maintenance problems in the corpus vector database, and associating corresponding solutions to obtain an enhanced vector database; Receiving a question text to be answered, and converting the question text into a vector representation; The vector representation is matched with the enhanced vector database to obtain a solution corresponding to the question text.
2. The method according to claim 1, characterized in that The corpus vector database is constructed using corpus texts including operation and maintenance problems and corresponding solutions, including: Obtain corpus text including operation and maintenance problems and corresponding solutions; Use vector embedding model to convert corpus text into vector data; Taking the operation and maintenance problems in the corpus text as indexes, a corpus vector database is constructed based on the vector data and a pre-constructed FAISS database.
3. The method according to claim 1, characterized in that The operation and maintenance problems in the corpus vector database are enhanced by using a large language model and prompt engineering technology, and the corresponding solutions are associated to obtain an enhanced vector database, including: Convert each piece of corpus in the corpus vector database into structured data, each piece of corpus including an operation and maintenance problem and a corresponding solution; Using a large language model and prompt engineering technology to obtain synonymous expressions and related questioning methods of operation and maintenance problems in each corpus, the synonymous expressions and related questioning methods are associated with corresponding solutions to generate new corpus; The new corpus is converted into vectors and added to the corpus vector database to obtain an enhanced vector database.
4. The method according to claim 1, characterized in that: The vector representation is matched with the enhanced vector database to obtain a solution corresponding to the question text, including: Calculating similarity scores between the vector representation and the corpus in the enhanced vector database, and determining a maximum similarity score; The solution corresponding to the question text is determined according to the relationship between the maximum similarity score and a preset threshold.
5. The method according to claim 4, characterized in that The preset threshold includes a high threshold and a low threshold, and the solution corresponding to the question text is determined according to the relationship between the maximum similarity score and the preset threshold, including: When the maximum similarity score is greater than the high threshold, the corresponding corpus is output; When the maximum similarity score is less than the low threshold, it is prompted that the question text is not in the enhanced vector database.
6. The method according to claim 5, characterized in that Determining a solution corresponding to the question text according to the relationship between the maximum similarity score and a preset threshold value also includes: When the maximum similarity score is greater than the lower threshold and less than the upper threshold, based on the preset prompt word, a large language model is used to determine whether the question text matches the corpus text corresponding to the maximum similarity score; When matching, the corpus text corresponding to the maximum similarity score is output; When there is no match, it indicates that the question text is not in the enhanced vector database.
7. The method according to claim 6, characterized in that The preset prompt words include whether the question text and the corpus text match, and the response is 1 if they match, and 0 if they do not match.
8. A question-answering enhancement device for an operation and maintenance question-answering robot, characterized in that: The device comprises: A database construction module is used to construct a corpus vector database using corpus texts including operation and maintenance problems and corresponding solutions; A database enhancement module, used to enhance the operation and maintenance problems in the corpus vector database by using a large language model and prompt engineering technology, and associate corresponding solutions to obtain an enhanced vector database; A question receiving module, used for receiving a question text to be answered and converting the question text into a vector representation; The matching module is used to match the vector representation with the enhanced vector database to obtain a solution corresponding to the question text.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the question-answering enhancement method of the operation and maintenance question-answering robot according to any one of claims 1 to 7 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the question-and-answer enhancement method of the operation and maintenance question-and-answer robot according to any one of claims 1 to 7.
Citation Information
Cited By
Nuclear power intelligent operation and maintenance platform capable of enabling large language model and working method of nuclear power intelligent operation and maintenance platform
CN121436163A