A text query method, device and equipment and storage medium

By segmenting text into text blocks and constructing a text tree, and using a retrieval model to determine the index sequence, the problem of inaccurate querying in long documents by the RAG model is solved, and more accurate text summarization is achieved.

CN119293268BActive Publication Date: 2025-12-16DIGITAL GUANGDONG NETWORK CONSTR CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411453243.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-12-16
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

In existing technologies, the Retrieval-Augmented Generation (RAG) model struggles to effectively handle the complex structures and information in long documents, leading to inaccurate query results or omission of key information.

Method used

The text is segmented into multiple text blocks, a text tree is constructed through clustering, and the identifier of each text block is determined. A pre-trained retrieval model is used to determine the index sequence of the query question in the text tree, and finally the text blocks are spliced ​​together to form an accurate text summary.

Benefits of technology

It improves the accuracy of text queries, ensuring the complete extraction of key information and the precision of query results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119293268B_ABST
    Figure CN119293268B_ABST
Patent Text Reader

Abstract

The application discloses a text query method and device, equipment and storage medium, and relates to the technical field of computers. The method comprises the following steps: after a text is divided into a plurality of text blocks, a text tree is constructed by clustering the text blocks, and identifiers of the text blocks in the text tree are determined; a query question is input into a pre-trained retrieval model, so that the retrieval model determines an index sequence corresponding to the query question in the text tree, the retrieval model being trained according to index sequences of a plurality of query questions corresponding to a text and important sentences corresponding to the text; and a text summary corresponding to the query question is determined according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree. According to the technical solution, the text tree retains low-level details and high-level themes of the text, and the text summary of the query question is more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of computer technology, and particularly relate to a text query method, device, equipment and storage medium. BACKGROUND

[0002] In the information explosion era, faced with massive data, effective ways are needed to help users retrieve, extract and integrate information. Document retrieval generation (RAG) is a model that combines retrieval and generation techniques, retrieves relevant information in a large-scale document set, and uses this information to guide text generation.

[0003] In the prior art, RAG can be used to query the content required by the user in the document.

[0004] However, RAG often has difficulty effectively processing complex structures and information in long documents, which can result in inaccurate query results or missing key information. SUMMARY

[0005] The present application provides a text query method, device, equipment and storage medium to determine the text summary corresponding to the query question in the text and improve the query accuracy.

[0006] In a first aspect, the embodiments of the present application provide a text query method, comprising:

[0007] After the text is divided into multiple text blocks, a text tree is constructed by clustering the text blocks, and the identifiers of the text blocks in the text tree are determined;

[0008] The query question is input into a pre-trained retrieval model to enable the retrieval model to determine the index sequence corresponding to the query question in the text tree, wherein the retrieval model is trained according to the index sequence of the important sentences corresponding to the multiple query questions and the text;

[0009] According to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree, the text summary corresponding to the query question is determined.

[0010] The technical scheme of the embodiment of the application provides a text query method, which comprises the following steps: after a text is divided into a plurality of text blocks, a text tree is constructed by clustering the text blocks, and identifiers of the text blocks in the text tree are determined; a query question is input into a pre-trained retrieval model, so that the retrieval model determines an index sequence corresponding to the query question in the text tree, wherein the retrieval model is trained according to a plurality of query questions corresponding to a text and index sequences of important sentences corresponding to the text; and a text summary corresponding to the query question is determined according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree. The above technical scheme can first divide the text into a plurality of text blocks by segmenting the text, and then construct a text tree according to the clustering results of the text blocks, and determine the identifiers of the text blocks in the text tree. The construction of the text tree and the determination of the identifiers of the text blocks in the text tree are realized according to the clustering results. The text tree retains the low-level details and high-level themes of the text. The identifiers of the text blocks in the text tree provide a query basis for text query based on the text tree. The query question is input into the pre-trained retrieval model, and the retrieval model can determine the index sequence corresponding to the query question in the text tree. The text blocks corresponding to the index sequence are determined at each layer in the text tree by comparing the index sequence and the identifiers of the text blocks in the text tree. The text summary is obtained by sequentially splicing the text blocks, and a more accurate text summary of the query question is determined.

[0011] Further, the text tree is constructed by clustering the text blocks, and the identifiers of the text blocks in the text tree are determined, which comprises the following steps:

[0012] The text blocks are divided into at least two text block sets by clustering the text blocks, so that the aggregation loss of each text block set is minimized. In a case where the number of text blocks contained in the text block set is greater than a number threshold, the text blocks contained in the text block set are taken as clustering objects, and the step of dividing the text blocks into at least two text block sets by clustering the text blocks is executed again until the number of text blocks contained in each text block set is not greater than the number threshold. The text tree is constructed according to the clustering results, and the identifiers of the text blocks in the text tree are determined.

[0013] Further, the text blocks are divided into at least two text block sets by clustering the text blocks, so that the aggregation loss of each text block set is minimized, which comprises the following steps:

