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

By generating adjacent text blocks for each text block in long text analysis, and refining text content using a large language model, the problem of unconsidered text block correlation is solved, and the accuracy of text block refining is improved. Rationality.

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

Patent Information

Application Number
CN202411014561.7
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

The prior art fails to effectively consider the correlation between text blocks in long text analysis, resulting in low accuracy in text refining.

Method used

By dividing the text to be refined into multiple text blocks, and generating text including text blocks, adjacent text blocks, refining content, weights and prompt text for each text block, using a large language model to refine text content, combined with weight adjustment and refining results, Preserve the original contextual relevance.

Benefits of technology

It improves the accuracy and rationality of text refining, so that the large language model can not only serve as a summary tool, but also integrates the contents of current and adjacent text blocks for comprehensive refining.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066190A_ABST
    Figure CN119066190A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a text content extraction method and device, electronic equipment and a storage medium. The text content extraction method comprises the following steps: dividing a to-be-extracted text into a plurality of text blocks; for each text block, generating a prompt text comprising the text block, the weight of the text block, the extracted content of the adjacent text block corresponding to the text block, the weight of the extracted content of the adjacent text block and a text extraction prompt word; performing text content extraction on the text block through a large language model according to the prompt text to obtain extracted content of the text block; and determining the extracted content of the to-be-extracted text according to the extracted content of the plurality of text blocks. According to the embodiment of the invention, the content can be extracted by integrating the current text block and the adjacent text block and the set weight, so that the text content which better meets the requirement can be extracted, and the accuracy of text extraction is 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 text content extraction method, device, electronic device and storage medium. Background Art

[0002] The emergence of Large Language Model (LLM) has made it possible to analyze complex long texts, such as the deconstruction, analysis, and evaluation of plots, scripts, and literature, but there is still no complete general and vertical solution. When analyzing long texts, if you want to answer questions based on the long text, you can extract the content of the long text so that you can answer questions based on the extracted content of the long text.

[0003] In the prior art, for long texts, since the text is too long, the long text is usually divided into multiple text chunks, and then the content of each text chunk is extracted separately, and finally the extracted content of each text chunk is combined into the extracted content corresponding to the long text. However, in the above method, each text chunk is independent of each other, while in fact, the information contained in the long text is related. The above text content extraction method does not take this correlation into account, resulting in low accuracy of text extraction. Summary of the invention

[0004] 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 text extraction. The specific technical solution is as follows:

[0005] In a first aspect of the present invention, a text content extraction method is provided, comprising:

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

[0007] For each of the text blocks, generating a prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and a text refinement prompt word;

[0008] According to the prompt text, extracting the text content of the text block through a large language model to obtain the extracted content of the text block;

[0009] The refined content of the text to be refined is determined according to the refined contents of the plurality of text blocks.

[0010] Optionally, when the text block is the first text block, the refined content of the adjacent text block corresponding to the text block is: the temporary refined content of the second text block; when the text block is not the first text block, the refined content of the adjacent text block corresponding to the text block is: the refined content of the previous text block of the text block.

[0011] Optionally, before generating a prompt text including the text block, the weight of the text block, the refined content of the adjacent text block corresponding to the text block, the weight of the refined content of the adjacent text block, and a text refinement prompt word, it also includes: when the text block is the first text block, obtaining temporary refined content of the second text block through a large language model.

[0012] Optionally, a prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and a text refinement prompt word is generated, including: adding the text block to the current text adding position of the prompt template, adding the weight of the text block to the current text weight adding position of the prompt template, adding the adjacent text block refined content to the adjacent text adding position of the prompt template, adding the weight of the adjacent text block refined content to the adjacent text weight adding position of the prompt template, to obtain the prompt text, wherein the prompt template also includes the text refinement prompt word.

[0013] Optionally, the text extraction prompt words are used to guide the large language model to extract text content from the text block, and the text extraction needs to be performed based on the weight of the text block and the weight of the extracted content of the adjacent text blocks.

[0014] Optionally, determining the refined content of the text to be refined based on the refined contents of the multiple text blocks includes: splicing the refined contents of the multiple text blocks into complete content, and determining the complete content as the refined content of the text to be refined.

