An intelligent questioning method based on large model retrieval enhancement and prompt strategy
By building an external knowledge vector database and comprehensive prompt strategy, the intelligent question-and-answer system solves the problem of insufficient accuracy and interactivity in complex data environments, improves the model's knowledge retrieval and information processing capabilities, and enhances the user experience.
Patent Information
- Application Number
- CN202411813353.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing intelligent question-and-answer systems are difficult to generate accurate and structured answers in complex data environments, and lack interaction ability and interpretability, lack of model background knowledge, poor correlation with questions, and insufficient accuracy.
By constructing an external knowledge vector database for retrieval enhancement, combining local relational databases, a comprehensive prompt strategy is built using a variety of external knowledge and problem vectors to dynamically retrieve and integrate external knowledge related to the problem, and generate structured query language and interactive problems.
It improves the knowledge retrieval and information processing capabilities of large language models in complex data environments, enhances the information acquisition capabilities of the model in specific fields, improves the interactivity and interpretability of the question-and-answer system, and improves the user experience.
Smart Images

Figure CN119760068A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence and natural language processing, and specifically relates to an intelligent number-asking method based on large model retrieval enhancement and prompting strategy. Background Art
[0002] With the rapid development of information technology, the demand for intelligent question answering systems is increasing. Especially in complex data environments, users hope to ask questions in natural language and get accurate and structured answers. However, there is relatively little research on large language model question answering systems for intelligent questions, which limits its potential in practical applications.
[0003] For intelligent question-answering systems, some studies have attempted to improve the performance of the model by combining external knowledge. Most existing technologies focus on general fields and lack in-depth discussions on vertical fields. For questions in vertical fields, natural language questions are converted into structured query languages, and large language models may generate incorrect query languages due to lack of knowledge in specific fields. At the same time, relying solely on the capabilities of large language models may not be able to find answers based on the existing knowledge in the model. Training a high-quality model requires a lot of data and resources, so large models need to use external knowledge bases to accurately produce structured query languages and perform retrieval queries based on external knowledge; secondly, there are relatively few studies on large language model question-answering systems that combine external knowledge, which limits their potential in practical applications; finally, the prompt strategies of existing solutions are often relatively simple and not flexible enough, and cannot be dynamically adjusted according to different query scenarios.
[0004] In general, although existing technologies have promoted the development of intelligent question-answering systems to some extent, there is still an urgent need to propose more effective solutions to the specific needs of intelligent question-answering in complex data environments. Summary of the invention
[0005] The technical problems to be solved by the present invention are:
[0006] In order to avoid the shortcomings of the prior art, the present invention provides an intelligent question-answering method based on large model retrieval enhancement and prompt strategy. By constructing an external knowledge vector database for retrieval enhancement and combining it with a local relational database, a comprehensive prompt strategy is constructed based on a variety of external knowledge vectors and question vectors to improve the accuracy of the question-answering function of the large language model, thereby alleviating the problems in the prior art such as insufficient model background knowledge, poor relevance between answers and questions, insufficient accuracy, lack of interactive capabilities and poor interpretability.
[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0008] An intelligent number-asking method based on large-model retrieval enhancement and prompt strategy, characterized by comprising:
[0009] Based on structured query language, data definition language, text data, PDF document blocks and local relational database, an external knowledge vector database for retrieval enhancement is constructed;
[0010] Based on the multi-source heterogeneous vector database and input questions, a multi-angle prompt strategy is constructed to obtain the structured query language corresponding to the question;
[0011] Based on the structured query language of questions and the PDF document block database, construct prompt strategies, obtain question-answering results and related analysis;
[0012] Based on the retrieval-enhanced external knowledge vector database and the input question, a prompt strategy is constructed to obtain interactive questions related to the current question.
[0013] A further technical solution of the present invention: the step of constructing an external knowledge vector database for retrieval enhancement based on structured query language, data definition language, text data, PDF document blocks and local relational database includes:
[0014] Constructing data sets for storing structured query language, data definition language, text data, and PDF document block metadata respectively;
[0015] Based on the multilingual embedding model, structured query language, data definition language, text data, and PDF document block metadata are converted into corresponding embedding vectors;
[0016] The embedding vectors of structured query language, data definition language, text data and PDF document blocks are combined into an embedding vector set, and the embedding vector set and the local relational database are jointly constructed into an external knowledge vector database for retrieval enhancement.
[0017] A further technical solution of the present invention is as follows: the step of constructing a multi-angle prompt strategy based on a multi-source heterogeneous vector database and an input question, and obtaining a structured query language corresponding to the question includes:
[0018] Input the input question into the multilingual embedding model to obtain the embedding vector corresponding to the input question;
[0019] Based on cosine similarity, calculate the similarity between the embedding vector corresponding to the question and all vectors in each embedding vector set in the external knowledge vector database;
[0020] The vector that is most relevant to the embedding vector corresponding to the input question is mapped through a mapping function to obtain a list of original text data corresponding to the vector;
[0021] The input question and the original text data list obtained after similarity calculation are integrated to form a multi-angle prompt strategy which is input into the big model to generate the structured query language corresponding to the input question.
[0022] A further technical solution of the present invention: the steps of constructing prompt strategies, obtaining question-answering results and related analysis based on the structured query language and PDF document block database of the question include:
[0023] Based on the structured query language corresponding to the input question generated by the big model, combined with the local relational database in the external knowledge base, the running result of the structured query language is obtained, and the running result is merged with the PDF document block database related to the input question group generated after similarity calculation to form a prompt strategy input into the big model to generate the answer output and related analysis of the input question.
[0024] A further technical solution of the present invention is as follows: the step of constructing a prompt strategy based on the search-enhanced external knowledge vector database and the input question, and obtaining an interactive question associated with the current question includes:
[0025] The structured query language vector list, data definition language vector list, text data vector list and PDF document block vector list related to the input question obtained from the external knowledge vector database through similarity calculation are combined with the input question to construct a comprehensive prompt strategy and input it into the large model to generate a series of interactive questions related to the current question.
[0026] A computer system, characterized in that it comprises: one or more processors, and a computer-readable storage medium for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the above-mentioned method.
[0027] A computer-readable storage medium, characterized in that it stores computer-executable instructions, which are used to implement the above method when executed.
[0028] A computer program product, characterized by comprising computer executable instructions, wherein the instructions are used to implement the above method when executed.
[0029] The beneficial effects of the present invention are:
[0030] The present invention provides an intelligent question-answering method based on large-model retrieval enhancement and prompt strategy. By constructing four external knowledge vector databases for retrieval enhancement and combining them with a local relational database, the large model is helped to dynamically retrieve and integrate external knowledge related to the question when generating answers, making up for the deficiency of insufficient background knowledge of the large model and enhancing the information acquisition ability of the model in a specific field. At the same time, a comprehensive prompt strategy is proposed, which not only provides a clear logical chain for the process of model-generated answers, helps users trace each step of the generation process, helps improve the interpretability and transparency of the model, but also guides users to further explore related content, enhances the interactivity and extensibility of the question-answering system, and improves the user experience.
[0031] 1. The present invention proposes a method for constructing an external knowledge vector database for retrieval enhancement based on structured query language, data definition language, text data, PDF document blocks and local relational database. The characteristic is that by using a variety of external knowledge to establish a vector database, the knowledge retrieval and information processing capabilities of a large model in a complex data environment are improved. In particular, in view of the problem that traditional models are prone to hallucinations when answering cross-domain questions, this method improves the adaptability of the model in handling cross-domain problems and enhances the accuracy and knowledge reasoning ability of the model.
[0032] 2. The present invention proposes a sum prompt strategy that integrates multiple external knowledge vector databases and question vectors. Through a detailed and comprehensive prompt strategy, it helps large models generate more accurate answers and reduce the occurrence of hallucinations. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like components throughout the drawings.
[0034] Figure 1 A block diagram of the method of the present invention. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0037] The present invention provides an intelligent questioning method based on large model retrieval enhancement and prompt strategy, which improves the accuracy of the large language model questioning function by constructing an external knowledge vector database for retrieval enhancement, combining with a local relational database, and integrating multiple external knowledge vectors and question vectors to form a comprehensive prompt strategy. The method includes the following steps:
[0038] Step 1: Based on structured query language, data definition language, text data, PDF document blocks and local relational database, an external knowledge vector database for retrieval enhancement is constructed;
[0039] Step 2: Based on the multi-source heterogeneous vector database and the input question, a multi-angle prompt strategy is constructed to obtain the structured query language corresponding to the question;
[0040] Step 3: Based on the structured query language of the question and the PDF document block database, construct a prompt strategy to obtain the question-answering results and related analysis;
[0041] Step 4: Based on the retrieval-enhanced external knowledge vector database and the input question, a prompt strategy is constructed to obtain interactive questions associated with the current question.
[0042] The above steps are as follows:
[0043] Step 1: Based on structured query language, data definition language, text data, PDF document blocks and local relational database, an external knowledge vector database for retrieval enhancement is constructed, including the following steps:
[0044] Step 11: Construct a data set A = {a1, a2, ..., a n}, B={b1,b2,...,b n}、C={c1,c2,...,c n}、D={d1,d2,...,d n} respectively store structured query language, data definition language, text data and PDF document block metadata, where a i , b i 、c i ,d i They are respectively data set a i , b i 、c i ,d i The i-th text in .
[0045] Step 12: Based on the multilingual embedding model stored in the Open Neural Network Exchange format (ONNX), the metadata in sets A, B, C, and D are converted into embedding vectors.
[0046] Using the multilingual embedding model, the dataset A = {a1, a2, ..., a n}, B={b1,b2,...,b n}、C={c1,c2,...,c n}、D={d1,d2,...,d n} is input into the multilingual embedding model. The multilingual embedding model is the all-MiniLM-L6-v2 model. The core of this model is the multi-head attention mechanism. It is based on the Transformer architecture and has a 6-layer network and a 384-dimensional hidden layer. n} as an example, after encoding it, we get the matrix A'={a'1,a'2,...,a' n}, where a' i is a i The vector obtained after encoding. Using the initialized feature matrix W Q , W K , W V Perform a linear transformation on A' to obtain the query vector Q = W Q A'=(q1,q2,...,q n ), key vector K = W K A'=(k1,k2,...,k n ) and value vector V = W V A'=(v1,v2,...,v n ). Using the scaled dot product as the attention score function, the output vector is expressed as Finally, multiple groups of Q, K and V are multiplied with the encoded input samples to obtain multiple groups of W Q , W K and W V , and then multiple groups W Q , W K and W VThe obtained multiple sets of feature matrices are concatenated to obtain the final output A”={a”1,a”2,...,a”n}∈R m×d Among them, a” i is the embedding vector of the i-th text in the embedding vector set A”, m is the upper limit of the number of words in the input document, that is, the sequence length, and d is the dimension of the embedding vector.
[0047] Similarly, the data set B = {b1, b2, ..., b n}、C={c1,c2,...,c n}、D={d1,d2,...,d n} is input into the multilingual embedding model to obtain the embedding vector set B” = {b”1, b”2, ..., b” n}∈R m×d ,C”={c”1,c”2,...,c” n}∈R m×d , D”={d”1,d”2,...,d” n}∈R m×d , where b” i ,c” i , d” i are the embedding vectors of the i-th text in the embedding vector sets B”, C”, and D” respectively.
[0048] Step 13: Based on the embedding vector set ε = {A”, B”, C”, D”}∈R m×d , and the local relational database G = {g1,g2,...,g n}, jointly construct a large model retrieval enhanced external knowledge base K = f (ε, G), where g i It is a data record or table structure in a local relational database, containing multiple fields such as ID, name, content, etc.
[0049] Step 2: Based on the multi-source heterogeneous vector database and the input question, a multi-angle prompt strategy is constructed to obtain the structured query language corresponding to the question, including the following steps:
[0050] Step 21: Input the input question Q into the multilingual embedding model to obtain the embedding vector Q' of the question.
[0051] Step 22: Based on the cosine similarity, calculate the similarity between the question vector Q' and all vectors in each embedding vector set in the external knowledge base, expressed as: The calculated vector most relevant to the input question is used through the mapping function f:{A”,B”,C”,D”}→{a,b,c,d} to obtain the original text data list corresponding to the vector.
[0053] Step 23: The input question Q and the related external knowledge list {a, b, c, d} obtained after similarity calculation are integrated to form a multi-angle prompt strategy which is input into the large model (Large Language Models, LLMs) to generate a structured query language corresponding to the input question.
[0054] Step 3: Based on the structured query language corresponding to the input question generated by the large model, with the help of the local relational database G = {g1, g2, ..., g n}, get the running result of the structured query language, merge the running result with the PDF document block database D" related to the input question group generated after similarity calculation, form a prompt strategy and input it into the big model to generate the answer output and related analysis of the input question.
[0055] Step 4: Combine the structured query language vector list, data definition language vector list, text data vector list and PDF document block vector list {a, b, c, d} related to the input question obtained from the external knowledge vector database through similarity calculation in step 22 with the input question, build a comprehensive prompt strategy and input it into the large model to generate a series of interactive questions related to the current question.
[0056] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should be included in the protection scope of the present invention.
Claims
1. An intelligent questioning method based on large model retrieval enhancement and prompt strategy, characterized in that: include: Based on structured query language, data definition language, text data, PDF document blocks and local relational database, an external knowledge vector database for retrieval enhancement is constructed; Based on the multi-source heterogeneous vector database and input questions, a multi-angle prompt strategy is constructed to obtain the structured query language corresponding to the question; Based on the structured query language of questions and the PDF document block database, construct prompt strategies, obtain question-answering results and related analysis; Based on the retrieval-enhanced external knowledge vector database and the input question, a prompt strategy is constructed to obtain interactive questions related to the current question.
2. According to claim 1, an intelligent questioning method based on large model retrieval enhancement and prompt strategy is characterized in that: The step of constructing an external knowledge vector database for retrieval enhancement based on structured query language, data definition language, text data, PDF document blocks and local relational database includes: Constructing data sets for storing structured query language, data definition language, text data, and PDF document block metadata respectively; Based on the multilingual embedding model, structured query language, data definition language, text data, and PDF document block metadata are converted into corresponding embedding vectors; The embedding vectors of structured query language, data definition language, text data and PDF document blocks are combined into an embedding vector set, and the embedding vector set and the local relational database are jointly constructed into an external knowledge vector database for retrieval enhancement.
3. According to claim 1, the intelligent questioning method based on large model retrieval enhancement and prompt strategy is characterized in that: The step of constructing a multi-angle prompt strategy based on a multi-source heterogeneous vector database and an input question, and obtaining a structured query language corresponding to the question includes: Input the input question into the multilingual embedding model to obtain the embedding vector corresponding to the input question; Based on cosine similarity, calculate the similarity between the embedding vector corresponding to the question and all vectors in each embedding vector set in the external knowledge vector database; The vector that is most relevant to the embedding vector corresponding to the input question is mapped through a mapping function to obtain a list of original text data corresponding to the vector; The input question and the original text data list obtained after similarity calculation are integrated to form a multi-angle prompt strategy which is input into the big model to generate the structured query language corresponding to the input question.
4. According to claim 1, the intelligent questioning method based on large model retrieval enhancement and prompt strategy is characterized in that: The steps of constructing prompt strategies, obtaining question-answering results and related analysis based on the structured query language and PDF document block database of the question include: Based on the structured query language corresponding to the input question generated by the big model, combined with the local relational database in the external knowledge base, the running result of the structured query language is obtained, and the running result is merged with the PDF document block database related to the input question group generated after similarity calculation to form a prompt strategy input into the big model to generate the answer output and related analysis of the input question.
5. According to claim 1, the intelligent questioning method based on large model retrieval enhancement and prompt strategy is characterized in that: The step of constructing a prompt strategy based on the search-enhanced external knowledge vector database and the input question to obtain an interactive question associated with the current question includes: The structured query language vector list, data definition language vector list, text data vector list and PDF document block vector list related to the input question obtained from the external knowledge vector database through similarity calculation are combined with the input question to construct a comprehensive prompt strategy and input it into the large model to generate a series of interactive questions related to the current question.
6. A computer system, characterized in that include: One or more processors, and a computer-readable storage medium for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method of claim 1.
7. A computer-readable storage medium, characterized in that Computer executable instructions are stored, and when the instructions are executed, they are used to implement the method of claim 1.
8. A computer program product, characterized in that The invention comprises computer executable instructions, which are used to implement the method of claim 1 when being executed.
Citation Information
Patent Citations
Intelligent number asking and reading method, system and equipment based on large language model and medium
CN117874181A
Domain question answer generation method and device, computer equipment and medium
CN118170881A
A system for generating answers to multiple questions using rag-based generative artificial intelligence technology
KR102710159B1
Cited By
Intelligent technical supervision analysis decision method and system
CN121859886A