[0014] divide the text blocks into 2-N text block sets respectively, and determine the aggregation loss corresponding to each division result, wherein N is the number of the text blocks; and determine the division result corresponding to the minimum aggregation loss as the target division result.

[0015] Further, constructing the text tree according to the clustering results comprises:

[0016] constructing the first layer of the text tree according to the first clustering results of the text blocks, wherein the nodes of the text tree represent each text block set corresponding to the first clustering results; and successively constructing the next layer of the text tree according to the clustering results of each text block set containing more text blocks than the number threshold, until each text block set contains no more text blocks than the number threshold, to obtain the text tree.

[0017] Further, determining the identifiers of the text blocks in the text tree comprises:

[0018] allocating a set number to each text block set of each layer of the text tree, and allocating a text number to each text block in each text block set, and determining the identifiers of the text blocks according to the text numbers of the text blocks and the set numbers of the text block sets to which the text blocks belong.

[0019] Further, the training step of the retrieval model comprises:

[0020] inputting each text used for constructing the text tree into a pre-trained query question generation model multiple times, so that the query question generation model determines multiple query questions corresponding to each text; determining important sentences corresponding to each text, and determining the index sequence of the important sentences in the text tree; performing model training by taking each query question corresponding to each text as the training input and taking the index sequence corresponding to the important sentences of the text as the training output, to obtain the retrieval model.

[0021] Further, determining the text summary corresponding to the query question according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree comprises:

[0022] determining the text blocks corresponding to each index in the index sequence by comparing each index in the index sequence with the identifiers of the text blocks in the text tree;

[0023] sequentially splicing the text blocks corresponding to each index in the index sequence according to the order of the indexes in the index sequence, to obtain the text summary.

[0024] In a second aspect, the embodiments of the present application further provide a text query device, comprising:

[0025] a segmentation module, configured to segment a text into a plurality of text blocks, construct a text tree by clustering the text blocks, and determine index identifiers of the text blocks in the text tree;

[0026] a determination module, configured to input a query question into a pre-trained retrieval model, so that the retrieval model determines a corresponding index sequence of the query question in the text tree, wherein the retrieval model is trained according to a plurality of query questions corresponding to a text and index sequences of important sentences corresponding to the text;

[0027] an execution module, configured to determine a text summary corresponding to the query question according to the corresponding index sequence of the query question in the text tree and the index identifiers of the text blocks in the text tree.

[0028] In a third aspect, the embodiments of the present application further provide an electronic device, comprising:

[0029] at least one processor; and a memory connected with the at least one processor in communication;

[0030] wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor, so that the at least one processor can execute the text query method according to any one of the first aspect.

[0031] In a fourth aspect, the embodiments of the present application further provide a storage medium containing computer executable instructions, which are used to execute the text query method according to any one of the first aspect when executed by a computer processor.

[0032] In a fifth aspect, the present application provides a computer program product, which comprises computer instructions, and when the computer instructions are run on a computer, the computer executes the text query method provided in the first aspect.

[0033] It should be noted that the above computer instructions can be stored on a computer readable storage medium in whole or in part. The computer readable storage medium can be packaged together with the processor of the text query device, or packaged separately from the processor of the text query device, and the present application does not limit this.

[0034] The second aspect, the third aspect, the fourth aspect and the fifth aspect in the present application can refer to the detailed description of the first aspect; and the beneficial effects of the description of the second aspect, the third aspect, the fourth aspect and the fifth aspect can refer to the beneficial effect analysis of the first aspect, which will not be described here.

[0035] In the present application, the name of the above-mentioned text query device does not constitute a limitation on the device or functional module itself, and in actual implementation, these devices or functional modules can appear in other names. As long as the functions of each device or functional module are similar to those in the present application, they belong to the scope of the claims of the present application and equivalent technologies.

[0036] These aspects or other aspects of the present application will be more apparent in the following description. BRIEF DESCRIPTION OF DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0038] Figure 1 A flow chart of a text query method provided by the embodiment of the present application;

[0039] Figure 2 A structural schematic diagram for generating a model for a query question;

[0040] Figure 3 A structural schematic diagram for a model to be trained;

[0041] Figure 4 A structural schematic diagram of a text query device provided by the embodiment of the present application;

[0042] Figure 5 A structural schematic diagram of an electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION

[0043] The present application will be further described in detail below in combination with the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, in order to facilitate the description, only the parts related to the present application are shown in the drawings, but not all the structures.

[0044] The term "and / or" in the present application only describes the association relationship of the associated objects, which means that there can be three kinds of relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone.

[0045] The terms "first" and "second" and the like in the description of the application and in the claims of the present application are used for the purpose of differentiating different objects or for differentiating different treatments of the same object, rather than for describing a specific order of the objects.

[0046] In addition, the terms "comprising" and "having" and any variations thereof in the description of the application are intended to cover the non-exclusive inclusion of the steps or units listed. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but can optionally further comprise other steps or units not listed, or can optionally further comprise other steps or units inherent to the process, method, product or device.

