Text generation method and device and computer equipment

By clustering text blocks and using summaries from clusters, the method enhances the RAG algorithm's output text comprehensiveness and accuracy, addressing the limitations of the RAG algorithm in handling long texts.

CN119202236APending Publication Date: 2024-12-27SHENZHEN ZHIXIAN FUTURE IND SOFTWARE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411332850.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The Retrieval-augmented Generation (RAG) algorithm generates incomplete and inaccurate output text due to limitations in the number of texts retrieved, especially when dealing with long texts or complex documents, such as those found in semiconductor manufacturing manuals, which results in missing contextual information.

Method used

The method involves splitting the text into multiple blocks, clustering these blocks into groups, generating summaries for each cluster, and retrieving summaries from these clusters to generate a summary of the clusters, generating summaries for each cluster, and generating output text for the query to be processed, and generating output text for the query to be processed.

Benefits of technology

The method improves the RAG algorithm by reducing the search scope and enhancing the comprehensiveness and accuracy of the output text by clustering text blocks and using summaries from clusters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202236A_ABST
    Figure CN119202236A_ABST
Patent Text Reader

Abstract

The invention provides a text generation method. After a to-be-processed text is obtained, the to-be-processed text is split into a plurality of text blocks. And clustering the plurality of text blocks to obtain at least two clusters, and generating an abstract of the cluster for each cluster. After a to-be-processed query is obtained, an abstract related to the to-be-processed query is retrieved, and an output text for the to-be-processed query is generated by utilizing the retrieved abstract. According to the method, the RAG is improved. According to the method, the text blocks are clustered, the retrieval range during retrieval is reduced, the returned information can be more comprehensive under the condition that the number of texts which can be retrieved at a time is limited, and the missing of context information is reduced. And furthermore, the output text generated through the RAG algorithm is more comprehensive and accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of text generation technology, and in particular to a text generation method, device and computer equipment. Background Art

[0002] The Retrieval-augmented Generation (RAG) algorithm is an artificial intelligence model that combines retrieval and generation technologies. The execution process of RAG mainly includes: retrieving text related to the query entered by the user in the text library. Then, based on the retrieved text and the query entered by the user, the output text for the query entered by the user is generated.

[0003] In the prior art, when using the RAG algorithm, when there are many texts in the text library, due to the limitation of the number of texts retrieved at one time, all texts related to the query cannot be retrieved, making the final generated output text incomplete and inaccurate. Summary of the invention

[0004] In order to overcome the problem that the RAG output text is not complete and accurate in the related art, this specification provides a text generation method, device and computer equipment.

[0005] According to a first aspect of an embodiment of this specification, a text generation method is provided, the method comprising:

[0006] Acquire multiple text blocks, and cluster the multiple text blocks to obtain at least two clusters;

[0007] For each cluster, a summary of the cluster is generated according to the text block corresponding to the cluster;

[0008] Obtaining a query to be processed, and retrieving a target abstract related to the query to be processed from the abstracts corresponding to at least two clusters;

[0009] An output text for the query to be processed is generated according to the query to be processed and the target summary.

[0010] According to a second aspect of the embodiments of this specification, a text generation device is provided, the device comprising:

[0011] A clustering module, used for acquiring a plurality of text blocks and clustering the plurality of text blocks to obtain at least two clusters;

[0012] A summary generation module, used for generating a summary of each cluster according to a text block corresponding to the cluster;

[0013] A retrieval module, configured to obtain a query to be processed, and retrieve a target abstract related to the query to be processed from the abstracts corresponding to at least two clusters;

[0014] The text generation module is used to generate an output text for the query to be processed according to the query to be processed and the target summary.

[0015] According to a third aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the text generation method as described in the first aspect of the embodiments of this specification is implemented.

[0016] According to a fourth aspect of the embodiments of this specification, a computer device is provided, the computer device comprising:

[0017] processor;

[0018] Memory for storing computer programs;

[0019] When the computer program is executed by the processor, the processor implements the text generation method as described in the first aspect of the embodiment of this specification.

[0020] This specification proposes a text generation method. After obtaining a text to be processed, the text to be processed is split into multiple text blocks. The multiple text blocks are clustered to obtain at least two clusters, and a summary of each cluster is generated for each cluster. After obtaining a query to be processed, a summary related to the query to be processed is retrieved, and an output text for the query to be processed is generated using the retrieved summary.

[0021] The above method improves RAG. By clustering text blocks, the search scope is reduced. When the number of texts that can be retrieved at one time is limited, the returned information can be more comprehensive and the lack of contextual information can be reduced. In turn, the output text generated by the RAG algorithm is more comprehensive and accurate.

