Retrieval enhancement method and device based on large model and storage medium
Through the search enhancement method based on large-models, text expansion of user query and knowledge base documents is solved, and the problem of poor matching effect caused by semantic gaps in the existing technology is achieved, and higher retrieval accuracy and system scalability are achieved.
Patent Information
- Application Number
- CN202510473462.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-05-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing search technology has poor matching results due to semantic gaps when processing user queries and knowledge base documents, and cannot be updated in time, which has problems with poor generalization ability and scalability.
The search enhancement method based on big model is adopted. By inputting the user's initial query text and knowledge base documents into a large language model, answer results and simulated query statements are generated, and text expansion is carried out, and query and knowledge base documents are transformed into a question-and-answer format to reduce semantic gaps.
It improves the accuracy of search results, simplifies the search process, and enhances the generalization ability and scalability of the search system.
Smart Images

Figure CN119988602A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a retrieval enhancement method, device and storage medium based on a large model. Background Art
[0002] Retrieval technology is an important means to obtain the required information. The purpose of retrieval is to identify user intentions and match user queries to corresponding knowledge documents. At present, the common matching method is the word embedding-based matching method, which converts both user text and document knowledge text into fixed-length word embedding vectors. By calculating the cosine similarity between vectors, the semantic matching score is obtained, and the matching with the highest similarity score is used as the query result.
[0003] However, although the word embedding vectors generated by the neural network model can be used for semantic representation, due to the natural semantic gap between user queries and local documents (user queries are usually interrogative sentences expressing questions; local documents are usually declarative sentences used to explain reasons), the semantic imbalance leads to poor final matching results. By incrementally training the word embedding model on a certain number of user queries and local document texts, the natural semantic gap between user queries and local documents can be "hard aligned", which can reduce the semantic gap between the two to a certain extent. However, since it takes time to retrain the model, it is impossible to update the retrieval system in a timely manner as documents expand, and there are problems with poor generalization and scalability. The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of this application is to provide a retrieval enhancement method, device and storage medium based on a large model, aiming to solve the technical problem of how to simplify the retrieval process and improve the accuracy of the retrieval results.
[0005] To achieve the above objectives, the present application proposes a retrieval enhancement method based on a large model, and the retrieval enhancement method based on a large model includes: Input the user's initial query text into the preset large language model to obtain the answer result; Inputting a preset user role, prompt and knowledge base document into the large language model to obtain a simulated query statement; Combining the answer result with the corresponding initial query text to obtain a target query text, and combining the knowledge base document with the corresponding simulated query statement to obtain a target knowledge base document; The target query text and the target knowledge base document are matched to obtain a target query result.
[0006] In one embodiment, the step of inputting the user's initial query text into a preset large language model to obtain an answer result includes: Based on the large language model, performing intent recognition on the initial query text to obtain the query intent; Information retrieval is performed in the general information base of the large language model according to the query intention to obtain the answer result corresponding to the initial query text.
[0007] In one embodiment, the step of inputting a preset user role, prompt and knowledge base document into the large language model to obtain a simulated query statement includes: Classifying the knowledge base documents according to the user roles to obtain sub-knowledge base documents; The sub-knowledge base document and the corresponding prompt are input into the large language model to obtain the simulated query statement.
[0008] In one embodiment, before the step of classifying the knowledge base documents according to the user roles to obtain sub-knowledge base documents, the step further includes: Determine the user role and the query scenario corresponding to the user role according to the knowledge base document; The prompt is generated according to the user role and the query scenario.
[0009] In one embodiment, after the step of inputting the preset user role, prompt and knowledge base document into the large language model to obtain the simulated query statement, the following step is further included: Performing a repeatability test on each of the simulated query statements to obtain a similarity; If the similarity is greater than a preset similarity threshold, the corresponding simulated query statement is confirmed to be a duplicate statement, and the duplicate statement is removed.
[0010] In one embodiment, the step of matching the target query text with the target knowledge base document to obtain the target query result includes: Convert the target query text and the target knowledge base document into vector representations to obtain a query statement vector and a knowledge document vector; Obtaining the similarity between the query statement vector and the knowledge document vector; If the similarity is greater than a preset similarity threshold, the query result is generated according to the knowledge document content corresponding to the knowledge document vector.
[0011] In one embodiment, the step of obtaining the similarity between the query statement vector and the knowledge document vector includes: Obtaining the Euclidean distance between the query statement vector and the knowledge document vector; The Euclidean distance is nonlinearly mapped to obtain the similarity.
[0012] In one embodiment, the step of generating the target query result according to the knowledge document content corresponding to the knowledge document vector includes: Acquire at least one query result obtained by matching the target query text with the target knowledge base document; Determining the association weights between the target query text and the corresponding query results; The query result with the highest association weight is used as the target query result.
[0013] In addition, to achieve the above-mentioned objectives, the present application also proposes a large model-based retrieval enhancement device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the large model-based retrieval enhancement method as described above.
[0014] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the large model-based retrieval enhancement method described above are implemented.
[0015] The present application provides a retrieval enhancement method based on a big model, which utilizes the semantic understanding and text generation capabilities of the big model to perform text expansion on both the user's query text and the knowledge base document, respectively, and convert both the user query and the domain knowledge text into a question-and-answer text format, so as to achieve the purpose of reducing the semantic gap between the user query and the knowledge base document, thereby reducing the semantic gap between the user query text and the knowledge base document and improving the accuracy of retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] Figure 1 A flowchart diagram of an embodiment of a retrieval enhancement method based on a large model of the present application is provided; Figure 2A brief flowchart diagram of an embodiment of a retrieval enhancement method based on a large model of the present application is provided; Figure 3 A schematic diagram of a large model expansion result provided in an embodiment of a large model-based retrieval enhancement method of the present application; Figure 4 Another flowchart diagram provided for an embodiment of a retrieval enhancement method based on a large model of the present application; Figure 5 It is a structural diagram of the hardware operating environment involved in the large model-based retrieval enhancement method in the embodiment of the present application.
[0019] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0020] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0021] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0022] The main solution of the embodiment of the present application is: input the user's initial query text into a preset large language model to obtain an answer result; input the preset user role, prompt and knowledge base document into the large language model to obtain a simulated query statement; combine the answer result and the corresponding initial query text to obtain a target query text, and combine the knowledge base document and the corresponding simulated query statement to obtain a target knowledge base document; match the target query text and the target knowledge base document to obtain a target query result.
[0023] Retrieval technology is an important means to obtain the required information. The purpose of retrieval is to identify user intentions and match user queries to corresponding knowledge documents. At present, the common matching method is the word embedding-based matching method, which converts both user text and document knowledge text into fixed-length word embedding vectors. By calculating the cosine similarity between vectors, the semantic matching score is obtained, and the matching with the highest similarity score is used as the query result.
[0024] However, although the word embedding vectors generated by the neural network model can be used for semantic representation, due to the natural semantic gap between user queries and local documents (user queries are usually interrogative sentences expressing questions; local documents are usually declarative sentences used to explain reasons), the semantic imbalance leads to poor final matching results. By incrementally training the word embedding model on a certain number of user queries and local document texts, the natural semantic gap between user queries and local documents can be "hard aligned", which can reduce the semantic gap between the two to a certain extent. However, since it takes time to retrain the model, it is impossible to update the retrieval system in a timely manner as documents expand, and there are problems with poor generalization and scalability.
[0025] Another common matching method is the keyword-based matching method, which splits the user query through the word segmentation model, uses the word weight analysis technology to capture the keyword, and then uses the keyword string matching to search the knowledge document to obtain the query result. This method only relies on string matching of some words in the sentence, and it is difficult to understand the overall semantics (for example, "apple" and "Apple mobile phone" both contain the keyword "apple", but the actual semantics are not consistent), which makes the user query result deviate from the actual semantics and cannot be accurately retrieved.
[0026] In order to solve the above problems, the present application provides a retrieval enhancement method based on a big model, which uses the semantic understanding and text generation capabilities of the big model to perform text expansion on both the user's query text and the knowledge base document, and converts both the user query and the domain knowledge text into a question-and-answer text format, so as to achieve the purpose of reducing the semantic gap between the user query and the knowledge base document, thereby reducing the semantic gap between the user query text and the knowledge base document and improving the retrieval accuracy.
[0027] It should be noted that the execution subject of this embodiment can be a computing service device with network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device or device capable of realizing the above functions. The following takes a retrieval enhancement device based on a large model as an example to illustrate this embodiment and the following embodiments.
[0028] Based on this, the embodiment of the present application provides a retrieval enhancement method based on a large model, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the large model-based retrieval enhancement method of the present application.
[0029] In this embodiment, the large model-based retrieval enhancement method is applied to a large model-based retrieval enhancement device, and the method includes steps S100 to S400: Step S100: input the user's initial query text into a preset large language model to obtain an answer result.
[0030] In this embodiment, the user's initial query text is expanded using a large language model. Optionally, the large language model can be Qianwen 2-7B, Wenxin Yiyan, GPT (Generative Pretrained Transformer), etc. Exemplarily, the general knowledge of the large model itself is used to first give a simple answer to the initial query text "How can XX disease be treated?" The answer result is: "XX disease usually requires surgical treatment. Asymptomatic patients can be observed, pay attention to diet, and avoid massage stimulation. XX drugs may have an auxiliary effect." Use the large model to first make a hypothetical answer to the initial query text, expand the user query, so that the initial query text not only contains the question itself, but also includes the answer results that may correspond to the question. After obtaining the answer result, the initial query text and the answer result generated by the large model are combined, and the new user query becomes a question-answer format: "Question: How can XX disease be treated? Answer: XX disease usually requires surgical treatment. Asymptomatic patients can be observed, pay attention to diet, and avoid massage stimulation. XX drugs may have an auxiliary effect." In this embodiment, the answer of the large model enriches the initial query text semantically, is closer to the correct answer, and has a semantic balance effect. For example, the answer of the large model emphasizes the treatment and auxiliary effects of XX drugs, which is almost completely corresponding to the real answer. From the key words of the answer, both the correct answer and the large model answer contain words such as "surgery", "effect", and "XX drug", which is conducive to semantic balance. It solves the problem that the user query text is generally a colloquial question sentence, while the corresponding domain knowledge is a declarative sentence of professional terminology, resulting in inconsistent text format; the user query text is short, while the corresponding domain knowledge text is long, resulting in inconsistent text length; and the content of the user query is often the surface phenomenon or symptoms of things, while the domain knowledge is the explanation and analysis of the problem, resulting in inconsistent knowledge content involved and other inconsistencies. The problem of matching difficulties caused by multiple inconsistencies.
[0031] Step S200: input the preset user role, prompt and knowledge base document into the large language model to obtain a simulated query statement.
[0032] It is understandable that the local knowledge base documents only contain long and professional answers, but no relevant questions corresponding to the answers, and there is a lack of knowledge matching the questions.
[0033] In this embodiment, the knowledge base document is expanded and enhanced using a large model. The large model simulates the user role based on the local knowledge base document, generates possible query statements, and stores them locally along with the original domain knowledge. The association relationship between the knowledge base document and the simulated query statement is stored using a database table structure. The knowledge document identifier, query statement identifier, and association weight information are inserted into the corresponding table using a database operation statement (such as INSERT INTO in SQL).
[0034] For example, the answer in the knowledge base document is: "XX disease is a benign disease, but it is easy to relapse after surgery. Patients can use XX medicine for treatment, which is safe and will not cause any harm or side effects to the body. The hope of cure is relatively high." The big model is called, and the prompt "Given the following document, please give the question that the user is most likely to ask" is given. The generated simulated query statement is: "How to treat XX disease". After the big model enhances and expands the local knowledge, the original document text and the simulated user query statement generated by the big model are spliced and combined, and the final local document is also turned into a question-and-answer format.
[0035] The original user query is "How can XX disease be treated?", and the user query simulated by the big model is "How to treat XX disease?" In terms of sentence length, semantics, keywords, sentence structure, etc., the simulated user queries based on document questions by the big model are almost consistent with real user queries, and can effectively match the semantics of the user's query text.
[0036] Step S300, combining the answer result and the corresponding initial query text to obtain a target query text, and combining the knowledge base document and the corresponding simulated query statement to obtain a target knowledge base document.
[0037] Step S400, matching the target query text with the target knowledge base document to obtain a target query result.
[0038] Please refer to Figure 2 and Figure 3 In this embodiment, after the bidirectional expansion and enhancement of the large model, the user's query text and domain knowledge are converted into two text pairs with similar length, same format and close semantics, which is convenient for the next step of question-answer matching. At this time, the target query text obtained after expansion is matched with the target knowledge base document to obtain the query result.
[0039] In an optional implementation, step S400 may include the following steps: The target query text and the target knowledge base document are converted into vector representations to obtain a query statement vector and a knowledge document vector.
[0040] The similarity between the query statement vector and the knowledge document vector is obtained.
[0041] If the similarity is greater than a preset similarity threshold, the query result is generated according to the knowledge document content corresponding to the knowledge document vector.
[0042] In this embodiment, the target query text and the target knowledge base document are matched by a matching method based on word embedding. First, a preprocessing operation is performed to remove noise information, unify the format, and segment the target query text and the target knowledge base document, remove irrelevant information such as punctuation marks and unobjectionable auxiliary words, ensure the consistency of the text format, avoid semantic recognition differences caused by different capitalization, and split the text into meaningful words for subsequent vectorization processing. Secondly, a text vectorization operation is performed. Optionally, the text can be vectorized by a word vector model such as Word2Vec, GloVe, or a pre-trained language model such as BERT (Bidirectional Encoder Representations from Transformers), GPT (Generative Pre-trained Transformer, Generative Pre-trained Model), to obtain a query statement vector and a knowledge document vector. Finally, the similarity between the query statement vector and the knowledge document vector is calculated. According to the nature of the knowledge base, the application scenario, and past experience, a suitable similarity threshold is set to determine whether the query statement and the knowledge document are similar enough, and then decide whether to generate a query result based on the knowledge document.
[0043] In this implementation, each element in the similarity matrix (i.e., the similarity value of each pair of query statements and knowledge base documents) is traversed. If a similarity value is found to be greater than a preset similarity threshold, it indicates that the corresponding query statement and knowledge document have a high semantic match. At this time, the knowledge document content corresponding to the knowledge document vector is extracted, the content is sorted and optimized, the duplicate parts are removed, and the content is arranged in a logical order to obtain the final query result.
[0044] Optionally, use Word2Vec to vectorize the text. The model is trained based on a large-scale corpus (which can include knowledge base documents and other text materials in related fields). After training, the model generates a vector representation of a fixed dimension (such as 300 dimensions) for each word. Then, for the preprocessed query text, the word vectors corresponding to the words in the text are combined (such as using simple average, weighted average, or TF-IDF weighting) to obtain the vector representation of the entire text.
[0045] Optionally, BERT is used to vectorize text. By calling the corresponding open source library (such as the transformers library), the query text and the text units of the knowledge base document are respectively input into the pre-trained BERT model to obtain the vector representation of its output.
[0046] In a feasible implementation manner, the step of obtaining the similarity between the query statement vector and the knowledge document vector includes: Obtaining the Euclidean distance between the query statement vector and the knowledge document vector; The Euclidean distance is nonlinearly mapped to obtain the similarity.
[0047] In this embodiment, the Euclidean distance between the query statement vector and the knowledge document vector is calculated, and the Euclidean distance is converted into similarity by nonlinear mapping, which may be Gaussian function mapping, hyperbolic tangent function mapping, and the like.
[0048] When nonlinear mapping is performed according to the Gaussian function, the formula of the Gaussian function is: S(d)=exp[-(d 2 / 2σ 2 )]; where d represents the Euclidean distance and σ represents the standard deviation, which determines the sensitivity of similarity to distance changes. When the Euclidean distance d=0, the similarity S=1, and the similarity is the highest when the two vectors completely overlap (i.e., the semantics are exactly the same); as the Euclidean distance increases, the similarity will gradually decrease according to the law of Gaussian distribution and approach 0.
[0049] In a feasible implementation manner, the similarity may also be determined according to methods such as cosine similarity, Manhattan distance, and Jaccard similarity coefficient.
[0050] In a feasible implementation manner, the step of generating the target query result according to the knowledge document content corresponding to the knowledge document vector may include: Acquire at least one query result obtained by matching the target query text with the target knowledge base document.
[0051] Determine the association weights between the target query text and the corresponding query results.
[0052] The query result with the highest association weight is used as the target query result.
[0053] In this embodiment, an association weight is established between the target query result and the corresponding query result. The association weight can be the similarity value between the knowledge base document and the corresponding query result. For example, if the similarity between the target query text and a knowledge base document is 0.8, 0.8 is used as the association weight between them. The association weight can also normalize the similarity value and use the normalized processing result as the association weight. For example, through the matching method, the similarities between multiple query results and the query text are obtained as [0.6, 0.8, 0.7] respectively, which are converted into normalized weights [0.3, 0.4, 0.3] through the normalization formula, and used as the association weight to make the weight distribution more reasonable. When the user enters the query statement, the most relevant (highest weight) knowledge document is displayed to the user as the target query result according to the association weight between the query statement and each knowledge document.
[0054] Alternatively, association rule mining tools such as the Apriori algorithm can be used to analyze the potential frequent patterns between user query statements and knowledge document access. For example, if it is found that a large number of users frequently access a knowledge document on data cleaning using Python libraries introduced in a specific chapter after querying "data cleaning methods in data analysis", the association between the two will be strengthened and the association weight will be increased.
[0055] Optionally, query statements and knowledge documents are clustered separately. For query statement clustering, they are divided into different groups based on semantic similarity to explore the common query topic categories of users; for knowledge document clustering, factors such as themes, fields, and knowledge structures are comprehensively considered for classification. Then, the interactive correlations between different clusters are analyzed, and the query statements and knowledge document cluster pairs that are frequently used in collaboration are accurately located, and the correlation structure between them is optimized in a targeted manner. For example, all query statements about the basic syntax of programming languages are clustered into one category, and all knowledge documents on introductory tutorials for programming languages are clustered into one category. If it is found that the two categories are closely related, their correlation weights are appropriately increased.
[0056] Optionally, key behavioral indicators such as user click-through rate, document browsing time, and repeated query rate can also be comprehensively analyzed. A high click-through rate (the proportion of knowledge documents viewed after query statements are clicked) and a long browsing time usually indicate that the query statement and the knowledge document are highly matched and the content is very attractive to users, and the association weight should be increased appropriately; conversely, if the click-through rate is low, the browsing time is too short, or the repeated query rate is high, it may mean that users fail to quickly obtain the required information, and the association relationship needs to be readjusted, such as optimizing the guidance of the query statement and repositioning the core content of the knowledge document.
[0057] In this embodiment, the semantic understanding and text generation capabilities of the large model are utilized to perform text expansion on both the user's query text and the knowledge base document, respectively, and both the user query and the domain knowledge text are converted into a question-and-answer text format, so as to achieve the purpose of reducing the semantic gap between the user query and the knowledge base document, thereby reducing the semantic gap between the user query text and the knowledge base document and improving the accuracy of retrieval.
[0058] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 , step S100 may include steps S110 to S120: Step S110: Based on the large language model, the initial query text is subjected to intent recognition to obtain the query intent.
[0059] In this embodiment, appropriate prompts are constructed based on the initial query text to guide the large language model to accurately identify its intent. Some key information such as field limitations and task requirements can be incorporated into the prompts, so that the large language model can focus on a specific scope and task type to make intent judgments and improve the accuracy of recognition. For example, for the query text "How can XX disease be treated", the prompt can be: "Please identify the intent of the following text: 'How can XX disease be treated', and analyze it from the perspective of related fields such as treatment methods and therapeutic drugs, and summarize its main intent in concise language." Through the API interface provided by the large language model, the constructed prompt is sent to the large language model in accordance with the specified request format. For example, Python is used in combination with the corresponding API call library (such as the openai library corresponding to some models of OpenAI, etc.), the request parameters are organized according to the interface requirements, and a request is initiated to obtain the intent recognition result returned by the large language model.
[0060] Step S120: performing information retrieval in the general information base of the large language model according to the query intention to obtain the answer result corresponding to the initial query text.
[0061] In this embodiment, based on the identified query intent, the search scope in the general information library of the large language model is clarified. The search is performed by keyword matching search, semantic similarity search, or a combination of multiple methods. According to the determined search scope and strategy, key information related to the query intent (such as core keywords, key semantic expressions, etc.) is used as input to initiate a search request. The large language model searches and matches in its general information library and returns information related to the query intent. The information retrieval results returned by the large language model are sorted, and duplicate and redundant parts are removed, and arranged in a certain logical order. The optimized and sorted content is used as the answer result corresponding to the query text.
[0062] Based on the first embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 , step S200 may include steps S210 to S240: Step S210: determining the user role and the query scenario corresponding to the user role according to the knowledge base document.
[0063] Step S220: Generate the prompt according to the user role and the query scenario.
[0064] In this embodiment, some rules and scenarios for simulating user roles are designed based on the fields involved in the knowledge base documents, as well as the common purposes and question angles of users when querying knowledge in this field. For example, if it is a medical knowledge base, possible user roles include ordinary patients, medical staff, etc., and the corresponding query scenarios include asking about disease symptoms, treatment methods, and precautions for medication. These roles and scenarios are refined and classified. Based on the sorted simulated user roles, prompts sent to the large model are constructed for each specific classification situation.
[0065] Step S230: classify the knowledge base documents according to the user roles to obtain sub-knowledge base documents.
[0066] Step S240: input the sub-knowledge base document and the corresponding prompt into the large language model to generate the simulated query statement.
[0067] In this embodiment, since the input length that the large model can process at one time may be limited, the constructed prompts can be sent to the large model in batches according to certain rules. The sub-knowledge base documents can be reasonably grouped and batched according to dimensions such as fields and roles to avoid request failures caused by prompts that are too long or too complex.
[0068] Conduct a comprehensive analysis of the knowledge base document content, and classify the knowledge content in the document according to the relevance to each role based on the different user roles that have been sorted out before (for example, in the enterprise management knowledge base, there are grassroots employees, middle-level managers, senior decision makers, etc.; in the e-commerce operation knowledge base, there are e-commerce sellers, e-commerce operation personnel, customer service personnel, etc.). These categories can be clearly divided by establishing different folders, database table records or tags. The classified knowledge base document content and the corresponding prompts are sent to the big model in turn, requesting it to generate corresponding simulation query statements based on this information.
[0069] In this embodiment, different user roles have quite different concerns and demands for knowledge in the knowledge base. By using classified input, the large model can focus more on the knowledge content related to a specific role, so that the generated query statements are more in line with the needs and expression habits of the role when actually querying knowledge.
[0070] In a feasible implementation manner, the following steps may be further included after step S200: A repeatability test is performed on each of the simulated query statements to obtain a similarity.
[0071] If the similarity is greater than a preset similarity threshold, the corresponding simulated query statement is confirmed to be a duplicate statement, and the duplicate statement is removed.
[0072] In this embodiment, all simulated query statements returned by the large model are organized into a list or set. The similarities between the simulated query statements are calculated in sequence based on methods such as text edit distance or semantic vector space. A similarity threshold is set, and illustratively, the similarity threshold is 0.8. All similarity values are calculated through traversal, and when the similarity value is greater than the similarity threshold, the corresponding statement is marked as a repeated or highly similar statement pair. After marking the repeated statement pairs, the marked statements are deleted to form a new set or list, and the result is obtained after removing the repeated or highly similar redundant statements. The above steps can avoid duplication and redundancy.
[0073] The present application provides a large model-based retrieval enhancement device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the large model-based retrieval enhancement method in the above-mentioned embodiment one.
[0074] Reference below Figure 5 , which shows a schematic diagram of the structure of a large model-based retrieval enhancement device suitable for implementing the embodiment of the present application. The large model-based retrieval enhancement device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDA, Personal Digital Assistant), tablet computers (PAD, portable android device), portable multimedia players (PMP, Portable Media Player), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The large model-based retrieval enhancement device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0075] like Figure 5 As shown, the retrieval enhancement device based on the large model may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM) 1004. Various programs and data required for the operation of the retrieval enhancement device based on the large model are also stored in the random access memory 1004. The processing device 1001, the read-only memory 1002, and the random access memory 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems may be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 1009. The communication device 1009 may allow the large model-based retrieval enhancement device to communicate with other devices wirelessly or by wire to exchange data. Although the large model-based retrieval enhancement device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or have instead.
[0076] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0077] The large-model-based retrieval enhancement device provided by the present application adopts the large-model-based retrieval enhancement method in the above-mentioned embodiment, which can solve the technical problem of how to simplify the retrieval process and improve the accuracy of the retrieval results. Compared with the prior art, the beneficial effects of the large-model-based retrieval enhancement device provided by the present application are the same as the beneficial effects of the large-model-based retrieval enhancement method provided by the above-mentioned embodiment, and the other technical features of the large-model-based retrieval enhancement device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0078] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0079] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0080] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the large model-based retrieval enhancement method in the above-mentioned embodiment.
[0081] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM, CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, radio frequencies (RF, Radio Frequency), etc., or any suitable combination of the above.
[0082] The computer-readable storage medium may be included in the retrieval enhancement device based on the large model; or it may exist independently without being assembled into the retrieval enhancement device based on the large model. The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the retrieval enhancement device based on the large model, the retrieval enhancement device based on the large model: inputs the user's initial query text into the preset large language model to obtain an answer result; inputs the preset user role, prompt and knowledge base document into the large language model to obtain a simulated query statement; combines the answer result with the corresponding initial query text to obtain a target query text, and combines the knowledge base document with the corresponding simulated query statement to obtain a target knowledge base document; matches the target query text with the target knowledge base document to obtain a target query result.
[0083] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0084] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0085] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0086] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned large-model-based retrieval enhancement method, and can solve the technical problem of how to simplify the retrieval process and improve the accuracy of the retrieval results. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the large-model-based retrieval enhancement method provided in the above-mentioned embodiment, and will not be repeated here.
[0087] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A retrieval enhancement method based on a large model, characterized in that: The method includes: Input the user's initial query text into the preset large language model to obtain the answer result; Inputting a preset user role, prompt and knowledge base document into the large language model to obtain a simulated query statement; Combining the answer result with the corresponding initial query text to obtain a target query text, and combining the knowledge base document with the corresponding simulated query statement to obtain a target knowledge base document; The target query text and the target knowledge base document are matched to obtain a target query result.
2. The retrieval enhancement method based on a large model as claimed in claim 1, characterized in that: The step of inputting the user's initial query text into a preset large language model to obtain an answer result comprises: Based on the large language model, performing intent recognition on the initial query text to obtain the query intent; Information retrieval is performed in the general information base of the large language model according to the query intention to obtain the answer result corresponding to the initial query text.
3. The retrieval enhancement method based on a large model as claimed in claim 1, characterized in that: The step of inputting the preset user role, prompt and knowledge base document into the large language model to obtain a simulated query statement comprises: Classifying the knowledge base documents according to the user roles to obtain sub-knowledge base documents; The sub-knowledge base document and the corresponding prompt are input into the large language model to obtain the simulated query statement.
4. The retrieval enhancement method based on a large model as claimed in claim 3, characterized in that: Before the step of classifying the knowledge base documents according to the user roles to obtain sub-knowledge base documents, the step further includes: Determine the user role and the query scenario corresponding to the user role according to the knowledge base document; The prompt is generated according to the user role and the query scenario.
5. The retrieval enhancement method based on a large model as claimed in claim 1, characterized in that: After the step of inputting the preset user role, prompt and knowledge base document into the large language model to obtain the simulated query statement, the following step is further included: Performing a repeatability test on each of the simulated query statements to obtain a similarity; If the similarity is greater than a preset similarity threshold, the corresponding simulated query statement is confirmed to be a duplicate statement, and the duplicate statement is removed.
6. The retrieval enhancement method based on a large model as claimed in claim 1, characterized in that: The step of matching the target query text with the target knowledge base document to obtain the target query result comprises: Convert the target query text and the target knowledge base document into vector representations to obtain a query statement vector and a knowledge document vector; Obtaining the similarity between the query statement vector and the knowledge document vector; If the similarity is greater than a preset similarity threshold, the target query result is generated according to the knowledge document content corresponding to the knowledge document vector.
7. The retrieval enhancement method based on a large model as claimed in claim 6, characterized in that: The step of obtaining the similarity between the query sentence vector and the knowledge document vector comprises: Obtaining the Euclidean distance between the query statement vector and the knowledge document vector; The Euclidean distance is nonlinearly mapped to obtain the similarity.
8. The retrieval enhancement method based on a large model as claimed in claim 6, characterized in that: The step of generating the target query result according to the knowledge document content corresponding to the knowledge document vector comprises: Acquire at least one query result obtained by matching the target query text with the target knowledge base document; Determining the association weights between the target query text and the corresponding query results; The query result with the highest association weight is used as the target query result.
9. A retrieval enhancement device based on a large model, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the large model-based retrieval enhancement method according to any one of claims 1 to 8.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the large model-based retrieval enhancement method as described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Knowledge question-answering method and device, equipment and storage medium
CN116737908A
Cited By
Method and device for updating vector knowledge base
CN120235138A
Personalized document retrieval method and device, equipment and storage medium
CN120316249A
Retrieval method and device for protecting sensitive words of user, storage medium and program product
CN120408719A
Training method of retrieval enhancement model, voice interaction method, server and medium
CN120783774A
Knowledge question-answering system based on intelligent agent
CN121029951A