[0015] Optionally, determining the refined content of the text to be refined based on the refined contents of multiple text blocks includes: splicing the refined contents of multiple text blocks into complete content; when the length of the complete content is less than or equal to the target length, determining the complete content as the refined content of the text to be refined; when the length of the complete content is greater than the target length, re-using the complete content as the text to be refined, and returning to execute the step of dividing the text to be refined into multiple text blocks.

[0016] Optionally, 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; and the context window length of the large language model is greater than twice the preset text length.

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

[0018] A division module, used for dividing the text to be extracted into multiple text blocks;

[0019] A generating module, for generating, for each of the text blocks, a prompt text including the text block, a weight of the text block, an extracted content of an adjacent text block corresponding to the text block, a weight of the extracted content of the adjacent text block, and a prompt word for text extraction;

[0020] A refining module, used to extract the text content of the text block through a large language model according to the prompt text, so as to obtain the refined content of the text block;

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

[0022] Optionally, when the text block is the first text block, the refined content of the adjacent text block corresponding to the text block is: the temporary refined content of the second text block; when the text block is not the first text block, the refined content of the adjacent text block corresponding to the text block is: the refined content of the previous text block of the text block.

[0023] Optionally, the device further comprises: an acquisition module, configured to acquire temporary refined content of the second text block by using a large language model when the text block is the first text block.

[0024] Optionally, the generation module is specifically used to add the text block to the current text adding position of the prompt template, add the weight of the text block to the current text weight adding position of the prompt template, add the adjacent text block refined content to the adjacent text adding position of the prompt template, add the weight of the adjacent text block refined content to the adjacent text weight adding position of the prompt template, to obtain the prompt text, and the prompt template also includes the text refined prompt word.

[0025] Optionally, the text extraction prompt words are used to guide the large language model to extract text content from the text block, and the text extraction needs to be performed based on the weight of the text block and the weight of the extracted content of the adjacent text blocks.

[0026] Optionally, the determination module is specifically configured to splice the extracted contents of the plurality of text blocks into complete content, and determine the complete content as the extracted content of the text to be extracted.

[0027] Optionally, the determination module is specifically used to splice the refined contents of multiple text blocks into complete content; when the length of the complete content is less than or equal to the target length, the complete content is determined as the refined content of the text to be refined; when 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 step of dividing the text to be refined into multiple text blocks is returned to execute.

[0028] Optionally, the division module is specifically used to divide the text to be refined into multiple text blocks according to a preset text block length; the context window length of the large language model is greater than twice the preset text length.

[0029] In another aspect of the implementation of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; the memory is used to store computer programs; and the processor is used to implement any of the above-mentioned text content extraction methods when executing the program stored in the memory.

[0030] 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 executed, the computer implements any of the above-mentioned text content extraction methods.

[0031] 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 implement any of the above-mentioned methods for extracting text content.

[0032] The text content extraction method, device, electronic device and storage medium provided by the embodiments of the present invention divide the text to be extracted into multiple text blocks, and for each text block, generate a prompt text including the text block, the weight of the text block, the extracted content of the adjacent text block corresponding to the text block, the weight of the extracted content of the adjacent text block, and a text extraction prompt word; based on the prompt text, the text block is subjected to text content extraction through a large language model to obtain the extracted content of the text block; and based on the extracted contents of the multiple text blocks, the extracted content of the text to be extracted is determined. It can be seen that in the embodiment of the present invention, for each text block, not only the current text block is considered, but also the refined content of the adjacent text blocks of the current text block, the weight of the current text block, and the weight of the refined content of the adjacent text blocks are further added. By adding the refined content of the adjacent text blocks, the original contextual relevance of the text to be refined can be retained, and by adding the weights, the influence of the refined content of the adjacent text blocks on the refined content of the current text block can be adjusted, so that the large language model is not just a simple summary acquisition tool, but can comprehensively extract the content of the current text block, the refined content of the adjacent text blocks, and the set weights, so as to extract text content that better meets the requirements and improve the accuracy of text extraction. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] 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.

[0034] Figure 1 The present invention is a flowchart of a method for extracting text content in an embodiment of the present invention.

[0035] Figure 2 The present invention is a flowchart of another method for extracting text content in an embodiment of the present invention.

[0036] Figure 3 A schematic diagram of a text content extraction process in an embodiment of the present invention.

