Text content extraction method and device, electronic equipment and storage medium

By dividing and fusing text blocks with prompt texts, the method enhances the accuracy and richness of content extraction in large language models, addressing the limitations of existing LLMs in generating optimal content from long texts.

CN119066189APending Publication Date: 2024-12-03BEIJING QIYI CENTURY SCI & TECH CO LTD

Patent Information

Application Number
CN202411014553.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

Existing large language models (LLMs) generate content with the highest probability based on training data, leading to insufficient accuracy in extracting refined content from long texts due to time and content depth factors.

Method used

Divide the text into multiple blocks, generate first and second prompt texts for each block using LLMs to extract and fuse multiple refined contents, considering diverse dimensions and angles, and determine the target refined content based on fused blocks.

Benefits of technology

Improves the richness and accuracy of extracted content by comprehensively considering multiple refined contents from different angles, enhancing the quality of text analysis and extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066189A_ABST
    Figure CN119066189A_ABST
Patent Text Reader

Abstract

Embodiments of the invention provide a text content extraction method and apparatus, an electronic device and a storage medium. The method comprises the steps of dividing a to-be-extracted text into a plurality of text blocks; for each text block, generating a first prompt text comprising the text block and a text extraction prompt word; performing text content extraction on the text block through a large language model according to the first prompt text to obtain a plurality of extracted contents corresponding to the text block; generating a second prompt text for content fusion according to the plurality of refined contents; according to the second prompt text, fusing the plurality of extracted contents through the large language model to obtain fused contents of the text block; and according to the fusion content of the plurality of text blocks, determining target extraction content of the to-be-extracted text. According to the embodiment of the invention, the richness and accuracy of the finally generated target extraction content can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a method, device, electronic device and storage medium for extracting text content. Background Art

[0002] The emergence of Large Language Model (LLM) makes it possible to analyze complex long texts, such as the deconstruction, analysis, and evaluation of plots, scripts, and literary works. When analyzing long texts, the long texts can be vectorized and then input into the large language model for analysis. For long texts, the text is too long to be input into the large language model at one time, because the large language model generally has a length limit.

[0003] In the prior art, long texts are usually divided into different chunks, and content extraction is performed on different chunks. When extracting content from chunks, conventional extraction tools (non-large language models) or large language models can be used for extraction. Conventional extraction tools output a fixed type of extracted content for a given chunk of content. The large language model uses a greedy decoding mode to return a generated content that is considered to have the highest probability when the large language model is executed this time.

[0004] The effect of using a large language model to generate refined content is better than that of conventional extraction tools. However, the way of extracting content using a large language model also has certain drawbacks. Since the large language model takes the generated content with the highest probability as the optimal content, and the highest probability is only the highest probability based on the training content during LLM pre-training, affected by the passage of time and the depth of content, the generated content with the highest probability is not necessarily the optimal one, resulting in insufficient accuracy of the final refined content. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a text content extraction method, device, electronic device and storage medium to improve the accuracy of the generated extracted content. The specific technical solution is as follows:

[0006] In a first aspect of the present invention, a method for extracting text content is provided, comprising:

[0007] Divide the text to be extracted into multiple text blocks;

[0008] For each of the text blocks, generating a first prompt text including the text block and a text extraction prompt word;

[0009] According to the first prompt text, extracting the text content of the text block by using a large language model to obtain a plurality of extracted contents corresponding to the text block;

[0010] Generating a second prompt text for content fusion according to the plurality of refined contents;

[0011] According to the second prompt text, the plurality of refined contents are fused by the large language model to obtain fused content of the text block;

[0012] According to the fused contents of the plurality of text blocks, the target refined contents of the text to be refined are determined.

[0013] In a second aspect of the present invention, there is also provided a text content extraction device, comprising:

[0014] A text block division module is used to divide the text to be extracted into multiple text blocks;

[0015] A first prompt generating module, configured to generate, for each of the text blocks, a first prompt text including the text block and a text extraction prompt word;

[0016] A content extraction module, configured to extract the text content of the text block through a large language model according to the first prompt text, and obtain a plurality of extracted contents corresponding to the text block;

[0017] A second prompt generating module, used for generating a second prompt text for content fusion according to the plurality of refined contents;

[0018] a content fusion module, configured to fuse the plurality of refined contents through the large language model according to the second prompt text to obtain fused content of the text block;

[0019] The refined content determination module is used to determine the target refined content of the text to be refined based on the fused content of the multiple text blocks.

[0020] In another aspect of the present invention, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes any of the above-mentioned methods for extracting text content.

[0021] In another aspect of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned methods for extracting text content.

