A method and system for acquiring input information for accurate retrieval of large models
Patent Information
- Application Number
- CN202410791744.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2044-06-18
AI Technical Summary
[0007]鉴于现有技术的上述缺点、不足,本发明提供一种用于大模型精准检索的输入信息的获取方法及系统,其解决了检索得到的包含关键词的文档非真正相关的文档,无法将本地有效的信息输入至大模型的技术问题
[0046] The beneficial effects of the present invention are: the method and system for obtaining input information for accurate retrieval of large models, by introducing an attention mechanism, can improve the accuracy of large model retrieval compared with the prior art, and retrieve documents that are truly relevant to the user's question and contain effective information.
Smart Images

Figure CN118656434B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of large model application technology, and in particular to a method and system for obtaining input information for accurate retrieval of large models. Background Technology
[0002] In recent years, large-scale data models, exemplified by OpenAI's GPT, have developed rapidly and attracted worldwide attention. However, in vertical applications, due to the "illusion" inherent in large-scale models during generation and the sensitivity of their internal data, Retrieval Augmented Generation (RAG) technology is needed. This involves first vectorizing the internal data and knowledge base, then retrieving relevant documents based on the user's question and inputting them into the large-scale model for generation, thereby improving the accuracy and reliability of the model's output. RAG models can retrieve relevant information from large amounts of text data and use it to generate answers or text. This technology is widely used in question-answering systems, dialogue generation, and text summarization.
[0003] Currently, RAG mainly includes: (1) Retrieval: The retrieval is responsible for retrieving and outputting relevant information from a large amount of text data. Commonly used retrievals include vector similarity-based retrieval and semantic understanding-based retrieval. The retrieval returns a set of relevant text fragments based on the input query. (2) Generator: The generator generates a coherent and relevant answer or text based on the input query and relevant text fragments; the generator usually adopts a large model with a Transformer architecture. (3) Fusion mechanism: The fusion mechanism is responsible for fusing the retrieved relevant text fragments with the generator's input so that the generator can better utilize this information.
[0004] When using RAG technology to retrieve internal knowledge bases based on user queries, the industry and academia generally calculate the similarity between query vectors and knowledge base vectors, and then retrieve relevant documents after reranking. However, research and experiments have shown that as the knowledge base continues to expand, directly calculating the similarity between user query vectors and knowledge base vectors will retrieve documents that contain query keywords but are not truly relevant, making it impossible to input effective local information into a large model.
[0005] Therefore, there is an urgent need for a method and system for obtaining input information for accurate retrieval of large models. Summary of the Invention
[0006] (a) Technical problems to be solved
[0007] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present invention provides a method and system for obtaining input information for accurate retrieval of large models, which solves the technical problem that the retrieved documents containing keywords are not truly relevant documents, and thus cannot input effective local information into the large model.
[0008] (II) Technical Solution
[0009] To achieve the above objectives, the main technical solutions adopted by the present invention include:
[0010] In a first aspect, embodiments of the present invention provide a method for obtaining input information for accurate retrieval of large models, including:
[0011] S100. In response to the current user's question, the question is vectorized to obtain a first vector and the keywords corresponding to the first vector as a keyword set one.
[0012] Based on the current user's question information, a first round of retrieval is performed in the vector database to obtain all vector results that match the first vector. For each vector result, a keyword set two is obtained. Each document in the vector database is a vector.
[0013] S200. For each keyword set two, delete the information in keyword set two that has the same keyword as keyword set one, and get the updated keyword set two as keyword set three.
[0014] S300. Perform feature extraction processing on each keyword set three to obtain a second vector. Perform a dot product operation on the first vector and the second vector, and use the result as the attention weight of the document to which each keyword set three belongs.
[0015] S400. Based on the attention weight of the documents to which each keyword set belongs, obtain documents within a preset range; combine the documents within the preset range with the question information and input them into a pre-given prompt word model to obtain input information for a large model used for accurate retrieval.
[0016] Optionally, S100 includes:
[0017] S11 0. Based on the current user's question information, input the question information into a vectorization model for vectorization processing to obtain a first vector;
[0018] S120. According to the preset keyword extraction algorithm, obtain each keyword corresponding to the first vector and use it as keyword set one;
[0019] S130. Based on the current user's question information, perform a first round of retrieval in the vector database, calculate the similarity between each vector in the vector database and the first vector, sort them according to the similarity, and obtain all vector results that match the first vector.
[0020] Each document in the vector database is a vector;
[0021] S140. Based on all vector results that match the first vector, extract the keywords of each vector result according to the preset keyword algorithm and use them as the second set of keywords.
[0022] Optionally, the vector database is obtained by vectorizing local knowledge base documents using a vectorization model; the vectorization model is pre-set.
[0023] The local knowledge base documents include laws and regulations, internal reports, professional books, and academic papers; the types of the local knowledge base documents are pdf, word, txt, or html.
[0024] Optionally, in S130,
[0025] The similarity between each vector in the computational vector database and the first vector includes:
[0026] Similarity can be calculated using the Euclidean distance method, the cosine similarity method, or the Jaccard similarity method.
[0027] Optionally, S100 further includes:
[0028] For all vector results obtained in the first round of retrieval that match the first vector, if there is a document in the vector results with a word count greater than a preset value, the document is split into K parts with word counts less than the preset value; where K is a natural number greater than or equal to 1.
[0029] For each part, keywords are extracted according to a preset keyword extraction algorithm to obtain a corresponding keyword set. The corresponding keyword sets are then combined to obtain the second keyword set for the document.
[0030] Optionally, S300 includes:
[0031] S310. For each keyword set three, input each keyword set three into a vectorization model, perform vectorization and pooling processing, and obtain a second vector.
[0032] S330. Perform a dot product operation between the first vector and each of the second vectors, and normalize the dot product results to obtain the attention weight of each second vector.
[0033] Optionally, in S330,
[0034] The process of normalizing the dot product result to obtain the attention weights for each third vector includes:
[0035] The softmax function is used to transform the dot product result into a probability distribution, and the attention weight of each third vector is obtained; the sum of all attention weights is 1.
[0036] Optionally, S400 includes:
[0037] Based on the attention weight of the documents to which each keyword set belongs, the documents to which each keyword set belongs are sorted, and the documents within the preset range are obtained. The preset range is determined according to the throughput of the large model. The documents within the preset range are combined with the question information and input into a pre-given prompt word model to obtain the input information for inputting the large model for accurate retrieval.
[0038] Optionally, keywords can be extracted using a preset keyword extraction algorithm, such as the textrank4zh algorithm.
[0039] Secondly, embodiments of the present invention provide a system for obtaining input information for accurate retrieval of large user models, comprising:
[0040] The first acquisition module is used to respond to the current user's question information, perform vectorization processing on the question information, and obtain the first vector and the keywords corresponding to the first vector as the keyword set one;
[0041] Based on the current user's question information, a first round of retrieval is performed in the vector database to obtain all vector results that match the first vector. For each vector result, a keyword set two is obtained. Each document in the vector database is a vector.
[0042] The second acquisition module is used to delete information in each keyword set two that has the same keywords as keyword set one, and obtain the updated keyword set two as keyword set three.
[0043] The third acquisition module is used to perform feature extraction processing on each keyword set three, obtain the second vector, perform a dot product operation on the first vector and the second vector, and use the result as the attention weight of the document to which each keyword set three belongs.
[0044] The fourth acquisition module is used to acquire documents within a preset range based on the attention weight of the documents to which each keyword set belongs; and to combine the documents within the preset range with the question information and input them into a pre-given prompt word model to obtain input information for a large model used for accurate retrieval.
[0045] (III) Beneficial Effects
[0046] The beneficial effects of the present invention are: the method and system for obtaining input information for accurate retrieval of large models, by introducing an attention mechanism, can improve the accuracy of large model retrieval compared with the prior art, and retrieve documents that are truly relevant to the user's question and contain effective information. Attached Figure Description
[0047] Figure 1 This is a flowchart illustrating a method for obtaining input information for accurate retrieval of large models according to an embodiment of the present invention.
[0048] Figure 2 This is an architecture diagram of conventional RAG technology in the background art of this invention;
[0049] Figure 3 This is a flowchart illustrating a method for obtaining input information for accurate retrieval of large models according to an embodiment of the present invention. Detailed Implementation
[0050] To better explain and facilitate understanding of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0051] This invention proposes a method and system for obtaining input information for accurate retrieval of large models. Based on the core idea of causality, it uses an attention mechanism to obtain the attention weights of each document, thereby obtaining documents that are truly relevant to the question and contain effective information. This improves the accuracy of large model retrieval and further solves the challenges and problems faced by large models in practical application scenarios.
[0052] To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the present invention can be understood more clearly and thoroughly, and that the scope of the present invention can be fully conveyed to those skilled in the art.
[0053] Detailed Description of Embodiments
[0054] Example 1
[0055] See Figure 1An embodiment of the present invention provides a method for obtaining input information for accurate retrieval of large models, comprising:
[0056] Step S100: In response to the current user's question, the question is vectorized to obtain the first vector and the keywords corresponding to the first vector as the first keyword set.
[0057] Based on the current user's question information, a first-round search is performed in the vector database to obtain all vector results that match the first vector. For each vector result, a second set of keywords is obtained. Each document in the vector database is a vector.
[0058] Step S200: For each keyword set two, delete the information in keyword set two that has the same keywords as keyword set one, and obtain the updated keyword set two as keyword set three.
[0059] Step S300: Based on feature extraction processing for each keyword set 3, obtain the second vector, perform dot product operation on the first vector and the second vector, and use the result as the attention weight of the document to which each keyword set 3 belongs.
[0060] Step S400: Based on the attention weight of the documents to which each keyword set belongs, obtain documents within a preset range; combine the documents within the preset range with the question information and input them into a pre-given prompt word model to obtain input information for a large model used for accurate retrieval.
[0061] In the specific implementation process, this invention is implemented using Python.
[0062] In this embodiment, step S100 includes:
[0063] Step S110: Based on the current user's question information, input the question information into the vectorization model for vectorization processing to obtain the first vector.
[0064] Step S120: According to the preset keyword extraction algorithm, obtain each keyword corresponding to the first vector and use it as the first keyword set.
[0065] Step S130: Based on the current user's question information, perform a first round of retrieval in the vector database, calculate the similarity between each vector in the vector database and the first vector, sort them according to the similarity, and obtain all vector results that match the first vector.
[0066] In a vector database, each document is represented as a vector.
[0067] Step S140: Based on all vector results that match the first vector, extract the keywords of each vector result according to the preset keyword algorithm and use them as the second set of keywords.
[0068] Specifically, the vector database is obtained by vectorizing local knowledge base documents using a vectorization model; the vectorization model is set in advance.
[0069] In this embodiment, step S130 further includes, during the first round of retrieval in the vector database, performing data denoising on the local knowledge base document vectors in the vector database to remove abnormal local knowledge base document vectors.
[0070] In the specific implementation process, the vectorization model is the bge-m3 vectorization model.
[0071] The local knowledge base documents include laws and regulations, internal reports, professional books, and papers; the document types are PDF, Word, TXT, or HTML.
[0072] In this embodiment, the local knowledge base documents are continuously updated.
[0073] In this embodiment, when there are non-Chinese documents among the documents obtained after the first round of retrieval, the non-Chinese documents are translated.
[0074] In this embodiment, in step S130,
[0075] Calculating the similarity between each vector in the vector database and the first vector includes:
[0076] Similarity can be calculated using the Euclidean distance method, the cosine similarity method, or the Jaccard similarity method.
[0077] In this embodiment, step S1 00 further includes:
[0078] For all vector results that match the first vector obtained in the first round of retrieval, if there is a document in the vector results with a word count greater than a preset value, the document is split into K parts with word counts less than the preset value; K is a natural number greater than or equal to 1.
[0079] For each part, keywords are extracted according to the preset keyword extraction algorithm to obtain the corresponding keyword set. The corresponding keyword sets are combined to obtain the second keyword set of the document.
[0080] In the actual implementation, the default value is 4096 tokens. For example, when a document has 5800 tokens, the document is split into two parts, one with 4096 tokens and the other with 1704 tokens.
[0081] In this embodiment, step S300 includes:
[0082] Step S310: For each keyword set three, input each keyword set three into the vectorization model, perform vectorization and pooling processing, and obtain the second vector.
[0083] Step S330: Perform a dot product operation between the first vector and each second vector, and normalize the dot product result to obtain the attention weight of each second vector.
[0084] In the specific implementation process, for example, each set of keywords is input into the vectorization model. After vectorization, each set of keywords is averaged and pooled, that is, the average value of each dimension of the keyword vector is calculated to obtain the second vector.
[0085] In this embodiment, in step S330,
[0086] The dot product result is then normalized to obtain the attention weights for each third vector, including:
[0087] The softmax function is used to transform the dot product result into a probability distribution, and the attention weight of each third vector is obtained; the sum of all attention weights is 1.
[0088] Step S400 includes:
[0089] Based on the attention weight of the documents to which each keyword set belongs, the documents to which each keyword set belongs are sorted, and the documents within the preset range are obtained. The preset range is determined according to the throughput of the large model. The documents within the preset range and the question information are combined and input into a pre-given prompt word model to obtain the input information for inputting the large model for accurate retrieval.
[0090] For example, if the predetermined range is the top 30%, then the documents belonging to each keyword set are sorted to obtain the top 30% of documents. The documents in the top 30% are then combined with the question information and input into a pre-given prompt word model to obtain the input information for the large model used for precise retrieval.
[0091] In this embodiment, the large model is ChatGPT-6B. After inputting the input information into ChatGPT-6B, more accurate search results can be obtained.
[0092] In the specific implementation process, keywords are extracted according to the preset keyword extraction algorithm, specifically the textrank4zh algorithm.
[0093] In this embodiment, by introducing an attention mechanism into the existing RAG architecture, and utilizing the idea of the attention mechanism, the document that is truly relevant to the question and contains effective information is retrieved through the dot product operation of the first vector and the second vector, thereby improving the accuracy of the retrieval.
[0094] Example 2
[0095] This embodiment provides a method for obtaining input information for accurate retrieval of large models, including:
[0096] Step S100: In response to the current user's question, the question is vectorized to obtain the first vector and the keywords corresponding to the first vector as the first keyword set.
[0097] Based on the current user's question information, a first-round search is performed in the vector database to obtain all vector results that match the first vector. For each vector result, a second set of keywords is obtained. Each document in the vector database is a vector.
[0098] Step S200: For each keyword set two, delete the information in keyword set two that has the same keywords as keyword set one, and obtain the updated keyword set two as keyword set three.
[0099] Step S300: Perform feature extraction processing on each keyword set 3 to obtain the second vector, perform dot product operation on the first vector and the second vector, and use the result as the attention weight of the document to which each keyword set 3 belongs.
[0100] Step S400: Based on the attention weight of the documents to which each keyword set belongs, obtain documents within a preset range; combine the documents within the preset range with the question information and input them into a pre-given prompt word model to obtain input information for a large model used for accurate retrieval.
[0101] For example, in this embodiment, the current user's question is "How to assess the security of data leaving the country?", which is input into the bge-m3 vectorization model to obtain the first vector; at the same time, according to the textrank4zh algorithm, the keyword set is obtained as: data, leaving the country, security, assessment;
[0102] Based on the user question "How to assess the security of data leaving the country?", a first round of searching was conducted in the vectorized local knowledge base documents, retrieving the ten most relevant documents. These ten documents are listed in descending order of similarity as follows:
[0103] Authentic8_GD_Open_Dark_Web_Research_Public.docx; Reflections on the National Security Development of Cyberspace.docx; Measures for Security Assessment of Cross-border Data Transfer (Draft for Comments).docx; move_to_the_Cloud_Challenges_and_Opportunities.docx; Guidelines for Security of Vehicle Data Collection and Processing.pdf; Several Provisions on Vehicle Data Security Management (Trial).docx; Information Security Technology - Guidelines for Security Assessment of Cross-border Data Transfer.docx; Data Security Law of the People's Republic of China.docx; Interpretation of the Technical Document "Guidelines for Security of Vehicle Data Collection and Processing".docx; Measures for Security Assessment of Cross-border Transfer of Personal Information and Important Data (Draft for Comments).docx;
[0104] Keyword extraction is performed on each of the above documents to obtain a second set of keywords for each document;
[0105] In the aforementioned document, “Information Security Technology - Data Export Security Assessment Guide.docx” contains 47,310 words. Therefore, the document is divided into 12 parts, and keywords are extracted from each part to obtain 12 keyword sets. Then, the intersection of the 12 keyword sets is taken to obtain the second keyword set of “Information Security Technology - Document Export Security Assessment Guide.docx”.
[0106] For each keyword set two corresponding to the ten documents, delete the information in keyword set two that has the same keywords as keyword set one, and obtain keyword set three;
[0107] For each keyword set 3, vectorization and pooling are performed, and then a dot product operation is performed with the first vector to obtain the attention weight corresponding to each document;
[0108] Based on the attention weight assigned to each document, the top 30% of documents are: Measures for Security Assessment of Cross-border Transfer of Personal Information and Important Data (Draft for Comments).docx, Measures for Security Assessment of Cross-border Transfer of Data (Draft for Comments).docx, and Information Security Technology - Guidelines for Security Assessment of Cross-border Transfer of Data.docx.
[0109] The above three documents and the user question "How to assess the security of data leaving the country" are input into a pre-given prompt word model to obtain the input information for ChatGPT-6B.
[0110] In this embodiment, by means of... Figure 2The existing RAG architecture shown can only retrieve documents that are highly relevant to the user's question in conventional retrieval. Based on this, the attention mechanism method can retrieve documents that are truly causally related, that is, documents that truly contain information that the user cares about, thereby improving the accuracy of retrieval.
[0111] Example 3
[0112] An embodiment of the present invention provides a method for obtaining input information for accurate retrieval of large models, which is based on causal relationships.
[0113] See Figure 3 In this embodiment, the intersection of keyword set one and keyword set two is keyword set four; information in keyword set two that has the same keywords as keyword set one is deleted, and the updated keyword set two is obtained as keyword set three.
[0114] In this embodiment, keyword set four is the intersection of keyword set one and keyword set two. That is, keyword set four contains both valid information from the user's question and valid information from the document. Therefore, keyword set four is treated as a latent variable. Both the user's question and the document are essentially generated from this latent variable. Therefore, in... Figure 3 In the causal relationship diagram shown, keyword four points to the user's question and the document, respectively.
[0115] Keyword set three, as another type of latent variable, can generate documents and ideal output text, and therefore, in situations such as... Figure 3 In the causal relationship diagram shown, keyword set three points to the document and the ideal output text, respectively;
[0116] The document acts as a collision factor in the causal relationship graph; the ideal output text is formed based on the user's question and the keyword set three, so the ideal output text is also a collision factor. According to the theory of causality, the user's question and the keyword set three will have a correlation.
[0117] Based on the conclusion that user questions and keyword sets three will generate a correlation, by using the attention mechanism, the document that is truly relevant to the question and contains effective information can be retrieved by performing a dot product operation between the question vector and the keyword set three vectors.
[0118] The embodiments of this invention are based on Reichenbach's Common Cause Principle, which sets forth the following... Figure 3 The hidden variable keyword set four and hidden variable keyword set three are shown; as a branching structure, once these two hidden variables are controlled separately, user questions and documents will be independent of each other, and documents and ideal text output will also be independent of each other.
[0119] Reichenbach's principle of common cause assumes that two events A and B are positively correlated: P(A∩B)>P(A)P(B). Furthermore, it assumes that neither event is a cause of the other. Therefore, A and B must share a common cause, making them conditionally independent. Reichenbach's principle of common cause establishes a link between causal structure and probabilistic correlation, thus facilitating causal inferences based on observed correlations.
[0120] according to Figure 3 The causal relationship diagram shown indicates that the research object of this invention satisfies the directed acyclic graph assumption, the causal Markov assumption, and the causal fidelity assumption, which are dependent on the causal graph model, thus ensuring the theoretical rationality of the technical idea of this invention.
[0121] The Directed Acyclic Graph (DAG) hypothesis assumes that the causal relationships between characteristic objects are described using DAGs.
[0122] The Causal Markov Assumption states that for a set of variables with sufficient causality, if all variables are conditionally independent of their non-descendant nodes, given the parent nodes of the variables, then this is said to satisfy the causal Markov Assumption. A directed acyclic graph (DAG) is a causal graph if and only if the joint probabilities of the nodes satisfy the Markov Assumption.
[0123] The Causal Faithfulness Assumption states that if, given a set of variables V, variables vi and vj are mutually independent or conditionally independent, then in a causal network graph G consisting of variables and their causal dependencies, all paths between vi and vj are d-separated by appropriate variables d in the set of variables V. Therefore, the joint distribution P of all random variables is said to be causally faithful to the graph G.
[0124] The present invention provides a method for obtaining input information for accurate retrieval of large models. By using causal relationship theory and attention mechanism, it can improve retrieval accuracy and obtain documents with true causal relationships, that is, documents that truly contain information that users care about.
[0125] Example 4
[0126] An embodiment of the present invention provides a system for acquiring input information for accurate retrieval of large models, comprising:
[0127] The first acquisition module is used to respond to the current user's question information, perform vectorization processing on the question information, and obtain the first vector and the keywords corresponding to the first vector as the keyword set one;
[0128] Based on the current user's question information, a first round of retrieval is performed in the vector database to obtain all vector results that match the first vector. For each vector result, a second set of keywords is obtained. Each document in the vector database is a vector.
[0129] The second acquisition module is used to delete information in each keyword set two that has the same keywords as keyword set one, and obtain the updated keyword set two as keyword set three.
[0130] The third acquisition module is used to perform feature extraction processing on each keyword set three, obtain the second vector, perform a dot product operation on the first vector and the second vector, and use the result as the attention weight of the document to which each keyword set three belongs.
[0131] The fourth acquisition module is used to acquire documents within a preset range based on the attention weight of the documents to which each keyword set belongs; and to combine the documents within the preset range with the question information and input them into a pre-given prompt word model to obtain input information for a large model used for accurate retrieval.
[0132] The input information acquisition system for accurate retrieval of large models in this embodiment significantly improves the accuracy of document retrieval at the semantic level.
[0133] In the description of this invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0134] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0135] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first and second features are in direct contact, or that they are in indirect contact through an intermediate medium. Furthermore, "above," "over," or "on top" the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply indicates that the first feature is at a higher horizontal level than the second feature. "Below," "below," or "beneath" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply indicates that the first feature is at a lower horizontal level than the second feature.
[0136] In the description of this specification, the terms "one embodiment," "some embodiments," "embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0137] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make modifications, alterations, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for obtaining input information for accurate retrieval of large models, characterized in that, include: S100. In response to the current user's question, the question is vectorized to obtain a first vector and the keywords corresponding to the first vector as a keyword set one. Based on the current user's question information, a first round of retrieval is performed in the vector database to obtain all vector results that match the first vector. For each vector result, a keyword set two is obtained. Each document in the vector database is a vector. For all vector results obtained in the first round of retrieval that match the first vector, if there is a document in the vector results with a word count greater than a preset value, the document is split into K parts with word counts less than the preset value; where K is a natural number greater than or equal to 1. For each part, keywords are extracted according to a preset keyword extraction algorithm to obtain a corresponding keyword set. The corresponding keyword sets are then combined to obtain the second keyword set for the document. S200. For each keyword set two, delete the information in keyword set two that has the same keyword as keyword set one, and get the updated keyword set two as keyword set three. S300. Perform feature extraction processing on each keyword set three to obtain a second vector. Perform a dot product operation on the first vector and the second vector, and use the result as the attention weight of the document to which each keyword set three belongs. S400: Based on the attention weight of the documents to which each keyword set belongs, obtain documents within a preset range; The documents within the preset range are combined with the question information and input into a pre-given prompt word model to obtain input information for a large model used for accurate retrieval.
2. The method for obtaining input information for accurate retrieval of large models according to claim 1, characterized in that, S100 includes: S110. Based on the current user's question information, input the question information into a vectorization model for vectorization processing to obtain a first vector; S120. According to the preset keyword extraction algorithm, obtain each keyword corresponding to the first vector and use it as keyword set one; S130. Based on the current user's question information, perform a first round of retrieval in the vector database, calculate the similarity between each vector in the vector database and the first vector, sort them according to the similarity, and obtain all vector results that match the first vector. Each document in the vector database is a vector; S140. Based on all vector results that match the first vector, extract the keywords of each vector result according to the preset keyword algorithm and use them as the second set of keywords.
3. The method for obtaining input information for accurate retrieval of large models according to claim 2, characterized in that, The vector database is obtained by vectorizing local knowledge base documents using a vectorization model; the vectorization model is pre-set. The local knowledge base documents include laws and regulations, internal reports, professional books, and academic papers; the types of the local knowledge base documents are pdf, word, txt, or html.
4. The method for obtaining input information for accurate retrieval of large models according to claim 2, characterized in that, In S130, The similarity between each vector in the computational vector database and the first vector includes: Similarity can be calculated using the Euclidean distance method, the cosine similarity method, or the Jaccard similarity method.
5. The method for obtaining input information for accurate retrieval of large models according to claim 1, characterized in that, The S300 includes: S310. For each keyword set three, input each keyword set three into a vectorization model, perform vectorization and pooling processing, and obtain a second vector. S330. Perform a dot product operation between the first vector and each of the second vectors, and normalize the dot product results to obtain the attention weight of each second vector.
6. The method for obtaining input information for accurate retrieval of large models according to claim 5, characterized in that, In S330 The process of normalizing the dot product result to obtain the attention weights for each third vector includes: The softmax function is used to transform the dot product result into a probability distribution, and the attention weight of each third vector is obtained; the sum of all attention weights is 1.
7. The method for obtaining input information for accurate retrieval of large models according to claim 1, characterized in that, The S400 includes: Based on the attention weight of the documents to which each keyword set belongs, the documents to which each keyword set belongs are sorted, and the documents within the preset range are obtained. The preset range is determined according to the throughput of the large model. The documents within the preset range are combined with the question information and input into a pre-given prompt word model to obtain the input information for inputting the large model for accurate retrieval.
8. A method for obtaining input information for accurate retrieval of large models according to claim 1 or 2, characterized in that, Keywords are extracted according to a preset keyword extraction algorithm, specifically the textrank4zh algorithm.
9. A system for acquiring input information for accurate retrieval of large models, characterized in that, include: The first acquisition module is used to respond to the current user's question information, perform vectorization processing on the question information, and obtain the first vector and the keywords corresponding to the first vector as the keyword set one; Based on the current user's question information, a first round of retrieval is performed in the vector database to obtain all vector results that match the first vector. For each vector result, a keyword set two is obtained. Each document in the vector database is a vector. For all vector results obtained in the first round of retrieval that match the first vector, if there is a document in the vector results with a word count greater than a preset value, the document is split into K parts with word counts less than the preset value; where K is a natural number greater than or equal to 1. For each part, keywords are extracted according to a preset keyword extraction algorithm to obtain a corresponding keyword set. The corresponding keyword sets are then combined to obtain the second keyword set for the document. The second acquisition module is used to delete information in each keyword set two that has the same keywords as keyword set one, and obtain the updated keyword set two as keyword set three. The third acquisition module is used to perform feature extraction processing on each keyword set three, obtain the second vector, perform a dot product operation on the first vector and the second vector, and use the result as the attention weight of the document to which each keyword set three belongs. The fourth acquisition module is used to acquire documents within a preset range based on the attention weight of the documents to which each keyword set belongs; The documents within the preset range are combined with the question information and input into a pre-given prompt word model to obtain input information for a large model used for accurate retrieval.
Citation Information
Patent Citations
Enterprise document library construction and retrieval method and system
CN117421333A
Patent information similarity calculation method based on key attention mechanism
CN117763088A