Document retrieval method and device, equipment and storage medium
By recognizing named entity and matching text blocks for query statements, combined with a pre-trained language model, the problem of inefficient document retrieval in large-scale knowledge bases is solved, and efficient and accurate document retrieval is achieved.
Patent Information
- Application Number
- CN202510081168.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-04-29
AI Technical Summary
With the increase in the amount of knowledge base data, existing document search methods have increased cost and time-consuming in maintaining and querying indexes, resulting in a significant decline in retrieval efficiency.
By obtaining the query statement and performing named entity recognition, matching the entity list in the preset document category, searching text blocks and generating reply statements using a pre-trained language model.
It effectively reduces maintenance costs, improves the accuracy and efficiency of document retrieval, and avoids the problem of too slow query caused by the increase in information.
Smart Images

Figure CN119903175A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a document retrieval method, device, equipment and storage medium. Background Art
[0002] When searching for documents, related retrieval methods face significant challenges as the amount of knowledge base data grows rapidly. When the amount of knowledge base data is small, relevant results can be efficiently returned based on simple indexes. However, with the sharp increase in the amount of knowledge base data, the limitations of related methods have gradually become apparent. Specifically, with the increase in the number of documents and the complexity of the content in the knowledge base, the index structure has become large and complex, which not only increases the cost of maintaining and querying the index, but also increases the time consumption of the retrieval process. The demand for computing resources has also increased significantly, ultimately leading to a significant decrease in retrieval efficiency. Summary of the invention
[0003] In order to solve the above technical problems, the embodiments of the present disclosure provide a document retrieval method, apparatus, device and storage medium.
[0004] In a first aspect, an embodiment of the present disclosure provides a document retrieval method, comprising:
[0005] Obtaining a query statement, and performing named entity recognition on the query statement to obtain a first entity list;
[0006] Matching the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determining at least one candidate document category according to the generated first matching result;
[0007] Retrieving at least one text block according to the first matching result to determine a target text block, wherein the at least one text block is obtained by performing text parsing on at least one preset document included in the at least one candidate document category;
[0008] The target text block is inferred using a pre-trained language model to generate a reply statement to the query statement.
[0009] Optionally, matching the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determining at least one candidate document category according to the generated first matching result, includes:
[0010] querying whether there is a target named entity identical to at least one first named entity included in the first entity list among at least one second named entities included in the at least one second entity list, wherein the at least one second named entity is identified from a summary of at least one preset document included in the at least one preset document category;
[0011] If the target named entity does not exist, the similarity between the first entity list and the at least one second entity list is calculated; and the second entity list corresponding to the target similarity greater than a preset threshold among the at least one similarity calculated is determined as the target entity list; or,
[0012] If the target named entity exists, determining the second entity list where the target named entity is located as the target entity list;
[0013] The preset document category corresponding to the target entity list is determined as the candidate document category.
[0014] Optionally, searching at least one text block according to the first matching result to determine a target text block includes:
[0015] Screening at least one preset document included in the at least one candidate document category according to the first matching result to determine at least one candidate document;
[0016] Retrieving the at least one candidate document based on the query statement to determine a target document;
[0017] The first entity list is matched with a third entity list corresponding to the target document, and a target text block is determined from at least one text block included in the target document based on a generated second matching result, wherein the third entity list includes at least one third named entity identified from the at least one text block.
[0018] Optionally, the first matching result includes a first matching degree reflecting a matching situation between the first entity list and the at least one second entity list, and screening at least one preset document included in the at least one candidate document category according to the first matching result to determine at least one candidate document includes:
[0019] Obtaining a pre-constructed document matrix of the at least one candidate document category;
[0020] Determine a first column sequence number and a first row and column value of at least one second named entity corresponding to the at least one candidate document category in the document matrix, wherein the first column sequence number represents the column number of the second named entity in the document matrix, and the first row and column value represents the number of times the second named entity appears in at least one preset document included in the candidate document category;
[0021] Generate a first ranking result of at least one preset document included in the candidate document category according to the first matching degree, the first column sequence number and the first row and column value;
[0022] At least one candidate document is determined from at least one preset document included in the candidate document category according to the first ranking result.
[0023] Optionally, the second matching result includes a second matching degree reflecting a matching situation between the first entity list and the at least one third entity list, and determining a target text block from at least one text block included in the target document according to the generated second matching result includes:
[0024] Obtaining a pre-constructed text block matrix of the target document;
[0025] Determine a second column sequence number and a second row and column value of the at least one third named entity in the text block matrix, wherein the second column sequence number represents the column number of the third named entity in the text block matrix, and the second row and column value represents the number of times the third named entity appears in at least one text block included in the target document;
[0026] generating a second sorting result of the at least one text block according to the second matching degree, the second column sequence number and the second row and column value;
[0027] According to the second sorting result, a target text block is determined in the at least one text block.
[0028] Optionally, before obtaining the query statement, the method further includes:
[0029] Acquire the at least one preset document, and parse the at least one preset document to generate the at least one text block;
[0030] Performing named entity recognition on the at least one text block to obtain a third entity list, wherein the third entity list includes at least one third named entity;
[0031] Counting the number of times the at least one third named entity appears in the at least one text block to obtain a first occurrence number;
[0032] A text block matrix of the preset document is formed according to the third entity list, the at least one text block and the first number, wherein the columns of the text block matrix represent third named entities, the rows of the text block matrix represent text blocks, and the row and column values of the text block matrix represent the first number.
[0033] Optionally, performing named entity recognition on the at least one text block to obtain a third entity list includes:
[0034] Performing named entity recognition on the at least one text block to obtain an initial entity list, wherein the initial entity list includes at least one named entity and at least one demonstrative pronoun;
[0035] Perform semantic analysis on the at least one text block, replace the at least one demonstrative pronoun with a corresponding entity, and obtain a third entity list.
[0036] Optionally, before obtaining the query statement, the method further includes:
[0037] Performing named entity recognition on the abstract summary of the at least one preset document to obtain at least one second entity list, wherein the second entity list includes at least one second named entity;
[0038] Calculating the similarity between the at least one preset document according to the at least one second entity list, and classifying the at least one preset document into at least one preset document category according to the similarity between the at least one preset document;
[0039] Counting the number of times the at least one second named entity corresponding to the preset document category appears in at least one preset document included in the preset document category to obtain a second number;
[0040] For the preset document category, a document matrix of the preset document category is formed based on the corresponding second entity list, at least one preset document and the second number of times, wherein the columns of the document matrix represent the second named entities, the rows of the document matrix represent the preset documents, and the row and column values of the document matrix represent the second number of times.
[0041] Optionally, before performing named entity recognition on the query statement to obtain the first entity list, the method further includes:
[0042] Historical data is obtained, and the query statement is rewritten based on the historical data, wherein the historical data is key data extracted from at least one previous statement of the query statement.
[0043] In a second aspect, an embodiment of the present disclosure provides a document retrieval device, the device comprising:
[0044] An acquisition unit, configured to acquire a query statement and perform named entity recognition on the query statement to obtain a first entity list;
[0045] a matching unit, configured to match the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determine at least one candidate document category according to a generated first matching result;
[0046] a retrieval unit, configured to retrieve at least one text block according to the first matching result to determine a target text block, wherein the at least one text block is obtained by performing text parsing on at least one preset document included in the at least one candidate document category;
[0047] The inference unit is used to infer the target text block through a pre-trained language model to generate a reply sentence for the query sentence.
[0048] In a third aspect, an embodiment of the present disclosure provides a document retrieval device, including:
[0049] Memory for storing computer programs;
[0050] A processor is used to execute the computer program, and the computer program implements the steps of the first aspect method when executed by the processor.
[0051] In a fourth aspect, an embodiment of the present disclosure provides a readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the method of the first aspect when executed by a processor.
[0052] The document retrieval method provided by the present application includes: obtaining a query statement, and performing named entity recognition on the query statement to obtain a first entity list; matching the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determining at least one candidate document category according to the generated first matching result; retrieving at least one text block according to the first matching result to determine a target text block, wherein the at least one text block is obtained by performing text parsing on at least one preset document included in the at least one candidate document category; and inferring the target text block through a pre-trained language model to generate a reply statement to the query statement. The method provided by the present application avoids the problem of slow query caused by the increase of document data, which not only reduces maintenance costs, but also improves the accuracy and efficiency of document retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0055] Figure 1A flowchart of a document retrieval method provided by an embodiment of the present disclosure;
[0056] Figure 2 A schematic diagram of a document retrieval process provided by an embodiment of the present disclosure;
[0057] Figure 3 for Figure 1 A schematic diagram of a detailed process of S103 in a document retrieval method is shown;
[0058] Figure 4 A flowchart of another document retrieval method provided by an embodiment of the present disclosure;
[0059] Figure 5 A schematic diagram of forming a text block matrix provided in an embodiment of the present disclosure;
[0060] Figure 6 A flowchart of another document retrieval method provided in an embodiment of the present disclosure;
[0061] Figure 7 A schematic diagram of forming a document matrix provided in an embodiment of the present disclosure;
[0062] Figure 8 A schematic diagram of the structure of a document retrieval system provided by an embodiment of the present disclosure;
[0063] Fig. 9 A schematic diagram of the structure of a document retrieval device provided in an embodiment of the present disclosure;
[0064] Fig.10 A schematic diagram of the structure of a document retrieval device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0065] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0066] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0067] Specifically, RAG (Retrieval-Augmented Generation) is an artificial intelligence technology that combines information retrieval technology with language generation models. This technology retrieves relevant information from an external knowledge base and inputs it as a prompt to a large language model (LLMs) to enhance the model's ability to handle knowledge-intensive tasks. Although RAG retrieval is effective in improving the actual accuracy and overall quality of model output. However, there are still some limitations with RAG retrieval. Specifically, RAG retrieval treats each document as an independent piece of information. If multiple documents are described at different levels based on the same core content, RAG retrieval cannot understand the deeper relationship between different documents. Secondly, if the contextual relationship and context between different documents or different information fragments are not understood, artificial intelligence may provide incoherent retrieval content, which can easily affect the retrieval accuracy. In addition, as the amount of information grows, finding the right document becomes slower and more complicated, the retrieval process becomes more and more time-consuming, and the consumption of resources is also increasing day by day.
[0068] To sum up, in document retrieval, related technologies have problems such as increased index maintenance costs, increased retrieval time, increased resource consumption, reduced retrieval accuracy, reduced retrieval efficiency and poor user retrieval experience.
[0069] In view of the above technical problems, the present disclosure provides a document retrieval method, which is described in detail through one or more of the following embodiments.
[0070] The document retrieval method provided by the embodiment of the present disclosure can be applied to the scenario of generating a reply statement of a query statement through document retrieval. The method can be executed by a document retrieval device, which can be implemented by software and / or hardware, and the device can be integrated in a document retrieval device. Among them, the document retrieval device can include but is not limited to mobile terminals such as smart phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Tablet Personal Computers, Tablet PCs), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, smart home devices, etc.
[0071] Figure 1 A flowchart of a document retrieval method provided by an embodiment of the present disclosure specifically includes the following steps: Figure 1 The following steps are shown:
[0072] S101: Obtain a query statement, and perform named entity recognition on the query statement to obtain a first entity list.
[0073] Understandably, a query statement input by a user through a terminal device is obtained, such as "What is the weather like in place A today?". Subsequently, named entity recognition is performed on the query statement to identify key information such as nouns and verbs in the query statement, and a first entity list is obtained, wherein the first entity list includes at least one first named entity, such as at least one first named entity refers to "today", "place A", "weather", etc. The at least one identified first named entity is arranged according to its category to form an entity list, and each item in the entity list generally contains a specific entity name and its corresponding category label. The first entity list can be used to further understand the user's query intent, optimize the retrieval results, and generate more accurate answer statements. Among them, named entity recognition refers to extracting specific types of entities (such as names of people, places, names of organizations, etc.) from the input information, and the specific named entity recognition method is not limited.
[0074] Optionally, before performing named entity recognition on the query statement to obtain the first entity list, the method further includes the following steps:
[0075] Historical data is obtained, and the query statement is rewritten based on the historical data, wherein the historical data is key data extracted from at least one previous statement of the query statement.
[0076] It is understandable that before the query statement is recognized, the query statement can be rewritten to improve the accuracy of the query. Specifically, the query statement is rewritten based on the user's historical data using a language model to generate a new query statement, which is then recognized. Among them, historical data refers to key data extracted from at least one previous statement submitted by the user, such as high-frequency words, common phrases, subject words, etc. For example, the previous query statement (previous statement) is "How is the weather in place A today?", and the current query statement is "What about tomorrow?". In this case, the current query statement is rewritten to "How is the weather in place A tomorrow?" in order to better understand the user's query intent.
[0077] S102: Match the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determine at least one candidate document category according to a generated first matching result.
[0078] It can be understood that at least one preset document category is pre-constructed, and the preset document category includes at least one preset document. Named entity recognition is performed on the summary overview of the at least one preset document to construct a second entity list, that is, there is at least one second entity list corresponding to the preset document category, and the second entity list can also be understood as a specific entity list extracted based on the summary content of the document under the document category.
[0079] It is understandable that, based on the above S101, the entities in the first entity list and the entities in the second entity list corresponding to different preset document categories are compared, the degree of match between the two entity lists is calculated, and based on the degree of match, a first matching result is generated, such as a high degree of match or a low degree of match. Subsequently, based on the first matching result, the preset document category with a higher degree of match is selected as the candidate document category, that is, the preset document category most relevant to the query statement is found, thereby helping to further screen or recommend related documents. Among them, the number of candidate document categories determined is not limited. This method of performing preliminary matching between query statements and document categories through entity lists can effectively reduce the amount of data for subsequent document retrieval, solve the problem of long retrieval time and high resource consumption caused by the growth of the amount of information in the knowledge base, and further improve the retrieval efficiency.
[0080] Optionally, matching the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determining at least one candidate document category according to the generated first matching result, can be specifically implemented by the following steps:
[0081] Query whether there is a target named entity identical to at least one first named entity included in the first entity list among at least one second named entity included in the at least one second entity list, wherein the at least one second named entity is identified from a summary of at least one preset document included in the at least one preset document category; if the target named entity does not exist, calculate the similarity between the first entity list and the at least one second entity list; and determine the second entity list corresponding to the target similarity greater than a preset threshold among the at least one similarity calculated as the target entity list; or, if the target named entity exists, determine the second entity list where the target named entity is located as the target entity list; and determine the preset document category corresponding to the target entity list as the candidate document category.
[0082] It can be understood that the specific process of determining at least one candidate document category is as follows: query whether there is at least one target named entity that is the same as the first named entity included in the first entity list among all the second named entities included in the second entity list, that is, perform an exact match between the first entity list and the second entity list according to the named entity. Among them, the second named entity is identified from the summary of at least one preset document included in the preset document category. If a second entity list has a target named entity that is the same as any first named entity, then the second entity list is determined as the target entity list, and the number of target entity lists is not limited. Alternatively, if a second entity list does not have a target named entity that is the same as any first named entity, that is, the exact match fails, then a similarity match is performed between the first entity list and the second entity list, and the similarity between the two is calculated, wherein the similarity match is a matching method between complete entity lists (i.e., between all entities), and the exact match is a matching method between single named entities. At least one second entity list can calculate similarity with the first entity list respectively to obtain at least one similarity, and then the second entity list corresponding to the target similarity greater than the preset threshold in the at least one similarity is determined as the target entity list. Subsequently, the preset document category corresponding to the target entity list is determined as the candidate document category.
[0083] S103: Retrieve at least one text block according to the first matching result to determine a target text block, wherein the at least one text block is obtained by performing text analysis on at least one preset document included in the at least one candidate document category.
[0084] It is understandable that, based on the above S102, after the candidate document category related to the user query is determined, a specific text block is further retrieved from the candidate document of this category to find the specific content that best matches the user query. The text block is parsed from the candidate document of this category, and a document can be decomposed into multiple text blocks, each of which can be a paragraph, chapter or text fragment. The specific parsing method for parsing the text block from the document is not limited.
[0085] S104: Inferring the target text block through a pre-trained language model to generate a reply statement for the query statement.
[0086] It is understandable that, based on the above S103, the target text block and the query sentence are used as the input of the pre-trained language model, and the language model will encode the target text block and the query sentence, and generate a reply sentence that conforms to the context according to the encoding result. The reply sentence can be a complete sentence, paragraph, keyword or phrase. For example, based on the above example, the reply sentence is "sunny" or "It will be sunny in place A tomorrow". Among them, the language model has been trained on a large amount of text data and has a strong natural language understanding and generation capability.
[0087] For example, see Figure 2 , Figure 2 A schematic diagram of a document retrieval process is provided for an embodiment of the present disclosure, wherein the document retrieval process includes query rewriting, named entity recognition, document aggregation categories, text block retrieval and model reasoning, wherein query rewriting is the process of rewriting query statements, named entity recognition is the process of identifying rewritten statements, document aggregation categories are the process of screening documents based on rewritten statements and entity lists, text block retrieval is the process of screening out text blocks that have semantic connections with rewritten statements from documents, and model reasoning is the process of inferring reply statements of rewritten statements based on text block contents. The specific implementation instructions of each process refer to the above embodiments and are not repeated here.
[0088] The document retrieval method provided by the embodiment of the present disclosure rewrites the query statement so that the subsequent language model can better understand the user's query intention. Through the preliminary matching of the first entity list and the preset document category corresponding to the second entity list, the candidate document class is determined, and then the text block is retrieved from the candidate document class. The method of performing preliminary matching according to the document category solves the problem of slow query caused by the increase in information volume, and further improves the retrieval efficiency.
[0089] Based on the above embodiments, Figure 3 for Figure 1 The detailed flow diagram of S103 in a document retrieval method shown in FIG. 1 is as follows. Optionally, searching for at least one text block according to the first matching result to determine a target text block specifically includes: Figure 3 The following steps are shown:
[0090] S301. Screen at least one preset document included in the at least one candidate document category according to the first matching result to determine at least one candidate document.
[0091] It is understandable that based on the matching results of the first entity list and the second entity list corresponding to the preset document category, the candidate document category most likely to contain content related to the user's query can be determined. Subsequently, by performing a detailed analysis on at least one preset document included in the candidate document category, the relevance of different preset documents to the user's query content is calculated to ensure that the selected candidate documents do contain the query content. Specifically, the at least one preset document included in the candidate document category can be sorted and screened according to the relevance score, and the most relevant preset document can be selected as the candidate document. A minimum relevance threshold can also be set or the top N preset documents after sorting can be selected as the candidate documents.
[0092] The first matching result includes a first matching degree reflecting a matching situation between the first entity list and the at least one second entity list.
[0093] Optionally, screening at least one preset document included in the at least one candidate document category according to the first matching result to determine at least one candidate document may be specifically implemented through the following steps:
[0094] Obtain a pre-constructed document matrix of at least one candidate document category; determine a first column number and a first row and column value of at least one second named entity corresponding to the at least one candidate document category in the document matrix, wherein the first column number represents the number of columns of the second named entity in the document matrix, and the first row and column value represents the number of times the second named entity appears in at least one preset document included in the candidate document category; generate a first sorting result of at least one preset document included in the candidate document category based on the first matching degree, the first column number and the first row and column value; and determine at least one candidate document from the at least one preset document included in the candidate document category based on the first sorting result.
[0095] It can be understood that a document matrix of a candidate document category is obtained, and the document matrix is constructed based on an entity list of at least one preset document included in the candidate document category, wherein the document matrix is a structured data representation, and each column represents a second named entity (such as "weather", "tomorrow", "A place", etc. in the above examples), and each second named entity has a column number, such as "weather" is in the first column, the column number is 1, "A place" is in the third column, and the column number is 3, each row represents a preset document, and each preset document has a row number, and the value in each cell (row and column value, cell value) represents the number of times a specific named entity appears in a specific document, such as the row and column value of the first row and the first column (1, 1) is 1, indicating that "weather" appears once in preset document 1.
[0096] Understandably, the first column number and the first row and column value of the second named entity corresponding to the candidate document category in the document matrix are determined, the first column number represents the column position of a second named entity in the document matrix, and the first row and column value represents the number of times a second named entity appears in each preset document. Subsequently, the product of the first matching degree, the first column number and the first row and column value is calculated to obtain the corresponding value of a second named entity, wherein a preset document has a second entity list, a second entity list includes at least one second named entity, and the sum of the corresponding values of at least one second named entity is recorded as the total corresponding value of the second entity list, and a total corresponding value can be calculated for each preset document. Subsequently, the preset documents are sorted according to the total corresponding values of the preset documents, and the preset documents with the highest ranking are selected as candidate documents. The number of preset documents is not limited, that is, the matching degree between the named entities and the frequency of occurrence of the named entities are comprehensively considered to generate the final sorting result. All preset documents included in the candidate document category can be sorted in the above manner, and then at least one preset document is selected as a candidate document. The candidate document is the one that is most likely to contain the user's query content. This method not only improves the accuracy of retrieval, but also locates relevant documents more efficiently, thereby improving user experience. The ranking calculation formula of the preset document is shown in formula (1).
[0097]
[0098] Where X represents the total corresponding value of the preset document, N i represents the i-th second named entity, S i V represents the first matching degree between the i-th second named entity and the first named entity. When the first entity list and the second entity list are exactly matched, the first matching degree is 1, that is, the two are exactly the same. When the first entity list and the second entity list are similarly matched, the first matching degree is the similarity, and the similarity range is between 0 and 1. i It is the row and column value of the i-th second named entity in the document matrix.
[0099] S302: Retrieve the at least one candidate document based on the query statement to determine a target document.
[0100] It can be understood that, based on the above S301, based on the query statement, at least one candidate document is subjected to RAG (Retrieval-Augmented Generation) retrieval to determine the target document. RAG retrieval can be understood as a technology that combines information retrieval and text generation.
[0101] S303: Match the first entity list with a third entity list corresponding to the target document, and determine a target text block from at least one text block included in the target document according to the generated second matching result.
[0102] The third entity list includes at least one third named entity identified from the at least one text block.
[0103] It is understandable that, based on the above S302, the preset document has a second entity list generated based on the summary, and the text blocks decomposed from the preset document have a third entity list. The third entity list corresponding to the target document refers to the third entity list of at least one text block decomposed from it. The entities in the third entity list and the first entity list are matched, and the similarity or matching degree between the two is calculated to generate a second matching result. The second matching result reflects the relevance of each text block to the user's query content. Subsequently, according to the second matching result, at least one text block with a higher relevance is selected from each text block of the target document as the target text block.
[0104] It can be understood that the entire process of determining the target text block includes: determining a candidate document category in at least one preset document category, determining a candidate document in at least one preset document under the candidate document category, and determining the target text in at least one text block decomposed from the candidate document. This method of utilizing document aggregation categories effectively avoids the problem of slow queries under massive data.
[0105] The second matching result includes a second matching degree reflecting a matching situation between the first entity list and the at least one third entity list.
[0106] Optionally, determining the target text block from at least one text block included in the target document according to the generated second matching result can be specifically implemented by the following steps:
[0107] Acquire a pre-constructed text block matrix of the target document; determine the second column sequence number and the second row and column value of the at least one third named entity in the text block matrix, wherein the second column sequence number represents the column number of the third named entity in the text block matrix, and the second row and column value represents the number of times the third named entity appears in at least one text block included in the target document; generate a second sorting result of the at least one text block according to the second matching degree, the second column sequence number and the second row and column value; and determine the target text block in the at least one text block according to the second sorting result.
[0108] It is understandable that there is a pre-constructed text block matrix for the target document, and the text block matrix is constructed based on at least one third named entity identified in at least one text block into which the target document is decomposed, wherein the text block matrix is also a structured data representation, wherein columns represent different third named entities, rows represent different text blocks, and row and column values represent the number of times a certain third named entity appears in a certain text block.
[0109] It can be understood that the second column number is the column position of the third named entity in the text block matrix, which can locate the specific position of the entity in the text block matrix. For example, the column number of "AA"' is 3, which is the third column in the text block matrix. The second row and column value is the number of times the third named entity appears in each text block, reflecting the importance of the entity in the text block. For example, in a certain text block, "AA"' appears 4 times, and the corresponding cell value (row and column value) is 4. The second matching degree characterizes the degree of matching between the third named entity and the first named entity, which can be determined by an exact match or a similar match. For the specific instructions on determining the target text block based on the second matching degree, the second column number and the second row and column value, please refer to the above-mentioned instructions for determining the candidate document in at least one preset document under the candidate document class, which will not be repeated here.
[0110] A document retrieval method provided by the embodiment of the present disclosure can, in the process of determining a target text block, understand the connection between preset documents included in a candidate document class through a document matrix, and then accurately determine the candidate document; and understand the semantic connection between text blocks included in the candidate document through a text block matrix, and infer the deeper relationship between different text blocks, so as to facilitate the determination of the content fragments most relevant to the user's query content, and then accurately determine the target text block. Not only the retrieval accuracy is improved, but the aggregation method between documents can also more accurately locate the specific content block, further improving the retrieval efficiency and user experience.
[0111] Based on the above embodiments, Figure 4 A flowchart of another document retrieval method provided by an embodiment of the present disclosure. Optionally, before obtaining the query statement, a text block matrix needs to be constructed, wherein the text block matrix reflects the semantic relationship between text blocks belonging to the same document, specifically including the following: Figure 4 The following steps are shown:
[0112] S401: Acquire the at least one preset document, and parse the at least one preset document to generate the at least one text block.
[0113] Understandably, at least one preset document stored in a database or file system is obtained. Subsequently, the preset document is parsed and decomposed into smaller, easier-to-process text blocks. A text block refers to a smaller unit after the document is decomposed. Specifically, it can be parsed by segmentation, division, and keyword extraction. A text block can be understood as a paragraph or a group of related sentences. The specific decomposition of the text block can be determined by the user according to the user's needs.
[0114] S402: Perform named entity recognition on the at least one text block to obtain a third entity list.
[0115] The third entity list includes at least one third named entity.
[0116] It is understandable that, based on the above S401, each text block can identify at least one third named entity, at least one third named entity can form a third entity list, and a preset document including at least one text block has at least one corresponding third entity list.
[0117] Optionally, performing named entity recognition on the at least one text block to obtain a third entity list may be specifically implemented by the following steps:
[0118] Perform named entity recognition on the at least one text block to obtain an initial entity list, wherein the initial entity list includes at least one named entity and at least one demonstrative pronoun; perform semantic analysis on the at least one text block, replace the at least one demonstrative pronoun with a corresponding entity, and obtain a third entity list.
[0119] Understandably, named entity recognition is performed on the text block to extract key information such as nouns, verbs and demonstrative pronouns in the text block to form an initial entity list, that is, the initial entity list contains not only named entities, but also demonstrative pronouns that have appeared in the text block (such as "you, me, it, he, she, this", etc.). Subsequently, semantic analysis technology is used to understand the contextual information between text blocks, determine the specific entities referred to by demonstrative pronouns, and replace demonstrative pronouns with entities actually referred to in the context, thereby generating a more complete third entity list, which helps to improve the accuracy of entity recognition, especially when processing text blocks with a large number of demonstrative pronouns, so as to better understand the true meaning of the text blocks.
[0120] Based on the above example, text block 1 is “AA held a technical conference in B, and it proposed...”, where the demonstrative pronoun “it” refers to “AA”′, and “AA” is the identified entity.
[0121] It is understandable that after replacing the demonstrative pronouns with the corresponding entities, the demonstrative pronouns in the text block are replaced synchronously, that is, the demonstrative pronouns in the text block are represented by entities to obtain the replaced text block. For example, the replaced text block 1 is "AA held a technical conference in B, and AA proposed..."
[0122] S403: Count the number of times the at least one third named entity appears in the at least one text block to obtain a first occurrence number.
[0123] It is understandable that, based on the above S402, for each named entity, a count is performed in each initial text block or replaced text block to record the number of times the entity appears.
[0124] S404: Form a text block matrix of the preset document according to the third entity list, the at least one text block and the first number of times.
[0125] The columns of the text block matrix represent the third named entity, the rows of the text block matrix represent the text blocks, and the values of the rows and columns of the text block matrix represent the first times.
[0126] It can be understood that, based on the above S403, the third named entity is used as the column of the text block matrix, the text block is used as the row of the text block matrix, and the number of times each entity appears in each text block is used as the row and column values to form the text block matrix of the preset document. The two-dimensional table form of the text block matrix is shown in Table 1.
[0127] Table 1:
[0128] N1 ... N C1 1 ... 2 C2 1 ... 0 C3 1 ... 1
[0129] In Table 1, N represents an entity, C represents a text block, and the value in the matrix represents the number of times the entity appears in the text block. For example, the value 2 at the position (1, n) in the matrix means that entity Nn appears twice in text block C1.
[0130] In a possible embodiment, the target document is decomposed into the following three text blocks and has the following named entities. The three text blocks are all replacement text blocks after the demonstrative pronouns replace the entities, wherein:
[0131] Text block 1: "AA held a technical conference in B, and AA proposed..."
[0132] Text block 2: "At the conference, AA demonstrated the latest technology D."
[0133] Text block 3: "D will be gradually extended to C in the coming months."
[0134] In this case, "AA" appears twice in text block 1, once in text block 2, and zero in text block 3. "B" appears only once in text block 1, and "C" appears only once in text block 3. The two-dimensional table form of the text block matrix is shown in Table 2.
[0135] Table 2:
[0136] AA B C Text Block 1 2 1 0 Text Block 2 1 0 0 Text Block 3 0 0 1
[0137] For example, Figure 5 A schematic diagram of forming a text block matrix is provided for an embodiment of the present disclosure. The formation process of the text block matrix involves a document, multiple text blocks, named entities and a text block matrix. The document is parsed to obtain multiple text blocks, and named entity recognition is performed on each text block to obtain multiple entities. A text block matrix is constructed based on the multiple entities and the multiple text blocks. In the subsequent text retrieval process, the target text block in the target document can be accurately located based on the text block matrix.
[0138] A document retrieval method provided by an embodiment of the present disclosure constructs a text block matrix that can reflect the contextual relationship between multiple text blocks included in a document, which helps to better understand the text content during the text retrieval process and provide more accurate data support.
[0139] Based on the above embodiments, Figure 6 A flowchart of another document retrieval method provided in an embodiment of the present disclosure is provided. Before obtaining the query statement, a document matrix representing the semantic relationship between documents needs to be constructed, which specifically includes the following steps: Figure 6 The following steps are shown:
[0140] S601: Perform named entity recognition on the abstract summary of the at least one preset document to obtain at least one second entity list.
[0141] The second entity list includes at least one second named entity.
[0142] It can be understood that the summary is a brief summary generated from a preset document, which can represent the core content of the preset document. Subsequently, named entity recognition is performed on the summary to extract named entities (such as names, place names, organizational structures, etc.) and form a second entity list.
[0143] Optionally, performing named entity recognition on the abstract summary of the at least one preset document to obtain at least one second entity list may be specifically implemented by the following steps:
[0144] Perform named entity recognition on the at least one abstract summary to obtain an initial entity list, wherein the initial entity list includes at least one named entity and at least one demonstrative pronoun; perform semantic analysis on the at least one abstract summary, replace the at least one demonstrative pronoun with a corresponding entity, and obtain a second entity list.
[0145] It can be understood that the specific implementation steps refer to the implementation steps of the third entity list mentioned above, which will not be repeated here.
[0146] It can be understood that after the demonstrative pronouns are replaced with the corresponding entities, the demonstrative pronouns in the summary overview are simultaneously replaced to obtain the replaced summary overview.
[0147] S602: Calculate the similarity between the at least one preset document according to the at least one second entity list, and classify the at least one preset document into at least one preset document category according to the similarity between the at least one preset document.
[0148] It is understandable that, based on the above S601, the similarity between the preset documents is calculated by calculating the similarity between the named entities in the second entity list. Subsequently, based on the similarity result, at least one preset document is divided into different categories, for example, documents with high similarity are classified into the same category. Other document category division methods are not limited.
[0149] S603: Count the number of times the at least one second named entity corresponding to the preset document category appears in at least one preset document included in the preset document category to obtain a second number.
[0150] It can be understood that, based on the above S602, each preset document category includes at least one preset document, and each preset summary overview is identified to obtain at least one second named entity. In this case, for each preset document category, the number of times each corresponding second named entity appears in all preset documents under the category is counted to obtain the second number, wherein the second number records the number of times each second named entity appears in each preset document.
[0151] S604: For the preset document category, form a document matrix of the preset document category according to the corresponding second entity list, at least one preset document and the second number of times.
[0152] The columns of the document matrix represent the second named entities, the rows of the document matrix represent the preset documents, and the values of the rows and columns of the document matrix represent the second times.
[0153] It is understandable that, based on the above S603, a document matrix is constructed for each preset document category. The formation of the document matrix according to the second entity list, at least one preset document and the second number of times refers to the formation process of the above text block matrix, which will not be repeated here. Among them, the document matrix can also be expressed as a two-dimensional matrix, wherein the columns of the document matrix represent the named entities extracted from the preset documents, the rows of the document matrix represent the preset documents, and each cell value in the document matrix represents the number of times the named entity appears in the preset document. The two-dimensional table form of the document matrix is shown in Table 3.
[0154] Table 3:
[0155] N1 ... N D1 1 ... 2 D2 1 ... 0 D3 1 ... 1
[0156] In Table 3, D represents a text block, and the cell value represents the number of times an entity appears in a document. For example, the value 2 at position (1, n) in the matrix means that entity Nn appears twice in document D1.
[0157] For example, Figure 7 A schematic diagram of forming a document matrix is provided for an embodiment of the present disclosure. The formation process of the document matrix involves multiple documents, abstract summarization, named entity recognition, document classification and document matrix formation, wherein each document is summarized. On the one hand, the main / core / key entities of the document can be understood through the summary overview. On the other hand, the amount of data for named entity recognition can be reduced compared to the entire document. On the other hand, the construction of the above text block matrix can already understand the complete / full / all entities of the document. Subsequently, named entity recognition is performed on each abstract overview, and the documents are classified according to the similarity between the entities included in the document. A document matrix is constructed for each type of document, that is, a document matrix of different preset document categories is constructed. The specific description of the formation process can be found in the above embodiment, which will not be repeated here.
[0158] The document retrieval method provided by the embodiment of the present disclosure constructs a document matrix capable of representing the contextual connections between documents belonging to the same document category, which helps to better understand and process a large amount of document data and improve the accuracy and efficiency of retrieval.
[0159] Based on the above embodiments, Figure 8A schematic diagram of the structure of a document retrieval system provided in an embodiment of the present disclosure, the document retrieval system includes query rewriting, document parsing, embedding model, vector library, text retrieval, large model reasoning and output answer, wherein query rewriting is used to rewrite query statements in combination with the contextual semantics between query statements, document parsing is used to parse documents into multiple text blocks and build text block matrix and document matrix, embedding model is used to vectorize query statements and parsing results and store them in vector library, text retrieval is used to retrieve relevant text blocks in vector library based on query statements, large model LLM is used to reason about text block content to generate answer statements and output them as answers. The detailed description of each module of the document retrieval system can be found in the above embodiment and will not be repeated here.
[0160] Fig. 9 The document retrieval device provided by the embodiment of the present disclosure can execute the processing flow provided by the document retrieval method embodiment, such as Fig. 9 As shown, the document retrieval device 900 includes an acquisition unit 901, a matching unit 902, a retrieval unit 903 and an inference unit 904, wherein:
[0161] An acquisition unit 901 is used to acquire a query statement and perform named entity recognition on the query statement to obtain a first entity list;
[0162] A matching unit 902, configured to match the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determine at least one candidate document category according to a generated first matching result;
[0163] A retrieval unit 903 is configured to retrieve at least one text block according to the first matching result to determine a target text block, wherein the at least one text block is obtained by performing text parsing on at least one preset document included in the at least one candidate document category;
[0164] The reasoning unit 904 is used to reason about the target text block through a pre-trained language model to generate a reply statement for the query statement.
[0165] Optionally, the matching unit 902 is used for:
[0166] querying whether there is a target named entity identical to at least one first named entity included in the first entity list among at least one second named entities included in the at least one second entity list, wherein the at least one second named entity is identified from a summary of at least one preset document included in the at least one preset document category;
[0167] If the target named entity does not exist, the similarity between the first entity list and the at least one second entity list is calculated; and the second entity list corresponding to the target similarity greater than a preset threshold among the at least one similarity calculated is determined as the target entity list; or,
[0168] If the target named entity exists, determining the second entity list where the target named entity is located as the target entity list;
[0169] The preset document category corresponding to the target entity list is determined as the candidate document category.
[0170] Optionally, the retrieval unit 903 is used to:
[0171] Screening at least one preset document included in the at least one candidate document category according to the first matching result to determine at least one candidate document;
[0172] Retrieving the at least one candidate document based on the query statement to determine a target document;
[0173] The first entity list is matched with a third entity list corresponding to the target document, and a target text block is determined from at least one text block included in the target document based on a generated second matching result, wherein the third entity list includes at least one third named entity identified from the at least one text block.
[0174] Optionally, the first matching result includes a first matching degree reflecting a matching situation between the first entity list and the at least one second entity list.
[0175] Optionally, the retrieval unit 903 is used to:
[0176] Obtaining a pre-constructed document matrix of the at least one candidate document category;
[0177] Determine a first column sequence number and a first row and column value of at least one second named entity corresponding to the at least one candidate document category in the document matrix, wherein the first column sequence number represents the column number of the second named entity in the document matrix, and the first row and column value represents the number of times the second named entity appears in at least one preset document included in the candidate document category;
[0178] Generate a first ranking result of at least one preset document included in the candidate document category according to the first matching degree, the first column sequence number and the first row and column value;
[0179] At least one candidate document is determined from at least one preset document included in the candidate document category according to the first ranking result.
[0180] Optionally, the second matching result includes a second matching degree reflecting a matching situation between the first entity list and the at least one third entity list.
[0181] Optionally, the retrieval unit 903 is used to:
[0182] Obtaining a pre-constructed text block matrix of the target document;
[0183] Determine a second column sequence number and a second row and column value of the at least one third named entity in the text block matrix, wherein the second column sequence number represents the column number of the third named entity in the text block matrix, and the second row and column value represents the number of times the third named entity appears in at least one text block included in the target document;
[0184] generating a second sorting result of the at least one text block according to the second matching degree, the second column sequence number and the second row and column value;
[0185] According to the second sorting result, a target text block is determined in the at least one text block.
[0186] Optionally, the document retrieval device 900 is further used for:
[0187] Acquire the at least one preset document, and parse the at least one preset document to generate the at least one text block;
[0188] Performing named entity recognition on the at least one text block to obtain a third entity list, wherein the third entity list includes at least one third named entity;
[0189] Counting the number of times the at least one third named entity appears in the at least one text block to obtain a first occurrence number;
[0190] A text block matrix of the preset document is formed according to the third entity list, the at least one text block and the first number, wherein the columns of the text block matrix represent third named entities, the rows of the text block matrix represent text blocks, and the row and column values of the text block matrix represent the first number.
[0191] Optionally, performing named entity recognition on the at least one text block to obtain a third entity list includes:
[0192] Performing named entity recognition on the at least one text block to obtain an initial entity list, wherein the initial entity list includes at least one named entity and at least one demonstrative pronoun;
[0193] Perform semantic analysis on the at least one text block, replace the at least one demonstrative pronoun with a corresponding entity, and obtain a third entity list.
[0194] Optionally, the document retrieval device 900 is further used for:
[0195] Performing named entity recognition on the abstract summary of the at least one preset document to obtain at least one second entity list, wherein the second entity list includes at least one second named entity;
[0196] Calculating the similarity between the at least one preset document according to the at least one second entity list, and classifying the at least one preset document into at least one preset document category according to the similarity between the at least one preset document;
[0197] Counting the number of times the at least one second named entity corresponding to the preset document category appears in at least one preset document included in the preset document category to obtain a second number;
[0198] For the preset document category, a document matrix of the preset document category is formed based on the corresponding second entity list, at least one preset document and the second number of times, wherein the columns of the document matrix represent the second named entities, the rows of the document matrix represent the preset documents, and the row and column values of the document matrix represent the second number of times.
[0199] Optionally, the document retrieval device 900 is further used for:
[0200] Historical data is obtained, and the query statement is rewritten based on the historical data, wherein the historical data is key data extracted from at least one previous statement of the query statement.
[0201] Fig. 9 The document retrieval device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be described in detail here.
[0202] Fig.10 A schematic diagram of the structure of a document retrieval device provided by an embodiment of the present disclosure. Fig.10 , which shows a schematic diagram of the structure of the electronic device 100 suitable for implementing the embodiment of the present disclosure. The electronic device 100 in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Fig.10The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0203] like Fig.10 As shown, the electronic device 100 may include a processing device 101 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 102 or a program loaded from a storage device 108 to a random access memory (RAM) 103 to implement the document retrieval method of the embodiment described in the present disclosure. In the RAM 103, various programs and data required for the operation of the electronic device 100 are also stored. The processing device 101, the ROM 102, and the RAM 103 are connected to each other via a bus 104. An input / output (I / O) interface 105 is also connected to the bus 104.
[0204] Typically, the following devices may be connected to the I / O interface 105: an input device 106 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 107 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 108 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 109. The communication device 109 may allow the electronic device 100 to communicate with other devices wirelessly or by wire to exchange data. Fig.10 The electronic device 100 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0205] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the document retrieval method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 109, or installed from the storage device 108, or installed from the ROM 102. When the computer program is executed by the processing device 101, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0206] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0207] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0208] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
Claims
1. A document retrieval method, characterized in that: The method comprises: Obtaining a query statement, and performing named entity recognition on the query statement to obtain a first entity list; Matching the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determining at least one candidate document category according to the generated first matching result; Retrieving at least one text block according to the first matching result to determine a target text block, wherein the at least one text block is obtained by performing text parsing on at least one preset document included in the at least one candidate document category; The target text block is inferred using a pre-trained language model to generate a reply statement to the query statement.
2. The method according to claim 1, characterized in that The matching of the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determining at least one candidate document category according to the generated first matching result, includes: querying whether there is a target named entity identical to at least one first named entity included in the first entity list among at least one second named entities included in the at least one second entity list, wherein the at least one second named entity is identified from a summary of at least one preset document included in the at least one preset document category; If the target named entity does not exist, the similarity between the first entity list and the at least one second entity list is calculated; and the second entity list corresponding to the target similarity greater than a preset threshold among the at least one similarity calculated is determined as the target entity list; or, If the target named entity exists, determining the second entity list where the target named entity is located as the target entity list; The preset document category corresponding to the target entity list is determined as the candidate document category.
3. The method according to claim 1, characterized in that The step of searching at least one text block according to the first matching result to determine a target text block includes: Screening at least one preset document included in the at least one candidate document category according to the first matching result to determine at least one candidate document; Retrieving the at least one candidate document based on the query statement to determine a target document; The first entity list is matched with a third entity list corresponding to the target document, and a target text block is determined from at least one text block included in the target document based on a generated second matching result, wherein the third entity list includes at least one third named entity identified from the at least one text block.
4. The method according to claim 3, characterized in that The first matching result includes a first matching degree reflecting a matching situation between the first entity list and the at least one second entity list, and the screening of at least one preset document included in the at least one candidate document category according to the first matching result to determine at least one candidate document includes: Obtaining a pre-constructed document matrix of the at least one candidate document category; Determine a first column sequence number and a first row and column value of at least one second named entity corresponding to the at least one candidate document category in the document matrix, wherein the first column sequence number represents the column number of the second named entity in the document matrix, and the first row and column value represents the number of times the second named entity appears in at least one preset document included in the candidate document category; Generate a first ranking result of at least one preset document included in the candidate document category according to the first matching degree, the first column sequence number and the first row and column value; At least one candidate document is determined from at least one preset document included in the candidate document category according to the first ranking result.
5. The method according to claim 3, characterized in that: The second matching result includes a second matching degree reflecting a matching situation between the first entity list and the at least one third entity list, and determining a target text block from at least one text block included in the target document according to the generated second matching result includes: Obtaining a pre-constructed text block matrix of the target document; Determine a second column sequence number and a second row and column value of the at least one third named entity in the text block matrix, wherein the second column sequence number represents the column number of the third named entity in the text block matrix, and the second row and column value represents the number of times the third named entity appears in at least one text block included in the target document; generating a second sorting result of the at least one text block according to the second matching degree, the second column sequence number and the second row and column value; According to the second sorting result, a target text block is determined in the at least one text block.
6. The method according to claim 1, characterized in that Before obtaining the query statement, the method further includes: Acquire the at least one preset document, and parse the at least one preset document to generate the at least one text block; Performing named entity recognition on the at least one text block to obtain a third entity list, wherein the third entity list includes at least one third named entity; Counting the number of times the at least one third named entity appears in the at least one text block to obtain a first occurrence number; A text block matrix of the preset document is formed according to the third entity list, the at least one text block and the first number, wherein the columns of the text block matrix represent third named entities, the rows of the text block matrix represent text blocks, and the row and column values of the text block matrix represent the first number.
7. The method according to claim 6, characterized in that Performing named entity recognition on the at least one text block to obtain a third entity list includes: Performing named entity recognition on the at least one text block to obtain an initial entity list, wherein the initial entity list includes at least one named entity and at least one demonstrative pronoun; Perform semantic analysis on the at least one text block, replace the at least one demonstrative pronoun with a corresponding entity, and obtain a third entity list.
8. The method according to claim 6, characterized in that Before obtaining the query statement, the method further includes: Performing named entity recognition on the abstract summary of the at least one preset document to obtain at least one second entity list, wherein the second entity list includes at least one second named entity; Calculating the similarity between the at least one preset document according to the at least one second entity list, and classifying the at least one preset document into at least one preset document category according to the similarity between the at least one preset document; Counting the number of times the at least one second named entity corresponding to the preset document category appears in at least one preset document included in the preset document category to obtain a second number; For the preset document category, a document matrix of the preset document category is formed based on the corresponding second entity list, at least one preset document and the second number of times, wherein the columns of the document matrix represent the second named entities, the rows of the document matrix represent the preset documents, and the row and column values of the document matrix represent the second number of times.
9. The method according to claim 1, characterized in that: Before performing named entity recognition on the query statement to obtain a first entity list, the method further includes: Historical data is obtained, and the query statement is rewritten based on the historical data, wherein the historical data is key data extracted from at least one previous statement of the query statement.
10. A document retrieval device, characterized in that: The device comprises: An acquisition unit, configured to acquire a query statement and perform named entity recognition on the query statement to obtain a first entity list; a matching unit, configured to match the first entity list with at least one second entity list corresponding to at least one pre-constructed preset document category, and determine at least one candidate document category according to a generated first matching result; a retrieval unit, configured to retrieve at least one text block according to the first matching result to determine a target text block, wherein the at least one text block is obtained by performing text parsing on at least one preset document included in the at least one candidate document category; The inference unit is used to infer the target text block through a pre-trained language model to generate a reply statement for the query statement.
11. A document retrieval device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the document retrieval method according to any one of claims 1 to 9 are implemented.
12. A 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 document retrieval method according to any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Retrieval enhancement generation method based on theme enhancement and related products
CN121166749A