[0037] Figure 4 Schematic diagram of a text analysis framework in an embodiment of the present invention.

[0038] Figure 5 It is a structural block diagram of a text content extraction device in an embodiment of the present invention.

[0039] Figure 6 The figure is a structural block diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0040] 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.

[0041] The text content extraction method provided by the embodiment of the present invention can be applied to any product or service that needs to analyze complex long texts. For example, it can be applied to script analysis, understanding and screening. In script analysis, the script is usually long, and the scripts in different directions are not absolutely good or bad, and there is no standard answer for evaluation, which is not easy to analyze; in script understanding, the manpower of script evaluation is limited, and it is likely that due to someone's subjective opinion, an excellent script that can be accepted by a larger group of people will be missed; 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. After refining by applying the text content extraction method provided by the embodiment of the present invention, it can be more convenient to analyze, understand and screen the script, and improve processing efficiency and accuracy. For another example, it can be applied to plot understanding. By applying the text content extraction method provided by the embodiment of the present invention to extract the text content of long texts such as plot introduction and lines, it can extract wonderful highlights or drama summaries for different dramas, and can produce more attractive generation results from multiple angles and dimensions.

[0042] The text content extraction method in the embodiment of the present invention can be executed in electronic devices such as computers.

[0043] In order to solve the problem of inaccurate content extraction caused by extracting the content of each text block separately, the embodiment of the present invention takes into account the correlation between text blocks. Further, considering that if a processing method of refining the content of the previous text is adopted, after the text blocks are divided, the content of the previous text block is firstly used in the summarize function module to obtain the summary, and then the summarization of the previous text block and the content of the next text block are used as the input of the summarize function module to obtain the summarization of the first two text blocks, and so on to obtain the summary result of the entire text, although this method takes into account the correlation between text blocks, but from the result, there are the following problems: the weight of the text block is not set according to the actual situation, resulting in unreasonable analysis results, for example, one possible situation is that the content proportion of the original text in the final text decreases in sequence according to the order of the text blocks, that is, the order in which the content of the text blocks appears determines their weight in the final summary result, and because the first text block is not affected by the summary of the predecessor text block, the proportion of the first text block is almost the largest, but this is unreasonable.

[0044] Therefore, in the embodiment of the present invention, for each text block, not only the current text block is considered, but also the refined content of the adjacent text blocks of the current text block, the weight of the current text block, and the weight of the refined content of the adjacent text blocks are further added. By adding the refined content of the adjacent text blocks, the original contextual relevance of the text to be refined can be retained. By adding the weight, the influence of the refined content of the current text block on the refined content of the adjacent text blocks can be adjusted, so that the large language model is not just a simple summary acquisition tool, but a comprehensive current text block, the refined content of the adjacent text blocks, and the set weights are used for content refinement, so as to refine text content that meets the requirements more. This method improves the problem of unreasonable analysis results due to the failure to set the weight of the text block, and improves the problem that the first text block has no contextual relevance basis. The following is a detailed introduction.

[0045] Figure 1 The present invention is a flowchart of a method for extracting text content in an embodiment of the present invention.

[0046] like Figure 1 As shown, the text content extraction method may include the following steps:

[0047] Step 101, dividing the text to be refined into multiple text blocks.

[0048] In the embodiment of the present invention, the text to be refined may be a complex and long text such as script content, plot content, literary work, etc.

[0049] Exemplarily, the text chunks may be divided according to a preset text chunk length, thereby dividing the text to be refined into a plurality of text chunks.

[0050] In an embodiment of the present invention, when setting the preset text block length, it is necessary to set it in combination with the context window length of the large language model. The context window length of the large language model refers to the maximum length of the input sequence that the large language model can process when performing data analysis. When dividing the text blocks, in order to ensure that the current text block can be received by the large language model in one delivery with the extracted content of the adjacent text blocks, the context window length of the large language model must be able to accommodate at least two text blocks, so the context window length of the large language model is greater than twice the preset text length. It should be noted that the input sequence also contains other information, such as weights, text extraction prompts, and so on.