[0022] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.

[0024] Figure 1 It is a flowchart of a text generation method shown in this specification according to an exemplary embodiment.

[0025] Figure 2It is a schematic diagram of the RAG retrieval process in the related technology shown in this specification.

[0026] Figure 3 This is a flowchart of the text generation method provided in this specification.

[0027] Figure 4 It is a block diagram of a text generation device shown in this specification according to an exemplary embodiment.

[0028] Figure 5 It is a hardware structure diagram of a computer device shown in this specification according to an exemplary embodiment. DETAILED DESCRIPTION

[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0030] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0031] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0032] There are many long texts in the field of semiconductor manufacturing. For example, in the field of semiconductor manufacturing, the manual of the equipment contains a lot of detailed technical information and operating instructions, and the overall length of the manual is relatively long. For another example, the semiconductor manufacturing process is complex and lasts for a long time, and each process stage will generate a large amount of test data. There are complex associations between the texts composed of these test data, and related phenomena may appear at different stages of the process, resulting in a large span of contextual information.

[0033] When the RAG algorithm is applied to a long text, the long text is usually divided into multiple text chunks. In the case of a long text, the long text will be divided into a larger number of text chunks. Since the maximum number of text chunks that can be retrieved in one search is limited, it is impossible to recall all query-related text chunks during the search of the long text, resulting in incomplete search results, which in turn affects the integrity of the output text generated by the RAG algorithm. In some cases, due to the insufficient number of retrieved text chunks, the returned content context may be missing, and the output text content generated by RAG is inaccurate.

[0034] In order to solve the problems in the related art, this specification proposes a text generation method. After obtaining the text to be processed, the text to be processed is split into multiple text blocks. The multiple text blocks are clustered to obtain at least two clusters, and a summary of the cluster is generated for each cluster. After obtaining the query to be processed, the summary related to the query to be processed is retrieved, and the retrieved summary is used to generate an output text for the query to be processed.

[0035] The above method improves RAG. By clustering text blocks, the search scope is reduced. When the number of texts that can be retrieved at one time is limited, the returned information can be more comprehensive and the lack of contextual information can be reduced. In turn, the output text generated by the RAG algorithm is more comprehensive and accurate.

[0036] Next, the embodiments of this specification are described in detail.

[0037] like Figure 1 As shown, Figure 1 This is a flowchart of a text generation method according to an exemplary embodiment of the present specification, comprising the following steps:

[0038] Step 101: obtain a plurality of text blocks, and cluster the plurality of text blocks to obtain at least two clusters.

[0039] Specifically, in order to facilitate retrieval, after obtaining multiple text blocks to be retrieved, the multiple text blocks can be clustered to obtain at least two clusters, which is convenient for subsequent generation of a summary of each cluster.

[0040] Among them, a text block refers to a text unit containing a certain number of sentences or paragraphs. Multiple text blocks are also the search range when performing a search in the subsequent steps. The number of text blocks in the multiple text blocks can be greater than a preset threshold, which can achieve a better effect of ensuring that the returned results are more comprehensive in this application scenario.

[0041] As for the source of the text blocks, the step 101 of obtaining multiple text blocks may include: obtaining the text to be processed, and splitting the text to be processed to obtain multiple text blocks. That is, multiple text blocks may be obtained by segmenting from a whole document. Of course, the above example does not limit the present specification, and multiple text blocks may also be obtained by obtaining multiple short texts as multiple text blocks.

[0042] In an optional implementation, the plurality of text blocks may be obtained by cutting a long document, that is, the text to be processed may be a long document.

[0043] During the clustering process, in order to facilitate clustering, feature extraction can be performed for each text block. In an optional implementation, the term frequency-inverse document frequency (TF-IDF) vector of the text block can be extracted as the input of the clustering algorithm. In other words, before clustering the multiple text blocks, the method further includes: performing feature extraction for each text block to obtain the term frequency-inverse document frequency TF-IDF vector corresponding to the text block; the TF-IDF vector is used as the input for clustering.

[0044] TF-IDF is a weight calculation method used to evaluate the importance of a word to a document set or one of the documents in a corpus. Among them, term frequency (TF) refers to the number of times a word appears in a document. Inverse Document Frequency (IDF) is a measure of the rarity of a word in a corpus. If a word appears in many text blocks, it means that it is not rare and may not have the ability to distinguish different text blocks, so its IDF value will be low. On the contrary, if a word appears less frequently in other text blocks, then its IDF value will be higher, indicating that it has better discrimination. Multiplying TF and IDF will give the TF-IDF value of a word in a text block. The higher the TF-IDF value, the more important the word is in the text block.

