Ultra-long text generation method and device, equipment and storage medium
By generating an initial text outline using a large model, processing chapter content in parallel, and inserting transitional text, the problem of low efficiency and poor coherence in generating extremely long texts is solved, achieving efficient and logically coherent text generation.
Patent Information
- Application Number
- CN202511379949.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2026-01-06
AI Technical Summary
Existing technologies generate extremely long texts with low efficiency and poor coherence. In particular, when processing long documents, they are prone to semantic coherence decay and forgetting of key information.
An initial text outline is generated using a large model, including multiple chapter titles and summaries. The text complexity is calculated to generate chapter content in parallel. Parallel computing and transitional text splicing techniques are used to ensure text coherence and quality.
It improves the efficiency and coherence of generating extremely long texts, reduces generation costs, and produces rich and logically coherent text content.
Smart Images

Figure CN121279271A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, specifically to a method, apparatus, device, and storage medium for generating ultra-long texts. Background Technology
[0002] In recent years, large-scale language models based on the Transformer architecture, such as the Generative Pre-trained Transformer (GPT) series, have generally adopted an autoregressive generation mechanism for text generation. This mechanism predicts and generates the next token in the text sequence one by one, gradually constructing the complete text output in a serial computation manner. However, text generation under this mechanism has drawbacks such as long processing time, loss of text coherence when processing long documents, and forgetting of key information. Summary of the Invention
[0003] This invention provides a method, apparatus, device, and storage medium for generating ultra-long text, in order to solve the problems of low efficiency and poor coherence in generating ultra-long text in the prior art.
[0004] To address the aforementioned technical problems, in a first aspect, the present invention provides a method for generating ultra-long text. This method includes: responding to a document generation instruction, generating an initial text outline of the target text using a large model; wherein the initial document outline includes multiple chapter titles and corresponding chapter content summaries; calculating the text complexity of the target text based on keyword information from the initial document outline, the text complexity being correlated with the topic breadth of the keywords and the expected word count of the target text; if the text complexity of the target text is greater than a preset threshold, determining the initial text outline as the target text outline; and generating and concatenating the text content corresponding to each chapter title in parallel based on the target text outline to obtain the target text.
[0005] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of generating and concatenating the text content corresponding to each chapter title in parallel based on the target text outline to obtain the target text includes: calling the large model in parallel to parse the content of each chapter title, generating and sorting the text content corresponding to each chapter title; and sequentially concatenating the text content corresponding to each chapter title, as well as the transition text between the text content corresponding to adjacent chapter titles, to obtain the target text.
[0006] In conjunction with the first aspect, in one possible implementation of the first aspect, calculating the text complexity of the target text based on the keyword information of the initial document outline includes: extracting features from the initial document outline to obtain the embedding vectors of the keywords; calculating the topic breadth of the keywords based on the embedding vectors of the keywords and the number of keywords; and calculating the text complexity of the target text based on the topic breadth of the keywords and the expected number of words in the target text; wherein the text complexity is positively correlated with the topic breadth of the keywords and the expected number of words in the target text.
[0007] In conjunction with the first aspect, one possible implementation of the first aspect further includes: the formula for calculating the topic breadth of the keyword is:
[0008] in, The topic breadth of the keywords; Let i,j∈{1,2,..,n} be the number of keywords. This is the embedding vector of the first keyword. This is the embedding vector for the second keyword; This is a pre-defined embedding vector extraction model.
[0009] In conjunction with the first aspect, one possible implementation of the first aspect further includes: the formula for calculating the text complexity of the target text is as follows:
[0010] in, The text complexity of the target text; The topic breadth of the keywords; The expected number of words in the target text; This is the first weight parameter; This is the second weighting parameter.
[0011] In conjunction with the first aspect, one possible implementation of the first aspect further includes: if the text complexity of the target text is less than the preset threshold, then adjusting the keyword information of the initial text outline based on a preset complexity adjustment rule; returning to the step of calculating the text complexity of the target text based on the keyword information of the initial document outline, until the text complexity of the target text is greater than the preset threshold.
[0012] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of generating an initial text outline of the target text through a large language model in response to a document generation instruction includes: obtaining target input information input by the user; generating an initial text outline of the target text through the large language model based on the target input information and a preset document generation mode; wherein the large language model includes a preset editing function.
[0013] Secondly, the present invention provides an ultra-long text generation device, comprising: a first generation module, configured to generate an initial text outline of a target text through a large model in response to a document generation instruction; wherein the initial document outline includes multiple chapter titles and corresponding chapter content summaries; a calculation module, configured to calculate the text complexity of the target text based on keyword information of the initial document outline, wherein the text complexity is related to the topic breadth of the keywords and the expected word count of the target text; a determination module, configured to determine the initial text outline as the target text outline if the text complexity of the target text is greater than a preset threshold; and a second generation module, configured to generate and concatenate the text content corresponding to each chapter title in parallel based on the target text outline to obtain the target text.
[0014] Thirdly, the present invention provides an ultra-long text generation device, including a memory and a processor, wherein: The memory is used to store computer programs; The processor is used to read the program in the memory and execute the steps of the ultra-long text generation method provided in the first aspect above.
[0015] Fourthly, the present invention provides a computer-readable storage medium having a readable computer program stored thereon, which, when executed by a processor, implements the steps of the ultra-long text generation method provided in the first aspect above.
[0016] Compared with the prior art, the present invention provides a method, apparatus, device, and storage medium for generating ultra-long text, which has the following beneficial effects: In response to document generation instructions, an initial text outline of the target text is generated through a large model. This initial text outline includes multiple chapter titles. Based on the keyword information of the initial text outline, the text complexity of the target text is calculated. The text complexity is related to the topic breadth of the keywords and the expected word count of the target text. If the text complexity of the target text exceeds a preset threshold, the initial text outline is determined as the target text outline. Based on the target text outline, the text content corresponding to each chapter title is generated in parallel and then concatenated to obtain the target text. This approach can improve the generation efficiency and text coherence of ultra-long texts, as well as the overall text quality, while reducing the generation cost of ultra-long texts. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and not all embodiments. For those skilled in the art, other drawings obtained from these drawings without creative effort are all within the scope of protection of this application. Figure 1 This is a flowchart illustrating the method for generating ultra-long text provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of the ultra-long text generation device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of the ultra-long text generation device provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0019] To make the description of this disclosure more detailed and complete, illustrative descriptions of embodiments and specific examples of the present invention are provided below; however, these are not the only forms of implementing or utilizing the specific embodiments of the present invention. The embodiments cover features of multiple specific embodiments and the methods, steps, and their order for constructing and operating these specific embodiments. However, other specific embodiments may also be used to achieve the same or equivalent functions and step sequences. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this application.
[0020] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in sequences other than those illustrated or described herein.
[0021] In the description of the embodiments of the present invention, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The word "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more. Other quantifiers should be understood similarly. The preferred embodiments described herein are only used to illustrate and explain the present invention and are not intended to limit the present invention. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0022] In traditional autoregressive generation mechanisms, large models achieve text output based on serial computation of each label. Their linear generation characteristics result in a positive correlation between time efficiency and text length. At the same time, due to the limited capacity of the fixed context window, there is a phenomenon of semantic coherence decay and loss of key information during the generation of long texts.
[0023] To address this issue, embodiments of this application provide a method, apparatus, device, and storage medium for generating ultra-long text, which can improve the text coherence of the generated ultra-long text, increase the generation efficiency of ultra-long text, and reduce the model generation cost.
[0024] Example 1 Figure 1 This is a flowchart illustrating a method for generating extremely long text provided in an embodiment of the present invention.
[0025] See Figure 1 A method for generating extremely long text includes the following steps: Step S110: In response to the document generation instruction, an initial text outline of the target text is generated through a large model; wherein, the initial document outline includes multiple chapter titles and corresponding chapter content summaries.
[0026] Specifically, the large model is a natural language processing model trained on a deep learning architecture, capable of generating coherent text based on document generation instructions. According to these instructions, the large model can generate an initial text outline of the target text required by the user. This initial outline includes multiple chapter titles, which macroscopically display the overall structure and core content direction of the target text. Each chapter title represents an important thematic section within the target text, providing a clear framework for subsequent detailed text generation.
[0027] In one possible implementation, in response to a document generation instruction, generating an initial text outline of the target text using a large language model includes: obtaining target input information input by the user; generating an initial text outline of the target text using a large language model based on the target input information and a preset document generation mode; wherein the large language model includes a preset directing function.
[0028] Specifically, the target input information can be text information, voice information, etc., entered by the user on the interactive interface. The target input information can include the topic keywords corresponding to the target text, the content generation direction, format requirements, etc.
[0029] Specifically, the preset document generation mode allows for different selection methods for the number of chapters in the initial text outline. For example, users can manually set the number of chapters in the initial text outline or set a range for the number of chapters, allowing the large model to automatically select the appropriate number. The initial text outline can include chapter titles and corresponding chapter content summaries. When generating the initial text outline, users can pre-set the number of chapter titles to be generated, for example, 5-20. Controlling the number of chapter titles to 5-20 can improve the computational efficiency of the large model during parallel computing and reduce the number of erroneous text generated. For example, users can set the large model to generate a text outline containing several chapters in the document generation command, or set a range for the number of chapters the large model needs to generate, such as 10-15 chapters, and set arrangement rules, such as "arranged in chronological order" or "sorted by importance." The large model can then automatically determine the optimal number of chapters corresponding to the initial text outline of the target text. These two methods of determining the number of chapters can adapt to different output scenarios, satisfying the needs of structured output while retaining the flexibility of intelligent generation.
[0030] Specifically, large models can obtain an initial text outline through prediction using multiple decoders based on the instruction function. ,in,
[0031] Enter information for the target. This refers to the schema or architecture of a large model, such as metadata used to describe data structures, organizational rules, or logical frameworks. This is the directing function.
[0032] For example, the target input information provided by the user can be converted into a standardized semantic vector sequence. This semantic vector sequence is concatenated with the template vector corresponding to the document generation pattern and then input into the editing function. The editing function uses a multi-head attention mechanism to identify the core elements in the input information and generate a sequence of chapter titles. During the generation process, the output layer of the editing function can employ a constraint decoding strategy to ensure that the chapter titles conform to preset naming conventions and logical order.
[0033] Step S120: Based on the keyword information of the initial document outline, calculate the text complexity of the target text. The text complexity is related to the topic breadth of the keywords and the expected number of words in the target text.
[0034] Specifically, the initial document outline can include multiple keywords and their corresponding keyword information. This keyword information reflects the core theme and key content of the target text. Text complexity is an indicator that quantifies the difficulty of generating the target text content; the greater the text complexity, the more difficult the target text generated from the initial document outline. Text complexity is related to the topic breadth of the keywords and the expected word count of the target text. The topic breadth of the keywords can be obtained through a preset algorithm, and the expected word count of the target text can be preset. Furthermore, the expected word count of the target text can be determined based on the user's historical expected word count. For example, if the user's historical expected word count is frequently set to 10,000 or 20,000 words, then the expected word count of the target text can be determined to be 10,000 or 20,000 words.
[0035] For example, a large model can extract keyword information from the initial document outline, calculate the topic breadth corresponding to the keyword information through a preset algorithm, and calculate the text complexity of the target text by combining it with the expected word count of the target text. By calculating the text complexity, the difficulty and depth of the text can be better grasped in the subsequent text generation process to ensure that the generated target text meets the user's needs.
[0036] In one possible implementation, the text complexity of the target text is calculated based on the keyword information of the initial document outline, including: extracting features from the initial document outline to obtain keyword embedding vectors; calculating the topic breadth of the keywords based on the keyword embedding vectors and the number of keywords; and calculating the text complexity of the target text based on the topic breadth of the keywords and the expected number of words in the target text; wherein the text complexity is positively correlated with the topic breadth of the keywords and the expected number of words in the target text.
[0037] Specifically, an embedding vector is a low-dimensional numerical vector obtained by extracting features from keywords using a natural language processing model. It represents the semantics or features of an object using a set of dense numbers (such as 300-dimensional floating-point numbers). It contains the semantic features of keywords and contextual information, and can quantify the position and relationship of keywords in a high-dimensional semantic space. The large model can perform keyword recognition and word segmentation on the initial text outline to obtain keywords. Then, it extracts features from the keywords using a pre-defined embedding vector extraction model. The word embedding layer of the model can convert the keywords into high-dimensional semantic vectors. Then, the context encoding module of the large model is used to obtain the association information of keywords in the logical structure of the outline, and the high-dimensional vector is reduced in dimensionality and semantically enhanced. Finally, a low-dimensional embedding vector containing the semantic features of keywords and contextual relationships is output.
[0038] Specifically, after obtaining the keyword embedding vectors and the number of keywords, the topic breadth corresponding to the keywords can be calculated. Topic breadth refers to an indicator that measures the scope of text topic coverage through the differences between keyword vectors. The topic breadth can quantify the breadth or diversity of the semantic range covered by a chapter topic through the distribution characteristics of keyword embedding vectors. The larger the topic breadth, the wider the semantic range covered by the keywords. Finally, the topic breadth and the expected word count can be weighted and summed to obtain the text complexity of the target text. The generation strategy can be dynamically adjusted according to the complexity score to quantify the complexity of the target text, avoid generating overly simple or overly complex text content, and facilitate the generation of high-quality long texts and improve the semantic coherence of long text generation.
[0039] In one possible implementation, the formula for calculating the topic breadth of keywords is:
[0040] in, The breadth of topics for keywords; The number of keywords, , ∈{1,2,..,n}; This is the embedding vector of the first keyword. This is the embedding vector for the second keyword; This is a pre-defined embedding vector extraction model.
[0041] Specifically, The pre-defined embedding vector extraction model is a pre-trained language model based on the Transformer architecture (such as BERT, GPT, etc.). It captures the semantic features and logical relationships of keywords through word embedding layers and context encoding modules, and can convert keyword text into low-dimensional semantic vectors.
[0042] Specifically, we can first go through The model converts each keyword into a fixed-dimensional embedding vector. It then iterates through all keyword combinations, calculating the cosine similarity between the vectors of each distinct keyword pair, and subtracting this similarity value from 1 to obtain the semantic dissimilarity score. Finally, it sums the semantic dissimilarity scores of all non-repeating keyword pairs and divides by 1. After normalization, the topic breadth of the keywords is finally obtained.
[0043] For example, each keyword is accessed through... The model is converted into a 768-dimensional vector. For example, for the keywords "artificial intelligence" and "machine learning," the resulting vectors are... and Then, the cosine similarity between the two vectors is calculated to obtain their corresponding semantic difference. The semantic difference is calculated pairwise for all keywords and averaged to obtain the topic breadth of the keywords.
[0044] In one possible implementation, the text complexity of the target text is calculated using the following formula:
[0045] in, The text complexity of the target text; The breadth of topics for keywords; The expected word count of the target text; This is the first weight parameter; This is the second weighting parameter.
[0046] Specifically, and It can be preset and adjusted according to different actual situations, and can be used to balance the impact of topic breadth and text length on complexity, for example... The value range can be set to 0.4-0.8. The value ranges from 0.2 to 0.6, and the sum of the two is kept at 1 to ensure the normalization of the calculation result. For example, in an academic paper generation scenario, A value of 0.7 can improve the topic diversity of the target text, and in the context of technical report generation, A value of 0.5 can increase the number of characters in the target text.
[0047] Specifically, after calculating the topic breadth of the initial text outline... Then, based on the user input or the preset target text's expected word count... Regarding the expected word count Take the logarithm to eliminate dimensional differences, then calculate the subject breadth. and The text complexity of the target text is obtained by multiplying each component by its corresponding weight coefficient and then linearly summing the results. For example, when =0.65、 =15000、 =0.6、 When the value is 0.4, the text complexity of the target text is... With a resolution of 2.1, it can flexibly adapt to different types of text generation needs, improve the coherence and accuracy of text generation, and help generate high-quality text that meets the expected complexity.
[0048] Step S130: If the text complexity of the target text is greater than a preset threshold, the initial text outline is determined as the target text outline.
[0049] Specifically, the preset threshold can be a pre-set critical value corresponding to the text complexity. When the text complexity of the target text is greater than the preset threshold, it can be considered that the content corresponding to the initial text outline has sufficient complexity and richness. At this time, the initial text outline can be determined as the target text outline to ensure that the subsequently generated text meets the user's expected standards in terms of content structure and topic depth, thereby improving the generation quality and coherence of ultra-long texts.
[0050] Specifically, when setting a preset threshold, a corresponding preset threshold can be set according to different text data. For example, the preset threshold can be related to the syntactic complexity of the text, the average depth of the dependency tree, the number of clauses; semantic complexity: word vector variance; lexical complexity, the proportion of professional terms, etc. By using a large amount of text data, a suitable preset threshold can be obtained in the end to prevent the complexity of the generated target text from being too low.
[0051] In one possible implementation, the method further includes: if the text complexity of the target text is less than a preset threshold, adjusting the keyword information of the initial text outline based on a preset complexity adjustment rule; returning to the step of calculating the text complexity of the target text based on the keyword information of the initial document outline, until the text complexity of the target text is greater than the preset threshold.
[0052] Specifically, if the text complexity of the target text is less than a preset threshold, it can be considered that the complexity of the target text is insufficient, and the target text generated subsequently will be too simplified. Therefore, it is necessary to delete the initial text outline and regenerate an initial text outline with higher text complexity.
[0053] Specifically, based on the preset complexity adjustment rules, the text complexity of the target text can be increased by increasing the number of keywords to broaden the topic, or by replacing the initial keywords with keywords with more complex semantics; by increasing the expected word count by modifying the chapter title structure; and by increasing the semantic density of keywords by introducing professional terms or compound sentences. Then, the text complexity of the adjusted target text is calculated until the text complexity of the target text is greater than the preset threshold, ensuring that the generated text content is rich and professional, and avoiding the generation of overly simple text.
[0054] For example, preset complexity adjustment rules can include adjusting keywords by "replacing basic vocabulary in the following text with academic / professional terms" or "using more precise verbs and adjectives to describe," such as replacing the keyword "growth" with "exponential increase" or "important" with "crucial." Sentence structures can also be expanded by "changing simple sentences into complex sentences containing relative and adverbial clauses" or "using parallel structures to express the core viewpoint," such as replacing "data increases" with "data shows significant growth, which not only reflects the surge in market demand but also reveals...". Complexity can also be increased by changing the logical hierarchy by "arguing the viewpoint in three points, each including theoretical basis and case studies" or "adopting a 'general-specific-general' structure, with each sub-argument connected by transition words," such as replacing a single-layer argument with a logical viewpoint of "firstly...secondly...however...finally...".
[0055] Step S140: Based on the target text outline, generate the text content corresponding to each chapter title in parallel and concatenate them to obtain the target text.
[0056] Specifically, after determining the target text outline, the large model can generate the text content corresponding to each chapter title in parallel according to the chapter content of the outline, and then splice the text content of each chapter in the order of the outline to obtain the target text that is structurally complete and logically coherent as required by the user. By generating the content of each chapter in parallel, the text generation speed of the large model can be improved, and the logical coherence of the text can be ensured.
[0057] For example, a user inputs a document generation command such as "Generate a review article on the application of artificial intelligence in the medical field, with a word count requirement of approximately 10,000 words." The large model can generate an initial text outline based on this command. For instance, the initial text outline may include eight chapter titles: "Introduction," "Overview of Artificial Intelligence Technology," "Application of Artificial Intelligence in Medical Diagnosis," "Application of Artificial Intelligence in Medical Image Analysis," "Application of Artificial Intelligence in Drug Development," "Application of Artificial Intelligence in Medical Management," "Challenges and Prospects," and "Conclusion." Each chapter title corresponds to a chapter content summary. Keywords such as "artificial intelligence," "medical," "diagnosis," and "image analysis" are extracted from the initial text outline, and the text complexity of the initial text outline is calculated. When the text complexity exceeds a preset threshold, the initial text outline is determined as the target text outline, and the text content corresponding to the eight chapters is generated simultaneously in parallel. For example, the generated content for the chapter "Application of Artificial Intelligence in Medical Diagnosis" includes the application of machine learning algorithms in disease prediction. The content of each chapter is then concatenated according to the outline order to obtain the target text.
[0058] In one possible implementation, based on the target text outline, the text content corresponding to each chapter title is generated in parallel and then concatenated to obtain the target text. This includes: calling a large model in parallel to parse the content of each chapter title, generating the text content corresponding to each chapter title and sorting it; and sequentially concatenating the text content corresponding to each chapter title, as well as the transition text between the text content corresponding to adjacent chapter titles, to obtain the target text.
[0059] Specifically, the large model is invoked in parallel to parse chapter titles. A multi-threaded scheduling mechanism is used to allocate computing resources, with each thread independently handling the semantic parsing task of one chapter title and generating the corresponding text content. Under parallel processing, the overall generation time of the target text can be composed of the maximum of the generation time of the target text outline and the generation time of the text content corresponding to each chapter title. The overall generation time of the target text can be calculated using the following formula:
[0060] in, The total generation time of the target text. The generation time of the target text outline. Generate the maximum time required for each chapter.
[0061] By generating the text content corresponding to each chapter title in parallel, the text generation speed can be improved. At the same time, the parallel generation of the text content corresponding to each chapter title can also alleviate the cascading propagation of erroneous tokens, thereby improving the overall quality of text generation.
[0062] After generating the text content corresponding to each chapter title, the chapters are sorted according to S defined by the big model based on the directing function, and transition text is inserted between the text content corresponding to adjacent chapter titles to enhance the coherence and readability of the generated text.
[0063] Transition text generation is achieved through a pre-trained text processing model. For example, T5 (Text-to-Text Transfer Transformer) can be used, which automatically generates transitional sentences by analyzing the semantic relationship between the last sentence of the preceding chapter and the first sentence of the following chapter. The T5 model is a pre-trained text generation model based on the Transformer architecture, capable of transforming natural language processing tasks into text generation tasks. Through an Encoder-Decoder structure, it encodes and decodes the input text, generating transitional sentences between each chapter of the target text.
[0064] in, This is the last sentence of chapter i. Using the T5 model to generate transition sentences between chapters, such as the first sentence of the next chapter, can improve the coherence of the target text.
[0065] Finally, the text content corresponding to each chapter title and the transition text between adjacent chapter titles are concatenated sequentially to obtain the target text.
[0066] For example, the target text outline contains 10 chapter titles. The large model assigns these 10 chapter titles to 10 independent threads, parsing each title in parallel to generate the corresponding text content. After generation, the text content corresponding to each chapter title is arranged in the order of "Industry Status Analysis → Technology Application → Case Study → Trend Prediction → … → Conclusion". The T5 model is invoked to generate transition text between the text content corresponding to adjacent chapter titles. For example, between the text content corresponding to the chapter titles "Technology Application" and "Case Study", the transition text "Based on the above-mentioned intelligent technologies, the actual effectiveness is further verified through typical enterprise practices" is generated and inserted. The text content corresponding to each chapter title and the transition text between adjacent chapter titles are then concatenated sequentially. Finally, the concatenated complete text is output as the final target text. By generating the text content corresponding to each chapter title in parallel, the text generation speed is increased, and by adding transition text between chapters, the coherence and readability of the generated text are enhanced, improving the overall quality of the target text.
[0067] This application discloses a method for generating ultra-long text, comprising: responding to a document generation instruction, generating an initial text outline of the target text through a large model; wherein the initial document outline includes multiple chapter titles; calculating the text complexity of the target text based on the keyword information of the initial document outline, the text complexity being related to the topic breadth of the keywords and the expected word count of the target text; if the text complexity of the target text is greater than a preset threshold, the initial text outline is determined as the target text outline; based on the target text outline, generating the text content corresponding to each chapter title in parallel and concatenating them to obtain the target text, which can improve the generation efficiency and text coherence of ultra-long text, as well as the overall text quality, and reduce the generation cost of ultra-long text.
[0068] Example 2 Based on the above-described method for generating extremely long texts, this invention provides an apparatus for generating extremely long texts, such as... Figure 2 As shown. The ultra-long text generation device 200 includes a first generation module 210, a calculation module 220, a determination module 230, and a second generation module 240.
[0069] The first generation module 210 is used to generate an initial text outline of the target text in response to a document generation instruction, using a large model; wherein the initial document outline includes multiple chapter titles and corresponding chapter content summaries; The calculation module 220 is used to calculate the text complexity of the target text based on the keyword information of the initial document outline. The text complexity is related to the topic breadth of the keywords and the expected number of words in the target text. The determination module 230 is used to determine the initial text outline as the target text outline if the text complexity of the target text is greater than a preset threshold. The second generation module 240 is used to generate the text content corresponding to each chapter title in parallel based on the target text outline and then concatenate them to obtain the target text.
[0070] For other details regarding the implementation of the above technical solution by each module in the above-mentioned ultra-long text generation device, please refer to the description of the ultra-long text generation method provided in the above-mentioned embodiments of the invention, which will not be repeated here.
[0071] Example 3 Based on the above methods for generating ultra-long texts, such as Figure 3 As shown, this embodiment of the invention also provides an ultra-long text generation device, which includes a processor 31 and a memory 32 coupled to the processor 31. The memory 32 stores a computer program, which, when executed by the processor 31, causes the processor 31 to perform the steps of the ultra-long text generation method in the above embodiment.
[0072] For other details regarding the implementation of the above technical solution by the processor 31 in the above-mentioned long text generation device, please refer to the description of the long text generation method provided in the above-mentioned embodiments of the invention, which will not be repeated here.
[0073] The processor 31 can also be called a CPU (Central Processing Unit). The processor 31 may be an integrated circuit chip with signal processing capabilities. The processor 31 can also be a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor, or the processor 31 can be any conventional processor.
[0074] Example 4 like Figure 4 As shown, this embodiment of the invention also provides a computer-readable storage medium storing a readable computer program 41. The computer program 41 can be stored in the storage medium in the form of a software product, including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks or optical disks, ROM (Read-Only Memory), RAM (Random Access Memory), or terminal devices such as computers, servers, mobile phones, and tablets.
[0075] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between apparatuses or modules, and may be electrical, mechanical, or other forms.
[0076] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0077] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0078] In the above embodiments, the implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, in the form of a computer program product.
[0079] A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0080] The technical solutions provided in this application have been described in detail above. Specific examples have been used in this application to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
[0081] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0082] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0083] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0084] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0085] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for generating an ultra-long text, characterized by, Comprising: in response to a document generation instruction, generating an initial text outline of a target text by a large model; wherein the initial document outline includes a plurality of chapter titles and corresponding chapter content summaries; based on keyword information of the initial document outline, calculating a text complexity of the target text, the text complexity being associated with a theme breadth of keywords and an expected word count of the target text; if the text complexity of the target text is greater than a preset threshold, determining the initial text outline as a target text outline; based on the target text outline, generating text content corresponding to each chapter title in parallel and splicing to obtain the target text.
2. The method of claim 1, wherein, The step of generating text content corresponding to each chapter title in parallel and splicing based on the target text outline to obtain the target text comprises: parallelly calling the large model to analyze the content of each chapter title, generate text content corresponding to each chapter title and sort; sequentially splicing the text content corresponding to each chapter title and the transition text between adjacent chapter titles to obtain the target text.
3. The method of claim 1, wherein, The step of calculating the text complexity of the target text based on the keyword information of the initial document outline comprises: extracting features from the initial document outline to obtain an embedding vector of the keywords; based on the embedding vector of the keywords and the number of keywords, calculating the theme breadth of the keywords; based on the theme breadth of the keywords and the expected word count of the target text, calculating the text complexity of the target text; wherein the text complexity is positively correlated with the theme breadth of the keywords and the expected word count of the target text.
4. The method of claim 3, wherein, Further comprising: The calculation formula of the theme breadth of the keywords is: wherein, is a subject breadth of the keyword; is a number of the keyword, i,j∈{1,2,..,n}; is an embedding vector of a first keyword, is an embedding vector of a second keyword; is a preset embedding vector extraction model.
5. The method of claim 3, wherein, Further comprising: The calculation formula of the text complexity of the target text is as follows: wherein, is a text complexity of the target text; is a topic breadth of the keyword; is an expected word count of the target text; is a first weight parameter; is a second weight parameter.
6. The method of claim 1, wherein, Further comprising: if the text complexity of the target text is less than the preset threshold, adjusting the keyword information of the initial text outline based on a preset complexity adjustment rule; returning to the step of calculating the text complexity of the target text based on the keyword information of the initial document outline until the text complexity of the target text is greater than the preset threshold.
7. The method of claim 1, wherein, The step of generating an initial text outline of a target text by a large language model in response to a document generation instruction comprises: obtaining target input information input by a user; based on the target input information and a preset document generation mode, generating the initial text outline of the target text by the large language model; wherein the large language model includes a preset director function.
8. An apparatus for generating an ultra-long text, characterized by comprising: Comprising: a first generation module for generating an initial text outline of a target text by a large model in response to a document generation instruction; wherein the initial document outline includes a plurality of chapter titles and corresponding chapter content summaries; a calculation module for calculating a text complexity of the target text based on keyword information of the initial document outline, the text complexity being associated with a theme breadth of keywords and an expected word count of the target text; determining that the text complexity of the target text is greater than a preset threshold, and determining the initial text outline as a target text outline; a second generation module, configured to generate text content corresponding to each of the chapter titles in parallel based on the target text outline, and splice the text content to obtain the target text.
9. An ultra-long text generation device, comprising a memory and a processor, wherein: the memory is configured to store a computer program; the processor is configured to read the computer program in the memory and perform the steps of any of the ultra-long text generation methods of claims 1-7.
10. A computer readable storage medium having a readable computer program stored thereon, wherein the program, when executed by a processor, implements the steps of any of the ultra-long text generation methods of claims 1-7.
Citation Information
Cited By
Method and device for intelligently generating report
CN122045413A