[0022] The text content extraction method, device, electronic device and storage medium provided by the embodiments of the present invention divide the text to be refined into multiple text blocks, and for each text block, extract the text content of the text block through a large language model to obtain multiple refined contents corresponding to the text block, fuse the multiple refined contents through the large language model to obtain the fused content of the text block, and determine the target refined content of the text to be refined according to the fused content of the multiple text blocks. Since multiple refined contents can be obtained when the text content of the text block is extracted through the large language model, and the multiple refined contents are fused as the final refined text of the text block, compared with a single refined content, multiple refined contents with more dimensions and more angles are comprehensively considered, which can improve the richness and accuracy of the target refined content finally generated. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0024] Figure 1 It is a flow chart of a text content extraction method provided by an embodiment of the present invention;

[0025] Figure 2 It is a flow chart of a text content extraction method provided by an embodiment of the present invention;

[0026] Figure 3 It is a flow chart of a text content extraction method provided by an embodiment of the present invention;

[0027] Figure 4 It is a schematic diagram of the overall framework of the text content extraction method provided by an embodiment of the present invention;

[0028] Figure 5 is a schematic diagram of a text analysis framework in an embodiment of the present invention;

[0029] Figure 6 It is a structural schematic diagram of a text content extraction device provided by an embodiment of the present invention;

[0030] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0031] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0032] Figure 1 is a flowchart of a text content extraction method provided by an embodiment of the present invention. The text content extraction method can be applied to electronic devices such as computers, such as Figure 1 As shown, the text content extraction method includes the following steps:

[0033] Step 110, dividing the text to be refined into a plurality of text blocks.

[0034] Among them, the text to be refined is a complex and long text, which contains a large number of words.

[0035] The text to be refined may be divided into a plurality of text blocks according to a fixed length of the text block; or, the text to be refined may be divided into a fixed number of text blocks based on a fixed number of text blocks.

[0036] Step 120: for each of the text blocks, generate a first prompt text including the text block and a text extraction prompt word.

[0037] Among them, the text extraction prompt words are prompt words used to guide the large language model to extract text content.

[0038] For each text block, the content is refined. When a text block is refined, a first prompt text (Prompt) including the text block and a text refinement prompt word is first generated. The text refinement prompt words are the same for different text blocks.

[0039] Step 130: According to the first prompt text, extract the text content of the text block through a large language model to obtain a plurality of extracted contents corresponding to the text block.

[0040] Since long texts are relatively complex, there is no standard answer for the refined text obtained by content extraction, and it is not a mathematical logic with a consensus standard. Refined texts of different dimensions and angles are acceptable as long as they are reasonable, and a unique and novel angle may be an important supplementary information for evaluating the text. At the same time, with the help of the theory that the decision of a group of experts is better than the decision of an expert, when the embodiment of the present invention extracts the content of a text block through a large language model, the large language model can output multiple refined contents corresponding to the text block.

[0041] The relevant parameters of the large language model output can be modified in advance, and the default greedy decoding method of the large language model can be changed to the beam search decoding method, so that the large language model can output multiple results with better effects. Among them, the greedy decoding method outputs the best result, and the beam search decoding method outputs multiple results with better effects.

[0042] For a text block, after generating the first prompt text of the text block, the first prompt text can be input into a large language model. The large language model can extract the text content of the text block in the first prompt text based on the guidance of the text extraction prompt words in the first prompt text to obtain multiple extracted contents corresponding to the text block.

[0043] Step 140: Generate a second prompt text for content fusion based on the multiple refined contents.

[0044] After obtaining multiple extracted contents corresponding to a text block, the multiple extracted contents can be merged into one content, and then a second prompt text for content fusion can be generated. The second prompt text includes the multiple extracted contents corresponding to the text block.

[0045] Step 150: According to the second prompt text, the plurality of refined contents are fused through the large language model to obtain fused content of the text block.

[0046] The second prompt text is input into the large language model, and the multiple extracted contents in the second prompt text are fused through the large language model to obtain the fused content of the text block. When the multiple extracted contents are fused through the large language model, different extracted contents are fully considered to fuse the multiple extracted contents obtained by different methods into a complete content, so that the obtained fused content can contain the text contents in the multiple extracted contents.

[0047] Step 160, determining the target refined content of the text to be refined based on the fused content of the plurality of text blocks.

[0048] The fused contents of multiple text blocks are spliced ​​in the order of the text blocks to obtain the target refined contents of the text to be refined.

