Information retrieval method and device, computer equipment and readable storage medium
By building an information retrieval database and using a large model to generate hypothetical feedback and vectorization processing, the problem of inaccurate retrieval results in existing technologies is solved, and higher retrieval accuracy and recall rate are achieved.
Patent Information
- Application Number
- CN202510795925.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-09-16
AI Technical Summary
In existing information retrieval technologies, keyword-based retrieval methods often result in retrieval results containing a large amount of information that is not directly related to user needs. Users need to spend a lot of time to filter out useful information, and lack an in-depth understanding of natural language semantics, resulting in insufficient retrieval accuracy.
By building an information retrieval database, generating hypothetical feedback of retrieval conditions and results, using large models for matching, and adopting vectorized processing to match between retrieval conditions and results, semantic coverage and accuracy are improved.
Improves the accuracy and recall of information retrieval, especially in situations lacking specificity or easily identifiable elements, significantly improving retrieval results.
Smart Images

Figure CN120653813A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information retrieval processing technology, and in particular to an information retrieval method, apparatus, computer equipment and readable storage medium. Background Art
[0002] Information retrieval refers to the process of searching, filtering, and retrieving relevant information from large-scale information resources based on user needs. It involves the automated processing and management of information in various forms, such as text, images, audio, and video, through computer systems. The goal of information retrieval is to enable users to quickly and easily find the information they need by effectively organizing and indexing information resources.
[0003] Keyword-based searches are simple and direct, requiring no complex query statements. This greatly improves search efficiency. However, because the keywords entered by users can be broad or vague, search results often contain a large amount of information that is not directly relevant to the user's needs. This can lead to users spending considerable time and effort filtering through the search results to find truly useful information.
[0004] Therefore, how to improve the accuracy of information retrieval has become a technical problem that needs to be solved urgently in this field. Summary of the Invention
[0005] The purpose of the present invention is to provide an information retrieval method, apparatus, computer equipment and readable storage medium to solve the above-mentioned technical problems in the prior art.
[0006] On the one hand, to achieve the above objectives, the present invention provides an information retrieval method.
[0007] The information retrieval method includes: constructing an information retrieval database, wherein the database includes multiple data; using the data as a first retrieval result, generating a first retrieval condition corresponding to the first retrieval result; receiving a second retrieval condition; generating a second retrieval result corresponding to the second retrieval condition; matching the second retrieval condition with the first retrieval condition to obtain a first matching result; matching the second retrieval result with the first retrieval result to obtain a second matching result; and determining retrieval feedback of the second retrieval condition based on the first matching result and the second matching result.
[0008] Furthermore, the steps of generating a first search condition corresponding to the first search result and generating a second search result corresponding to the second search condition include: presetting a first template and a second template; using a large model, the first template and the first search result to generate multiple first search conditions; using a large model, the second template and the second search condition to generate multiple second search results.
[0009] Furthermore, the steps of matching the second retrieval condition with the first retrieval condition to obtain a first matching result, and matching the second retrieval result with the first retrieval result to obtain a second matching result include: converting the first retrieval condition, the second retrieval condition, the first retrieval result and the second retrieval result into vectors; calculating a first similarity between the vector of the second retrieval condition and the vector of the first retrieval condition; determining a first matching result based on the first similarity; calculating a second similarity between the vector of the second retrieval result and the vector of the first retrieval result; and determining a second matching result based on the second similarity.
[0010] Furthermore, the second search condition is a search word, and when the data is text: the step of converting the first search result into a vector includes: dividing the first search result into blocks to obtain several first result text blocks, and converting each first result text block into a first result vector; the step of generating the first search condition corresponding to the first search result includes: generating several first search conditions corresponding to each first result text block; the step of converting the first search condition into a vector includes: converting each first search condition into a first condition vector; the step of converting the second search condition into a vector includes: converting the second search condition into a second condition vector; the step of converting the second search result into a vector includes: dividing the second search result into blocks to obtain several second result text blocks, and converting each second result text block into a second result vector.
[0011] Furthermore, the step of determining the first matching result based on the first similarity includes: taking the first condition vector whose first similarity satisfies the first similarity condition as a candidate condition vector; the step of determining the second matching result based on the second similarity includes: taking the first result vector whose second similarity satisfies the second similarity condition as a candidate result vector; the step of determining the retrieval feedback of the second retrieval condition based on the first matching result and the second matching result includes: determining the first result text block from the candidate condition vector to obtain the first candidate text block; determining the first result text block from the candidate result vector to obtain the second candidate text block; when the first candidate text block and the second candidate text block belong to the same candidate text block, using the first similarity and the second similarity to calculate the score of the candidate text block; and determining the retrieval feedback of the second retrieval condition based on the score.
[0012] Furthermore, the steps of dividing the first search result into blocks and the steps of dividing the second search result into blocks respectively include: segmenting the text to be divided into blocks to obtain multiple paragraph units; and combining adjacent paragraph units into text blocks according to a preset text block size.
[0013] Furthermore, the first similarity and the second similarity are both cosine distances, and the score of the candidate text block is calculated using the first similarity and the second similarity using the following formula: R=q*W+p*M, wherein R is the score of the candidate text block, p and q are weight coefficients respectively, W is the first similarity, and M is the second similarity; the step of determining the retrieval feedback of the second retrieval condition based on the score includes: taking the candidate text block corresponding to the lowest score as the retrieval feedback.
[0014] On the other hand, to achieve the above object, the present invention provides an information retrieval device.
[0015] The information retrieval device includes: a construction module for constructing an information retrieval database, wherein the database includes multiple data; a first processing module for generating a first retrieval condition corresponding to the first retrieval result using the data as the first retrieval result; a receiving module for receiving a second retrieval condition; a second processing module for generating a second retrieval result corresponding to the second retrieval condition; a first matching module for matching the second retrieval condition with the first retrieval condition to obtain a first matching result; a second matching module for matching the second retrieval result with the first retrieval result to obtain a second matching result; and a determination module for determining the retrieval feedback of the second retrieval condition based on the first matching result and the second matching result.
[0016] On the other hand, to achieve the above objectives, the present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0017] On the other hand, to achieve the above object, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above method when executed by a processor.
[0018] The information retrieval method, apparatus, computer device, and readable storage medium provided by the present invention construct an information retrieval database using the data to be retrieved, then use the data to be retrieved as the first retrieval result to generate a first retrieval condition corresponding to the first retrieval result. When a second retrieval condition for retrieving information in the information retrieval database is received, hypothetical feedback of the second retrieval condition, i.e., the second retrieval result, is first generated. When matching, the retrieval condition is not matched with the retrieval result, but rather matching is performed between the retrieval conditions and between the retrieval results, and finally the retrieval feedback of the second retrieval condition is determined using the matching results in both directions. Through the present invention, compared with the prior art of matching between the retrieval condition and the retrieval result, the retrieval condition and the retrieval result space can be aligned separately, which is beneficial to improving the accuracy of the retrieval, especially when the retrieval lacks specificity or lacks easily identifiable elements. The effect is significant. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present invention. The same reference symbols are used throughout the drawings to represent the same components. In the drawings: Figure 1 A flowchart of the information retrieval method provided in Example 1 of the present invention; Figure 2 A flowchart of the information retrieval method provided in Example 2 of the present invention; Figure 3 A schematic diagram of an information retrieval method provided in Embodiment 2 of the present invention; Figure 4 A schematic diagram of constructing a vector database provided in the second embodiment of the present invention; Figure 5 A schematic diagram of generating a search vector according to the second embodiment of the present invention; Figure 6 A schematic diagram of vector matching provided in the second embodiment of the present invention; Figure 7 A block diagram of an information retrieval device provided in Embodiment 3 of the present invention; Figure 8 This is a hardware structure diagram of the computer device provided in Example 4 of the present invention. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0021] Example 1 The embodiment of the present invention provides an information retrieval method, through which the accuracy of information retrieval can be improved. Specifically, Figure 1 This is a flow chart of the information retrieval method provided in Example 1 of the present invention, such as Figure 1 As shown, the information retrieval method provided by this embodiment includes the following steps S101 to S107.
[0022] Step S101: constructing an information retrieval database.
[0023] The database includes multiple data items. The data may be in different forms such as text, image, audio, or video. The information retrieval method provided in this embodiment is used to retrieve required data from the information retrieval database using a retrieval condition consisting of several retrieval terms.
[0024] For example, in large enterprises or institutions, it is usually necessary to manage a large number of documents and files. An information retrieval database is constructed using these documents and files. The information retrieval method provided by this embodiment can help users quickly find the required content using retrieval conditions, thereby improving work efficiency. In the academic field, an information retrieval database is constructed using data such as academic papers. The information retrieval method provided by this embodiment can help researchers find relevant academic papers and research results using retrieval conditions, thereby helping researchers quickly obtain the required academic resources and promote academic exchanges and research progress. In the field of software development, an information retrieval database is constructed using codes and functions. The information retrieval method provided by this embodiment allows developers to use retrieval conditions to search for the required code snippets and functions, thereby improving development efficiency and code reuse. In the picture / audio / video recommendation scenario, an information retrieval database is constructed using pictures / audio / video. The information retrieval method provided by this embodiment can quickly determine the pictures / audio / video that need to be recommended based on the retrieval conditions.
[0025] Step S102: using the data as a first search result, generating a first search condition corresponding to the first search result.
[0026] In this step, the data in the information retrieval database is used as the search result, and the corresponding search conditions are generated in reverse order. In other words, the search result is used as the answer to generate the potential question of the answer. Optionally, the large model is used to propose search conditions for the search structure to generate search conditions corresponding to the search results. One search condition can be generated for each search result, or multiple search conditions can be generated for each search result, each search condition including several search terms.
[0027] Step S103: Receive the second search condition.
[0028] Specifically, the second search condition is a set of search terms input by the user, and the user intends to find search results from the information retrieval database through the set of search terms.
[0029] Step S104: Generate a second search result corresponding to the second search condition.
[0030] After receiving the search conditions entered by the user, the search results are not directly searched from the information retrieval database using the search conditions. Instead, the search results corresponding to the second search conditions are generated first. That is, the second search conditions are used as a question, and a hypothetical answer to the question is generated through the large model.
[0031] Step S105: Match the second search condition with the first search condition to obtain a first matching result.
[0032] Step S106: Match the second search result with the first search result to obtain a second matching result.
[0033] In steps S105 and S106 , matching is performed between the search conditions and between the search results. Specifically, any matching method in the prior art may be used to find mutually matching search condition pairs and search result pairs.
[0034] Step S107: Determine the search feedback of the second search condition according to the first matching result and the second matching result.
[0035] The first matching result is a match between search conditions, meaning it finds the first search condition that matches the second search condition, and the first search condition is generated from the first search result, meaning it finds the first search result that matches the second search condition. The second matching result is a match between search results, meaning it finds the first search result that matches the second search result, and the second search result is generated from the second search condition, meaning it finds the first search result that matches the second search condition. In summary, the matching results from both directions are combined to ultimately determine the search feedback for the second search condition.
[0036] In the information retrieval method provided in this embodiment, an information retrieval database is constructed using the data to be retrieved, and then the data to be retrieved is used as the first retrieval result to generate a first retrieval condition corresponding to the first retrieval result. When a second retrieval condition for retrieving information in the information retrieval database is received, hypothetical feedback of the second retrieval condition is first generated, that is, the second retrieval result. When matching, the retrieval condition is not matched with the retrieval result, but rather the retrieval conditions and the retrieval results are matched separately, and finally the retrieval feedback of the second retrieval condition is determined using the matching results in both directions. Compared with the prior art of matching between the retrieval condition and the retrieval result, the information retrieval method provided in this embodiment can align the retrieval condition and the retrieval result space separately, which is beneficial to improving the accuracy of the retrieval, especially when the retrieval lacks specificity or lacks easily identifiable elements. The effect is significant.
[0037] Optionally, in one embodiment, the steps of generating a first search condition corresponding to a first search result and generating a second search result corresponding to a second search condition include: presetting a first template and a second template; generating multiple first search conditions using a large model, the first template and the first search result; and generating multiple second search results using the large model, the second template and the second search condition.
[0038] Specifically, in this embodiment, to improve the semantic coverage between the first search condition and the first search result, and to enhance the rationality of the second search result inferred from the second search condition, the system, while invoking the large model, introduces a search template mechanism. This template is a structured prompt that guides the large model in generating more targeted expressions. The first template guides the generation of the first search condition. The first template can adopt the following format: "If the following text represents the answer the user wants to obtain, please write a possible search query." The system uses the first search result as input and, in conjunction with the first template, invokes the large model to generate multiple search expressions with different styles and intents, such as keyword-based ("load balancing strategy"), question-based ("How to improve service throughput?"), and instruction-based ("Find scheduling algorithm optimization solutions"). Each piece of data can generate three to five search conditions, forming multiple first search conditions corresponding to the first search result. Similarly, the second template converts the second search condition submitted by the user into multiple second search results. The second template can be structured as follows: "Please provide a reasonable or speculative answer to the user's question." The system uses this second template to guide the large model to generate multiple possible answers (i.e., secondary search results) for the second search condition, enhancing semantic richness and fault tolerance. For example, for the question "How to solve the distributed consistency problem," the model might output speculative answers in different styles, such as "Using the Paxos algorithm," "Introducing the Raft consensus mechanism," or "Using Zookeeper for coordination," as multiple secondary search results corresponding to the second search condition.
[0039] By adopting the information retrieval method provided in this embodiment, the system expands both the condition space and the result space, so that subsequent matching no longer relies on single-point information, but instead performs alignment between multiple to-be-matched contents, thereby enhancing matching robustness.
[0040] Optionally, in one embodiment, the second search condition is matched with the first search condition to obtain a first matching result, and the second search result is matched with the first search result to obtain a second matching result. The steps include: converting the first search condition, the second search condition, the first search result, and the second search result into vectors; calculating a first similarity between the vector of the second search condition and the vector of the first search condition; determining the first matching result based on the first similarity; calculating a second similarity between the vector of the second search result and the vector of the first search result; and determining the second matching result based on the second similarity.
[0041] Specifically, in this embodiment, in order to support the matching and retrieval of multimodal data, or to achieve semantic-level matching between different types of text, the retrieval conditions and retrieval results are respectively mapped to a unified space, which includes vector representations of different modalities such as text, images, audio, and video, to ensure that semantic-level matching can be performed in a unified representation structure.
[0042] For text-based search terms or results, language models such as BERT and ERNIE can be used to encode and generate vectors. For image-based search results, such as medical images and scene graphs, visual encoding models are used to map the image content into vectors. For audio, such as speech clips or music samples, pre-trained audio models are used to extract semantic features. For video data, a video time series modeling network can be used to extract vectors representing the overall semantics. All vectors are uniformly projected into the same dimensional space to achieve arbitrary and cross-modal matching capabilities.
[0043] The second search conditions, such as text questions and user voice questions, are converted into vectors, and similarity is calculated with the vectors of all first search conditions. The first search conditions whose similarity meets the requirements are selected as the first matching results based on the similarity. The second search results generated by the large model, such as images, text summaries, voice answers, etc., are converted into vectors, and similarity is calculated with the vectors of the first search results. The first search results whose similarity meets the requirements are selected as the second matching results based on the similarity.
[0044] The information retrieval method provided in this embodiment achieves arbitrary or multimodal alignment of retrieval conditions and results across modalities and across modalities through unified encoding and similarity matching strategies for arbitrary or multimodal retrieval scenarios. This supports a variety of combinations, including text-to-text, text-to-image, image-to-image, audio-to-audio, video-to-image, and audio-to-text. Specifically for text-to-text retrieval, vector alignment is performed in both the question space and the answer space, avoiding mismatches caused by shallow keyword overlap and improving the semantic robustness of the matching.
[0045] Optionally, in one embodiment, the second search condition is a search term, and when the data is text: the step of converting the first search result into a vector includes: dividing the first search result into blocks to obtain several first result text blocks, and converting each first result text block into a first result vector; the step of generating the first search condition corresponding to the first search result includes: generating several first search conditions corresponding to each first result text block; the step of converting the first search condition into a vector includes: converting each first search condition into a first condition vector; the step of converting the second search condition into a vector includes: converting the second search condition into a second condition vector; the step of converting the second search result into a vector includes: dividing the second search result into blocks to obtain several second result text blocks, and converting each second result text block into a second result vector.
[0046] In this embodiment, when there is a large amount of long plain text data in the information retrieval database, such as technical reports, academic papers, product manuals, etc., in order to improve the semantic coverage and retrieval granularity of such data, a block processing mechanism is adopted for the first and second text-type retrieval results, and each text block is independently converted into a vector and retrieved.
[0047] Specifically, the full text of the first search result is segmented according to a fixed number of characters, sentences, or semantic segments to form multiple first result text blocks. For example, it can be segmented using a sliding window of 200 words per segment, or segmented based on semantic paragraphs. Each text block is then vector-encoded using a text embedding model to obtain multiple first result vectors. After segmentation, the original position information of the text block can be retained for subsequent result display and interpretation. For each first result text block, a large language model is used to generate a corresponding set of first search conditions. Each text block can generate multiple question-style, keyword-style, or imperative search expressions. These first search conditions are encoded as first condition vectors for semantic-level comparison with user input.
[0048] If the user enters a second search condition, which is a search term or natural language phrase, the system uses the text embedding model to generate a second condition vector. If the second search result is a hypothetical text result (generated by the large model), the system also performs a block-by-block operation to obtain several second result text blocks. These blocks are then vectorized to generate multiple second result vectors, supporting more refined matching strategies.
[0049] When matching search conditions, the cosine similarity calculation is performed between the second condition vector and multiple first condition vectors, supporting partial semantic alignment. When matching search results, the second result vector is matched with multiple first result vectors at the text block level, enabling more fine-grained content retrieval and traceability. The final matching results can be output at the text block level, accurately locating the matching paragraph.
[0050] The information retrieval method provided by this embodiment not only establishes a matching mechanism between retrieval conditions and retrieval results at the overall document level, but also achieves more detailed semantic modeling and matching judgment at the granularity of text blocks, which helps to deal with practical problems such as long documents with redundant content and widely distributed keywords, and significantly improves the positioning accuracy and feedback accuracy of information retrieval.
[0051] Optionally, in one embodiment, the step of determining the first matching result based on the first similarity includes: taking the first condition vector whose first similarity satisfies the first similarity condition as a candidate condition vector; the step of determining the second matching result based on the second similarity includes: taking the first result vector whose second similarity satisfies the second similarity condition as a candidate result vector; the step of determining the retrieval feedback of the second retrieval condition based on the first matching result and the second matching result includes: determining the first result text block of the source candidate condition vector to obtain the first candidate text block; determining the first result text block of the source candidate result vector to obtain the second candidate text block; when the first candidate text block and the second candidate text block belong to the same candidate text block, using the first similarity and the second similarity to calculate the score of the candidate text block; and determining the retrieval feedback of the second retrieval condition based on the score.
[0052] In this embodiment, in order to improve the semantic accuracy and positioning interpretability of the final retrieval feedback, a similarity condition control and intersection scoring mechanism is introduced when matching in two directions. Specifically, after completing the similarity calculation between the second retrieval condition and the first retrieval condition vector, the first condition vector whose similarity meets the first similarity condition is selected as the candidate condition vector set. For example, when the similarity is the cosine distance, the first similarity condition is that the cosine distance is less than 0.2, that is, when the cosine distance between the second condition vector and the first condition vector is less than 0.2, the first condition vector is the candidate condition vector. Similarly, after the similarity calculation between the second result vector and the first retrieval vector, the first result vector whose similarity meets the second similarity condition is used as the candidate result vector set, wherein the first similarity condition and the second similarity condition can be the same or different, supporting flexible adjustment according to the task scenario, and controlling the balance between matching accuracy and recall.
[0053] Each first condition vector originates from a text block of the first search result, and the source text blocks corresponding to all candidate condition vectors are recorded as a set of first candidate text blocks. Similarly, each candidate result vector also corresponds to its source text block, recorded as a set of second candidate text blocks. The intersection of the two sets is the semantic intersection area of the candidate text block, which means that the text block has a high degree of match in both the question semantics and the answer semantics. For each text block that belongs to both the first candidate text block and the second candidate text block (i.e., the same candidate text block), the system calculates its final score and determines which text blocks are the final search feedback based on the scores of the candidate text blocks. In other words, the original content of the text block is returned to the user as the final search feedback.
[0054] The information retrieval method provided in this embodiment cross-references information from two independent semantic paths (the condition alignment path and the result alignment path) to implement a comprehensive judgment mechanism for semantic consistency and content relevance. This method is particularly suitable for long-text retrieval and relevance inference tasks in semantically ambiguous scenarios, such as legal text matching, technical document question answering, and academic resource locating.
[0055] Optionally, in one embodiment, the steps of dividing the first search result into blocks and the steps of dividing the second search result into blocks respectively include: segmenting the text to be divided into blocks to obtain multiple paragraph units; and combining adjacent paragraph units into text blocks according to a preset text block size.
[0056] In this embodiment, in order to improve the controllability and semantic continuity in the long text retrieval scenario, the long text type data in the first retrieval result and the second retrieval result are processed in a block manner based on the paragraph structure.
[0057] The segmentation process consists of two stages: the first stage is paragraph recognition; the second stage is text block synthesis. First, paragraph boundary recognition is performed on the original text. For example, natural paragraphs are identified based on line breaks, or regular expressions are used to match common structural paragraph starts, such as "1.", "First step:", "[Functional module]", etc. For text with irregular formatting, the semantic paragraph segmentation model can be used for semantic paragraph recognition. After paragraph recognition, the original text is segmented into multiple paragraph units, each of which is a natural semantic segment.
[0058] To control the text granularity and model load of subsequent vectorization processing, a maximum text block length threshold, such as a maximum number of characters or words, is preset. Starting from the first paragraph, adjacent paragraph units are sequentially spliced together until the threshold is reached, forming a complete text block. If the length of a paragraph reaches or exceeds the threshold, it is treated as a separate text block. The resulting multiple text blocks can completely cover the original text, and each block maintains paragraph continuity, enhancing semantic coherence and facilitating the subsequent generation of search criteria and the stability of vector representation.
[0059] In the technical document retrieval scenario, this strategy combining segmentation and merging can avoid the loss of problem description due to logical breaks within the paragraph; in the academic paper matching scenario, more detailed structural control can be performed based on paragraph titles; in policy and regulation queries, each regulatory article is usually a paragraph unit, and the block strategy can preserve the integrity of the legal article.
[0060] The information retrieval method provided in this embodiment implements a text block construction strategy that is more semantically structure-aware, making the subsequent matching, scoring, and feedback processes more stable and controllable, thereby improving the robustness and user experience of the information retrieval system in long text processing.
[0061] Optionally, in one embodiment, the first similarity and the second similarity are both cosine distances, and the score of the candidate text block is calculated using the first similarity and the second similarity using the following formula: R=q*W+p*M, where R is the score of the candidate text block, p and q are weight coefficients respectively, W is the first similarity, and M is the second similarity; the step of determining the retrieval feedback of the second retrieval condition based on the score includes: taking the candidate text block corresponding to the lowest score as the retrieval feedback.
[0062] In this embodiment, to achieve a more interpretable and adjustable scoring mechanism, weights are assigned to the matching similarities from the condition side and the result side respectively, and a unified linear scoring function is used to evaluate and rank the candidate text blocks.
[0063] Specifically, for all text representations involved in the matching, cosine similarity is used as a similarity measurement method, and the specific calculation formula will not be repeated here. For each candidate text block that appears in both the first matching result and the second matching result, its score is calculated using the weighted sum method, and the influence of the two matching paths on the overall feedback is adjusted by the adjustable weight coefficient. For example, set p=0.5, q=0.5, and the weight coefficient can be dynamically adjusted according to the business scenario, or determined by self-learning of the model. After calculating the scores of all candidate text blocks, the text block with the lowest score in the candidate set is selected as the final feedback, realizing the principle of strongest association consistency, that is, only when both directions are highly similar, the score corresponding to the text block is the smallest. The selected candidate text block can be returned to the user as the final retrieval feedback, or used in subsequent downstream modules such as summary generation and answer display.
[0064] The information retrieval method provided in this embodiment not only improves the semantic consistency of the feedback results, but also provides a clear and controllable calculation path for the feedback logic, facilitating the precision-recall trade-off and decision transparency explanation during deployment.
[0065] Example 2 Text retrieval technology, as a crucial component of information retrieval, aims to search, classify, and filter text collections based on their content (e.g., keywords and semantics). Keyword-based retrieval primarily retrieves text through keyword matching. Keywords are first extracted from the user's query, and then a search is performed to retrieve text containing the keywords. Keyword-based retrieval is simple and straightforward, requiring no complex query statements, significantly improving search efficiency. However, because user-entered keywords can be broad or vague, search results often contain a large amount of information not directly relevant to the user's needs. Furthermore, keyword-based retrieval relies primarily on keyword matching, lacking a deep understanding of natural language semantics. Consequently, search results may not meet the user's actual needs. Users must expend considerable time and effort filtering through search results to identify truly useful information. In real-world applications, user queries often lack specificity or easily identifiable elements. For example, there is little overlap between the question and the answer, making retrieval challenging.
[0066] An embodiment of the present invention provides an information retrieval method that solves the problem of quickly and accurately searching for text information required by users within a text repository, improving the accuracy of text retrieval based on search terms. The Large Language Model (LLM) is an artificial intelligence algorithm based on deep learning. By training on large amounts of text data, it learns the grammar, semantics, and context of a language, thereby modeling and understanding natural language text. LLM has a wide range of applications in natural language processing, including but not limited to text generation, text classification, machine translation, and sentiment analysis. Leveraging the LLM's powerful text generation and semantic understanding capabilities, it generates hypothetical answers based on user questions and associated potential questions based on existing information text. By matching known questions with generated potential questions and generated hypothetical answers with existing knowledge, the knowledge text required by the end user is selected. This innovation transforms the traditional "question-to-answer" retrieval model into a dual matching strategy of "question-to-question" and "answer-to-answer." This not only enriches the query dimensionality but also aligns the semantic space between the query and the desired knowledge, significantly improving retrieval accuracy and recall. Furthermore, after creating "hypothetical" answers and "potential" questions, all questions and answers are converted into vectors, their similarities are calculated in the vector space, and the answers are retrieved from the text to further improve the accuracy and recall of information retrieval.
[0067] Specifically, Figure 2 This is a flowchart of the information retrieval method provided in Example 2 of the present invention. Figure 3 This is a schematic diagram of the information retrieval method provided in the second embodiment of the present invention, as shown in FIG. Figure 2 and Figure 3 As shown, the information retrieval method provided in this embodiment includes the following steps: 1. Build a vector database; 2. Generate hypothetical answers based on user queries and build retrieval vectors; 3. Query the vector database based on the search vector and return the search results.
[0068] The following steps are specifically included when constructing a vector database: a. Obtain the original text dataset; b. Preprocess a text by first segmenting it and then dividing it into blocks according to a preset block size, that is, combining two adjacent small segments into blocks to obtain a text block; c. Input the segmented text blocks into the pre-trained BERT model, output the vector corresponding to the text block (i.e., the first result vector), and store it in the vector library; d. Set the question generation prompt template and the number of generated questions, and generate relevant questions for each text block as potential questions; e. Input the generated potential question into the pre-trained BERT model, input the vector corresponding to the potential question (that is, the first conditional vector), and store it in the vector library.
[0069] At this time, the vector database includes vectors corresponding to the original text blocks and vectors corresponding to potential problems.
[0070] When generating hypothetical answers based on user queries and building retrieval vectors, the following steps are specifically included: a. Set up an answer generation prompt template and generate the answer based on the user's input as a hypothetical answer; b. The generated hypothetical answer is segmented and reassembled into blocks according to the above logic to obtain text blocks. This is then input into the pre-trained BERT model and converted into a vector (the second result vector) to serve as the subsequent search content. c. The user input is also converted into a vector (also known as the second condition vector), which is also used as the subsequent search content. This completes the preparatory work before the search.
[0071] When querying the vector database based on the search vector and returning the search results, the specific steps include: a. Based on the search content in both directions (the second condition vector and the second result vector) in step 2, calculate the similarity with the potential problem vector in the vector database (i.e., the first condition vector) and the original text block vector (the first result vector). Select the vectors whose similarity meets the conditions and select the text blocks in the intersection as candidate text blocks.
[0072] b. Perform a weighted operation on all candidate text blocks using similarity to calculate the score of the text block. The final text block to be fed back to the user is further determined based on the score and returned to the user in a custom format.
[0073] During the text retrieval process, by generating hypothetical answers that can be used to answer user-entered questions and potential questions that users may enter related to existing text, the semantic space of the search terms and answers is aligned, improving the semantic matching between the search terms and answers. At the same time, they are mapped to the vector space. By calculating the similarity in the vector space and querying related text blocks, the relevance of the retrieval results is enhanced, thereby improving the accuracy and recall rate of the retrieval.
[0074] Figure 4 A schematic diagram of constructing a vector database provided in the second embodiment of the present invention is shown in FIG. Figure 4 As shown in Figure 2, the construction of the vector database specifically includes the following four steps: 1. Segmentation & Blocking For a given text, we segment it based on line breaks and then divide it into blocks based on the preset block size. This ensures that each block has complete meaning, improving subsequent search results. For example, if a text contains four paragraphs: paragraph 1, paragraph 2, paragraph 3, and paragraph 4, during the block operation, paragraphs 1 and 2, which have fewer words, are merged into block 1, paragraph 3 is divided into block 2, and paragraph 4 is divided into block 3.
[0075] 2. Generate potential questions Set the question generation prompt template Prompt1. Using the large language model (ChatGLM), generate a specified number of related questions for the text block obtained in step 1. Specifically, Prompt1 reads: "Based on the following text, please generate at least two questions related to the text's theme, details, or underlying meaning. The text content is as follows {R}. Please output the questions in the format 'question 1 question 2'." R represents the text block for which questions are to be generated. For example, ChatGLM generates two related potential questions a and b for text block 1; two related potential questions c and d for text block 2; and two related potential questions c and f for text block 3.
[0076] 3. Vectorization The resulting text blocks and generated questions are fed into the pre-trained BERT model to generate their corresponding vectors. Using vectors captures semantic similarities between words, placing similar words closer together in the vector space. Mathematical and statistical methods can also be used to analyze and process this text data, significantly benefiting subsequent text retrieval. For example, using the BERT model, generated questions af are converted into vectors 1-6, and the original text blocks 1-3 are converted into vectors 7-9.
[0077] 4. Build a vector database All vectors generated in the above steps are stored in a database to create a vector database for subsequent retrieval. It should be noted that the vectors used to generate the question and the vectors used to generate the text block need to be identified so that subsequent retrieval can be independent of each other. For example, vectors 1-9 form a vector database, and vectors 1-6 and 7-9 are identified separately to distinguish the question vector from the original text vector.
[0078] When storing vectors, you can use an open source vector database and map vectors and text blocks so that subsequent calculations can match the vectors. Whether it is the vector of the problem or the vector of the text block, it can be returned to the format required by the user.
[0079] Figure 5 This is a schematic diagram of generating a search vector provided in the second embodiment of the present invention, as shown in FIG. Figure 5As shown, when generating a search vector, ChatGLM is first used to generate a hypothetical answer to the user input. Specifically, the user input is queried with the ChatGLM, and the output of the ChatGLM serves as the hypothetical answer. The hypothetical answer is then segmented and divided into blocks. For example, if the hypothetical answer contains paragraphs 1, 2, 3, and 4, paragraphs 1 and 2 form text block 1, while paragraphs 3 and 4 form text block 2. The text blocks and user input are then vectorized to obtain text block vector A, text block vector B, and question vector C. Finally, all search vectors are merged to complete the conversion from user input to search vectors. At this point, all preparations are complete; the search process then begins.
[0080] Figure 6 This is a vector matching diagram provided by the second embodiment of the present invention, such as Figure 6 As shown, when searching and matching from a vector database, the vector database is first calculated and matched based on the retrieval vector composed of the question vector and the hypothetical answer vector, that is, the cosine distance between the question vector and the potential question vector is calculated, and the cosine distance between the hypothetical answer vector and the text block vector is calculated, and the most similar texts in the vector space are calculated. For example, through the cosine distance calculation, the similarity conditions are met including question vector C and vector 1, question vector C and vector 4, hypothetical answer vector A and vector 7, hypothetical answer vector B and vector 9.
[0081] Next, the text block scores are calculated based on the matching results. Question vector C matches vectors 1 and 4, meaning the result matched by the question vector (condition vector) is: original text block 1 and original text block 2 (the first candidate text block). Hypothetical answer vector A matches vector 7, and hypothetical answer vector B matches vector 9. This means the result matched by the answer vector (result vector) is: original text block 1 and original text block 3 (the second candidate text block).
[0082] The intersection of the results matched in the two directions is the original text block 1, so the original text block 1 is the candidate text block. A weighted operation is performed on all candidate text blocks to calculate the score, and a preset number of candidate text blocks with the lowest scores are selected as retrieval feedback. The calculation method is R=q*W+p*M, where R is the score of the candidate text block, W is the cosine distance value between the question vector C and vector 1, M is the cosine distance value between the hypothetical answer vector A and vector 7, and q and p are weight values. This article sets q=0.5 and p=0.5. For the above original text block 1, the score is also the lowest after the weighted operation, so it is the first choice for retrieval feedback.
[0083] Example 3 Corresponding to the above-mentioned embodiment 1, embodiment 3 of the present invention provides an information retrieval device. The corresponding technical feature details and corresponding technical effects can be referred to the above-mentioned embodiment 1 and will not be repeated in this embodiment. Figure 7 A block diagram of an information retrieval device provided in the third embodiment of the present invention, such as Figure 7 As shown, the apparatus includes: a construction module 301 , a first processing module 302 , a receiving module 303 , a second processing module 304 , a first matching module 305 , a second matching module 306 and a determination module 307 .
[0084] Among them, the construction module 301 is used to construct an information retrieval database, wherein the database includes multiple data; the first processing module 302 is used to use the data as the first retrieval result to generate a first retrieval condition corresponding to the first retrieval result; the receiving module 303 is used to receive the second retrieval condition; the second processing module 304 is used to generate a second retrieval result corresponding to the second retrieval condition; the first matching module 305 is used to match the second retrieval condition with the first retrieval condition to obtain a first matching result; the second matching module 306 is used to match the second retrieval result with the first retrieval result to obtain a second matching result; and the determination module 307 is used to determine the retrieval feedback of the second retrieval condition based on the first matching result and the second matching result.
[0085] Optionally, in one embodiment, when the first processing module and the second processing module generate the first search condition corresponding to the first search result and generate the second search result corresponding to the second search condition, the specific steps performed include: presetting the first template and the second template; using the large model, the first template and the first search result to generate multiple first search conditions; using the large model, the second template and the second search condition to generate multiple second search results.
[0086] Optionally, in one embodiment, when the first matching module and the second matching module match the second retrieval condition with the first retrieval condition to obtain a first matching result, and match the second retrieval result with the first retrieval result to obtain a second matching result, the specific steps performed include: converting the first retrieval condition, the second retrieval condition, the first retrieval result and the second retrieval result into vectors; calculating the first similarity between the vector of the second retrieval condition and the vector of the first retrieval condition; determining the first matching result based on the first similarity; calculating the second similarity between the vector of the second retrieval result and the vector of the first retrieval result; and determining the second matching result based on the second similarity.
[0087] Optionally, in one embodiment, the second search condition is a search word, and when the data is text: the step of converting the first search result into a vector includes: dividing the first search result into blocks to obtain several first result text blocks, and converting each first result text block into a first result vector; the step of generating the first search condition corresponding to the first search result includes: generating several first search conditions corresponding to each first result text block; the step of converting the first search condition into a vector includes: converting each first search condition into a first condition vector; the step of converting the second search condition into a vector includes: converting the second search condition into a second condition vector; the step of converting the second search result into a vector includes: dividing the second search result into blocks to obtain several second result text blocks, and converting each second result text block into a second result vector.
[0088] Optionally, in one embodiment, the step of determining the first matching result based on the first similarity includes: taking the first condition vector whose first similarity satisfies the first similarity condition as a candidate condition vector; the step of determining the second matching result based on the second similarity includes: taking the first result vector whose second similarity satisfies the second similarity condition as a candidate result vector; the step of determining the retrieval feedback of the second retrieval condition based on the first matching result and the second matching result includes: determining the first result text block from the candidate condition vector to obtain the first candidate text block; determining the first result text block from the candidate result vector to obtain the second candidate text block; when the first candidate text block and the second candidate text block belong to the same candidate text block, using the first similarity and the second similarity to calculate the score of the candidate text block; and determining the retrieval feedback of the second retrieval condition based on the score.
[0089] Optionally, in one embodiment, the steps of segmenting the first search result and the steps of segmenting the second search result respectively include: segmenting the text to be segmented to obtain multiple paragraph units; and synthesizing adjacent paragraph units into text blocks according to a preset text block size.
[0090] Optionally, in one embodiment, the first similarity and the second similarity are both cosine distances, and the score of the candidate text block is calculated using the first similarity and the second similarity using the following formula: R=q*W+p*M, wherein R is the score of the candidate text block, p and q are weight coefficients respectively, W is the first similarity, and M is the second similarity; the step of determining the retrieval feedback of the second retrieval condition based on the score includes: taking the candidate text block corresponding to the lowest score as the retrieval feedback.
[0091] Example 4 This embodiment also provides a computer device, such as a smart phone, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server or cabinet server (including an independent server or a server cluster composed of multiple servers) that can execute programs. Figure 8 As shown, the computer device 01 of this embodiment includes at least but not limited to: a memory 012 and a processor 011 which can be interconnected via a system bus. Figure 8 It should be pointed out that Figure 8 The computer device 01 is shown only with components memory 012 and processor 011 , but it should be understood that implementation of all of the components shown is not a requirement and more or fewer components may alternatively be implemented.
[0092] In this embodiment, memory 012 (i.e., readable storage medium) includes flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, a magnetic disk, an optical disk, etc. In some embodiments, memory 012 may be an internal storage unit of computer device 01, such as the hard disk or internal memory of computer device 01. In other embodiments, memory 012 may also be an external storage device of computer device 01, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash memory card, etc. Of course, memory 012 may also include both internal storage units and external storage devices of computer device 01. In this embodiment, memory 012 is typically used to store the operating system installed on computer device 01 and various reference software, such as the program code of the information retrieval device of the embodiment. In addition, the memory 012 can also be used to temporarily store various types of data that have been output or are to be output.
[0093] In some embodiments, processor 011 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. Processor 011 is typically used to control the overall operation of computer device 01. In this embodiment, processor 011 is used to execute program code stored in memory 012 or process data, such as information retrieval methods.
[0094] Example 5 This embodiment also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic storage device, a disk, an optical disk, a server, an app reference store, etc., which stores a computer program that, when executed by a processor, implements a corresponding function. The computer-readable storage medium of this embodiment is used to store an information retrieval device, which, when executed by a processor, implements the information retrieval method of this embodiment.
[0095] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0096] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method.
[0098] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. An information retrieval method, characterized in that: include: Building an information retrieval database, wherein the database includes a plurality of data; Taking the data as a first search result, generating a first search condition corresponding to the first search result; receiving a second search condition; generating a second search result corresponding to the second search condition; Matching the second search condition with the first search condition to obtain a first matching result; Matching the second search result with the first search result to obtain a second matching result; and Determine retrieval feedback for the second retrieval condition based on the first matching result and the second matching result.
2. The information retrieval method according to claim 1, wherein: The steps of generating a first search condition corresponding to the first search result and generating a second search result corresponding to the second search condition include: Preset the first template and the second template; Generate a plurality of first search conditions using the macro model, the first template, and the first search result; A plurality of second search results are generated using the large model, the second template and the second search condition.
3. The information retrieval method according to claim 1, wherein: The steps of matching the second search condition with the first search condition to obtain a first matching result, and matching the second search result with the first search result to obtain a second matching result include: Converting the first search condition, the second search condition, the first search result, and the second search result into vectors; Calculating a first similarity between the vector of the second search condition and the vector of the first search condition; determining a first matching result according to the first similarity; Calculating a second similarity between the vector of the second search result and the vector of the first search result; A second matching result is determined according to the second similarity.
4. The information retrieval method according to claim 3, wherein: The second search condition is a search term, and when the data is text: The step of converting the first search result into a vector includes: dividing the first search result into blocks to obtain a plurality of first result text blocks, and converting each of the first result text blocks into a first result vector; The step of generating the first search condition corresponding to the first search result includes: generating a plurality of the first search conditions corresponding to each of the first result text blocks; The step of converting the first search condition into a vector includes: converting each of the first search conditions into a first condition vector; The step of converting the second search condition into a vector includes: converting the second search condition into a second condition vector; The step of converting the second search result into a vector includes: dividing the second search result into blocks to obtain a plurality of second result text blocks, and converting each second result text block into a second result vector.
5. The information retrieval method according to claim 4, characterized in that: The step of determining a first matching result according to the first similarity includes: taking the first condition vector whose first similarity satisfies a first similarity condition as a candidate condition vector; The step of determining a second matching result according to the second similarity includes: taking the first result vector whose second similarity satisfies a second similarity condition as a candidate result vector; The step of determining retrieval feedback of the second retrieval condition based on the first matching result and the second matching result includes: determining a first result text block derived from the candidate condition vector to obtain a first candidate text block; determining a first result text block derived from the candidate result vector to obtain a second candidate text block; when the first candidate text block and the second candidate text block belong to the same candidate text block, calculating a score of the candidate text block using the first similarity and the second similarity; and determining retrieval feedback of the second retrieval condition based on the score.
6. The information retrieval method according to claim 4, characterized in that: The steps of dividing the first search result into blocks and the steps of dividing the second search result into blocks respectively include: Segment the text to be segmented into multiple paragraph units; Adjacent paragraph units are combined into a text block according to the preset text block size.
7. The information retrieval method according to claim 4, characterized in that: The first similarity and the second similarity are both cosine distances, and the score of the candidate text block is calculated using the first similarity and the second similarity using the following formula: R=q*W+p*M, where R is the score of the candidate text block, p and q are weight coefficients, W is the first similarity, and M is the second similarity; The step of determining the retrieval feedback of the second retrieval condition according to the score includes: taking the candidate text block corresponding to the lowest score as the retrieval feedback.
8. An information retrieval device, characterized in that: include: A construction module, configured to construct an information retrieval database, wherein the database includes a plurality of data; A first processing module, configured to use the data as a first search result and generate a first search condition corresponding to the first search result; A receiving module, configured to receive a second search condition; A second processing module, configured to generate a second search result corresponding to the second search condition; a first matching module, configured to match the second search condition with the first search condition to obtain a first matching result; A second matching module, configured to match the second search result with the first search result to obtain a second matching result; and A determination module is used to determine the search feedback of the second search condition according to the first matching result and the second matching result.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: 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 having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.