[0047] Before the example embodiments are discussed in more detail, it should be mentioned that some example embodiments are described as processes or methods depicted as flow diagrams. While the flow diagrams depict the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations can be re-arranged. The processes can be terminated when their operations are completed, but can also have additional steps not included in the figure. The processes can correspond to methods, functions, routines, subroutines, etc. In addition, the embodiments and features of the embodiments in the present application can be combined with each other, without conflict.

[0048] It should be noted that in the embodiments of the present application, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration. Any implementation or embodiment described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or advantageous than other embodiments or implementations. Rather, the use of the words "exemplary" or "for example" is intended to present concepts in a concrete manner.

[0049] In the description of the present application, "a plurality of" means two or more, unless otherwise specified.

[0050] Natural Language Processing (NLP) is a branch of computer science that studies how to make computers understand and generate natural language used by humans. The goal of natural language processing is to enable computers to communicate with humans smoothly, accurately and intelligently, thereby improving the efficiency of human life and work. Natural language processing involves many aspects, such as speech recognition, speech synthesis, text analysis, text generation, machine translation, question and answer system, dialogue system, etc. In the aspect of text generation, natural language text needs to be generated according to given information or target, such as machine translation, text summarization, question and answer system, dialogue system, etc. In this way, text can be used for communication and expression, and new text content can be created.

[0051] RAG is a model that combines retrieval and generation techniques, which generates answers or content by referencing information from external knowledge bases, has strong explainability and customization ability, and is suitable for text generation. The working principle of RAG is to retrieve relevant information in a large-scale document collection, and then use this information to guide the generation of text, thereby improving the quality and accuracy of prediction. Specifically, RAG realizes text generation through three key parts: retrieval, utilization and generation. In the retrieval stage, RAG retrieves relevant information from the document collection; in the utilization stage, RAG uses the retrieved information to fill in the text or answer the question; in the generation stage, RAG generates the final text content according to the retrieved knowledge.

[0052] However, RAG can only handle short text segments and has limitations in handling long documents. Based on RAG, text queries may result in inaccurate query results or missing key information.

[0053] Therefore, the present application proposes a text query method to improve query accuracy.

[0054] The text query method proposed by the present application will be described in detail below in conjunction with the drawings and embodiments.

[0055] Figure 1 A flowchart of a text query method provided for the embodiments of the present application, the embodiments can be applicable to the case of determining the corresponding text summary of the query question in the text, improving the query accuracy, and the method can be executed by a text query device, as shown in Figure 1 The specific steps include the following steps:

[0056] Step 110, divide the text into multiple text blocks.

[0057] Wherein, the text can be understood as a text collection, and the text is composed of a large number of long texts and short texts. The text block contains no more than Q words, and Q is a natural number. The specific value of Q can be set according to actual needs, which is not limited here.

[0058] Specifically, the text can be segmented to divide the text into continuous text blocks (chunks nodes). Specifically, first, the text can be segmented based on a word segmentation algorithm, and then Q words from the start of each text can be taken as a text block to segment the text while maintaining the coherence of the semantics.

[0059] In the embodiments of the present application, the text is divided into multiple text blocks by segmenting the text.

[0060] Step 120, dividing the text blocks into at least two text block sets by clustering the text blocks, so as to minimize the aggregation loss of each text block set.

[0061] In an implementation, step 120 can specifically include:

[0062] dividing the text blocks into 2-N text block sets respectively, and determining the aggregation loss corresponding to each division result, wherein N is the number of text blocks; determining the division result corresponding to the minimum aggregation loss as the target division result.

[0063] Specifically, first, the text blocks can be vectorized, that is, embedding processing can be performed on each text block based on an embedding algorithm to generate a text vector corresponding to each text block. Specifically, the text vector corresponding to each text block can be determined based on term frequency-inverse document frequency (TF-IDF), Word to Vector (Word2Vec), or Bidirectional Encoder Representation from Transformers (BERT). Second, the text blocks can be clustered based on the feature dimensions of the text vectors corresponding to the text blocks. The feature dimensions are determined according to the embedding algorithm used for vectorizing the text blocks. Specifically, first, the text blocks are divided into two text block sets, and the aggregation loss after dividing into two text block sets is calculated. Then, the text blocks are divided into three text block sets, and the aggregation loss after dividing into three text block sets is calculated. This process is repeated until the text blocks are divided into N text block sets, and the aggregation loss after dividing into N text block sets is calculated.

[0064] For example, the text blocks are divided into two text block sets A and B, that is, C = (A, B) can be determined, where C represents a set composed of all text blocks, A ∈ C, B ∈ C, The aggregation loss after dividing into two text block sets A and B is calculated. Since the aggregation degree between the two text block sets A and B is lost after dividing the text blocks into two text block sets A and B, it can be determined that wherein, represents the aggregation degree between text block X i belongs to A, and text block X j belongs to B, u ij represents the aggregation degree between text block x i and text block x j , u ij can be determined according to the aggregation matrix corresponding to the text blocks.

[0065] The text blocks are divided into m text block sets, that is, C=(C1, C2, C3, C4, C5, …Cm) can be determined, wherein C1∈C, C2∈C, C3∈C, C4∈C, C5∈C, …, Cm∈C, The aggregation loss after being divided into m text block sets is calculated, that is, L can be determined