[0051] Exemplarily, the preset text block length may be a preset number of characters or a preset number of tokens, etc. 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. The specific value of the preset text block length may be set according to actual needs, and this embodiment does not impose any restrictions thereon. By dividing the text to be refined according to the preset text block length, the divided text blocks can meet actual needs, thereby improving the rationality of the text blocks.

[0052] Exemplarily, the text to be refined is divided starting from the starting position of the text according to a preset text block length, and a section of text with the preset text block length is cut off as the first text block; subsequently, a section of text with the preset text block length is cut off from the starting position of the remaining text respectively to obtain subsequent text blocks, until the last text block is cut off, thereby dividing the text to be refined into multiple text blocks.

[0053] Step 102, for each of the text blocks, generate prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and the text refinement prompt word.

[0054] In the embodiment of the present invention, for each text block, the refined content of the adjacent text blocks corresponding to the text block can be obtained. This method also adds the refined content of the adjacent text blocks to the first text block, thereby improving the problem that the first text block has no contextual association basis.

[0055] Exemplarily, for any text block, when the text block is the first text block, the refined content of the adjacent text block corresponding to the text block is: the temporary refined content of the second text block. When the text block is not the first text block, the refined content of the adjacent text block corresponding to the text block is: the refined content of the previous text block of the text block.

[0056] Exemplarily, when the text block is the first text block, before the text content of the first text block is refined, the temporary refined content of the second text block can be obtained through the large language model, and the temporary refined content of the second text block is used as the adjacent text refined content corresponding to the first text block. Exemplarily, the content of the second text block is delivered to the large language model using prompt rendering, and the text content of the second text block is refined by the large language model, so as to obtain the temporary refined content of the second text block.

[0057] Specifically, the second text block and the temporary text extraction prompt word can be combined to obtain a temporary prompt text; according to the temporary prompt text, the second text block is subjected to text content extraction by the large language model to obtain the temporary extracted content of the second text block. The temporary text extraction prompt word is a prompt word used to guide the large language model to extract the text content of the second text block. For example, the temporary text extraction prompt word can be: extract the text content of the text block.

[0058] In the embodiment of the present invention, for each text block, the weight of the extracted content of the adjacent text block corresponding to the text block can be pre-set. This method can adjust the influence of the extracted content of the current text block on the extracted content of the adjacent text block by setting the weight, improves the problem of unreasonable analysis results caused by not setting the weight of the text block, and thus more accurately guides the large language model to extract the text content of the text block.

[0059] The specific values ​​of the weight of the text block and the weight of the extracted content of the adjacent text block can be set according to actual needs. The weights set for different text blocks can be the same or different. The weight of the subsequent text block can be set smaller than the weight of the previous text block, or the weight of the subsequent text block can be set greater than the weight of the previous text block. This embodiment does not impose any restrictions on this.

[0060] In an embodiment of the present invention, for each text block, a prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and a text refinement prompt word can be generated.

[0061] Exemplarily, a prompt template (Prompt) may be preset, and the prompt template may include a current text adding position, a current text weight adding position, an adjacent text adding position, an adjacent text weight adding position, a text refinement prompt word, and the like.

[0062] The text extraction prompt words are prompt words used to guide the large language model to extract text content. Exemplarily, the text extraction prompt words can be used to guide the large language model to extract text content from the text block, and the text content extraction needs to be performed based on the weight of the text block and the weight of the extracted content of the adjacent text blocks.

[0063] For example, the prompt template can be expressed as follows:

[0064] Current text:…

[0065] Current text weights:…

[0066] Preceding / Following text:…

[0067] Preceding / Following text weights:…

[0068] Get abstract only from current text, but referred to both current andpreceding / following texts, with weights respectively

[0069] in:

[0070] The string "Current text:" is used as a marker to indicate the current text adding position, followed by the content of the current text block;

[0071] The string "Current text weights:" is used as a marker to indicate the location where the current text weight is added, followed by the weight of the current text block, which reflects the degree of influence of the current text block on the refinement of its own text content, and is a floating point number less than or equal to 1.

[0072] The string "Preceding / Following text:" is used as a marker to indicate the location where adjacent text is added, followed by the refined content of the previous or following text block of the current text block;

[0073] The string "Preceding / Following text weights:" is used as a marker to indicate the location where the adjacent text weights are added, followed by the degree of influence of the refined content of the previous or following text block of the current text block on the text content refinement of the current text block. The sum of the adjacent text weights and the current text weight is 1, which is a floating point number less than 1.