[0045] In the process of characterizing a text block by TF-IDF, the text block can be first segmented to obtain each word in the text block, and then the TF-IDF value of each word can be calculated. The TF-IDF value of each word is used as an element of the text block feature vector to obtain the text block feature vector.

[0046] TF-IDF can be used to determine the importance of each word in a text block and reduce the weight of unimportant words, thereby facilitating summary generation in subsequent steps.

[0047] During clustering, a K-means clustering (K-means) algorithm may be used for clustering, that is, a plurality of text blocks are clustered by the K-means algorithm to obtain a preset number of clusters.

[0048] K-means clustering algorithm is an unsupervised learning algorithm used to divide data into K clusters. The specific implementation steps are as follows: First, preset the number of clusters K, and randomly generate K initial cluster centers. Then, for each text block to be clustered, calculate the distance between the text block and the center of each cluster, and assign it to the cluster closest to it. After all text blocks are assigned, re-update the cluster center based on the mean of all text blocks in each cluster. Repeat the above steps of assigning text blocks and updating cluster centers until the change in the cluster center is less than the preset threshold or the preset number of iterations is reached.

[0049] When the text blocks are clustered by the K-means algorithm, a suitable number of clusters K may be set based on experience so that multiple text blocks in each cluster have similarities.

[0050] Through the K-means algorithm, more accurate multiple clusters can be obtained with high efficiency, effectively clustering text blocks with similar contents.

[0051] Step 103: for each cluster, generate a summary of the cluster according to the text block corresponding to the cluster.

[0052] Specifically, after clustering, in order to facilitate subsequent retrieval, a summary can be generated for each cluster.

[0053] Each cluster may include multiple text blocks, and the text blocks corresponding to the cluster are also the text blocks clustered into the cluster. The generated summary is also the summary of the multiple text blocks corresponding to the cluster.

[0054] Step 103 may be implemented by inputting the multiple text blocks corresponding to each cluster into a large language model respectively, and generating summaries of the multiple clusters respectively according to the large language model.

[0055] In addition, in an optional implementation, step 103 may include: for each cluster, extracting the feature vector of each sentence in the text block corresponding to the cluster; constructing a text graph between the sentences corresponding to the cluster; the text graph includes multiple nodes, the nodes correspond to the sentences corresponding to the cluster one by one, and the weights of the edges between the nodes represent the similarities between the sentences corresponding to the nodes; for each node in the text graph, iteratively updating the importance score of the node according to the weight of the edge connected to the node; and taking at least one sentence with the highest importance score as the summary of the cluster.

[0056] In an optional embodiment, the feature vector of the sentence can use the TF-IDF vector, through which the importance of each word in the sentence can be reflected. The similarity between sentences in the text graph can be calculated by cosine similarity, etc. In addition, when generating summaries, several sentences ranked in the top importance scores can be selected as the summaries of the cluster. These sentences should be able to represent the main content of the cluster clusters, while maintaining a certain diversity and ensuring that the main content of the cluster clusters is covered.

[0057] The importance score of a node is also the importance score of the sentence corresponding to the node. The importance score of a node can be continuously updated through iterations until the number of iterations is reached or the importance score tends to be stable.

[0058] As for the specific update method, in addition to updating according to the weights of the edges around the nodes, a damping coefficient can also be preset to update the weights. The damping coefficient represents the probability that the user will continue to read the sentences corresponding to the adjacent nodes when browsing to the sentences of the current node.

[0059] The specific updating method may be to update using the following formula (1).

[0060]

[0061] Where W(i) represents the weight of node i, and the corresponding W(j) represents the weight of node j. d represents the damping coefficient, which can be taken as 0.85. In(i) represents all nodes connected to node i, that is, node j is the node connected to node i. Out(j) represents all nodes connected to node k, that is, node j is the node connected to node j. w ji represents the weight value of the edge between node j and node i, and correspondingly, w jk Represents the weight of the edge between node j and node k.

[0062] Through the above steps, we can generate a concise and informative summary for each cluster, which helps users quickly understand the core content of the cluster.

[0063] Step 105 : obtaining a query to be processed, and retrieving a target abstract related to the query to be processed from the abstracts corresponding to at least two clusters.

[0064] Step 107: Generate an output text for the query to be processed according to the query to be processed and the target summary.