[0066] It should be noted that the determination step of the aggregation matrix corresponding to the text block is as follows: for N text blocks, first, an NxN matrix is constructed, and each element in the matrix represents the aggregation degree between the text blocks, and second, the similarity between the text blocks can be calculated based on the formula Score ij =V T tanh(W p p i +W t t j ), wherein V T is a transformation matrix, p i represents a text vector corresponding to the text block x i , t j represents a text vector corresponding to the text block x j , W p represents a transformation parameter corresponding to the text block x i , W t represents a transformation parameter corresponding to the text block x j , if the similarity is greater than a preset threshold, the value is recorded based on the corresponding element in the matrix, otherwise, the corresponding element in the matrix is set to 0 or other values representing low aggregation.

[0067] Further, the aggregation losses corresponding to the division results are compared, the division result corresponding to the minimum aggregation loss is determined as the target division result, and the text blocks are divided according to the target division result, that is, the text blocks can be divided into at least two text block sets, and at this time, the division manner makes the aggregation loss also minimum.

[0068] In the embodiment of the application, the text blocks are divided into at least two text block sets by clustering the text blocks.

[0069] Step 130, determine whether the number of text blocks contained in each text block set is not greater than the number threshold.

[0070] If the number of text blocks contained in each text block set is not greater than the number threshold, step 140 is performed; otherwise, the text blocks contained in the text block set are taken as clustering objects, and step 120 is returned to be executed.

[0071] Specifically, after the text blocks are divided into at least two text block sets, the number of text blocks contained in each text block set can be determined, and if the number of text blocks contained in any text block set is greater than the number threshold, the text blocks contained in the text block set are taken as clustering objects, and the step 120 is returned to be executed until the number of text blocks contained in each text block set is not greater than the number threshold, so that the clustering and division of the text blocks are realized.

[0072] The step 140 can specifically include:

[0073] In an implementation manner, the step 140 can specifically include:

[0074] The first layer of the text tree is constructed according to the first clustering result of the text blocks, wherein the nodes of the text tree represent each text block set corresponding to the first clustering result; the next layer of the text tree is constructed according to the clustering result of each text block set containing text blocks whose number is greater than the number threshold in turn until the number of text blocks contained in each text block set is not greater than the number threshold, so that the text tree is obtained; each text block set in each layer of the text tree is assigned a set number, and each text block in each text block set is assigned a text number, and the identifier of each text block is determined according to the text number of each text block and the set number of the text block set to which the text block belongs.

[0075] Specifically, first, the first layer of the text tree can be constructed according to each text block set divided by the first clustering result of the text blocks, that is, each text block set corresponding to the first clustering result can be taken as the node of the text tree to construct the first layer, at this time, each text block set corresponding to the first layer node can also be assigned a set number, and each text block in each text block set containing text blocks whose number is not greater than the number threshold can be assigned a text number; second, the next layer of the text tree can be constructed according to the clustering result of each text block set containing text blocks whose number is greater than the number threshold, at this time, each text block set corresponding to the node of the layer can also be assigned a set number, and each text block in each text block set containing text blocks whose number is not greater than the number threshold can be assigned a text number; the next layer of the text tree is repeatedly constructed according to the clustering result of each text block set containing text blocks whose number is greater than the number threshold, each text block set corresponding to the node of the layer is assigned a set number, and each text block in each text block set containing text blocks whose number is not greater than the number threshold is assigned a text number, until all the text blocks are added to the text tree.

[0076] In actual application, the text tree can be constructed in the process of clustering the text blocks, that is, after the first clustering is completed, the first layer of the text tree is constructed according to the first clustering result, and the remaining layers of the text tree are constructed according to the subsequent clustering results in turn until all the text blocks are added to the text tree.

[0077] Of course, while constructing the text tree, the identifier of each text block can be determined based on the set number of each text set and the text number of each text block. The identifier of a text block indicates its position in the text tree, facilitating text retrieval. Understandably, text blocks with high similarity will have identifiers with the same prefix.

[0078] In this embodiment of the invention, by clustering text blocks, the text blocks are divided into at least two sets of text blocks. Furthermore, based on the clustering results, a text tree is constructed and the identifiers of each text block in the text tree are determined. The text tree preserves the low-level details and high-level topics of the text, and the identifiers of each text block in the text tree provide a query basis for text queries based on the text tree.

[0079] Step 150: Input the query question into the pre-trained retrieval model so that the retrieval model can determine the index sequence corresponding to the query question in the text tree.

[0080] The retrieval model is trained based on multiple query questions corresponding to the text and the index sequence of important sentences corresponding to the text.

[0081] In one implementation, the training steps of the retrieval model include:

[0082] The texts used to construct the text tree are input multiple times into a pre-trained query question generation model, so that the query question generation model can determine multiple query questions corresponding to each text; the important sentences corresponding to each text are identified, and the index sequence corresponding to the important sentences is determined in the text tree; the model is trained using the multiple query questions corresponding to each text as training input and the index sequence corresponding to the important sentences of the text as training output, to obtain the retrieval model.

