Text block retrieval method, computer program product and equipment
The hierarchical search method and large language model generate document summary indexes, which solves the problems of low matching efficiency and insufficient accuracy in the prior art, and achieves more efficient and accurate text block retrieval.
Patent Information
- Application Number
- CN202510560332.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-12
AI Technical Summary
The existing knowledge retrieval modules have shortcomings in retrieval efficiency and accuracy, especially in the RAG framework, where text block matching efficiency is low and the accuracy is low.
The hierarchical search method is used to obtain the target document through document summary matching, and then match text blocks in the target document. The large language model is used to generate the document summary index, and a vector representation of the document summary is generated through the embedding model and keyword extraction technology, and two-level matching is performed to improve efficiency and accuracy.
By reducing the number of matches, the efficiency of text block retrieval is improved, and the accuracy of matching is improved by introducing document context information, ensuring that relevant text blocks are easier to be retrieved.
Smart Images

Figure CN120470090A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of computer technology, and more particularly, to a text block retrieval method, computer program product, and device. Background Art
[0002] Retrieval-Augmented Generation (RAG) is a framework that combines retrieval and generation techniques. It first processes the user's question using a question processing module. Then, a knowledge retrieval module retrieves relevant information from a document repository. Finally, an answer generation module generates an answer based on the information retrieved from the document repository. The RAG framework is commonly used in scenarios such as question-answering systems and dialogue systems.
[0003] The knowledge retrieval module typically matches a question with each text chunk during retrieval, searching for the chunk that matches the question. A text chunk refers to the text generated by splitting a document according to a specific splitting logic. The document library stores multiple chunks of text generated by splitting documents. However, existing knowledge retrieval module text chunk retrieval methods suffer from low retrieval efficiency and accuracy. Summary of the Invention
[0004] In view of this, one or more embodiments of this specification provide a text block search method, a computer program product, and a device.
[0005] According to a first aspect of one or more embodiments of this specification, a text block retrieval method is proposed, including:
[0006] Get the target question to be answered;
[0007] Matching the target question with the document summaries of each document in the document library to obtain the target document corresponding to the matching document summaries;
[0008] A text block matching the target question is determined from a plurality of text blocks included in the target document.
[0009] According to a second aspect of one or more embodiments of this specification, a text block search device is provided, comprising:
[0010] The acquisition module is used to obtain the target question to be answered;
[0011] A first matching module is used to match the target question with the document summaries of each document in the document library to obtain target documents corresponding to the matched document summaries;
[0012] The second matching module is used to determine a text block that matches the target question from multiple text blocks included in the target document.
[0013] According to a third aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which computer instructions are stored. When the instructions are executed by a processor, the text block retrieval method as described in the first aspect of the embodiments of this specification is implemented.
[0014] According to a fourth aspect of the embodiments of this specification, a computer device is provided, comprising:
[0015] processor;
[0016] a memory for storing processor-executable instructions;
[0017] The processor implements the text block retrieval method as described in the first aspect of the embodiment of this specification by running the executable instructions.
[0018] According to a fifth aspect of the embodiments of this specification, a computer program product is provided. When the computer program product is executed by a processor, it implements the text block retrieval method as described in the first aspect of the embodiments of this specification.
[0019] This specification provides a text block retrieval method. First, a target question to be answered is obtained. The target question is then matched with the document summaries of various documents in a document library to obtain matching target documents. Furthermore, a text block corresponding to the target question is matched within the target document.
[0020] For the target question, the document summary is first matched, and then the text blocks in the matched target document are matched. Through two-level matching, the low matching efficiency problem caused by the large number of text blocks is reduced. At the same time, compared with the problem of not being able to match useful text blocks due to the lack of text block context information caused by the text block segmentation problem when matching directly on the text blocks, the method of this specification matches the document summary first, and the document summary includes the context information in the document. It is easier to match the document's overall content and documents related to the target question during matching, thereby making it easier to match the text blocks in the target document, thereby improving the matching accuracy.
[0021] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.
[0023] Figure 1 This is a schematic diagram of a RAG framework shown in this specification.
[0024] Figure 2 This is a schematic diagram of a knowledge retrieval module shown in this specification.
[0025] Figure 3 This is a schematic diagram of generating a second characterization vector shown in this specification.
[0026] Figure 4 This is a flowchart of a text block retrieval method shown in this specification.
[0027] Figure 5 This is a block diagram of a text block retrieval device shown in this specification.
[0028] Figure 6 This is a hardware structure diagram of a computer device shown in this manual. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments are not intended to represent all implementations consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of one or more embodiments of this specification, as detailed in the appended claims.
[0030] It should be noted that in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than those described in this specification. In addition, a single step described in this specification may be broken down into multiple steps for description in other embodiments, and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0031] To address the low retrieval efficiency and accuracy issues in existing technologies, this specification provides a text block retrieval method. First, a target question to be answered is obtained. The target question is then matched against the document summaries of each document in a document repository to obtain matching target documents. Furthermore, a text block corresponding to the target question is matched within the target document.
[0032] For the target question, the document summary is first matched, and then the text blocks in the matched target document are matched. Through two-level matching, the low matching efficiency problem caused by the large number of text blocks is reduced. At the same time, compared with the problem of not being able to match useful text blocks due to the lack of text block context information caused by the text block segmentation problem when matching directly on the text blocks, the method of this specification matches the document summary first, and the document summary includes the context information in the document. It is easier to match the document's overall content and documents related to the target question during matching, thereby making it easier to match the text blocks in the target document, thereby improving the matching accuracy.
[0033] Next, we will describe in detail a text block search method provided in this specification. First, we will describe the RAG framework. Figure 1 As shown in Figure 3, the RAG framework generally includes three modules: question processing module, knowledge retrieval module and answer generation module.
[0034] The question processing module is responsible for processing the semantics of the input target question. Specific processing can include synonym replacement. For example, if a question contains noun A, which has different meanings in different contexts, it can be replaced by another unambiguous noun B in a certain context to avoid ambiguity. The question processing module can then decide whether to replace noun A with noun B based on the context of the target question.
[0035] like Figure 1 As shown, the knowledge retrieval module is responsible for retrieving text blocks that match the target question from the text library. The answer generation module is used to generate the answer to the target question based on the retrieved text blocks and the target question. The method in this specification mainly improves the knowledge retrieval module. In addition, it can be understood that although the above description uses the RAG architecture as an example, the method in this specification can be applied not only to the RAG architecture, but also to other scenarios where corresponding text blocks need to be retrieved from the text library.
[0036] For the methods provided in this manual, Figure 2 As shown, unlike the retrieval methods in related arts, the method in this specification does not directly match the target question with each text block. Instead, it first retrieves document summaries matching the target question from the document summaries included in the text library (referred to as the document summary library in the figure), and uses the document corresponding to the retrieved document summary as the target document. Then, it retrieves the text block matching the target question from the text blocks included in the target document.
[0037] In other words, the method of this specification implements hierarchical retrieval, with retrieval performed at the document granularity in the first tier and at the text block granularity in the second tier. Hierarchical retrieval reduces the number of matches and increases matching efficiency. At the same time, based on the document's contextual information, documents more relevant to the target question can be retrieved, thus avoiding the problem of failing to retrieve relevant text blocks due to a lack of contextual information in the text blocks due to inappropriate text block segmentation granularity. Furthermore, limiting the text block retrieval scope to target documents that match the target question avoids the problem of introducing documents irrelevant to the target question.
[0038] Next, the text block retrieval method involved in this specification will be described. First, the preparatory work done before executing the method of this specification will be described.
[0039] In order to match text blocks better and more efficiently, the RAG framework in related technologies generally needs to perform block vectorization processing on the text library.
[0040] Specifically, each document in a text block can first be segmented into smaller chunks. Chunks can be segmented into paragraphs, sentences, or even smaller granularities. Next, an embedding model is used to convert each chunk into a vector representation. An index is then built, storing the vectors for each chunk in a vector database or index for fast retrieval.
[0041] In this way, when the user enters a target question, the target question can be converted into a vector, and the text block most relevant to the text block can be obtained from the index through similarity calculation.
[0042] The method of this specification changes the retrieval method, and the index generation method also needs to be changed accordingly.
[0043] Specifically, a large language model is first used to generate a summary of the document. The large language model may be a large language model that has been fine-tuned for the purpose of generating a summary.
[0044] In this specification, the Large Language Model (LLM) may also be referred to as the large model. The large language model is a natural language processing model based on deep learning technology. Its parameter scale usually reaches billions to hundreds of billions or even higher, and it has powerful language understanding and generation capabilities. The large language model can adopt the Transformer architecture or its variants (such as GPT, BERT, etc.). This architecture uses the attention mechanism to achieve global modeling of sequence data, which can efficiently handle long-distance dependencies, thereby performing well in natural language tasks. The large language model learns the statistical characteristics and semantic relevance of language by pre-training on a large-scale corpus, giving it excellent generalization capabilities. The core capabilities of the large language model include but are not limited to: understanding contextual semantics, generating coherent and grammatically correct text, performing logical reasoning, and handling multi-task scenarios. Its usage methods generally include two modes: direct inference and fine-tuning. In direct inference mode, the user guides the large language model to generate specific outputs by designing prompts. The prompts can be textual task descriptions or instructions, stimulating the semantic understanding and generation capabilities of the large language model. In fine-tuning mode, the large language model is further trained on a small-scale dataset in a specific domain to optimize its performance on a specific task. The powerful generalization and flexibility of large language models make them a valuable tool in the field of artificial intelligence technology, providing efficient and accurate solutions for automated text generation and comprehension.
[0045] It should be noted that the key technologies of large language models can be found in the detailed description in the paper "A Survey of Large Language Models" (paper number: arXiv:2303.18223v16, published on March 11, 2025, public link: https: / / doi.org / 10.48550 / arXiv.2303.18223), which will not be repeated in this manual.
[0046] Secondly, the document summary of each document is used to generate a document summary index, which facilitates the first-level coarse-grained retrieval later.
[0047] The following steps are similar to those in the related art. Specifically, each document can be segmented into multiple text blocks. The specific segmentation algorithm can be sentence-based segmentation, paragraph-based segmentation, or fixed-length segmentation. The text blocks are then vectorized, and the vectors for each document's text block are stored in the same vector library. Information such as the identifier of each text block and the identifier of the document to which it belongs are also stored.
[0048] Among them, for the document summary, the specific form of the document summary will be described here with multiple embodiments, and the following embodiments do not limit this specification.
[0049] First, embedding is performed on the document summary.
[0050] Specifically, a pre-trained embedding model can be used to embed the document summary to obtain an embedding vector for the document summary. This embedding vector is referred to as the first embedding vector in the following text. Since the second representation vector refers to the vector representation of the document summary, in this embodiment, when the embedding vector of the document summary is the first embedding vector, the first embedding vector is also referred to as the second representation vector. This term is used here to distinguish it from the first representation vector corresponding to the target question described later.
[0051] The embedding process may be to perform word embedding processing on the document summary; using the word embedding processing results, obtain sentence embedding results corresponding to multiple sentences included in the document summary; and obtain a second representation vector corresponding to the document based on the average value or weighted average value between the multiple sentence embedding results.
[0052] Before word embedding, text preprocessing can be performed, including operations such as word segmentation, stop word removal, and stemming to convert the text into a machine-readable format. Specifically, the word embedding process can map each word in the document to a low-dimensional vector space based on a pre-set mapping relationship between words and vectors. Alternatively, the word embedding process can directly extract embedding features based on the word embedding model.
[0053] The embedding model can be a Bidirectional Encoder Representation from Transformers (BERT) based on transformers, etc.
[0054] Alternatively, you can directly perform sentence embedding on the document summary and then take the average or weighted average of multiple sentence embedding results to obtain the second representation vector corresponding to the document. Sentence embedding can be implemented using the sentence-based BERT (Sentence-BERT, SBERT) and the BAAI General Embedding (BGE-M3) model.
[0055] By embedding the document summary, the document summary can be converted into a low-dimensional, continuous vector representation, capturing the semantic information of the text, so that relevant documents can be matched more accurately for the target problem.
[0056] Second, extract keywords from each document summary.
[0057] Specifically, keywords in the document summary can be obtained according to a keyword extraction algorithm as a representation of the document summary.
[0058] A specific method for keyword extraction will be described herein through a specific embodiment. It should be understood that this method does not limit this specification. A specific method for keyword extraction may include: determining multiple candidate keywords through word segmentation for the document summary; and determining keywords that meet similarity requirements based on the similarity between each candidate keyword and the embedding vector corresponding to the document.
[0059] Specifically, the document summary is first converted into a high-dimensional first embedding vector using an embedding model. Next, a sliding window is used to extract a number of candidate keywords of a preset length from the first embedding vector. The similarity between the candidate keywords and the first embedding vector is calculated, and the relevance of the keywords to the document summary is evaluated based on the similarity. Finally, a preset number of keywords (e.g., 1 or 2) with the highest scores are selected as the keyword extraction results.
[0060] The above process can be implemented through a BERT-based keyword extraction method (KeyBERT).
[0061] After extraction is complete, a Best Matching 25 (BM25) searcher instance can be created for subsequent queries to find document summaries that are most relevant to the keywords in the target question. BM25 is a search algorithm based on term frequency and inverse document frequency, effectively measuring the importance of keywords in a document. By extracting keywords and matching them using the BM25 algorithm, the most relevant documents can be found efficiently.
[0062] In addition, when extracting keywords, text keywords can also be extracted through other methods, for example, by matching text keywords with text keywords of the target question. This manual does not limit this.
[0063] Third, combine the first and second methods.
[0064] Specifically, if Figure 3 As shown, for each document, a first embedding vector (i.e., the embedding vector of the document summary) and a second embedding vector corresponding to the keywords of the document summary can be obtained, and a second representation vector corresponding to the document summary can be determined based on the two vectors. Specifically, any second representation vector can be determined based on the weighted sum of the first embedding vector corresponding to the document and the second embedding vector corresponding to the keywords of the document. Figure 3As shown in Figure 2, this method can not only embed documents, but also process the target problem accordingly.
[0065] The calculation formula of the second characterization vector is shown in formula (1).
[0066]
[0067] Where X is the second representation vector, X1 is the first embedding vector, and X2 is the second embedding vector. α1 is the weight coefficient corresponding to the first embedding vector, and α2 is the weight coefficient corresponding to the second embedding vector. The sum of the two weight coefficients is 1. h(s) is the embedding vector of the document summary generated by the embedding model. ||h(s)||2 represents the L2 norm of the vector h(s), which is used for normalization. w1,w2,…w n is the keyword extracted through the above steps, g(w i ) refers to the second embedding vector extracted by keywords, λ i It is the weight coefficient of the keyword, which can be obtained through statistical methods such as term frequency, term frequency-inverse document frequency (TF-IDF), etc.
[0068] The coefficient values of the weight coefficients of the two embedding vectors in the weighted sum may be preset based on historical experience.
[0069] In addition, in an optional embodiment, the coefficient value of the weight coefficient in the weighted sum can be determined in the following manner: using the current coefficient value to determine the current document that matches each question in the test data set; the test data set includes multiple questions and labels that represent documents that match each question; based on the current document and the document indicated by the label, determining the matching accuracy corresponding to the current coefficient value; and determining the coefficient value of the weight coefficient based on the matching accuracy corresponding to each candidate coefficient value.
[0070] Specifically, a test dataset can be obtained in advance, and matching documents corresponding to each question in the test dataset can be annotated. Multiple sets of preset coefficient values are then obtained. For each current coefficient value, the weighted sum of the first embedding vector and the second embedding vector is calculated using these coefficient values to obtain a second representation vector. This second representation vector is then used to match the question with the document. This matching can be accomplished using methods such as similarity calculation. In this way, based on the matching rates of each set of coefficient values, the coefficient with the highest matching rate can be used as the coefficient value for the weighting coefficient.
[0071] In the above process, in an optional implementation, the similarity calculation between the question and the document can refer to formula (2) as shown in
[0072] sim(a,b)=cos(θ)·exp(-β||ab|| 2 ) (2)
[0073] Among them, a and b are the vectors corresponding to the question and document respectively, cos(θ) is the cosine similarity between the two vectors, exp(-β||ab|| 2 ) is the adjustment term, β is the adjustment parameter, ||ab‖ 2 is the square of the Euclidean distance between two vectors.
[0074] By selecting the coefficient value of the weight coefficient by the above method, a more appropriate coefficient value can be selected, thereby balancing the weights of the first embedding vector and the second embedding vector, thereby improving the matching performance.
[0075] In an optional embodiment, the second representation vector, the first embedding vector, the second embedding vector mentioned above, and the first representation vector corresponding to the target problem mentioned later can all be 1024-dimensional.
[0076] The main reasons for choosing 1024-dimensional vectors are: First, many embedding models are trained on 1024-dimensional vectors, resulting in better performance on 1024-dimensional vectors, which can capture rich semantic information. Second, 1024 dimensions achieve a balance between semantic representation and computational efficiency. Compared to lower-dimensional vectors (such as 128 or 256 dimensions), they can represent more complex semantic information while still maintaining good storage and computational performance.
[0077] Through the above process, we can obtain the document summary of each document in the text library and the text block corresponding to each document. Next, we can use the text library to match the target question.
[0078] like Figure 4 As shown, the text block retrieval method provided in this specification includes the following steps:
[0079] Step 401: Obtain the target question to be answered.
[0080] Specifically, we first need to obtain the target question to be answered in order to match the text block to the target question.
[0081] The target question may be a text content to be answered input by the user. As described above, before step 401, semantic processing may be performed on the text input by the user to obtain the target question.
[0082] Step 401 : Match the target question with the document summaries of each document in the document library to obtain target documents corresponding to the matching document summaries.
[0083] Specifically, a first-level coarse-grained matching can be performed first. In other words, the target question is matched with each document to obtain a target document that meets the requirements.
[0084] The matching mentioned in this specification can be achieved by calculating similarity, etc. The similarity can be achieved by cosine similarity, Euclidean distance, etc.
[0085] The target documents may be a preset number of documents with the highest matching degree to the target question, or documents with a matching degree greater than a preset threshold to the target question. This specification does not limit the form of the target documents.
[0086] As for the specific implementation method of step 403, it can be to obtain a first representation vector corresponding to the target question and a second representation vector corresponding to the document summary of each document in the document library; match the first representation vector and each second representation vector to obtain the target document corresponding to the matching second representation vector.
[0087] In other words, the document summary is represented in the form of a second representation vector. Accordingly, the first representation vector corresponding to the target question can be extracted through the embedding model. Furthermore, by calculating the similarity between the first and second representation vectors, the target document that matches the second representation vector can be determined.
[0088] As mentioned above, the second representation vector can be in various forms. Next, the specific implementation process of step 403 will be described in combination with the various representation forms of document summaries mentioned above.
[0089] First, when the second representation vector is a sentence-level embedding vector of the document summary, the above method for extracting the first embedding vector of the document summary can be used to embed the target document to obtain the first representation vector.
[0090] Then, based on the similarity calculation between the first representation vector and each second representation vector (ie, the first embedding vector), the target document that meets the requirements is determined.
[0091] Second, when the second representation vector is a keyword-level embedding vector of the document summary, the above method for extracting the second embedding vector of the document summary can be used to extract and embed keywords from the target document to obtain the first representation vector.
[0092] Then, based on the similarity calculation between the first representation vector and each second representation vector (ie, second embedding vector), the target document that meets the requirements is determined.
[0093] Third, if the second representation vector is determined based on the weighted sum of the first and second embedding vectors, the method for calculating the first and second embedding vectors mentioned above can be used to obtain the sentence-level and keyword-level embedding vectors corresponding to the target document. The weighted sum of the two vectors can then be calculated to obtain the first representation vector.
[0094] Then, based on the similarity calculation between the first characterization vector and each second characterization vector, the target document that meets the requirements is determined.
[0095] In addition, when the document summary is expressed in the form of keywords, you can also: obtain the first keyword of the target question; obtain the second keyword in the document summary of each document in the document library; match the first keyword with each second keyword to obtain the target document corresponding to the matching second keyword.
[0096] Here, whether the target question matches each document can be determined based on whether the first keyword and the second keyword are the same.
[0097] Step 405: Determine a text block that matches the target question from the multiple text blocks included in the target document.
[0098] Specifically, after obtaining one or more target documents through the first-level matching in step 403, a second-level fine-grained matching may be further performed to obtain text blocks that match the target question from the target documents.
[0099] A specific matching method may be to obtain a first representation vector of the target document and a third representation vector of each text block included in the target document. Based on the similarity between the first representation vector and each third representation vector, the text blocks with the highest similarity are obtained, or the text blocks with similarity greater than a preset threshold are obtained.
[0100] In an optional embodiment, three levels of text block matching can also be performed. Specifically, the documents in the text library are pre-divided into multiple text segments, each of which includes multiple text blocks. The corresponding step 405 may include: determining a target text segment that matches the target question from the multiple text segments included in the target document; and determining a text block that matches the target question from the multiple text blocks included in the target text segment.
[0101] That is, after the first level of matching, the second level of matching is performed on the text segments in the target document, and then the third level of matching is performed on the text blocks in the target text segments. This can reduce the number of matches and improve the efficiency of text block retrieval.
[0102] In an optional embodiment, multiple target documents are obtained in step 403, and similarity scores between each target document and the target question are also obtained. In step 405, a text block that matches the target question can be determined based on the similarity scores of each target document and the similarity between each text block included in the target document and the target question.
[0103] Since text blocks lack contextual information, contextual information can be introduced through document summaries. The matching degree between each text block and the target question can be comprehensively determined by the similarity score of the target document and the similarity between the target question and the text block.
[0104] Optionally, a coefficient value of the weight coefficient may be preset, and the matching degree is determined based on a weighted sum of the similarity of the target document and the similarity between the target question and the text block.
[0105] When the method of this specification is applied to RAG, after executing step 405, an answer text corresponding to the target question can be generated based on the text block matching the target question. This answer text can then be output to the user. The answer text can be generated using a large language model.
[0106] The above method can achieve the following technical effects.
[0107] First, reduce the amount of calculation and improve retrieval efficiency.
[0108] Compared to the related art which requires similarity matching calculations for all text blocks, this specification first performs document-level matching, which can quickly locate a smaller number of documents that best match the target question, reducing the number of text blocks that need to be matched.
[0109] It also avoids matching text blocks of documents that are irrelevant to the target question, reduces unnecessary calculations, and improves retrieval efficiency.
[0110] Second, improve matching accuracy.
[0111] In step 403, the document summary is used for matching, and the context information of the document is introduced, so that the relevant text blocks can be retrieved more easily.
[0112] Specifically, in the related art, problems with the block segmentation algorithm may result in a lack of contextual information in the text blocks, which in turn may cause the text blocks related to the target question to be missed due to the lack of contextual information. The method of this specification can introduce more contextual information, and perform text block matching from the target document, making it easier to match the text blocks related to the target question. For those text blocks that are not in the target document, these text blocks may appear to be related to the target question, but in fact, it can be determined based on the context that the text blocks are not related to the target question. The above method can avoid the influence of these text blocks on the retrieval results.
[0113] like Figure 4 As shown, Figure 4 This specification is a text block search device according to an exemplary embodiment, the device comprising
[0114] An acquisition module 410 is used to acquire a target question to be answered;
[0115] A first matching module 420 is configured to match the target question with the document summaries of each document in the document library to obtain target documents corresponding to the matching document summaries;
[0116] The second matching module 430 is configured to determine a text block that matches the target question from among the multiple text blocks included in the target document.
[0117] In an optional embodiment, the first matching module 420 is specifically used to obtain a first representation vector corresponding to the target question and a second representation vector corresponding to the document summary of each document in the document library; match the first representation vector and each second representation vector to obtain a target document corresponding to the matching second representation vector.
[0118] In an optional implementation, any second representation vector is determined based on a weighted sum of a first embedding vector corresponding to the document summary and a second embedding vector corresponding to a keyword of the document summary.
[0119] In an optional embodiment, a coefficient value determination module 401 (not shown in the figure) is further included, which is used to use the current coefficient value to determine the current document that matches each question in the test data set; the test data set includes multiple questions and labels that represent documents that match each question; based on the current document and the document indicated by the label, the matching accuracy corresponding to the current coefficient value is determined; according to the matching accuracy corresponding to each candidate coefficient value, the coefficient value of the weight coefficient is determined.
[0120] In an optional embodiment, an embedding module 402 (not shown in the figure) is further included, which is used to perform word embedding processing on the document summary; using the word embedding processing results, sentence embedding results corresponding to multiple sentences included in the document summary are obtained; based on the average value or weighted average value among the multiple sentence embedding results, a second representation vector corresponding to the document is obtained.
[0121] In an optional embodiment, the first matching module 420 is specifically used to obtain the first keyword of the target question; obtain the second keyword in the document summary of each document in the document library; match the first keyword with each second keyword to obtain the target document corresponding to the matched second keyword.
[0122] In an optional embodiment, the first matching module 420 is further configured to determine a plurality of candidate keywords through word segmentation processing for the document summary; and determine keywords that meet the similarity requirement based on the similarity between each candidate keyword and the embedding vector corresponding to the document.
[0123] In an optional embodiment, the documents in the text library are pre-divided into multiple text segments, each of which includes multiple text blocks; the second matching module 430 is specifically used to determine a target text segment that matches the target question from the multiple text segments included in the target document; and determine a text block that matches the target question from the multiple text blocks included in the target text segment.
[0124] In an optional embodiment, the first matching module 420 is specifically used to obtain multiple target documents and a similarity score between each target document and the target question; the second matching module 430 is specifically used to determine a text block that matches the target question based on the similarity score of each target document and the similarity between each text block included in the target document and the target question.
[0125] In an optional embodiment, a text generation module 440 (not shown in the figure) is further included, which is used to generate an answer text corresponding to the target question based on the text block matching the target question.
[0126] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0127] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying any creative work.
[0128] like Figure 6 As shown, Figure 6 The figure shows a hardware structure diagram of a computer device, which may include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other within the device via the bus 1050.
[0129] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is configured to execute relevant programs to implement the technical solutions provided in the embodiments of this specification. The processor implements the above-described method by running executable instructions.
[0130] The memory 1020 for storing processor-executable instructions can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 1020 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1020.
[0131] The input / output interface 1030 is used to connect input / output modules to implement information input and output. The input / output modules can be configured as components within the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.
[0132] The communication interface 1040 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).
[0133] The bus 1050 comprises a path for transmitting information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).
[0134] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, it will be understood by those skilled in the art that the above device may only include the components necessary to implement the embodiments of this specification, and does not necessarily include all the components shown in the figure.
[0135] The embodiments of this specification also provide a computer program product, which implements the above-mentioned text block retrieval method when executed by a processor.
[0136] The embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon, which implements the above-mentioned text block retrieval method when executed by a processor.
[0137] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0138] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0139] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0140] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
Claims
1. A text block retrieval method, comprising: Get the target question to be answered; Matching the target question with the document summaries of each document in the document library to obtain target documents corresponding to the matching document summaries; A text block matching the target question is determined from a plurality of text blocks included in the target document.
2. The method according to claim 1, wherein The step of matching the target question with the document summaries of each document in the document library to obtain target documents corresponding to the matched document summaries includes: Obtaining a first representation vector corresponding to the target question and a second representation vector corresponding to the document summary of each document in the document library; The first representation vector is matched with each second representation vector to obtain a target document corresponding to the matched second representation vector.
3. The method according to claim 2, wherein: Any second representation vector is determined based on a weighted sum of the first embedding vector corresponding to the document summary and the second embedding vector corresponding to the keyword of the document summary.
4. The method according to claim 3, wherein: The coefficient value of the weight coefficient in the weighted sum is determined by the following method: Determining a current document that matches each question in a test dataset using the current coefficient value; the test dataset includes a plurality of questions and labels representing documents that match each question; Determining a matching accuracy corresponding to the current coefficient value based on the current document and the document indicated by the tag; The coefficient value of the weight coefficient is determined according to the matching accuracy rate corresponding to each candidate coefficient value.
5. The method according to claim 2, wherein: The method for obtaining the second representation vector corresponding to any document includes: Perform word embedding processing on the document summary; Using the word embedding processing results, obtain sentence embedding results corresponding to the multiple sentences included in the document summary; A second representation vector corresponding to the document is obtained according to an average value or a weighted average value among the multiple sentence embedding results.
6. The method according to claim 1, wherein The step of matching the target question with the document summaries of each document in the document library to obtain target documents corresponding to the matched document summaries includes: Obtaining the first keyword of the target question; Obtain the second keyword in the document summary of each document in the document library; The first keyword is matched with each second keyword to obtain target documents corresponding to the matched second keywords.
7. The method according to claim 6, wherein: The method for obtaining the second keyword in any document summary includes: For the document summary, multiple candidate keywords are determined through word segmentation processing; Based on the similarity between each candidate keyword and the embedding vector corresponding to the document, the keywords that meet the similarity requirements are determined.
8. The method according to claim 1, wherein The documents in the text library are pre-divided into a plurality of text segments, each of which includes a plurality of text blocks; Determining a text block that matches the target question from a plurality of text blocks included in the target document includes: Determining a target text segment that matches the target question from a plurality of text segments included in the target document; A text block matching the target question is determined from a plurality of text blocks included in the target text segment.
9. The method according to claim 1, wherein Get the target document corresponding to the matching document summary, including: Obtain multiple target documents and a similarity score between each target document and the target question; Determining a text block that matches the target question from a plurality of text blocks included in the target document includes: The text block that matches the target question is determined based on the similarity scores of the target documents and the similarities between the target documents and the target question.
10. The method according to claim 1, wherein The method further comprises: Generate an answer text corresponding to the target question based on the text block that matches the target question.
11. A computer program product, wherein when the computer program product is executed by a processor, the computer program product implements the method according to any one of claims 1 to 10.
12. A computer device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 10 by running the executable instructions.
Citation Information
Cited By
Question and answer generation method and system, electronic equipment, storage medium and program product
CN120821812A
Retrieval method and device, electronic equipment, storage medium and computer program product
CN120873173A
Multi-strategy fusion large model retrieval enhancement generation method
CN121166867A