[0074] The instruction "Get abstract only from current text, but referred to both current and preceding / following texts, with weights respectively" indicates a text extraction prompt word, which means extracting content from the current text block. However, how to extract and organize the content is based on the influence weight of the preceding / following texts and the current text block content.

[0075] Exemplarily, for any text block, the process of generating a prompt text including the text block, the weight of the text block, the adjacent text block extract content corresponding to the text block, the weight of the adjacent text block extract content, and the text extract prompt word may include: adding the text block to the current text adding position of the prompt template, adding the weight of the text block to the current text weight adding position of the prompt template, adding the adjacent text block extract content to the adjacent text adding position of the prompt template, adding the weight of the adjacent text block extract content to the adjacent text weight adding position of the prompt template, and obtaining the prompt text, wherein the prompt template also includes the text extract prompt word. This method informs the large language model of the scope of weight distribution and summary generation in the form of natural language by designing a prompt template, and uses the context understanding (in-context learning) ability of the large language model to generate a logical connection relationship, so that the context connection is smoother, and the subsequent content will not gradually shrink due to the order of complex text segmentation.

[0076] Step 103: According to the prompt text, the text block is refined by using a large language model to obtain the refined content of the text block.

[0077] Exemplarily, for each of the text blocks, after the prompt text of the text block is generated, the prompt text of the text block can be input into the large language model, and the large language model extracts the text content of the text block based on the prompt text according to the guidance of the text extraction prompt words in the prompt text, thereby obtaining the refined content of the text block. The extraction process within the large language model can be processed according to actual experience, and this embodiment will not be discussed in detail here.

[0078] Step 104, determining the refined content of the text to be refined based on the refined contents of the plurality of text blocks.

[0079] Exemplarily, after obtaining the refined contents of the plurality of text blocks, the refined contents of the plurality of text blocks can be spliced ​​into complete contents, and the complete contents can be determined as the refined contents of the text to be refined. Specifically, the splicing can be performed in the order of the text blocks, so as to maintain the original relevance of the text information.

[0080] In the embodiment of the present invention, for each text block, not only the current text block is considered, but also the refined content of the adjacent text blocks of the current text block, the weight of the current text block, and the weight of the refined content of the adjacent text blocks are further added. By adding the refined content of the adjacent text blocks, the original contextual relevance of the text to be refined can be retained, and by adding the weights, the influence of the refined content of the current text block on the refined content of the adjacent text blocks can be adjusted, so that the large language model is not only used as a simple summary acquisition tool, but can comprehensively extract the content of the current text block, the refined content of the adjacent text blocks, and the set weights, so as to extract text content that better meets the requirements, thereby improving the accuracy of text extraction.

[0081] Figure 2 The present invention is a flowchart of another method for extracting text content in an embodiment of the present invention.

[0082] like Figure 2 As shown, the text content extraction method may include the following steps:

[0083] Step 201, dividing the text to be refined into multiple text blocks.

[0084] Step 202, for each of the text blocks, generate prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and the text refinement prompt word.

[0085] Step 203: According to the prompt text, the text block is refined by using a large language model to obtain the refined content of the text block.

[0086] Step 204, splicing the extracted contents of the plurality of text blocks into complete content.

[0087] Exemplarily, the refined contents of the multiple text blocks may be spliced ​​into complete content in the order of the multiple text blocks.

[0088] Step 205, determining whether the length of the complete content is less than or equal to the target length. If not, executing step 206; if yes, executing step 207.

[0089] In the embodiment of the present invention, the length of the complete content may be compared with the target length to determine whether the desired extracted length has been reached.

[0090] The specific value of the target length can be set according to actual needs, and this embodiment does not limit this. For example, if the extracted content is to be embedded, the context window length acceptable to the embedding interface is considered as the target length; if the extracted content is to be placed in the context understanding (in-context learning) module of the large language model as plug-in knowledge, the context window length acceptable to the large language model is considered as the target length, and so on.

[0091] Step 206, taking the complete content as the text to be refined again, and returning to execute step 201.

[0092] 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 process returns to step 201, and the above-mentioned operation of refining the text to be refined is performed in a loop until the length of the complete content is less than or equal to the target length.