[0083] Figure 2 A diagram illustrating the model generated for the query question, such as Figure 2 As shown, the query question generation model consists of a Transformer Encoder and a Transformer Decoder. The Transformer Encoder takes a document as input, in which a predetermined number of words (X1 and X2 in the figure) are hidden based on random rules, and a predetermined number of sentences (Y in the figure) are hidden based on rules with high scores. Its output is the hidden words. The Transformer Decoder takes the document and the hidden words as input and outputs the hidden sentences, which are the query questions. The query question generation model is trained on training documents and the corresponding query questions for those documents, and can be used to determine the query questions corresponding to a document.

[0084] The text multiple times inputted into the pre-trained query question generation model for constructing the text tree, since the decoding strategy of the query question generation model is a random strategy, the same text multiple times inputted into the query question generation model can generate multiple different but related query vectors.

[0085] The important sentence corresponding to the text can be understood as the sentence with the highest similarity to other sentences in the text, specifically, a preset number of sentences are extracted from all sentences in the text, when the text includes n sentences and the preset number is m, there are C N M A kind of extraction method, for each extraction method, the similarity of the extracted sentence and the remaining sentence is calculated and summed, and the sentence extracted by the extraction method corresponding to the maximum sum value is determined as the important sentence. Further, the index sequence of the important sentence corresponding to each text can be determined in the text tree.

[0086] Figure 3 The schematic diagram of the to-be-trained model is shown as Figure 3 The to-be-trained model is composed of a Transformer Encoder and a Transformer Decoder, the Transformer Encoder adopts a standard transformer layer composed of N transformer blocks, the input of which is the query question corresponding to the text, and the output is the feature vector of the query question, the Transformer Decoder adopts a standard transformer decode layer composed of M transformer blocks, the input of which is the feature vector of the query question, and the output is the index sequence of the important sentence corresponding to the text, that is, the Where idx i represents the i-th word in the text block x i , X represents the output of the Transformer Encoder, i.e. the feature vector of the query question; W represents all parameters; W i represents the i-th step parameter.

[0087] In order to obtain a consistent regular expression, two index sequences predicted for the same query question can be determined to minimize the bidirectional KL divergence, which can be determined based on the following formula:

[0088] Further, a loss function can be constructed based on the minimized bidirectional KL divergence. That is, the loss function can be determined as:

[0089]

[0090] Where, The cross entropy loss of the predicted index sequence is determined as E(q) represents the probability of the model outputting the index sequence of the important sentence corresponding to the text as the input of the model with the query question corresponding to the text. i Loss idx i The consistency of different index sequences predicted for the same query question is regularized.

[0091] The model training is performed on the to-be-trained model with each query question corresponding to each text as the training input and the index sequence corresponding to the important sentence corresponding to each text as the training output, and the retrieval model is obtained when the loss function converges. The query question is input into the retrieval model, and the retrieval model can output the index sequence corresponding to the query question in the text tree.

[0092] It should be noted that the model training can be performed on the to-be-trained model with each query question corresponding to each text and the index sequence corresponding to the important sentence corresponding to each text as positive samples, and each query question corresponding to each text and a random index sequence as negative samples.

[0093] In the embodiment of the application, the index sequence corresponding to the query question in the text tree is determined according to the retrieval model.

[0094] Step 160, determining the text summary corresponding to the query question according to the index sequence corresponding to the query question in the text tree and the identifiers of each text block in the text tree.

[0095] In an embodiment, step 160 can specifically include:

[0096] By comparing each index in the index sequence with the identifier of each text block in the text tree, the text block corresponding to each index is determined; and the text blocks corresponding to each index in the index sequence are sequentially spliced in the order of the indexes in the index sequence to obtain the text summary.

[0097] The index sequence is composed of a plurality of indexes arranged in order.

[0098] Specifically, after the index sequence is determined, for each index constituting the index sequence, the identifier of the text block corresponding to each node of the corresponding layer of the text tree can be compared with the index, the text block corresponding to the identifier consistent with the index is determined as the text block corresponding to the index, and all text blocks corresponding to the indexes are determined. Further, the text blocks corresponding to each index in the index sequence are sequentially spliced in the order of the indexes in the index sequence, and the text summary can be obtained.

[0099] In actual application, the cosine similarity of each node of each layer to the query question can be determined, the text block corresponding to the maximum cosine similarity is determined as the target text block corresponding to the layer. Of course, the target text block corresponding to each layer can be determined from the root node of the text tree, or the target text block corresponding to each layer can be determined from the bottom layer of the text tree. The target text blocks corresponding to each layer are connected in hierarchical order to obtain the query result corresponding to the query question. If the query result corresponding to the query question is inconsistent with the text summary, the index sequence corresponding to the query result corresponding to the query question is taken as a positive sample, and the index sequence corresponding to the text summary corresponding to the query question is taken as a negative sample, and the retrieval model is continuously optimized.