[0049] The text content extraction method provided in the present embodiment divides the text to be extracted into multiple text blocks, and for each text block, extracts the text content of the text block through a large language model to obtain multiple extracted contents corresponding to the text block, fuses the multiple extracted contents through a large language model to obtain the fused content of the text block, and determines the target extracted content of the text to be extracted based on the fused contents of the multiple text blocks. When the text content of the text block is extracted through a large language model, multiple extracted contents can be obtained, and the multiple extracted contents are fused as the final extracted text of the text block. Compared with a single extracted content, this method comprehensively considers multiple extracted contents of more dimensions and angles, and can improve the richness and accuracy of the target extracted content finally generated.

[0050] On the basis of the above technical solution, the generation of the first prompt text including the text block and the text extraction prompt word includes: adding the text block to the text adding position of the first prompt template to obtain the first prompt text, and the first prompt template includes the text adding position and the text extraction prompt word.

[0051] The first prompt template is a pre-written prompt word template, in which a text adding position can be specified based on preset symbols, and the first prompt template includes text extraction prompt words.

[0052] For each text block, the content of the text block can be added to the text adding position in the first prompt template, so that the content of the text block and the original text extraction prompt words in the first prompt template form the first prompt text. By including the text extraction prompt words and the text adding position in the first prompt template, it is convenient to add the text block to the text adding position to generate the first prompt text. The first prompt text generated in this way can better guide the large language model to extract the content of the text block.

[0053] On the basis of the above technical solution, the step of dividing the text to be refined into a plurality of text blocks includes: dividing the text to be refined into a plurality of text blocks according to a preset text block length.

[0054] The preset text length may be a preset number of characters or a preset number of tokens. In natural language processing, a token refers to a basic unit in a text, which may be a word, a phrase, a punctuation mark, a character, etc.

[0055] According to the preset text block length, segmentation is started from the starting position of the text to be extracted, and a section of text with the preset text block length is intercepted as the first text block; subsequently, a section of text with the preset text block length is intercepted from the starting position of the remaining text respectively to obtain subsequent text blocks, until the last text block is intercepted, thus dividing the text to be extracted into multiple text blocks.

[0056] Compared with dividing the text according to a fixed number of text blocks, dividing the text to be refined according to a preset text block length can improve the rationality of the divided text blocks, because the length of the text blocks divided according to a fixed number of text blocks may not meet the requirements, and further division is required.

[0057] On the basis of the above technical solution, for each of the text blocks, the above operations of generating the first prompt text, refining the text content, generating the second prompt text and fusing the refined content are performed in parallel.

[0058] In the process of processing each text block, all text blocks can be processed in parallel, that is, with the help of the idea of ​​MapReduce in engineering, multiple text blocks can be processed in parallel according to the above steps 120 to 150. MapReduce is a programming model used for parallel computing of large-scale data sets (greater than 1TB). When implementing it, a Map function is specified to map a set of key-value pairs (the processing process of a text block) into a set of new key-value pairs (the processing process of other text blocks), and a concurrent Reduce function is specified to ensure that each of all mapped key-value pairs shares the same key group.

[0059] By processing each text block in parallel, the processing speed can be increased, thereby improving the efficiency of extracting text content.

[0060] Figure 2 1 is a flowchart of a text content extraction method provided by an embodiment of the present invention. The text content extraction method can be applied to electronic devices such as computers. Based on the above embodiment, the first prompt text also includes a scoring prompt word. Figure 2 As shown, the text content extraction method includes the following steps:

[0061] Step 210, dividing the text to be refined into a plurality of text blocks;

[0062] Step 220: for each of the text blocks, generate a first prompt text including the text block, text extraction prompt words and scoring prompt words.

[0063] The first prompt template may include a text extraction prompt word, a scoring prompt word, and a text adding position. When processing each text block, the content of the text block may be added to the text adding position in the first prompt template to obtain a first prompt text including the text block, the text extraction prompt word, and the scoring prompt word. Among them, the scoring prompt word is used to guide the large language model to score each outputted extracted content, that is, to output the score corresponding to the extracted content. The score corresponding to the extracted content may be a probability, which represents the closeness of the extracted content to the original text.

[0064] Step 230, input the first prompt text into the large language model, and use the large language model to extract the text content of the text block based on the text extraction prompt words and the scoring prompt words to obtain multiple extracted contents corresponding to the text block and a score corresponding to each of the extracted contents.

[0065] The first prompt text is input into the large language model. The large language model extracts the text content of the text block in the first prompt text based on the guidance of the text extraction prompt word in the first prompt text to obtain multiple extracted contents corresponding to the text block. At the same time, based on the guidance of the scoring prompt word, multiple extracted contents and the scores corresponding to each extracted content are output, that is, in the format of a tuple of (extracted content, score). The multiple extracted contents output by the large language model are a certain number (Top-k) of extracted contents with the highest scores.

[0066] Step 240: Select at least two refined contents whose scores are greater than or equal to a threshold score from the multiple refined contents.

