Information retrieval method and device, electronic equipment and computer readable storage medium
By extracting and matching user prompt information outlines and selecting relevant knowledge texts and generating system prompt texts, the problem of inaccurate answers in the knowledge management scenario is solved, and efficient and accurate information retrieval and answer generation are achieved.
Patent Information
- Application Number
- CN202510222229.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-07-25
AI Technical Summary
In complex knowledge management scenarios, the existing technology cannot accurately select the correct text from the knowledge base, resulting in the inability to generate accurate answers.
By obtaining user prompt information for summary extraction, determining user intention labels, and filtering the target text in the knowledge text library based on the intention labels and profile information, generating system prompt text and target knowledge text are spliced and entered into a large language model to generate high-quality answers.
It improves the accuracy and efficiency of information retrieval, generates more accurate and adaptable answers to actual needs, and solves the problem of inaccurate text selection in the knowledge base.
Smart Images

Figure CN120371997A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of natural language processing technologies, and in particular, to an information retrieval method, apparatus, electronic device, and computer-readable storage medium. Background Art
[0002] Retrieval-Augmented Generation (RAG) is an artificial intelligence technology that combines information retrieval technology and language generation models. It first retrieves knowledge through a user's question, and then incorporates the retrieved knowledge as context into the prompt words of a large language model to obtain a better answer effect. Currently, RAG mainly focuses on technical optimization to improve the relevance between the retrieved knowledge and the user's question. However, in the case of a complex and diverse knowledge base, where there are differences in the same type of text (such as management systems) for different management objects, when multiple texts with similar semantics are retrieved from the knowledge base through a user's question, the large language model will experience knowledge confusion when using them to answer, resulting in an inability to obtain the correct answer to the user's question. Summary of the Invention
[0003] In view of this, embodiments of the present disclosure provide an information retrieval method, apparatus, electronic device, and computer-readable storage medium to solve the problem in the prior art of being unable to generate an accurate answer due to the inability to accurately select the correct text from the knowledge base in a complex knowledge management scenario.
[0004] In a first aspect of embodiments of the present disclosure, an information retrieval method is provided, including:
[0005] Obtain user prompt information, perform summary extraction on the user prompt information to obtain user prompt summary information corresponding to the user prompt information;
[0006] Perform label matching on the user prompt information to determine user intention labels corresponding to the user prompt information from various preset labels;
[0007] Based on the user intention labels and the user prompt summary information, screen each knowledge text in the knowledge text library to obtain target knowledge texts;
[0008] Generate a system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain a target prompt text, and input the target prompt text into a large language model to obtain a target answer corresponding to the user prompt information.
[0009] In a second aspect of embodiments of the present disclosure, an information retrieval apparatus is provided, including:
[0010] The summary extraction module is configured to obtain user prompt information, extract a summary of the user prompt information, and obtain a user prompt summary corresponding to the user prompt information;
[0011] The label matching module is configured to perform label matching on the user prompt information and determine a user intention label corresponding to the user prompt information from various preset labels;
[0012] The screening module is configured to screen each knowledge text in the knowledge text library based on the user intention label and the user prompt summary information to obtain a target knowledge text;
[0013] The answer generation module is configured to generate a system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain a target prompt text, and input the target prompt text into a large language model to obtain a target answer corresponding to the user prompt information.
[0014] In a third aspect of the embodiments of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above method are implemented.
[0015] In a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0016] The beneficial effects of the embodiments of the present disclosure compared with the prior art are as follows: By obtaining user prompt information, extracting a summary of the user prompt information, the user prompt summary information corresponding to the user prompt information is obtained, and the core points and the main intention of the user are refined from the detailed information provided by the user. At the same time, according to the user prompt information, the user intention label corresponding to the user prompt information is determined from each preset label, providing guidance for the subsequent screening of knowledge texts. Based on the user intention label and the user prompt summary information, each knowledge text in the knowledge text library is screened, and the most relevant document or fragment, that is, the target knowledge text, is selected from the knowledge text library, reducing the number of irrelevant texts, solving the problem of inaccurate retrieval caused by the complex content of the knowledge text library, and increasing the possibility of finding the correct answer. A system prompt text is generated, and the system prompt text, the target knowledge text, and the user prompt information are concatenated to obtain a target prompt text, and the target prompt text is input into a large language model. Utilizing the powerful language generation ability of the large language model, the existing information resources are maximally utilized to generate a high-quality answer, that is, the target answer corresponding to the user prompt information. Through precise intention understanding, efficient knowledge text screening, and the application of a large language model, the present disclosure effectively solves the problem in the prior art that accurate answers cannot be generated due to the inability to accurately select the correct text from the knowledge base in complex knowledge management scenarios, improves the accuracy and efficiency of information retrieval, and significantly enhances the quality of information retrieval and answer generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present disclosure. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to these drawings.
[0018] Figure 1 is a schematic diagram of the application scenario of the embodiments of the present disclosure;
[0019] Figure 2 is a schematic flowchart of an information retrieval method provided by the embodiments of the present disclosure;
[0020] Figure 3 is a schematic structural diagram of an information retrieval model provided by the embodiments of the present disclosure;
[0021] Figure 4 is a schematic structural diagram of an information retrieval device provided by the embodiments of the present disclosure;
[0022] Figure 5 is a schematic structural diagram of an electronic device provided by the embodiments of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0023] In the following description, specific details such as specific system architectures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present disclosure. However, those skilled in the art should understand that the present disclosure can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from obscuring the description of the present disclosure.
[0024] It should be noted that the user information (including but not limited to terminal device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in the present disclosure are all information and data that have been authorized by the user or fully authorized by all parties.
[0025] A method and apparatus for information retrieval according to an embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0026] Figure 1 It is a schematic diagram of an application scenario of an embodiment of the present disclosure. The application scenario may include terminal devices 1, 2, and 3, a server 4, and a network 5.
[0027] The terminal devices 1, 2, and 3 may be hardware or software. When the terminal devices 1, 2, and 3 are hardware, they may be various electronic devices with a display screen and supporting communication with the server 4, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.; when the terminal devices 1, 2, and 3 are software, they may be installed in the above-mentioned electronic devices. The terminal devices 1, 2, and 3 may be implemented as multiple software or software modules, or may also be implemented as a single software or software module, and the embodiments of the present disclosure do not limit this. Further, various applications may be installed on the terminal devices 1, 2, and 3, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0028] The server 4 may be a server providing various services. For example, it may be a background server that receives requests sent by terminal devices with which it establishes a communication connection. The background server may receive and analyze such requests sent by terminal devices and generate a processing result. The server 4 may be a single server, or may be a server cluster composed of several servers, or may also be a cloud computing service center, and the embodiments of the present disclosure do not limit this.
[0029] It should be noted that the server 4 can be hardware or software. When the server 4 is hardware, it can be various electronic devices that provide various services for the terminal devices 1, 2, and 3. When the server 4 is software, it can be multiple software or software modules that provide various services for the terminal devices 1, 2, and 3, or it can be a single software or software module that provides various services for the terminal devices 1, 2, and 3. The embodiments of the present disclosure do not limit this.
[0030] The network 5 can be a wired network connected by coaxial cables, twisted pairs, and optical fibers, or it can be a wireless network that can interconnect various communication devices without wiring. For example, Bluetooth, Near Field Communication (NFC), Infrared, etc. The embodiments of the present disclosure do not limit this.
[0031] The user can establish a communication connection with the server 4 via the network 5 through the terminal devices 1, 2, and 3 to receive or send information, etc. Specifically, obtain the user prompt information, perform a summary extraction on the user prompt information to obtain the user prompt summary information corresponding to the user prompt information; perform a label matching on the user prompt information to determine the user intention label corresponding to the user prompt information from each preset label; screen each knowledge text in the knowledge text library based on the user intention label and the user prompt summary information to obtain the target knowledge text; generate a system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain the target prompt text, and input the target prompt text into the large language model to obtain the target answer corresponding to the user prompt information.
[0032] It should be noted that the specific types, quantities, and combinations of the terminal devices 1, 2, and 3, the server 4, and the network 5 can be adjusted according to the actual needs of the application scenario. The embodiments of the present disclosure do not limit this.
[0033] Next, a method and device for information retrieval according to an embodiment of the present disclosure will be described in detail with reference to the accompanying drawings.
[0034] Figure 2 is a schematic flowchart of a method for information retrieval provided by an embodiment of the present disclosure. Figure 1 The information retrieval method can be executed by a terminal device or a server. As Figure 2 shown, this terminal device or server method includes:
[0035] Step 201, obtain the user prompt information, and perform a summary extraction on the user prompt information to obtain the user prompt summary information corresponding to the user prompt information.
[0036] Specifically, the user prompt information is the specific questions or requests input by the user through the interaction interface, which can be directly input text, text transcribed from voice, text generated by image conversion, or text formed by fusing multiple inputs from the user. By obtaining the user prompt information, the specific needs of the user are received, providing basic data for subsequent processing.
[0037] The user prompt information is analyzed in depth, and the core problem is extracted from the detailed information provided by the user. After summary extraction, a more concise and core-content focused user prompt summary information is generated. The user prompt summary information not only retains the main intention of the user's original input but also removes unnecessary details and redundancies. For example, the user prompt information can be "Inquire about the attendance management method for commercial shipping employees", and the user prompt summary information obtained after summary extraction is "Attendance management method". By extracting the summary information, the actual needs and intentions of the user can be understood faster and more clearly. On the one hand, it reduces unnecessary consumption of computing resources, and on the other hand, it removes redundant information and focuses more on the core topic. The user prompt summary information helps to more accurately match relevant knowledge texts in the subsequent process.
[0038] Step 202: Perform tag matching on the user prompt information to determine the user intention tag corresponding to the user prompt information from each preset tag.
[0039] In some embodiments, the preset tags are a predefined set of tags, and each tag represents a specific theme or category. For example, the preset tags can be "Recruitment process", "Employee training", "Performance evaluation", etc. At the same time, the preset tags are also the tags of each knowledge text in the knowledge text library, and the tags are stored in the knowledge text library in the form of metadata along with the knowledge texts. The user intention tag is the tag that can represent the user's query intention determined after tag matching. The user prompt information is matched with each preset tag to determine one or more user intention tags corresponding to the user prompt information from each preset tag. Through tag matching, the user's intention can be understood more accurately, which helps to select the most relevant text from the knowledge text library in the subsequent process, reduces misjudgment and missed judgment, and improves the accuracy of the answer. On the other hand, by determining the user intention tag corresponding to the user prompt information, the screening process of the text in the knowledge base can be accelerated, reducing unnecessary text search and comparison time, which helps to quickly generate answers and improve the overall information retrieval efficiency.
[0040] Step 203: Screen each knowledge text in the knowledge text library based on the user intention tag and the user prompt summary information to obtain the target knowledge text.
[0041] In some embodiments, the user intention tag is a tag that can represent the user's query intention determined after tag matching. The user prompt summary information is the core point or main intention extracted from the user prompt information, and is a short but information text fragment focused on the core needs. The knowledge text library is a database of knowledge resources containing a large number of knowledge texts and feature vectors of knowledge texts. In the knowledge text library, there are a large number of knowledge texts with similar semantics. For example, in the case where the knowledge text library is a complex enterprise knowledge management database, there are documents with similar semantics in the enterprise knowledge management database. For example, under the human resource management knowledge base, there may be two systems of documents for regular employees and dispatched employees for attendance management. Filter the knowledge texts in the knowledge text library according to the user intention tag, and retain those knowledge texts with the user intention tag. Then, natural language processing technology can be used to compare the user prompt summary information with the knowledge texts with the user intention tag to find the matching knowledge texts, screen out the knowledge texts most relevant to the user prompt information, and finally the filtered knowledge texts contain the key information that can directly answer the user's question and are more in line with the user's intention, that is, the target knowledge texts.
[0042] When there are multiple similar documents for different business departments or roles in the knowledge base text, it is easy to have the phenomenon of knowledge confusion. For example, the same term may have different meanings in different departments, or there may be two system documents for regular employees and dispatched employees for attendance management under the human resource management knowledge base. By combining the user intention tag and the user prompt summary information, the specific documents applicable to the user can be more accurately identified. For example, if the user's question involves the attendance management of regular employees, the relevant documents of dispatched employees can be excluded. By combining the user intention tag and the user prompt summary information, the content that the user really cares about can be more accurately located, the interference of irrelevant knowledge texts can be reduced, the target knowledge texts containing the key information that can directly answer the user's question can be obtained, and the retrieval accuracy can be improved. The filtered target knowledge texts are highly relevant to the user's question (user prompt information), so the target answers corresponding to the user prompt information generated by finally referring to the target knowledge texts are also more accurate and reliable.
[0043] Step 204, generate a system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain a target prompt text, and input the target prompt text into the large language model to obtain the target answer corresponding to the user prompt information.
[0044] In some embodiments, the system prompt text is a piece of guiding instructions or background information used to guide the large language model to understand the requirements and context of the current task, and may include information such as task descriptions, expected output formats, etc. The above system prompt text, target knowledge text, and user prompt information are concatenated and combined in a certain order and format to obtain a complete prompt text, that is, the target prompt text. The target prompt text combines specific user needs, relevant knowledge, and clear task guidance, providing a structured and comprehensive input, enhancing the relevance and accuracy of the answer, and enabling the large language model to generate more accurate answers based on a full understanding of the context. The concatenated target prompt text is used as input and passed to the large language model. Utilizing the powerful language generation ability of the large language model, based on rich context information, a high-quality answer is generated, generating the target answer corresponding to the user prompt information that is both accurate and meets the actual needs. By concatenating the system prompt text, target knowledge text, and user prompt information and inputting them into the large language model for reasoning, the problem of being unable to generate accurate answers due to the inability to accurately select text in the knowledge base in complex knowledge management scenarios can be effectively solved, optimizing the knowledge selection strategy, improving the accuracy of the answer, and obtaining the target answer corresponding to the high-quality user prompt information. The above large language model is a large language model that supports streaming output, such as Chat Generative Pre-trained Transformer (ChatGPT).
[0045] Based on the information retrieval method provided by the present disclosure, by obtaining user prompt information, extracting a summary of the user prompt information to obtain user prompt summary information corresponding to the user prompt information, and refining the core points and the main intention of the user from the detailed information provided by the user. At the same time, determine the user intention label corresponding to the user prompt information from each preset label according to the user prompt information, providing guidance for subsequent knowledge text screening. Screen each knowledge text in the knowledge text library based on the user intention label and the user prompt summary information, select the most relevant document or fragment from the knowledge text library, that is, the target knowledge text, reduce the number of irrelevant texts, solve the problem of inaccurate retrieval caused by the complex content of the knowledge text library, and increase the possibility of finding the correct answer. Generate a system prompt text, splice the system prompt text, the target knowledge text and the user prompt information to obtain a target prompt text, and input the target prompt text into a large language model. Utilize the powerful language generation ability of the large language model to maximize the use of existing information resources and generate a high-quality answer, that is, the target answer corresponding to the user prompt information. The present disclosure effectively solves the problem in the prior art that it is impossible to generate an accurate answer due to the inability to accurately select the correct text from the knowledge base in a complex knowledge management scenario through precise intention understanding, efficient knowledge text screening and the application of the large language model, improves the accuracy and efficiency of information retrieval, and significantly enhances the quality of information retrieval and answer generation.
[0046] In some embodiments, screening each knowledge text in the knowledge text library based on the user intention label and the user prompt summary information to obtain the target knowledge text includes:
[0047] Obtain the text label corresponding to each knowledge text in the knowledge text library and the feature vector of each knowledge text;
[0048] Traverse the text labels corresponding to each knowledge text in the knowledge text library to determine at least one candidate knowledge text that matches the user intention label;
[0049] Perform feature embedding on the user prompt summary information to obtain the feature vector of the user prompt summary information;
[0050] According to the feature vector of at least one candidate knowledge text and the feature vector of the user prompt summary information, determine the semantic matching score between each candidate knowledge text and the user prompt summary information;
[0051] According to the semantic matching scores corresponding to each candidate knowledge text, screen the target knowledge text from at least one candidate knowledge text.
[0052] Specifically, each knowledge text and its corresponding feature vector are maintained in the knowledge text library. The text labels corresponding to each knowledge text are stored in the knowledge text library along with the knowledge text in the form of metadata. Obtaining the text labels and feature vectors of each knowledge text in the knowledge text library, the text labels can be used to quickly identify the theme or category of each knowledge text, while the feature vectors of the knowledge texts can be used to represent the semantic content of the knowledge texts, facilitating subsequent semantic matching.
[0053] Furthermore, by traversing the knowledge text library and comparing the user intention labels with the text labels of each knowledge text, a set of candidate knowledge texts relevant to the user's needs can be quickly screened out. Through label matching, a large number of irrelevant knowledge texts can be quickly excluded, narrowing the scope of subsequent processing and improving the retrieval efficiency. A pre-trained language model can be used to perform feature embedding on the user prompt summary information, capture the deep semantic information of the user prompt summary information, convert the user prompt summary information into a feature vector, and obtain the feature vector of the user prompt summary information. By mapping the user prompt summary information to the same vector space as the feature vectors of the knowledge texts, it is convenient for subsequent similarity calculation. The pre-trained language model can be a pre-trained language model based on the transformer architecture (BERT, Bidirectional Encoder Representations from Transformers), a robustly optimized BERT model (Robustly Optimized BERT approach, RoBERTa), etc. Cosine similarity, dot product, etc. can be used to calculate the semantic matching scores between the feature vectors of each candidate knowledge text and the feature vector of the user prompt summary information, and obtain the semantic matching scores corresponding to each candidate knowledge text. The semantic matching scores corresponding to the candidate knowledge texts can quantify the semantic matching degree between the candidate knowledge texts and the user prompt summary information, providing a basis for subsequent screening. Finally, according to the high and low of the semantic matching scores corresponding to each candidate knowledge text, the candidate knowledge text that best matches the user prompt summary information is selected as the target knowledge text, ensuring that the finally selected knowledge text is highly relevant to the user's needs. First, perform a preliminary screening through text labels, and then perform a refined screening through semantic matching, which can more accurately select the text relevant to the user's needs from the knowledge text library, avoid the problem of being unable to generate accurate answers due to the inability to accurately select the correct text from the knowledge base, improve the accuracy of screening, and maintain the efficiency of processing.
[0054] In some embodiments, obtaining the text labels and feature vectors of each knowledge text in the knowledge text library includes:
[0055] Perform chunking processing on the knowledge text library to obtain multiple knowledge texts;
[0056] Perform feature embedding on each knowledge text to obtain the feature vectors of each knowledge text;
[0057] Perform label matching on each knowledge text to determine the text label corresponding to each knowledge text from each preset label.
[0058] Specifically, perform chunking on the knowledge text library, splitting the large knowledge text library into smaller, more manageable and analyzable knowledge texts. Each knowledge text can be a paragraph, a chapter or an independent article. The above chunking method can be to use natural language processing technology to identify natural breakpoints in the knowledge text library, such as paragraph boundaries, headings, etc., with paragraph boundaries and headings as the splitting basis, or to use a topic model to identify different topics in the knowledge text library and split according to topic boundaries to obtain individual knowledge texts. The topic model can be a Latent Dirichlet Allocation (LDA) model. Through chunking, the content of the knowledge text library can be processed and analyzed at a finer granularity, which helps to locate relevant parts more quickly in the subsequent process.
[0059] Furthermore, input each knowledge text into a pre-trained model to convert each knowledge text into a high-dimensional vector representation, obtaining the feature vectors of each knowledge text. The pre-trained model has been trained on a large-scale corpus and can capture the semantic information of the text well. The pre-trained model can be BERT, RoBERTa, DistilBERT, a distilled version of the BERT model, etc. By feature embedding, the deep semantic information of each knowledge text is captured, enabling subsequent comparison and matching at the semantic level when performing target knowledge text matching, rather than just based on surface lexical matching. Each preset label is a label that is preset to cover the main topics or categories of the knowledge text library. For example, in the case of an enterprise internal knowledge management document as the knowledge text library, the preset labels may include "recruitment process", "employee training", "performance evaluation", "benefits", "attendance management", etc. The knowledge text and each preset label can be input into a large language model, and the large language model performs label matching on each knowledge text to determine one or more labels most suitable for each knowledge text, generating the text label corresponding to each knowledge text. The present disclosure does not limit the number of text labels corresponding to each knowledge text.
[0060] Through chunking, feature embedding and label matching, corresponding semantic representations (feature vectors) and structured metadata (text labels) are generated for each knowledge text in the knowledge text library. The feature vectors of each knowledge text and the text labels corresponding to each knowledge text will be used for subsequent information retrieval and screening to ensure that the correct target knowledge text can be accurately selected from the knowledge text library, thereby generating an accurate answer.
[0061] In some embodiments, label matching is performed on the user prompt information, and the user intent label corresponding to the user prompt information is determined from each preset label, including:
[0062] The user prompt information and each preset label are input into a large language model to perform label matching on the user prompt information and generate the user intent label corresponding to the user prompt information.
[0063] Specifically, a prompt word, the user prompt information, and a preset set of labels (each preset label) are used as inputs and passed to the large language model. Based on its trained data and understanding ability, the large language model analyzes the user prompt information, compares it with each preset label, and outputs the label that matches the user's query intent, that is, the user intent label corresponding to the user prompt information. The user intent label is output in a structured format, where the structured format is in the form of a lightweight data interchange (JavaScript Object Notation, JSON) list. If no intent label can be recognized from the limited range (each preset label) according to the user prompt information, an empty list is output.
[0064] By inputting the user prompt information and each preset label into the large language model for label matching, and utilizing the semantic understanding and context analysis capabilities of the large language model, one or more preset labels that best match the user prompt information are determined, achieving more accurate label matching.
[0065] In some embodiments, abstract extraction is performed on the user prompt information to obtain the user prompt summary information corresponding to the user prompt information, including:
[0066] The user prompt information is input into the large language model to summarize the user prompt information and obtain the user prompt summary information corresponding to the user prompt information.
[0067] Specifically, abstract extraction is to extract the core content or main idea from a relatively long text (in this application, it is the user prompt information) to obtain a shorter and more refined form of expression of the longer text. A prompt word and the user prompt information are input into the large language model for abstract extraction. By utilizing the semantic understanding and information extraction capabilities of the large language model, key information or important details are extracted from the user prompt information, and the user prompt information is deeply analyzed and processed, thereby generating a concise, clear, and accurate user prompt summary information that can reflect the core of the user prompt information. The user prompt information contains a large amount of details and redundant information. Directly processing the user prompt information not only consumes a large amount of computing resources but also affects the accuracy of subsequent tasks. By performing abstract extraction on the user prompt information through the large language model, the key content of the user prompt information can be quickly extracted, providing more valuable information input for subsequent knowledge text retrieval and helping to more accurately match relevant knowledge texts in the future.
[0068] In some embodiments, determining a semantic matching score between each candidate knowledge text and the user prompt summary information according to the feature vectors of at least one candidate knowledge text and the feature vector of the user prompt summary information includes:
[0069] Calculating the similarity between the feature vector of each candidate knowledge text and the feature vector of the user prompt summary information to obtain the corresponding similarity score for each candidate knowledge text, and determining the corresponding similarity score for each candidate knowledge text as the semantic matching score for each candidate knowledge text;
[0070] Or,
[0071] Performing a concatenation process on the feature vector of each candidate knowledge text and the feature vector of the user prompt summary information respectively to obtain each fused feature vector; inputting each fused feature vector into a multi-layer perceptron, and performing a non-linear transformation on each fused feature vector to enable semantic matching probability prediction for each candidate knowledge text, so as to obtain the semantic matching score corresponding to each candidate knowledge text.
[0072] In some embodiments, a similarity measurement method can be used to calculate the similarity between the feature vector of each candidate knowledge text and the feature vector of the user prompt summary information to obtain the corresponding similarity score for each candidate knowledge text. The higher the similarity score, the more semantically matched the candidate knowledge text is with the user prompt summary information, and the calculated similarity score is directly used as the semantic matching score of the candidate knowledge text. The similarity measurement method can be cosine similarity, dot product, Euclidean distance, etc.
[0073] In addition, the feature vector of each candidate knowledge text can be concatenated with the feature vector of the user prompt summary information respectively to obtain each fused feature vector, and the fused feature vector is input into a pre-trained multi-layer perceptron (MLP). The MLP contains multiple hidden layers and can learn complex non-linear relationships. The MLP outputs a probability value between 0 and 1, and the output probability value can represent the probability that there is a semantic match between the candidate knowledge text and the user prompt summary information. The above probability value is the semantic matching score corresponding to the candidate knowledge text.
[0074] When there are multiple similar knowledge texts in the knowledge text library but targeting different objects, knowledge confusion may occur, resulting in inaccurate generated answers because the correct text cannot be accurately selected. By calculating the semantic matching scores and based on the sorting mechanism of the semantic matching scores, the knowledge text that better conforms to the user's specific query intention can be determined according to the feature vector of the user's prompt summary information, enhancing the user experience and more accurately identifying the target knowledge text that best matches the user's prompt summary information, thus solving the problem of inaccurate generated answers caused by the inability to accurately select the correct text.
[0075] In some embodiments, obtaining user prompt information includes:
[0076] Obtaining the current prompt information and historical prompt information input by the user, and generating user prompt information based on the current prompt information and the historical prompt information.
[0077] Specifically, the current prompt information can be obtained through a front-end interface (such as a web form, a mobile application interface) or an interaction device (such as a microphone, a touch screen). The current prompt information is the direct input provided by the user in the current session or operation, and can be data in the form of text, voice, or others. The current prompt information can provide the most direct expression of the user's needs and reflect the user's current concerns or needs. The historical prompt information is a set of information of all relevant questions or requests provided by the user in past interactions, and the historical prompt information can come from the same session or multiple sessions.
[0078] Combining the current prompt information with the historical prompt information to obtain a data set containing all relevant information. The natural language processing technology can be used to analyze the combined data set, identify key topics, intentions, and logical relationships. Based on the analysis results, the core points that best represent the user's true needs are refined to generate user prompt information. By combining the current prompt information and the historical prompt information, a user prompt information that more completely and accurately represents the user's intention can be generated.
[0079] In some embodiments, the present disclosure also provides an information retrieval model. Refer to Figure 3, The information retrieval model includes: a large language model 301, a retrieval module 302, and a splicing module 303. Obtain the user prompt information, input the user prompt information into the large language model 301 to perform a summary of the user prompt information, and obtain the user prompt summary information corresponding to the user prompt information. Input the user prompt information and each preset tag into the large language model 301 to perform tag matching on the user prompt information and generate the user intention tag corresponding to the user prompt information. Input the user prompt summary information, the user prompt summary information, and each knowledge text in the knowledge text library into the retrieval module 302, and screen each knowledge text in the knowledge text library based on the user intention tag and the user prompt summary information to obtain the target knowledge text. Generate a system prompt text, and input the system prompt text, the target knowledge text, and the user prompt information into the splicing module 303 for splicing to obtain the target prompt text, and input the target prompt text into the large language model to obtain the target answer corresponding to the user prompt information. Through the information retrieval model provided by the present disclosure, accurate intention understanding, efficient knowledge text screening, and the application of the large language model are carried out, effectively solving the problem in the prior art that accurate answers cannot be generated due to the inability to accurately select the correct text from the knowledge base in complex knowledge management scenarios, improving the accuracy and efficiency of information retrieval, and significantly improving the quality of information retrieval and answer generation.
[0080] All of the above optional technical solutions can be combined arbitrarily to form optional embodiments of the present disclosure, which will not be elaborated herein one by one.
[0081] The following is an embodiment of the device of the present disclosure, which can be used to execute the embodiment of the method of the present disclosure. For the details not disclosed in the embodiment of the device of the present disclosure, please refer to the embodiment of the method of the present disclosure.
[0082] Figure 4 is a schematic diagram of an information retrieval device provided by an embodiment of the present disclosure. As Figure 4 shown, the information retrieval device includes:
[0083] A summary extraction module 401, configured to obtain user prompt information, perform summary extraction on the user prompt information, and obtain the user prompt summary information corresponding to the user prompt information;
[0084] A tag matching module 402, configured to perform tag matching on the user prompt information and determine the user intention tag corresponding to the user prompt information from each preset tag;
[0085] A screening module 403, configured to screen each knowledge text in the knowledge text library based on the user intention tag and the user prompt summary information to obtain the target knowledge text;
[0086] The answer generation module 404 is configured to generate system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain the target prompt text, and input the target prompt text into the large language model to obtain the target answer corresponding to the user prompt information.
[0087] According to the technical solution provided by the embodiments of the present disclosure, by obtaining the user prompt information, extracting the summary of the user prompt information to obtain the user prompt summary information corresponding to the user prompt information, and refining the core points and the main intention of the user from the detailed information provided by the user. At the same time, determine the user intention label corresponding to the user prompt information from each preset label according to the user prompt information, providing guidance for the subsequent screening of knowledge texts. Based on the user intention label and the user prompt summary information, screen each knowledge text in the knowledge text library, and select the most relevant document or fragment from the knowledge text library, that is, the target knowledge text, reducing the number of irrelevant texts, solving the problem of inaccurate retrieval caused by the complex content of the knowledge text library, and increasing the possibility of finding the correct answer. Generate system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain the target prompt text, and input the target prompt text into the large language model. Utilize the powerful language generation ability of the large language model to maximize the utilization of existing information resources and generate high-quality answers, that is, the target answers corresponding to the user prompt information. The present disclosure effectively solves the problem in the prior art that accurate answers cannot be generated due to the inability to accurately select the correct text from the knowledge base in complex knowledge management scenarios through precise intention understanding, efficient knowledge text screening, and the application of large language models, improving the accuracy and efficiency of information retrieval and significantly enhancing the quality of information retrieval and answer generation.
[0088] In some embodiments, the screening module 403 is configured to obtain the text labels and the feature vectors of each knowledge text in the knowledge text library; traverse the text labels corresponding to each knowledge text in the knowledge text library to determine at least one candidate knowledge text that matches the user intention label; perform feature embedding on the user prompt summary information to obtain the feature vector of the user prompt summary information; determine the semantic matching scores between each candidate knowledge text and the user prompt summary information according to the feature vectors of at least one candidate knowledge text and the feature vector of the user prompt summary information; and screen the target knowledge text from at least one candidate knowledge text according to the semantic matching scores corresponding to each candidate knowledge text.
[0089] In some embodiments, the screening module 403 is configured to perform chunking processing on the knowledge text library to obtain multiple knowledge texts; perform feature embedding on each knowledge text to obtain the feature vector of each knowledge text; and perform label matching on each knowledge text to determine the text label corresponding to each knowledge text from each preset label.
[0090] In some embodiments, the label matching module 402 is configured to input the user prompt information and each preset label into a large language model to perform label matching on the user prompt information and generate user intention labels corresponding to the user prompt information.
[0091] In some embodiments, the summary extraction module 401 is configured to input the user prompt information into a large language model to perform a summary of the user prompt information and obtain user prompt summary information corresponding to the user prompt information.
[0092] In some embodiments, the screening module 403 is configured to calculate the similarity between the feature vectors of each candidate knowledge text and the feature vector of the user prompt summary information, obtain the similarity scores corresponding to each candidate knowledge text, and determine the similarity scores corresponding to each candidate knowledge text as the semantic matching scores corresponding to each candidate knowledge text.
[0093] In some embodiments, the screening module 403 is configured to perform splicing processing on the feature vectors of each candidate knowledge text and the feature vector of the user prompt summary information respectively to obtain each fused feature vector; input each fused feature vector into a multi-layer perceptron to perform non-linear transformation on each fused feature vector, so as to predict the semantic matching probability of each candidate knowledge text and obtain the semantic matching scores corresponding to each candidate knowledge text.
[0094] In some embodiments, the summary extraction module 401 is configured to obtain the current prompt information and historical prompt information input by the user, and generate user prompt information according to the current prompt information and historical prompt information.
[0095] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present disclosure.
[0096] Figure 5 is a schematic diagram of the electronic device 500 provided by the embodiments of the present disclosure. As Figure 5 shown, the electronic device 500 of this embodiment includes: a processor 501, a memory 502, and a computer program 503 stored in the memory 502 and executable on the processor 501. When the processor 501 executes the computer program 503, the steps in the above method embodiments are implemented. Alternatively, when the processor 501 executes the computer program 503, the functions of each module / unit in the above device embodiments are implemented.
[0097] The electronic device 500 can be an electronic device such as a desktop computer, a notebook, a handheld computer, and a cloud server. The electronic device 500 can include, but is not limited to, a processor 501 and a memory 502. Those skilled in the art can understand that Figure 5 merely examples of the electronic device 500, which do not constitute a limitation on the electronic device 500, may include more or fewer components than those shown in the figure, or different components.
[0098] The processor 501 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0099] The memory 502 can be an internal storage unit of the electronic device 500. For example, the hard disk or memory of the electronic device 500. The memory 502 can also be an external storage device of the electronic device 500. For example, a plug-in hard disk equipped on the electronic device 500, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The memory 502 can also include both an internal storage unit and an external storage device of the electronic device 500. The memory 502 is used to store computer programs and other programs and data required by the electronic device.
[0100] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0101] When an integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of the present disclosure, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in the readable storage medium. When the computer program is executed by a processor, the steps of the above-described various method embodiments can be implemented. The computer program can include computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice within the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0102] The above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them; although the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of the present disclosure, and should all be included within the protection scope of the present disclosure.
Claims
1. An information retrieval method, characterized in that, Including: Obtain user prompt information, extract a summary of the user prompt information to obtain user prompt summary information corresponding to the user prompt information; Perform label matching on the user prompt information to determine a user intention label corresponding to the user prompt information from various preset labels; Based on the user intention label and the user prompt summary information, screen each knowledge text in the knowledge text library to obtain a target knowledge text; Generate a system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain a target prompt text, and input the target prompt text into a large language model to obtain a target answer corresponding to the user prompt information.
2. The method according to claim 1, characterized in that The screening of each knowledge text in the knowledge text library based on the user intention label and the user prompt summary information to obtain a target knowledge text includes: Obtain text labels corresponding to each knowledge text in the knowledge text library and feature vectors of each knowledge text; Traverse the text labels corresponding to each knowledge text in the knowledge text library to determine at least one candidate knowledge text that matches the user intention label; Perform feature embedding on the user prompt summary information to obtain a feature vector of the user prompt summary information; According to the feature vectors of at least one candidate knowledge text and the feature vector of the user prompt summary information, determine the semantic matching scores between each candidate knowledge text and the user prompt summary information; According to the semantic matching scores corresponding to each candidate knowledge text, screen the target knowledge text from the at least one candidate knowledge text.
3. The method according to claim 2, wherein The obtaining of text labels corresponding to each knowledge text in the knowledge text library and feature vectors of each knowledge text includes: Perform chunking processing on the knowledge text library to obtain multiple knowledge texts; Perform feature embedding on each knowledge text to obtain feature vectors of each knowledge text; Perform label matching on each knowledge text to determine a text label corresponding to each knowledge text from various preset labels.
4. The method according to claim 1, characterized in that, The performing of label matching on the user prompt information to determine a user intention label corresponding to the user prompt information from various preset labels includes: Input the user prompt information and the various preset labels into the large language model to perform label matching on the user prompt information and generate the user intention label corresponding to the user prompt information.
5. The method according to claim 1, wherein The extracting of a summary of the user prompt information to obtain user prompt summary information corresponding to the user prompt information includes: Input the user prompt information into the large language model to perform a summary of the user prompt information and obtain the user prompt summary information corresponding to the user prompt information.
6. The method according to claim 2, characterized in that, The determining of the semantic matching scores between each candidate knowledge text and the user prompt summary information according to the feature vectors of at least one candidate knowledge text and the feature vector of the user prompt summary information includes: Calculate the similarity between the feature vectors of each of the candidate knowledge texts and the feature vector of the user prompt summary information, obtain the corresponding similarity scores of each candidate knowledge text, and determine the corresponding semantic matching scores of each candidate knowledge text as the corresponding semantic matching scores of each candidate knowledge text; Or, Perform splicing processing on the feature vectors of each of the candidate knowledge texts and the feature vector of the user prompt summary information respectively to obtain each fused feature vector; input each of the fused feature vectors into a multi-layer perceptron, and perform non-linear transformation on each of the fused feature vectors to enable semantic matching probability prediction for each of the candidate knowledge texts, and obtain the corresponding semantic matching scores of each candidate knowledge text.
7. The method according to claim 1, wherein The obtaining of the user prompt information includes: Obtain the current prompt information and historical prompt information input by the user, and generate user prompt information according to the current prompt information and the historical prompt information.
8. An information retrieval device, characterized in that, Including: A summary extraction module, configured to obtain user prompt information, perform summary extraction on the user prompt information, and obtain the user prompt summary information corresponding to the user prompt information; A label matching module, configured to perform label matching on the user prompt information, and determine the user intention label corresponding to the user prompt information from each preset label; A screening module, configured to screen each knowledge text in the knowledge text library based on the user intention label and the user prompt summary information to obtain a target knowledge text; An answer generation module, configured to generate a system prompt text, splice the system prompt text, the target knowledge text, and the user prompt information to obtain a target prompt text, and input the target prompt text into a large language model to obtain the target answer corresponding to the user prompt information.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 7 are implemented.