[0065] Specifically, this specification optimizes the RAG algorithm to process long documents. Figure 2As shown, the text library in the related art stores multiple text blocks, and when searching, a text block n related to the query is obtained from the text library. Different from the RAG algorithm in the related art, the method of this specification does not directly search for text blocks related to the query, but searches for the abstracts of the clusters. Figure 3 As shown, in the method of this specification, the text library stores the abstracts corresponding to multiple clusters, and retrieves and returns the target abstract (abstract m shown in the figure) related to the query in the text library. It should be noted that although Figure 3 It is shown that the text library stores text blocks corresponding to multiple clusters, but when searching, the query is matched with the abstracts of the circular clusters in the text library, rather than with the clusters or the text blocks themselves. This reduces the search scope and improves the search efficiency. In addition, the method of generating abstracts through clustering can recall more comprehensive search results. Moreover, compared with generating output text based on multiple documents, the method of this specification uses abstracts to generate output text, which simplifies the generation process of output text.

[0066] Next, step 105 and step 107 will be described in detail.

[0067] First, it should be noted that step 101 and step 103 may be performed in advance. After step 101 and step 103 are performed once, step 105 and step 107 may be performed multiple times to generate output texts for multiple queries to be processed.

[0068] The query to be processed may be a query input by a user. The method may be applied to a question-answering system, a search system, etc. Correspondingly, the query input by the user may be in the form of a search formula or a specific question, which is not limited in this specification.

[0069] In the case that the query to be processed is a query input by a user, obtaining the query to be processed may include: obtaining the query input by the user as the query to be processed.

[0070] The specific implementation of the retrieval method in step 105 may be: determining the similarity between the query to be processed and the abstracts corresponding to at least two clusters; determining an abstract whose similarity to the query to be processed is greater than a preset similarity threshold, and using the determined abstract as a target abstract.

[0071] Specifically, during retrieval, the feature vector of the query can be extracted to determine the similarity between the feature vector of the query and the feature vector of each abstract. The abstract whose similarity with the query is greater than the preset similarity threshold is then used as the target abstract. The feature vector extracted here can be the TF-IDF vector mentioned above, or a vector extracted by text embedding. The similarity here can be cosine similarity, Euclidean distance, etc.

[0072] During retrieval, if the similarity between the query and any abstract is less than a preset similarity threshold, the output text may be content indicating that the user cannot find relevant information.

[0073] If the similarity between the query and two or more summaries is greater than a preset similarity threshold, then all of these summaries can be used as target summaries. In addition, in order to make the returned content more concise, if the similarity between the query and two or more summaries is greater than a preset similarity threshold, the summaries with the highest similarity to the query can be selected as the target summaries from the summaries with similarities greater than the similarity threshold.

[0074] The implementation of step 107 may be based on a large language model. Specifically, step 107 may include inputting the query to be processed and the target summary into the large model so that it generates the output text.

[0075] In addition, when the query to be processed is a query input by the user, the output text may be displayed after step 105. This allows the user to quickly obtain a visualized result. In addition, the retrieved summary and the text block corresponding to the summary may be displayed, so that the user can quickly obtain the source of the output text, giving the user a better user experience.

[0076] Corresponding to the embodiments of the aforementioned method, this specification also provides embodiments of an apparatus and a computer device to which it is applied.

[0077] like Figure 4 As shown, Figure 4 is a block diagram of a text generation device according to an exemplary embodiment of the present specification, the device comprising:

[0078] A clustering module 410 is used to obtain a plurality of text blocks and cluster the plurality of text blocks to obtain at least two clusters;

[0079] A summary generation module 420 is used to generate a summary of each cluster according to the text block corresponding to the cluster;

[0080] A retrieval module 430 is used to obtain a query to be processed, and retrieve a target abstract related to the query to be processed from the abstracts corresponding to at least two clusters;

[0081] The text generation module 440 is configured to generate an output text for the query to be processed according to the query to be processed and the target summary.

[0082] In an optional embodiment, the summary generation module 420 is specifically used to: for each cluster, extract the feature vector of each sentence in the text block corresponding to the cluster; construct a text graph between the sentences corresponding to the cluster; the text graph includes multiple nodes, the nodes correspond to the sentences corresponding to the cluster one by one, and the weights of the edges between the nodes represent the similarities between the sentences corresponding to the nodes; for each node in the text graph, iteratively update the importance score of the node according to the weight of the edge connected to the node; and use at least one sentence with the highest importance score as the summary of the cluster.