[0067] The threshold score may be a preset score or may be obtained based on statistics of scores of multiple refined contents.

[0068] At least two refined contents having scores greater than or equal to a threshold score are selected from the multiple refined contents for subsequent fusion.

[0069] In one embodiment of the present invention, before selecting at least two refined contents having scores greater than or equal to a threshold score from the multiple refined contents, the method further includes: determining an average, a median or a mode of the scores of the multiple refined contents as the threshold score.

[0070] A voting mechanism is implemented between different tuples to select a threshold score. The average, median or mode of the scores of each extracted content can be calculated, and the obtained average, median or mode is determined as the threshold score, and then at least two extracted contents with scores greater than or equal to the threshold score are selected. Among them, when calculating the median of the scores of each extracted content, the scores of each extracted content can be arranged in order of size, and a score in the middle position is determined, which is the median of the scores of each extracted content; when calculating the mode of the scores of each extracted content, the score that appears the most times among the scores of each extracted content is determined as the mode of the scores of each extracted content.

[0071] By determining the average, median or mode of the scores of multiple refined contents as the threshold score, and then selecting the refined contents to be fused based on the threshold score, it is possible to screen the refined contents from all the refined contents in a self-consistency (SC) manner, so that the refined contents with better refining effects can be selected, and the accuracy of the final refined contents can be further improved.

[0072] Step 250: Generate the second prompt text including the at least two refined contents and the fused prompt word.

[0073] The fusion prompt words are prompt words used to guide the large language model to perform text fusion.

[0074] In one embodiment of the present invention, the generating of the second prompt text including the at least two refined contents and the fused prompt word includes: adding the at least two refined contents to the content adding position of the second prompt template to obtain the second prompt text, wherein the second prompt template includes the content adding position and the fused prompt word.

[0075] The second prompt template is a pre-written prompt word template, in which a content adding position can be specified based on a preset symbol, and the second prompt template includes a fusion prompt word. The fusion prompt word is a prompt word used to guide the large language model to perform text content fusion.

[0076] When it is necessary to merge at least two refined contents of a text block, the at least two contents of the text block can be added to the content adding position in the second prompt template, so that the at least two contents of the text block and the original fusion prompt words in the second prompt template form the second prompt text. By including the fusion prompt words and the content adding position in the second prompt template, it is convenient to add at least two refined contents to the content adding position to generate the second prompt text. The second prompt text generated in this way can better guide the large language model to merge the at least two refined contents.

[0077] Step 260: According to the second prompt text, the plurality of refined contents are fused through the large language model to obtain fused content of the text block.

[0078] The second prompt text is input into the large language model, and the at least two selected refined contents are fused through the large language model to obtain fused content of the text block.

[0079] Step 270, determining the target refined content of the text to be refined based on the fused content of the plurality of text blocks.

[0080] The text content extraction method provided in this embodiment uses a large language model to extract the content of each text block, and simultaneously outputs multiple extracted contents corresponding to each text block and a score corresponding to each extracted content, and then selects at least two extracted contents whose scores are greater than or equal to a threshold score, and fuses the at least two selected extracted contents as the final extracted content (fused content) of the text block, which can improve the accuracy of the final extracted content of the text block.

[0081] Figure 3 is a flowchart of a text content extraction method provided by an embodiment of the present invention. The text content extraction method can be applied to electronic devices such as computers, such as Figure 3As shown, the text content extraction method includes the following steps:

[0082] Step 310, dividing the text to be refined into multiple text blocks.

[0083] Step 320: for each of the text blocks, generate a first prompt text including the text block and a text extraction prompt word.

[0084] Step 330: According to the first prompt text, the text block is refined by a large language model to obtain a plurality of refined contents corresponding to the text block.

[0085] Step 340: Generate a second prompt text for content fusion based on the multiple refined contents.

[0086] Step 350: According to the second prompt text, the plurality of refined contents are fused through the large language model to obtain fused content of the text block.

[0087] Step 360: splice the fused contents of the multiple text blocks into complete content.

[0088] According to the order of each text block in the content to be refined, the fused contents of multiple text blocks are spliced ​​into the overall complete content.

[0089] Step 370 , determine whether the length of the complete content is less than or equal to the target length, if yes, execute step 380 , if not, execute step 390 .

[0090] The target length is the window length that can be input into the large language model.

[0091] The length of the complete content is compared with the target length to determine whether the length of the complete content is less than or equal to the target length.

[0092] Step 380: determine the complete content as the target refined content.

[0093] If the length of the complete content is less than or equal to the target length, the complete content is determined as the target refined content of the text to be refined.

[0094] Step 390, taking the complete content as the text to be refined again, and looping through steps 310 to 390 until the length of the complete content is less than or equal to the target length.