[0100] In the embodiment of the application, by comparing the sequences of the index sequences corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree, the text blocks corresponding to each index in each layer of the text tree are determined, the text blocks corresponding to each index are spliced, the text summary is obtained, and a more accurate text summary of the query question is determined.

[0101] The text query method provided by the embodiment of the application includes: first, the text can be segmented into a plurality of text blocks by segmenting the text; second, the text blocks can be divided into at least two text block sets by clustering the text blocks, and the loss of the aggregation degree of each text block set after division is minimized; the number of text blocks contained in each text block set is determined; if the number of text blocks contained in the text block set is greater than a number threshold, the text blocks contained in the text block set are taken as clustering objects, and the clustering of the text blocks to divide the text blocks into at least two text block sets is returned to be executed until the number of text blocks contained in each text block set is not greater than the number threshold; a text tree is constructed according to the clustering result, and the identifiers of the text blocks in the text tree are determined; the construction of the text tree and the determination of the identifiers of the text blocks in the text tree are realized according to the clustering result; the text tree retains the low-level details and high-level themes of the text; the identifiers of the text blocks in the text tree provide a query basis for text query based on the text tree; a query question is input into a pre-trained retrieval model, the retrieval model can determine the index sequence corresponding to the query question in the text tree, the text blocks corresponding to each index in each layer of the text tree are determined by comparing the sequences of the index sequences corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree, the text blocks corresponding to each index are spliced, a text summary is obtained, and a more accurate text summary of the query question is determined.

[0102] Figure 4A structural schematic diagram of a text query device provided by an embodiment of the present application, which can be applied to a case where a text summary corresponding to a query question needs to be determined in a text, and query accuracy is improved. The device can be realized by software and / or hardware, and is generally integrated in an electronic device, such as a computer device.

[0103] As shown in Figure 4 , the device comprises:

[0104] A segmentation module 410, configured to segment a text into a plurality of text blocks, construct a text tree by clustering the text blocks, and determine identifiers of the text blocks in the text tree;

[0105] A determination module 420, configured to input a query question into a pre-trained retrieval model, so that the retrieval model determines an index sequence corresponding to the query question in the text tree, wherein the retrieval model is trained according to a plurality of query questions corresponding to a text and index sequences of important sentences corresponding to the text;

[0106] An execution module 430, configured to determine a text summary corresponding to the query question according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree.

[0107] The text query device provided by the embodiment segments a text into a plurality of text blocks, constructs a text tree by clustering the text blocks, and determines identifiers of the text blocks in the text tree; inputs a query question into a pre-trained retrieval model, so that the retrieval model determines an index sequence corresponding to the query question in the text tree, wherein the retrieval model is trained according to a plurality of query questions corresponding to a text and index sequences of important sentences corresponding to the text; and determines a text summary corresponding to the query question according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree. The above technical solution first segments a text into a plurality of text blocks, then clusters the text blocks, constructs a text tree according to the clustering result, and determines identifiers of the text blocks in the text tree. The construction of the text tree and the determination of the identifiers of the text blocks in the text tree are realized according to the clustering result. The text tree retains low-level details and high-level themes of the text. The identifiers of the text blocks in the text tree provide a query basis for text query based on the text tree. The query question is input into a pre-trained retrieval model, and the retrieval model can determine an index sequence corresponding to the query question in the text tree. By comparing the index sequence and the identifiers of the text blocks in the text tree, the text blocks corresponding to the index sequence are determined at each layer in the text tree. The text blocks are sequentially spliced to obtain a text summary, and a more accurate text summary of the query question is determined.

[0108] On the basis of the above-mentioned embodiments, the segmentation module 410 is specifically configured to:

[0109] segment the text into a plurality of text blocks; divide the text blocks into at least two text block sets by clustering the text blocks, so as to minimize the aggregation loss of each text block set; in a case where it is determined that the number of text blocks contained in the text block set is greater than a number threshold, take the text blocks contained in the text block set as clustering objects, and return to execute the operation of dividing the text blocks into at least two text block sets by clustering the text blocks, until the number of text blocks contained in each text block set is not greater than the number threshold; construct the text tree according to the clustering result, and determine the identifiers of the text blocks in the text tree.

[0110] In an implementation, the operation of dividing the text blocks into at least two text block sets by clustering the text blocks, so as to minimize the aggregation loss of each text block set, includes:

[0111] dividing the text blocks into 2-N text block sets respectively, and determining the aggregation loss corresponding to each division result, wherein N is the number of text blocks; and determining the division result corresponding to the minimum aggregation loss as a target division result.

[0112] In an implementation, the operation of constructing the text tree according to the clustering result includes:

[0113] constructing a first layer of the text tree according to the first clustering result of the text blocks, wherein the nodes of the text tree represent each text block set corresponding to the first clustering result; and in turn, constructing a next layer of the text tree according to the clustering result of each text block set containing the text blocks whose number is greater than the number threshold, until the number of text blocks contained in each text block set is not greater than the number threshold, to obtain the text tree.