[0083] In an optional embodiment, a feature extraction module 400 (not shown in the figure) is further included, which is used to extract features for each text block to obtain a term frequency-inverse document frequency TF-IDF vector corresponding to the text block; the TF-IDF vector is used as input for clustering.

[0084] In an optional embodiment, the clustering module 410 is specifically configured to cluster the multiple text blocks by using a K-means clustering algorithm to obtain a preset number of clusters.

[0085] In an optional embodiment, the clustering module 410 is specifically used to obtain a query input by a user as a query to be processed. The device further includes a display module 450 (not shown in the figure) for displaying the output text.

[0086] In an optional embodiment, the retrieval module 430 is specifically configured to determine the similarity between the query to be processed and the abstracts corresponding to at least two clusters; determine an abstract whose similarity to the query to be processed is greater than a preset similarity threshold, and use the determined abstract as a target abstract.

[0087] In an optional embodiment, the clustering module 410 is specifically used to obtain the text to be processed, and split the text to be processed to obtain multiple text blocks.

[0088] In an optional embodiment, the text generation module 440 is specifically configured to input the query to be processed and the target summary into the large model so that it generates the output text.

[0089] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0090] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0091] like Figure 5 As shown, Figure 5 A hardware structure diagram of a computer device is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.

[0092] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0093] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0094] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0095] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

[0096] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).

[0097] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0098] The embodiments of the present specification also provide a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the text generation method as described in the first aspect of the embodiments of the present specification is implemented.

[0099] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0100] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0101] This specification also provides a computer program, which implements the above-mentioned text generation method when executed by a processor.

[0102] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0103] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0104] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A text generation method, characterized in that: The method comprises: Acquire multiple text blocks, and cluster the multiple text blocks to obtain at least two clusters; For each cluster, a summary of the cluster is generated according to the text block corresponding to the cluster; Obtaining a query to be processed, and retrieving a target abstract related to the query to be processed from the abstracts corresponding to at least two clusters; An output text for the query to be processed is generated according to the query to be processed and the target summary.

2. The method according to claim 1, characterized in that For each cluster, generating a summary of the cluster according to the text block corresponding to the cluster, including: For each cluster, extract the feature vector of each sentence in the text block corresponding to the cluster; Constructing a text graph between sentences corresponding to the clusters; the text graph includes a plurality of nodes, the nodes correspond to the sentences corresponding to the clusters one by one, and the weights of the edges between the nodes represent the similarities between the sentences corresponding to the nodes; For each node of the text graph, iteratively update the importance score of the node according to the weight of the edge connected to the node; At least one sentence with the highest importance score is used as the summary of the cluster.

3. The method according to claim 1, characterized in that: Before clustering the plurality of text blocks, the method further comprises: Feature extraction is performed on each text block to obtain a term frequency-inverse document frequency TF-IDF vector corresponding to the text block; the TF-IDF vector is used as input for clustering.

4. The method according to claim 1, characterized in that: The clustering of the multiple text blocks to obtain at least two clusters includes: The K-means algorithm is used to cluster multiple text blocks to obtain a preset number of clusters.

5. The method according to claim 1, characterized in that The obtaining of pending queries includes: Get the query entered by the user as the query to be processed; The method further comprises: Displays the output text.

6. The method according to claim 1, characterized in that The step of retrieving a target abstract related to the query to be processed from the abstracts corresponding to the at least two clusters respectively includes: Determining the similarity between the query to be processed and the abstracts corresponding to at least two clusters; Determine a summary whose similarity with the query to be processed is greater than a preset similarity threshold, and use the determined summary as a target summary.

7. The method according to claim 1, characterized in that The obtaining of multiple text blocks includes: The text to be processed is obtained, and the text to be processed is split to obtain multiple text blocks.

8. The method according to claim 1, characterized in that Generate output text for the query to be processed, including: The query to be processed and the target summary are input into the large model so that it generates the output text.

9. A text generation device, characterized in that: The device comprises: A clustering module, used for acquiring a plurality of text blocks and clustering the plurality of text blocks to obtain at least two clusters; A summary generation module, used for generating a summary of each cluster according to a text block corresponding to the cluster; A retrieval module, configured to obtain a query to be processed, and retrieve a target abstract related to the query to be processed from the abstracts corresponding to at least two clusters; The text generation module is used to generate an output text for the query to be processed according to the query to be processed and the target summary.

10. A computer device, characterized in that: The computer device comprises: processor; Memory for storing computer programs; When the computer program is executed by the processor, the processor implements the text generation method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Text processing method and device for improving information retrieval and generation quality and computer system

    CN118535710A