[0095] If the length of the complete content is greater than the target length, the complete content is used again as the text to be refined, and the above-mentioned operation of refining the content of the text to be refined is executed in a loop, that is, steps 310 to 390 are executed in a loop until the length of the complete content is less than or equal to the target length.

[0096] The text content extraction method provided in this embodiment determines the complete content as the target extracted content of the content to be extracted when the length of the complete content is less than or equal to the target length, and when the length of the complete content is greater than the target length, the complete content is again used as the content to be extracted and the content extraction process is performed until the length of the complete content is less than or equal to the target length. The content to be extracted of the complex long text is iteratively extracted, so that the target extracted content finally obtained can be input into the large language model at one time, which is convenient for analyzing the complex long text through the large language model.

[0097] Figure 4 is a schematic diagram of the overall framework of the text content extraction method provided by the embodiment of the present invention, such as Figure 4 As shown, firstly, the text to be extracted is divided into multiple text blocks, and then based on the idea of ​​MapReduce, the content of each text block is extracted in parallel, and a set of key-value pairs (the processing process of a text block) is mapped into a set of new key-value pairs (the processing process of other text blocks) through a Map function, and a concurrent Reduce function is specified to ensure that each of all mapped key-value pairs shares the same key group; when extracting the content of a text block, the text block is extracted through a large language model (LLMs), and a beam search decoding method is used to output multiple extracted contents and a score corresponding to each extracted content (that is, output the Top-k extracted contents and the score corresponding to each extracted content), and a threshold score is determined based on the scores of multiple extracted contents, and multiple extracted contents are filtered based on the threshold score, and at least two extracted contents with scores greater than or equal to the threshold score are screened out for prompt rendering (Prompt The method further comprises the steps of: performing a large language model (MLM) to generate a second prompt text including at least two refined contents and a fused prompt word, inputting the second prompt text into a large language model, and merging the at least two refined contents into a fused content through the large language model as the final refined content of the text block; splicing the fused contents of all text blocks into a complete content, and if the length of the complete content is less than or equal to a target length, using the complete content as the target refined content; and if the length of the complete content is greater than the target length, using the complete content as the content to be refined again, and cyclically executing the content refinement process until the length of the complete content is less than or equal to the target length.

[0098] Compared with the greedy decoding method that only uses a large language model to generate a fixed refined content, the text content extraction method provided by the embodiment of the present invention can improve the richness and accuracy of the refined content from more dimensions and more angles.

[0099] The text content extraction method provided by the embodiment of the present invention can be applied to any product or service that analyzes complex long texts. For example, it can be applied to script analysis, understanding and screening. In script analysis, the script is usually long and not easy to analyze, but it is convenient to analyze after being refined by applying the text content extraction method provided by the embodiment of the present invention; in script understanding, the manpower for script evaluation is limited, and it is convenient to understand based on the extracted content, which can avoid the problem of missing excellent scripts that can be accepted by a larger group of people because of someone's subjective views; in script screening, the amount of scripts is large, and a large amount of manpower is required to screen out valuable and suitable scripts from many scripts. It is difficult to screen each script by checking it, and screening based on the extracted content is convenient for comparing different scripts, thereby improving the screening efficiency. It can also be applied to plot understanding. By extracting the text content of long texts such as plot introductions and lines, exciting highlights or episode summaries can be extracted for different dramas, and more attractive generation results can be generated from multiple angles and dimensions.

[0100] The text content extraction method provided by the embodiment of the present invention can be applied to Figure 5 In the text analysis framework shown in Figure 5 As shown, the following processes are performed in the text analysis framework: large language models (LLMs) role setting (set the role); prompt rendering (Prompt rendering), using large language models (LLMs) to raise text analysis questions; using large language models (LLMs) to answer text analysis questions and obtain text analysis answers (Documents retrieval); text analysis answer selection and evaluation (Answer choice / evaluation); based on the multi-channel feedback that meets the expectations in the text analysis question raising stage, the text analysis question answering stage, the text analysis answer selection and evaluation stage, multi-layer sample enhancement is performed in the text analysis question raising stage, the text analysis question answering stage, the text analysis answer selection and evaluation stage. The text content extraction method in the embodiment of the present invention can be applied to Figure 5 The stage of using large language models to answer text analysis questions.

[0101] (1) Role Setting of Large Language Model

[0102] Set the role of the large language model according to the type of text to be analyzed. Let the large language model know the set role through prompt rendering. For example, using OpenAI, the role of the large language model can be set through the initial system role.

[0103] For example, in engineering implementation, two class instances can be created, each of which uses the call of the large language model as a method that can be used by itself. Each instance has its own Prompt attribute, and the role of the large language model is set as the questioner and the answerer respectively.

[0104] (2) Raising text analysis questions

[0105] For the questioner, the Prompt paradigm is combined with the set role to enable the large language model to independently raise text analysis questions corresponding to the text to be analyzed. The guidance of the Prompt paradigm allows the large language model to think about which text analysis questions should be raised under the current role.

[0106] Optionally, the Prompt paradigm can be a chain thinking method such as COT (Chain of Thoughts); or it can be a more complex SA (Self-Ask) + SE (Search Engine) method, which also shows the thinking process of why this role asks a certain text analysis question, and can also use the search engine to assist in finding professional questions that can be used for text analysis in the professional field related to the role during the thinking process; it can also further use the ReAct (Reasoning and Action) method to further decompose specific text analysis problems, and ask single-hop or even recursive questions to the decomposed questions to enhance the large language model's understanding of text analysis problems; of course, other methods can also be used to analyze the text to be analyzed in order to raise text analysis questions.

[0107] (3) Answer text analysis questions

[0108] As an answerer, you can build a tool library that can be used by large language models, and use your own knowledge, network resources, and text vector libraries to answer text analysis questions based on the question and answer context.

[0109] Define the action space (Action Space) that can be called by the respondent. In addition to the API (Application Program Interface) that can be called by the third party (such as the search engine interface, etc.), the reasoning interface of various models can also be registered in the Action Space.

[0110] Guided by the prompt paradigm, the large language model can be used to understand text analysis questions based on the questioner and answerer's question and answer history, and choose the way to answer text analysis questions. Answers can be made based on the actual knowledge accumulated during pre-training; or based on the understanding of the interface description in the Action Space, the interface call can be used to solve the problem. For example, for understanding the plot, relevant information can be obtained with the help of search engines. For the analysis of complex and long texts, question matching based on the text vector library and the integration and answer of related content can be used to get rid of the dilemma that the large language model cannot quickly and cost-effectively inject a large amount of vertical information and the context window limitation during application.

[0111] By analyzing a complex long text, the refined content of the text is obtained, and a text vector library is established based on the refined content of the text. The subsequent large language model can convert the text analysis question into a text vector library request, thereby obtaining an answer based on the text vector library. Among them, the process of analyzing the text to obtain the refined content of the text can be implemented by using the text content extraction method provided in the embodiment of the present invention.

[0112] (4) Text Analysis Answer Evaluation

[0113] Given that the analysis of complex and long texts is not a simple logical or mathematical problem, it usually does not have a "standard answer" in the traditional sense, and it focuses more on the analysis process rather than just the final result. Therefore, an evaluation mechanism can be established for the answers to the above questions to obtain the scores of the text analysis answers.

[0114] (5) Multi-layer sample enhancement

[0115] If the score of the text analysis answer is in line with expectations, the input and output in (2) to (4) above are added as feedback samples to the corresponding links to achieve sample reflux, so that the large language model can achieve better performance.

[0116] Figure 6 is a structural diagram of a text content extraction device provided by an embodiment of the present invention, such as Figure 6 As shown, the text content extraction device includes:

[0117] A text block division module 510 is used to divide the text to be refined into multiple text blocks;

[0118] A first prompt generating module 520, configured to generate, for each of the text blocks, a first prompt text including the text block and a text extraction prompt word;

[0119] A content extraction module 530 is used to extract the text content of the text block through a large language model according to the first prompt text, so as to obtain a plurality of extracted contents corresponding to the text block;

[0120] A second prompt generating module 540, configured to generate a second prompt text for content fusion according to the plurality of refined contents;

[0121] A content fusion module 550 is used to fuse the plurality of refined contents through the large language model according to the second prompt text to obtain fused content of the text block;

[0122] The refined content determination module 560 is used to determine the target refined content of the text to be refined according to the fused content of the multiple text blocks.

[0123] Optionally, the first prompt text also includes a scoring prompt word;

[0124] The content extraction module is specifically used for:

[0125] Inputting the first prompt text into the large language model, extracting the text content of the text block based on the text extraction prompt word and the scoring prompt word through the large language model, and obtaining a plurality of extracted contents corresponding to the text block and a score corresponding to each of the extracted contents;

[0126] The second prompt generating module comprises:

[0127] a content screening unit, configured to select at least two refined contents having the scores greater than or equal to the threshold score from the plurality of refined contents;

[0128] The second prompt generating unit is used to generate the second prompt text including the at least two refined contents and the fused prompt word.

[0129] Optionally, the device further comprises:

[0130] The threshold score determination module is used to determine the average, median or mode of the scores of the multiple refined contents as the threshold score.

[0131] Optionally, the second prompt generating unit is specifically used for:

[0132] The at least two refined contents are added to the content adding position of the second prompt template to obtain the second prompt text, wherein the second prompt template includes the content adding position and the fused prompt word.

[0133] Optionally, the first prompt generating module is specifically used for:

[0134] The text block is added to the text adding position of the first prompt template to obtain the first prompt text, wherein the first prompt template includes the text adding position and the text refining prompt word.

[0135] Optionally, the refined content determination module includes:

[0136] A content splicing unit, used for splicing the fused contents of the plurality of text blocks into a complete content;

[0137] a refined content determination unit, configured to determine the complete content as the target refined content if the length of the complete content is less than or equal to the target length;

[0138] A loop control unit is used to, if the length of the complete content is greater than the target length, use the complete content as the text to be refined again, and cyclically execute the above-mentioned operation of content extraction on the text to be refined until the length of the complete content is less than or equal to the target length.

[0139] Optionally, the text block division module is specifically used for:

[0140] According to the preset text block length, the text to be refined is divided into a plurality of text blocks.

[0141] Optionally, for each of the text blocks, the above operations of generating the first prompt text, refining the text content, generating the second prompt text, and fusing the refined content are performed in parallel.

[0142] The text content extraction device provided in the present embodiment divides the text to be extracted into multiple text blocks, and for each text block, extracts the text content of the text block through a large language model to obtain multiple extracted contents corresponding to the text block, fuses the multiple extracted contents through a large language model to obtain the fused content of the text block, and determines the target extracted content of the text to be extracted based on the fused contents of the multiple text blocks. When the text content of the text block is extracted through a large language model, multiple extracted contents can be obtained, and the multiple extracted contents are fused as the final extracted text of the text block. Compared with a single extracted content, this comprehensively considers multiple extracted contents of more dimensions and angles, which can improve the richness and accuracy of the target extracted content finally generated.

[0143] The embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, it includes a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.

[0144] Memory 603, used for storing computer programs;

[0145] The processor 601 is used to execute the program stored in the memory 603 to implement the following steps:

[0146] Divide the text to be extracted into multiple text blocks;

[0147] For each of the text blocks, generating a first prompt text including the text block and a text extraction prompt word;

[0148] According to the first prompt text, extracting the text content of the text block by using a large language model to obtain a plurality of extracted contents corresponding to the text block;

[0149] Generating a second prompt text for content fusion according to the plurality of refined contents;

[0150] According to the second prompt text, the plurality of refined contents are fused by the large language model to obtain fused content of the text block;

[0151] According to the fused contents of the plurality of text blocks, the target refined contents of the text to be refined are determined.

[0152] Optionally, the first prompt text also includes a scoring prompt word;

[0153] The extracting the text content of the text block by using a large language model according to the first prompt text to obtain a plurality of extracted contents corresponding to the text block includes:

[0154] Inputting the first prompt text into the large language model, extracting the text content of the text block based on the text extraction prompt word and the scoring prompt word through the large language model, and obtaining a plurality of extracted contents corresponding to the text block and a score corresponding to each of the extracted contents;

[0155] The step of generating a second prompt text for content fusion according to the plurality of refined contents includes:

[0156] Selecting at least two refined contents whose scores are greater than or equal to a threshold score from the plurality of refined contents;

[0157] The second prompt text including the at least two refined contents and the fused prompt word is generated.

[0158] Optionally, before selecting at least two refined contents having scores greater than or equal to a threshold score from the multiple refined contents, the method further includes:

[0159] The average, median or mode of the scores of the plurality of refined contents is determined as the threshold score.

[0160] Optionally, the generating the second prompt text including the at least two refined contents and the fused prompt word includes:

[0161] The at least two refined contents are added to the content adding position of the second prompt template to obtain the second prompt text, wherein the second prompt template includes the content adding position and the fused prompt word.

[0162] Optionally, generating a first prompt text including the text block and the text extraction prompt word includes:

[0163] The text block is added to the text adding position of the first prompt template to obtain the first prompt text, wherein the first prompt template includes the text adding position and the text refining prompt word.

[0164] Optionally, determining the target refined content of the text to be refined according to the fused content of the plurality of text blocks includes:

[0165] splicing the fused contents of the plurality of text blocks into a complete content;

[0166] If the length of the complete content is less than or equal to the target length, determining the complete content as the target refined content;

[0167] If the length of the complete content is greater than the target length, the complete content is used again as the text to be refined, and the above-mentioned operation of refining the text to be refined is performed repeatedly until the length of the complete content is less than or equal to the target length.

[0168] Optionally, dividing the text to be refined into a plurality of text blocks includes:

[0169] According to the preset text block length, the text to be refined is divided into a plurality of text blocks.

[0170] Optionally, for each of the text blocks, the above operations of generating the first prompt text, refining the text content, generating the second prompt text, and fusing the refined content are performed in parallel.

[0171] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0172] The communication interface is used for communication between the above electronic device and other devices.