[0093] Step 207: determine the complete content as the refined content of the text to be refined.

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

[0095] In the embodiment of the present invention, by setting a target length, the length of the complete content is compared with the target length, so that the refined content of the text to be refined can meet subsequent usage requirements, further improving the accuracy and rationality of the refined content.

[0096] Figure 3 A schematic diagram of a text content extraction process in an embodiment of the present invention.

[0097] like Figure 3As shown in the figure, in the process of text content extraction, the text to be extracted (Whole doc / text) is first divided into text blocks (Split into chunks) to obtain multiple text blocks (chunks); before the first text block, that is, text block 0 (chunk0), is subjected to text content extraction, the second text block, that is, text block 1 (chunk1), is first delivered to the large language model (LLMs) for text content extraction to obtain a temporary extracted content (abstract0'); when the text content of text block 0 (chunk0) is extracted, the text block 0 (chunk0) and the temporary extracted content (abstract0') are delivered to the large language model (LLMs) for text content extraction to obtain the extracted content 0 (abstract0) of the text block 0 (chunk0); when the text content of text block 1 (chunk1) is extracted, the extracted content of the text block 0 (chunk0) is delivered to the large language model (LLMs) for text content extraction. Refined content 0 (abstract0) and text block 1 (chunk1) are delivered to the large language model (LLMs) for text content extraction to obtain the refined content 1 (abstract1) of text block 1 (chunk1); and so on, to obtain the refined content (abstract) of each text block (chunk); the refined content of each text block is summarized and merged (Reduce / merge) to obtain the refined content of the text to be refined; if the length of the refined content of the text to be refined is less than or equal to the target length, the process ends; if the length of the refined content of the text to be refined is greater than the target length, the refined content of the text to be refined is re-used as the text to be refined, and the above-mentioned text content extraction process is executed repeatedly until the length of the refined content of the text to be refined is less than or equal to the target length.

[0098] The text content extraction method proposed in the embodiment of the present invention can be applied to Figure 4 In the text analysis framework shown in Figure 4 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 4 The stage of using large language models to answer text analysis questions.

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

[0100] 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.

[0101] 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.

[0102] (2) Raising text analysis questions

[0103] 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.

[0104] 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.

[0105] (3) Answer text analysis questions

[0106] 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.

[0107] 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.

[0108] Guided by the prompt paradigm, the large language model can be used to understand text analysis questions based on the question and answer history of the questioner and the answerer, and choose the way to answer the text analysis questions. The world knowledge accumulated during pre-training can be used to answer; or the interface call can be used to solve the problem based on the understanding of the interface description in the Action Space. For example, for the understanding of the plot, the search engine can be used to obtain relevant information. For the analysis of complex and long texts, the 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.

[0109] 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 the text content extraction method proposed in the embodiment of the present invention.

[0110] (4) Text Analysis Answer Evaluation

[0111] 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.

[0112] (5) Multi-layer sample enhancement

[0113] 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.

[0114] Figure 5 It is a structural block diagram of a text content extraction device in an embodiment of the present invention.

[0115] like Figure 5 As shown, the text content extraction device may include the following modules:

[0116] A division module 401 is used to divide the text to be refined into a plurality of text blocks;

[0117] A generating module 402 is used to generate, for each of the text blocks, a prompt text including the text block, a weight of the text block, an extracted content of an adjacent text block corresponding to the text block, a weight of the extracted content of the adjacent text block, and a text extraction prompt word;

[0118] The refining module 403 is used to extract the text content of the text block through a large language model according to the prompt text to obtain the refined content of the text block;

[0119] The determination module 404 is used to determine the refined content of the text to be refined according to the refined contents of the multiple text blocks.

[0120] Optionally, when the text block is the first text block, the refined content of the adjacent text block corresponding to the text block is: the temporary refined content of the second text block; when the text block is not the first text block, the refined content of the adjacent text block corresponding to the text block is: the refined content of the previous text block of the text block.

[0121] Optionally, the device further comprises: an acquisition module, configured to acquire temporary refined content of the second text block by using a large language model when the text block is the first text block.