[0114] In an implementation, the operation of determining the identifiers of the text blocks in the text tree includes:

[0115] allocating a set number to each text block set of each layer of the text tree, and allocating a text number to each text block in each text block set, and determining the identifiers of the text blocks according to the text numbers of the text blocks and the set numbers of the text block sets to which the text blocks belong.

[0116] On the basis of the above-mentioned embodiments, the device further includes:

[0117] The training module is configured to input each text into a pre-trained query question generation model to make the query question generation model determine a plurality of query questions corresponding to each text, determine important sentences corresponding to each text, and determine an index sequence of the important sentences in the text tree, train the model by taking each query question corresponding to each text as a training input and taking an index sequence corresponding to the important sentences of each text as a training output, and obtain the retrieval model.

[0118] On the basis of the above-mentioned embodiments, the execution module 430 is specifically configured to:

[0119] By comparing each index in the index sequence with the identifier of each text block in the text tree, the text block corresponding to each index is determined, and each text block corresponding to each index is spliced in the order of each index in the index sequence to obtain the text summary.

[0120] The text query device provided by the embodiments of the present application can execute the text query method provided by any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of executing the text query method.

[0121] It should be noted that in the above-mentioned embodiments of the text query device, each unit and module included is only divided according to the function logic, but is not limited to the above-mentioned division, as long as the corresponding function can be realized; in addition, the specific name of each functional unit is only for the convenience of mutual differentiation, and does not limit the protection scope of the present application.

[0122] Figure 5 A structural schematic diagram of an electronic device provided by the embodiments of the present application is provided. Figure 5 A block diagram of an exemplary electronic device 5 suitable for use in implementing embodiments of the present application is shown. Figure 5 The electronic device 5 shown is merely an example and should not be taken as limiting the functionality or applicability of embodiments of the present application.

[0123] As shown in Figure 5 The electronic device 5 is shown in the form of a general computing electronic device. Components of the electronic device 5 can include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 connecting the different system components including the system memory 28 and the processing unit 16.

[0124] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0125] Electronic device 5 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 5, including volatile and non-volatile media, removable and non-removable media.

[0126] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 5 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 5 Not shown; usually referred to as a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0127] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of the present invention.

[0128] The electronic device 5 can also communicate with one or more external devices 14 such as a keyboard, a pointing device, a display 24, etc.; other devices that enable a user to interact with the electronic device 5; and / or any devices (e.g., a networking module, a Figure 5 modem, etc.) that enable the electronic device 5 to communicate with one or more other computing devices. Such communication can occur via an input / output (I / O) interface 22. Still yet, the electronic device 5 can communicate with one or more networks, such as a local area network (LAN), a wide area network (WAN), and / or the Internet, through a network adapter 20. As Figure 5 illustrated, the network adapter 20 can communicate with the other components of the electronic device 5 via bus 18. It should be appreciated that although the network adapter 20 is illustrated as a separate component, the network adapter 20 can be integrated with another component, such as the processor 16.

[0129] The processor 16 can execute the various functional applications and page displays stored in the system memory 28, such as to implement the text query method provided by any embodiments of the present application, which includes:

[0130] After the text is segmented into a plurality of text blocks, a text tree is constructed by clustering the text blocks, and identifiers of the text blocks in the text tree are determined;

[0131] The query question is input into a pre-trained retrieval model, so that the retrieval model determines an index sequence corresponding to the query question in the text tree, wherein the retrieval model is trained according to index sequences of a plurality of query questions corresponding to a text and important sentences corresponding to the text;

[0132] According to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree, a text summary corresponding to the query question is determined.

[0133] Of course, those skilled in the art can understand that the processor can also implement the technical solutions of the text query method provided by any embodiments of the present application.

[0134] The embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement, for example, the text query method provided by the embodiments of the present application, which includes:

[0135] After the text is segmented into a plurality of text blocks, a text tree is constructed by clustering the text blocks, and identifiers of the text blocks in the text tree are determined;

[0136] inputting the query question into a pre-trained retrieval model to make the retrieval model determine an index sequence corresponding to the query question in the text tree, wherein the retrieval model is trained according to index sequences of a plurality of query questions corresponding to a text and important sentences corresponding to the text;

[0137] determining a text summary corresponding to the query question according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree.

[0138] The computer storage medium of the embodiment of the application can adopt any combination of one or more computer readable media. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, 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 thereof. In this document, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or component.

[0139] The computer readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, in which a computer readable program code is carried. Such a propagated data signal can take on many forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can be used to carry or store a program for use by or in connection with an instruction execution system, device or component.

[0140] The program code contained on the computer readable medium can be transmitted in any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination thereof.

[0141] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0142] Those skilled in the art will appreciate that the modules or steps of the present application described above can be implemented in general computing devices, which can be centralized on a single computing device or distributed over a network of multiple computing devices. Alternatively, they can be implemented by computer-executable program code stored in a storage device and executed by a computing device, or they can be implemented as individual integrated circuit modules, or a plurality of modules or steps can be implemented as a single integrated circuit module. Thus, the present application is not limited to any particular combination of hardware and software.