[0173] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0174] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0175] In another embodiment provided by the present invention, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the text content extraction method described in any of the above embodiments.

[0176] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the text content extraction method described in any one of the above embodiments.

[0177] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0178] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0179] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0180] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for extracting text content, characterized in that: include: Divide the text to be extracted into multiple text blocks; For each of the text blocks, generating a first prompt text including the text block and a text extraction prompt word; According to the first prompt text, extracting the text content of the text block by using a large language model to obtain a plurality of extracted contents corresponding to the text block; Generating a second prompt text for content fusion according to the plurality of refined contents; According to the second prompt text, the plurality of refined contents are fused by the large language model to obtain fused content of the text block; According to the fused contents of the plurality of text blocks, the target refined contents of the text to be refined are determined.

2. The method according to claim 1, characterized in that The first prompt text also includes a scoring prompt word; The extracting the text content of the text block by using a large language model according to the first prompt text to obtain a plurality of extracted contents corresponding to the text block includes: Inputting the first prompt text into the large language model, extracting the text content of the text block based on the text extraction prompt word and the scoring prompt word through the large language model, and obtaining a plurality of extracted contents corresponding to the text block and a score corresponding to each of the extracted contents; The step of generating a second prompt text for content fusion according to the plurality of refined contents includes: Selecting at least two refined contents whose scores are greater than or equal to a threshold score from the plurality of refined contents; The second prompt text including the at least two refined contents and the fused prompt word is generated.