[0122] Optionally, the generation module 402 is specifically used to add the text block to the current text adding position of the prompt template, add the weight of the text block to the current text weight adding position of the prompt template, add the adjacent text block refined content to the adjacent text adding position of the prompt template, add the weight of the adjacent text block refined content to the adjacent text weight adding position of the prompt template, to obtain the prompt text, and the prompt template also includes the text refined prompt word.

[0123] Optionally, the text extraction prompt words are used to guide the large language model to extract text content from the text block, and the text extraction needs to be performed based on the weight of the text block and the weight of the extracted content of the adjacent text blocks.

[0124] Optionally, the determination module 404 is specifically configured to splice the extracted contents of the plurality of text blocks into complete contents, and determine the complete contents as the extracted contents of the text to be extracted.

[0125] Optionally, the determination module 404 is specifically used to splice the refined contents of multiple text blocks into complete content; when the length of the complete content is less than or equal to the target length, the complete content is determined as the refined content of the text to be refined; when 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 step of dividing the text to be refined into multiple text blocks is returned to execute.

[0126] Optionally, the division module 401 is specifically configured to divide the text to be refined into a plurality of text blocks according to a preset text block length. The context window length of the large language model is greater than twice the preset text length.

[0127] In the embodiment of the present invention, for each text block, not only the current text block is considered, but also the refined content of the adjacent text blocks of the current text block, the weight of the current text block, and the weight of the refined content of the adjacent text blocks are further added. By adding the refined content of the adjacent text blocks, the original contextual relevance of the text to be refined can be retained, and by adding the weights, the influence of the refined content of the current text block on the refined content of the adjacent text blocks can be adjusted, so that the large language model is not only used as a simple summary acquisition tool, but can comprehensively extract the content of the current text block, the refined content of the adjacent text blocks, and the set weights, so as to extract text content that better meets the requirements, thereby improving the accuracy of text extraction.

[0128] The embodiment of the present invention further provides an electronic device, such as Figure 6 As shown, it includes a processor 501 , a communication interface 502 , a memory 503 and a communication bus 504 , wherein the processor 501 , the communication interface 502 , and the memory 503 communicate with each other via the communication bus 504 .

[0129] Memory 503, used for storing computer programs;

[0130] The processor 501 is used to execute the program stored in the memory 503, and implements the following steps:

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

[0132] For each of the text blocks, generating a prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and a text refinement prompt word;

[0133] According to the prompt text, extracting the text content of the text block through a large language model to obtain the extracted content of the text block;

[0134] The refined content of the text to be refined is determined according to the refined contents of the plurality of text blocks.

[0135] Optionally, when the text block is the first text block, the refined content of the adjacent text block corresponding to the text block is: the temporary refined content of the second text block; when the text block is not the first text block, the refined content of the adjacent text block corresponding to the text block is: the refined content of the previous text block of the text block.

[0136] Optionally, before generating a prompt text including the text block, the weight of the text block, the refined content of the adjacent text block corresponding to the text block, the weight of the refined content of the adjacent text block, and a text refinement prompt word, it also includes: when the text block is the first text block, obtaining temporary refined content of the second text block through a large language model.

[0137] Optionally, a prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and a text refinement prompt word is generated, including: adding the text block to the current text adding position of the prompt template, adding the weight of the text block to the current text weight adding position of the prompt template, adding the adjacent text block refined content to the adjacent text adding position of the prompt template, adding the weight of the adjacent text block refined content to the adjacent text weight adding position of the prompt template, to obtain the prompt text, wherein the prompt template also includes the text refinement prompt word.

[0138] Optionally, the text extraction prompt words are used to guide the large language model to extract text content from the text block, and the text extraction needs to be performed based on the weight of the text block and the weight of the extracted content of the adjacent text blocks.

[0139] Optionally, determining the refined content of the text to be refined based on the refined contents of the multiple text blocks includes: splicing the refined contents of the multiple text blocks into complete content, and determining the complete content as the refined content of the text to be refined.

[0140] Optionally, it includes: splicing the refined contents of multiple text blocks into complete content; when the length of the complete content is less than or equal to the target length, determining the complete content as the refined content of the text to be refined; when the length of the complete content is greater than the target length, re-using the complete content as the text to be refined, and returning to execute the step of dividing the text to be refined into multiple text blocks.