[0143] In addition, the acquisition, storage, use, processing, etc. of data in the technical solutions of the present application comply with relevant provisions of national laws and regulations.

[0144] Note that the above are only preferred embodiments of the present application and the technical principles applied. Those skilled in the art will understand that the present application is not limited to the specific embodiments herein, and that various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the scope of the present application. Therefore, although the present application has been described in detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims

1. A method of text query, characterized by, The method comprises the following steps: After the text is divided into a plurality of text blocks, a text tree is constructed by clustering the text blocks, and identifiers of the text blocks in the text tree are determined; A query question is input into a pre-trained retrieval model, so that the retrieval model determines the corresponding index sequence of the query question in the text tree, wherein the retrieval model is trained according to a plurality of query questions corresponding to a text and an index sequence of important sentences corresponding to the text; According to the corresponding index sequence of the query question in the text tree and the identifiers of the text blocks in the text tree, a text summary corresponding to the query question is determined; Wherein, the text tree is constructed by clustering the text blocks, and the identifiers of the text blocks in the text tree are determined, comprising: By clustering the text blocks, the text blocks are divided into at least two text block sets, so that the aggregation loss of each text block set is minimized; In the case where the number of text blocks contained in the text block set is greater than the number threshold, the text blocks contained in the text block set are taken as clustering objects, and the step of dividing the text blocks into at least two text block sets by clustering the text blocks is returned to be executed until the number of text blocks contained in each text block set is not greater than the number threshold; According to the clustering result, the text tree is constructed, and the identifiers of the text blocks in the text tree are determined.

2. The text query method of claim 1, wherein, By clustering the text blocks, the text blocks are divided into at least two text block sets, so that the aggregation loss of each text block set is minimized, comprising: The text blocks are respectively divided into 2-N text block sets, and the aggregation loss corresponding to each division result is determined, wherein N is the number of text blocks; The division result corresponding to the minimum aggregation loss is determined as the target division result.

3. The text query method of claim 1, wherein, According to the clustering result, the text tree is constructed, comprising: According to the first clustering result of the text blocks, the first layer of the text tree is constructed, wherein the nodes of the text tree represent each text block set corresponding to the first clustering result; According to the clustering result of each text block set containing more text blocks than the number threshold, the next layer of the text tree is constructed in turn until the number of text blocks contained in each text block set is not greater than the number threshold, and the text tree is obtained.

4. The text query method of claim 3, wherein, In the text tree, the identifiers of the text blocks are determined, comprising: Each text block set in each layer of the text tree is assigned a set number, and each text block in each text block set is assigned a text number, and the identifiers of the text blocks are determined according to the text numbers of the text blocks and the set numbers of the text block sets to which the text blocks belong.

5. The text query method of claim 1, wherein, The training steps of the retrieval model comprise: Each text used to construct the text tree is input into a pre-trained query question generation model multiple times, so that the query question generation model determines a plurality of query questions corresponding to each text; Important sentences corresponding to each text are determined, and an index sequence of the important sentences in the text tree is determined; The model is trained by taking each query question corresponding to the text as a training input and taking an index sequence corresponding to an important sentence of the text as a training output, to obtain the retrieval model.

6. The text query method of claim 1, wherein, The text summary corresponding to the query question is determined according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree, and includes: The text block corresponding to each index in the index sequence is determined by comparing each index in the index sequence with the identifiers of the text blocks in the text tree. The text summary is obtained by sequentially splicing the text blocks corresponding to each index in the index sequence according to the order of the indexes in the index sequence.

7. A text query apparatus, characterized by It includes: The segmentation module is configured to segment a text into a plurality of text blocks, construct a text tree by clustering the text blocks, and determine identifiers of the text blocks in the text tree. The determination module is configured to input a query question into a pre-trained retrieval model to enable the retrieval model to determine an index sequence corresponding to the query question in the text tree, wherein the retrieval model is trained according to a plurality of query questions corresponding to a text and index sequences of important sentences corresponding to the text. The execution module is configured to determine a text summary corresponding to the query question according to the index sequence corresponding to the query question in the text tree and the identifiers of the text blocks in the text tree. The segmentation module is specifically configured to divide the text blocks into at least two text block sets by clustering the text blocks to minimize the aggregation loss of each text block set, return to execute the division of the text blocks into at least two text block sets by clustering the text blocks until the number of text blocks contained in each text block set is not greater than a number threshold, construct the text tree according to the clustering result, and determine the identifiers of the text blocks in the text tree.

8. An electronic device, comprising: The electronic device includes: At least one processor; and a memory connected in communication with the at least one processor; The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the text query method of any one of claims 1-6.

9. A storage medium containing computer-executable instructions, wherein: The computer executable instructions, when executed by a computer processor, are used to execute the text query method of any one of claims 1-6.

Citation Information

Patent Citations

  • Question and answer query method and device, computing equipment and computer readable storage medium

    CN117094401A

  • Method for recommending text content based on concern, and computer device

    US20180373787A1