3. The method according to claim 2, characterized in that Before selecting at least two refined contents having scores greater than or equal to a threshold score from the plurality of refined contents, the method further includes: The average, median or mode of the scores of the plurality of refined contents is determined as the threshold score.

4. The method according to claim 2, characterized in that: The step of generating the second prompt text including the at least two refined contents and the fused prompt word comprises: The at least two refined contents are added to the content adding position of the second prompt template to obtain the second prompt text, and the second prompt template includes the content adding position and the fused prompt word.

5. The method according to any one of claims 1 to 4, characterized in that: The step of generating a first prompt text including the text block and the text-refining prompt word comprises: The text block is added to the text adding position of the first prompt template to obtain the first prompt text, wherein the first prompt template includes the text adding position and the text refining prompt word.

6. The method according to any one of claims 1 to 4, characterized in that: The step of determining target extracted content of the text to be extracted based on the fused content of the plurality of text blocks comprises: splicing the fused contents of the plurality of text blocks into a complete content; If the length of the complete content is less than or equal to the target length, the complete content is determined as the target refined content; If the length of the complete content is greater than the target length, the complete content is used again as the text to be refined, and the above-mentioned operation of refining the text to be refined is performed repeatedly until the length of the complete content is less than or equal to the target length.

7. The method according to any one of claims 1 to 4, characterized in that: The step of dividing the text to be extracted into a plurality of text blocks includes: According to the preset text block length, the text to be refined is divided into a plurality of text blocks.