[0141] Optionally, 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; and the context window length of the large language model is greater than twice the preset text length.

[0142] The communication bus mentioned in the above terminal 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.

[0143] The communication interface is used for communication between the above terminal and other devices.

[0144] 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.

[0145] 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.

[0146] 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 executed on a computer, the computer implements the text content extraction method described in any of the above embodiments.

[0147] 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 implement the text content extraction method described in any one of the above embodiments.

[0148] 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.

[0149] 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.

[0150] 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.

[0151] 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 text content extraction method, characterized in that: include: Divide the text to be extracted into multiple text blocks; For each of the text blocks, generating a prompt text including the text block, the weight of the text block, the refined content of the adjacent text blocks corresponding to the text block, the weight of the refined content of the adjacent text blocks, and a text refinement prompt word; According to the prompt text, extracting the text content of the text block through a large language model to obtain the extracted content of the text block; The refined content of the text to be refined is determined according to the refined contents of the plurality of text blocks.

2. The method according to claim 1, characterized in that When the text block is the first text block, the refined content of the adjacent text block corresponding to the text block is: the temporary refined content of the second text block; When the text block is not the first text block, the refined content of the adjacent text block corresponding to the text block is: the refined content of the previous text block of the text block.

3. The method according to claim 2, characterized in that Before generating a prompt text including the text block, the weight of the text block, the refined content of the adjacent text block corresponding to the text block, the weight of the refined content of the adjacent text block, and the text refinement prompt word, the method further includes: When the text block is the first text block, the temporary refined content of the second text block is obtained through the large language model.

4. The method according to claim 1, characterized in that: Generating a prompt text including the text block, the weight of the text block, the refined content of the adjacent text block corresponding to the text block, the weight of the refined content of the adjacent text block, and a text refinement prompt word, including: Add the text block to the current text adding position of the prompt template, add the weight of the text block to the current text weight adding position of the prompt template, add the adjacent text block refined content to the adjacent text adding position of the prompt template, add the weight of the adjacent text block refined content to the adjacent text weight adding position of the prompt template, and obtain the prompt text, wherein the prompt template also includes the text refined prompt word.

5. The method according to claim 1, characterized in that The text extraction prompt words are used to guide the large language model to extract the text content of the text block, and the text content extraction needs to be performed according to the weight of the text block and the weight of the extracted content of the adjacent text blocks.

6. The method according to claim 1, characterized in that Determining the refined content of the text to be refined according to the refined contents of the plurality of text blocks includes: The extracted contents of the plurality of text blocks are spliced ​​into complete content, and the complete content is determined as the extracted content of the text to be extracted.

7. The method according to claim 1, characterized in that Determining the refined content of the text to be refined according to the refined contents of the plurality of text blocks includes: splicing the extracted contents of the plurality of text blocks into complete content; When the length of the complete content is less than or equal to the target length, determining the complete content as the refined content of the text to be refined; When 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 process returns to the step of dividing the text to be refined into a plurality of text blocks.

8. The method according to claim 1, characterized in that Divide the text to be extracted into multiple text blocks, including: The text to be refined is divided into a plurality of text blocks according to a preset text block length; and the context window length of the large language model is greater than twice the preset text length.

9. A text content extraction device, characterized in that: include: A division module, used for dividing the text to be extracted into multiple text blocks; A generating module, for generating, for each of the text blocks, a prompt text including the text block, a weight of the text block, an extracted content of an adjacent text block corresponding to the text block, a weight of the extracted content of the adjacent text block, and a prompt word for text extraction; A refining module, used to extract the text content of the text block through a large language model according to the prompt text, so as to obtain the refined content of the text block; The determination module is used to determine the refined content of the text to be refined based on the refined contents 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 according to 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.

Citation Information

Patent Citations

  • Information identification method and device based on graph convolutional neural network, and storage medium

    CN112949477A

  • Method and device for assisting visual questioning and answering of visually impaired people, computing equipment and storage medium

    CN113032535A

  • Document processing method and device

    CN114817444A

  • Long text processing method and device, electronic equipment and storage medium

    CN117764066A

  • Document abstract generation method, computer equipment, storage medium and program product

    CN118332104A

Cited By

  • RAG-based electric power communication management file assisted compilation method and system

    CN120234405A