8. The method according to any one of claims 1 to 4, characterized in that: For each of the text blocks, the above operations of generating the first prompt text, refining the text content, generating the second prompt text, and fusing the refined content are performed in parallel.

9. A text content extraction device, characterized in that: include: A text block division module is used to divide the text to be extracted into multiple text blocks; A first prompt generating module, configured to generate, for each of the text blocks, a first prompt text including the text block and a text extraction prompt word; A content extraction module, configured to extract the text content of the text block through a large language model according to the first prompt text, and obtain a plurality of extracted contents corresponding to the text block; A second prompt generating module, used for generating a second prompt text for content fusion according to the plurality of refined contents; a content fusion module, configured to fuse the plurality of refined contents through the large language model according to the second prompt text to obtain fused content of the text block; The refined content determination module is used to determine the target refined content of the text to be refined based on the fused content of the multiple text blocks.

10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 8 when executing a program stored in a memory.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

12. A computer program product comprising instructions, characterized in that: When the computer program product is executed on a computer, the computer is enabled to implement the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Public opinion abstract extraction method, device and equipment and computer readable storage medium

    CN109582967A

  • Text feature extraction method and device, computer equipment and storage medium

    CN113449081A

  • Text extraction method, system and related device

    CN116719914A

  • Abstract generation method and device, equipment, storage medium and product

    CN116894089A

  • Text long field extraction method and device based on large language model

    CN117973375A

Cited By

  • Method and system for multi-dimensionally summarizing classroom live-recorded texts

    CN120319248A