A large model-based text generation method, electronic equipment and storage medium
By quantitatively evaluating text feature values and selecting generation methods, the problem of large models processing complex text under limited resources is solved, achieving efficient generation of high-quality text suitable for intelligent writing and information aggregation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU YUNSHEN TECH CO LTD
- Filing Date
- 2026-03-18
- Publication Date
- 2026-06-26
AI Technical Summary
Large models struggle to effectively handle large volumes and complex text data when resources are limited, resulting in limitations in the accuracy and efficiency of generated text.
By acquiring multiple related texts associated with the event topic, the system quantitatively evaluates the feature values of text size, number of entities, and number of entity relationships. Based on the comparison results of these feature values with preset thresholds, the system automatically selects the text generation method, including direct generation or information extraction generation, to balance computational efficiency and the accuracy of text content.
Under resource constraints, it achieves efficient generation of high-quality text, breaks through the bottleneck of large models in processing long texts and complex materials, and provides a reliable solution for intelligent writing and information aggregation.
Smart Images

Figure CN121881996B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text processing, and in particular to a text generation method, electronic device, and storage medium based on a large model. Background Technology
[0002] Currently, large-scale data models, with their powerful and rapid reasoning capabilities, are widely used in many fields such as text processing, efficiently generating text reports from given text materials. However, limited by their own computing resources and storage capacity, large-scale models can only process a set number or complexity of text. In key application scenarios such as generating factual text reports, to ensure the accuracy and reliability of the generated text, it is often necessary to incorporate as much real-time text material as possible. This creates a pressing technical challenge: how to overcome the limitations of the number and complexity of text to be processed under the hard constraint of limited large-scale model resources, fully utilize massive amounts of real-time text material, and generate high-quality, high-precision text reports has become a critical technical problem that needs to be solved. Summary of the Invention
[0003] To address the aforementioned technical problems, the technical solution adopted by this invention is as follows:
[0004] According to a first aspect of the present invention, a text generation method based on a large model is provided, the method comprising the following steps:
[0005] S100, Obtain input information from the user, the input information including the event topic or including the event topic and reference text.
[0006] S200, based on the event topic, retrieve multiple related texts associated with the event topic from the text library; the text library stores the main text and extracted information of multiple texts, and the extracted information includes a summary and a knowledge graph.
[0007] S300: If the input information only includes the event topic, multiple related texts will be used as model guidance texts; if the input information includes the event topic and reference texts, multiple related texts and reference texts will be used as model guidance texts.
[0008] S400, obtain the first feature value, second feature value, and third feature value of the model-guided text; wherein, the first feature value is used to represent the text size, the second feature value is used to represent the number of entities in the text, and the third feature value is used to represent the number of entity relations in the text.
[0009] S500, compare the first feature value, second feature value and third feature value of the obtained model-guided text with the preset scale threshold, entity number threshold and entity relationship number threshold respectively, and determine the current text generation method based on the comparison results. The text generation method includes a first generation method and a second generation method. The first generation method is to directly generate a text using a large model based on the input model-guided text. The second generation method is to generate a text using a large model based on the extracted information of the input model-guided text.
[0010] S600, based on the determined current text generation method and model-guided text, the target text corresponding to the input information is generated using a large model. According to a second aspect of the present invention, an electronic device is provided, including a processor and a memory; the processor executes the steps of the method described in the first aspect of the present invention by calling programs or instructions stored in the memory.
[0011] According to a second aspect of the present invention, a computer-readable storage medium is provided that stores a program or instructions that cause a computer to perform the steps of the method described in the first aspect of the present invention.
[0012] The present invention has at least the following beneficial effects:
[0013] The text generation method based on a large model provided in this invention first obtains multiple related texts associated with the event topic from a text library. Next, it obtains a first feature value, a second feature value, and a third feature value from these related texts. The first feature value characterizes the text size, the second feature value characterizes the number of entities in the text, and the third feature value characterizes the number of entity relationships in the text. Then, it compares the obtained first, second, and third feature values of the related texts with preset size thresholds, entity number thresholds, and entity relationship number thresholds, respectively, and determines the current text generation method based on the comparison results. Finally, based on the determined current text generation method, it uses a large model to generate the target text corresponding to the input information. This invention automatically selects between original text generation and information extraction generation methods by quantitatively evaluating the length, entity complexity, and relationship density of text materials. Under resource-constrained conditions, it can balance computational efficiency and text content accuracy, breaking through the bottleneck of large models in processing long texts and complex materials, and providing an efficient and reliable solution for fields such as intelligent writing and information aggregation.
[0014] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart of a text generation method based on a large model provided in an embodiment of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0019] It should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. A process can be terminated when its operation is complete, but it may also have additional steps not included in the figures. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.
[0020] This invention provides a text generation method based on a large model, such as... Figure 1 As shown, the method includes the following steps:
[0021] S100, Obtain input information from the user, the input information including the event topic or including the event topic and reference text.
[0022] S200, based on the event topic, retrieve multiple related texts associated with the event topic from the text library; the text library stores multiple texts and extraction information for each text, the extraction information including summaries and knowledge graphs.
[0023] S300: If the input information only includes the event topic, multiple related texts will be used as model guidance texts; if the input information includes the event topic and reference texts, multiple related texts and reference texts will be used as model guidance texts.
[0024] S400, obtain the first feature value, second feature value, and third feature value of the model-guided text; wherein, the first feature value is used to represent the text size, the second feature value is used to represent the number of entities in the text, and the third feature value is used to represent the number of entity relations in the text.
[0025] S500, compares the first feature value, second feature value, and third feature value of the obtained model-guided text with preset scale threshold, entity number threshold, and entity relationship number threshold, respectively, and determines the current text generation method based on the comparison results. The text generation method includes a first generation method and a second generation method. The first generation method is to directly generate a text using a large model based on the input model-guided text, and the second generation method is to generate a text using a large model based on the extracted information of the input model-guided text.
[0026] S600: Based on the determined current text generation method and model-guided text, the target text corresponding to the input information is generated using a large model.
[0027] The text generation method based on a large model provided in this invention first obtains multiple related texts associated with the event topic from a text library. Next, it obtains a first feature value, a second feature value, and a third feature value from these related texts. The first feature value characterizes the text size, the second feature value characterizes the number of entities in the text, and the third feature value characterizes the number of entity relationships in the text. Then, it compares the obtained first, second, and third feature values of the related texts with preset size thresholds, entity number thresholds, and entity relationship number thresholds, respectively, and determines the current text generation method based on the comparison results. Finally, based on the determined current text generation method, it uses a large model to generate the target text corresponding to the input information. This invention automatically selects between original text generation and information extraction generation methods by quantitatively evaluating the length, entity complexity, and relationship density of text materials. Under resource-constrained conditions, it can balance computational efficiency and text content accuracy, breaking through the bottleneck of large models in processing long texts and complex materials, and providing an efficient and reliable solution for fields such as intelligent writing and information aggregation.
[0028] Furthermore, in S100, user input information can be obtained through a preset input interface, which includes, but is not limited to, a graphical interactive interface and a command line input box.
[0029] In this embodiment of the invention, the event may be a factual event; in one illustrative embodiment, it may be a news event. The reference text may be text related to the topic of the event, such as a news report. The reference text may be one or more texts.
[0030] In this embodiment of the invention, the text library is a dynamic database built using a distributed storage architecture, storing text materials from multiple sources such as news websites, social media, and professional databases in real time. The text materials are collected using web crawling methods, specifically including: employing the Scrapy framework or HttpClient technology, based on a preset URL seed library and keyword rules, crawling web pages from target websites at set time intervals (e.g., every 5 minutes), and extracting the plain text content from the web pages using an HTML parser (e.g., jsoup, BeautifulSoup); simultaneously, using anti-crawler strategies (e.g., simulating user behavior, IP proxy pool rotation) to ensure the stability and legality of the crawling process.
[0031] In this embodiment of the invention, the summary and knowledge graph can be obtained based on existing technologies, such as open-source large models like Qwen3.
[0032] Furthermore, the S200 specifically includes:
[0033] S201, based on m text retrieval algorithms, obtain the similarity between the event topic and the body text of each text in the text library, and obtain m first similarity sets. The i-th first similarity set includes the similarity between the event topic obtained based on the i-th text retrieval algorithm and the body text of all texts in the text library; i takes values from 1 to m.
[0034] In this embodiment of the invention, the m text retrieval algorithms include at least keyword matching algorithms and word vector cosine similarity algorithms.
[0035] S202, based on m text retrieval algorithms, obtain the similarity between the event topic and the summary of each text in the text library, resulting in m second similarity sets. The i-th second similarity set includes the similarity between the event topic obtained based on the i-th text retrieval algorithm and the summaries of all texts in the text library.
[0036] In this embodiment of the invention, obtaining the similarity between the event topic and the main text or summary of the text based on the keyword matching algorithm can be achieved through the following steps:
[0037] (1) Perform word segmentation on the event topic and extract the keyword set KW={kw1, kw2, ..., kw} of the event topic. a ..., kw q}, kw aLet 'a' be the a-th word of the event topic, where 'a' takes values from 1 to 'q', and 'q' is the number of words in the event topic.
[0038] (2) For each text T in the text library, calculate the keyword matching degree sim_key(T)=∑ a=1 q (tf-idf(kw a ,T)×w(kw a )), where tf-idf(kw a (T) is the keyword kw a The TF-IDF value in the main text or summary of text T, w(kw) a () is the keyword kw a The weights can be determined based on topic importance analysis.
[0039] In this embodiment of the invention, obtaining the similarity between the event topic and the main text or summary of the text based on the word vector similarity algorithm can be achieved through the following steps:
[0040] (a) The text to be processed is mapped into semantic vectors using a pre-trained language model (such as the bge-m3 model). The text to be processed includes the event topic, the main text of the text in the text library, and the summary.
[0041] (b) Calculate the similarity between the text vector of the event topic and the text vector of the text body, and calculate the similarity between the text vector of the event topic and the text vector of the summary, as the similarity between the event topic and the text body or summary.
[0042] S203, based on m first similarity sets and m second similarity sets, obtain the multiple related texts.
[0043] In one illustrative embodiment of the present invention, S203 may specifically include:
[0044] S2031, set counter j=1.
[0045] S2032, if j≤m, execute S2033, otherwise execute S2034.
[0046] S2033, add the text and text ID corresponding to all similarities greater than the j-th similarity threshold in the j-th first similarity set as candidate text records to the candidate text record set, and add the text and text ID corresponding to all similarities greater than the j-th similarity threshold in the j-th second similarity set as candidate text records to the candidate text record set, set j=j+1, and execute S2032; the initial value of the candidate text record set is empty.
[0047] In this embodiment of the invention, the text ID can be the topic of the text or a text number, etc. Each text retrieval algorithm corresponds to a similarity threshold, and the similarity threshold for each text retrieval algorithm may be different. The similarity threshold for each text retrieval algorithm can be determined based on the actual situation.
[0048] S2034, perform deduplication on the candidate text records in the candidate text record set to obtain the deduplicated candidate text record set, which is used as the target candidate text set; execute S2035.
[0049] In this embodiment of the invention, candidate text records in the candidate text record set can be deduplicated based on text ID. That is, for multiple candidate text records with the same text ID, only one candidate text record is retained in the candidate text record set.
[0050] S2035, take each text in the target candidate text set as a target text, and input all the target texts and the event topic into the reordering model to obtain the multiple related texts.
[0051] Furthermore, S2035 may specifically include:
[0052] S10, input the candidate texts in the target candidate text set and the event topic into the re-ranking model to obtain the relevance between each candidate text and the event topic.
[0053] In this embodiment of the invention, the re-ranking model can be an existing re-ranking model structure, such as the BGE-Rerank-V2-M3 model, which has powerful multilingual processing and long text processing capabilities. The BGE-Rerank-V2-M3 model is a fine-tuned version of the BGE-M3 model and is part of the FlagEmbedding project. It is specifically optimized for result re-ranking tasks in information retrieval. This model demonstrates stable performance improvements in re-ranking tasks for documents of various languages and lengths, with particularly significant advantages when processing non-English languages and technical documents. It can more accurately understand the overall content of a document, capture long-distance semantic relationships, handle complex multi-paragraph documents, and significantly improve the accuracy of the retrieval system.
[0054] S11, sort all relevance scores in descending order, and select the candidate texts corresponding to the top L relevance scores as the multiple related texts.
[0055] In this embodiment of the invention, L can be set according to actual needs, for example, it can be set to 100~200.
[0056] Furthermore, in another embodiment of the present invention, S203 specifically includes:
[0057] S20, based on m first similarity sets and m second similarity sets, obtain the fusion similarity S of the r-th text in the text library. r =w1×∑ m i=1 w i ×s1 ri +w2×∑ m i=1 w i ×s2 ri Where w1 is the weight of the main body of the text, w2 is the weight of the summary of the text, and w1 + w2 = 1. i Let ∑ be the weight of the i-th text recall algorithm. m i=1 w i =1, s1 ri Let s2 be the similarity between the body of the r-th text and the event topic obtained based on the i-th text retrieval algorithm. ri Let r be the similarity between the summary of the r-th text obtained based on the i-th text retrieval algorithm and the event topic; r takes values from 1 to n, where n is the number of texts in the text library.
[0058] In this embodiment of the invention, the weight of each text retrieval algorithm can be an empirical value. For example, the weight of the keyword matching algorithm is 0.4, and the weight of the semantic similarity algorithm is 0.6.
[0059] In one illustrative embodiment of the present invention, the weights of the main text and the summary can be empirical values, for example, w1=0.3 and w2=0.7. In one illustrative embodiment, the weight of the main text can be obtained as follows: w1=P1 / (P1+P2), where P1 is the number of entities in the main text and P2 is the number of entities in the summary. In another illustrative embodiment, w1=Len1 / (Len1+βLen2). Len1 is the length of the main text, Len2 is the length of the summary, and β is a balancing factor, which can range from 0.5 to 2.
[0060] In this embodiment of the invention, the length of the main text refers to the number of characters in the main text, and the length of the summary refers to the number of characters in the summary.
[0061] S21. Sort the n fusion similarities in descending order to get the sorted n fusion similarities.
[0062] S22, take the texts corresponding to the top L fusion similarities among the sorted n fusion similarities as the multiple associated texts, where L≥1.
[0063] In this embodiment, multiple related texts are obtained through linear weighting. Compared with obtaining multiple related texts based on a re-ranking model, this method can improve the efficiency of obtaining related texts and is suitable for large-scale text retrieval scenarios that are sensitive to response time.
[0064] In another embodiment of the present invention, S203 may specifically include:
[0065] S30, based on m first similarity sets and m second similarity sets, obtain the fusion similarity S of the r-th text in the text library. r =w1×∑ m i=1 w i ×s1 ri +w2×∑ m i=1 w i ×s2 ri Where w1 is the weight of the main body of the text, w2 is the weight of the summary of the text, and w1 + w2 = 1. i Let ∑ be the weight of the i-th text recall algorithm. m i=1 w i =1, s1 ri Let s2 be the similarity between the body of the r-th text and the event topic obtained based on the i-th text retrieval algorithm. ri Let be the similarity between the summary of the r-th text obtained based on the i-th text retrieval algorithm and the event topic.
[0066] S31. Sort the n fusion similarities in descending order to get the sorted n fusion similarities.
[0067] S32, select the texts corresponding to the top L1 fusion similarities among the sorted n fusion similarities as candidate texts, where L1≥L.
[0068] In this embodiment of the invention, L1 can be set according to actual needs to control the number of candidate texts entering the re-ranking model. The granularity of the filtering can be flexibly adjusted under different data scales and application scenarios, for example, it can be set to about 500.
[0069] S33, input the candidate texts and the event topics into the re-ranking model to obtain the relevance between each candidate text and the event topic.
[0070] Those skilled in the art should understand that the specific implementation of S33 can be found in the specific implementation of S2035 mentioned above.
[0071] S34, Sort all the relevance scores obtained in S33 in descending order, and select the candidate texts corresponding to the top L relevance scores as the multiple related texts.
[0072] The technical effects of the embodiments defined in S30 to S34 are as follows:
[0073] Compared to the simple linear weighting method, this embodiment first filters out some candidate texts by setting L1 after calculating the fusion similarity, which narrows the text range processed by the subsequent re-ranking model, reduces the amount of computation, and improves efficiency. At the same time, the subsequent re-ranking model is used for fine scoring and ranking, which makes up for the lack of semantic understanding depth of linear weighting, can capture more complex semantic relationships between text and topic, and improve the accuracy of the final associated text.
[0074] Compared to the acquisition method of a simple re-ranking model, this embodiment first calculates the fusion similarity using linear weighting and performs preliminary screening, filtering out a large number of irrelevant texts, significantly reducing the input size of the re-ranking model and significantly improving the overall processing efficiency; moreover, the fusion similarity calculated by linear weighting provides a preliminary relevance reference for subsequent re-ranking, helping the re-ranking model to focus more efficiently on potentially relevant texts and optimize the ranking effect.
[0075] Furthermore, in S400, the first feature value of each text satisfies the following condition: F1 = c1 × NC + c2 × NP 2 Where F1 is the first feature value, NC is the number of characters in the main body of the text, NP is the number of paragraphs in the main body of the text, and c1 and c2 are weight coefficients, c1+c2=1, c1 and c2 can be determined based on the actual situation. In an illustrative embodiment, when the text is news text, more attention needs to be paid to the processing pressure brought by the number of characters. In this case, c1=0.7 and c2=0.3 can be set.
[0076] In this embodiment of the invention, the number of entities and entity relationships in each associated text can be obtained through the corresponding knowledge graph. Entities in the reference text can be extracted based on rule templates or keyword matching, and entity relationships in the reference text can be extracted based on co-occurrence statistics.
[0077] Those skilled in the art should understand that the first feature value of the model-guided text can be equal to the sum of the first feature values of all the texts it contains, the second feature value of the model-guided text can be equal to the sum of the second feature values of all the texts it contains, and the third feature value of the model-guided text can be equal to the sum of the third feature values of all the texts it contains.
[0078] Further, S500 specifically includes: if the first feature value is less than or equal to a preset scale threshold, and the second feature value is less than or equal to a preset entity number threshold, and the third feature value is less than or equal to a preset entity relationship number threshold, then determine to use a first generation method as the current text generation method; otherwise, that is, if the first feature value is greater than the preset scale threshold, or if the first feature value is less than or equal to the preset scale threshold, but the second feature value is greater than the preset entity number threshold, and the third feature value is greater than the preset entity relationship number threshold, or if the first feature value is less than or equal to the preset scale threshold, but the second feature value is greater than the preset entity number threshold, or if the first feature value is less than or equal to the preset scale threshold, but the third feature value is greater than the preset entity relationship number threshold, then determine to use a second generation method as the current text generation method.
[0079] In this embodiment of the invention, the scale threshold can be determined based on the processing power of the large model used. In one illustrative embodiment, the scale threshold Z can be: Z = min(roundup(C) max / C min ), C upper ), where C max This sets a maximum limit on the number of tokens a large model can process per word. For example, large models (such as the GPT series and BERT) have explicit limits on the number of input tokens; for instance, GPT-3.5 typically has an input limit of around 4096 tokens. This is because processing tokens consumes memory and computational resources; too many tokens will exceed the model's processing capacity, leading to decreased computational efficiency or even failure to run. min This represents the average number of tokens per text, which can be obtained through historical data statistics. (C) upper This is a preset upper limit for the scale threshold, which can be set based on actual needs.
[0080] In this embodiment of the invention, a token refers to the basic unit that a large model divides into when processing text. A word, a part of a word, or a special symbol can all serve as a token, falling under the category of "marker." The number of tokens affects the model's ability to capture and understand textual information. Too few tokens may not contain sufficient semantic information, while too many may introduce redundancy or exceed the model's processing capacity, leading to poor performance. Therefore, when using a large model, it is necessary to reasonably control the number of tokens in the input model-guided text, processing them through methods such as summarization and truncation.
[0081] In this embodiment of the invention, the entity quantity threshold and entity relationship threshold can be set based on actual needs. In one illustrative embodiment, the entity quantity threshold and entity relationship threshold can be empirical values. In a news text scenario, the entity quantity threshold Te = 20 and the entity relationship threshold Tr = 15 to meet real-time requirements. In another illustrative embodiment, Te = rounddown(C max ×de / Le), where de is the token occupancy coefficient of the entity, which can be an empirical value, for example, de=0.3. Le is the average token length of a single entity, which can be obtained based on historical data statistics. Rounddown() rounds down. Tr=rounddown(C max (×dr / Lr), where dr is the token occupancy coefficient of the entity relationship, which can be an empirical value, for example, dr=0.2. Lr is the average token length of a single entity relationship, which can be obtained based on historical data statistics.
[0082] In this embodiment of the invention, the collaborative decision-making mechanism of feature values and thresholds can adapt to different input scenarios, and is especially suitable for complex scenarios that need to process multi-source heterogeneous texts. It has significant application value in fields such as news generation and academic summarization.
[0083] Furthermore, the S600 may specifically include:
[0084] S601, if the current text generation method is the first generation method, use the model guidance text as the model instruction information and execute S602; if the current text generation method is the second generation method, and the model guidance text only includes multiple related texts, use the extracted information of the model guidance text as the model instruction information and execute S602; if the current text generation method is the second generation method, and the model guidance text includes multiple related texts and reference texts, use the extracted information of the multiple related texts as the model instruction information and execute S602.
[0085] S602, based on the model indication information and the topic generation restriction information input by the user, call the non-inference large model to generate multiple candidate topics; execute S603.
[0086] In embodiments of the present invention, the topic generation restriction information may include, for example, topic scope, content direction, style and tone, length, and the inclusion or exclusion of specific elements. Those skilled in the art should understand that the right to set the topic generation restriction information is entirely left to the user. The present invention only provides the underlying framework supporting such custom settings, and its core objective is to ensure, through adaptive design, that the generated topics accurately meet the user's actual usage needs.
[0087] S603, in response to the user selecting a target topic from the plurality of candidate topics, based on the model indication information, the target topic selected by the user, and the framework generation constraint information input by the user, the non-inference large model is invoked to generate the corresponding text framework; S604 is executed.
[0088] In this embodiment of the invention, the limiting information involved in framework generation may include, for example, the framework's structural hierarchy, core module composition, element constraints, format specifications, and applicable scenario boundaries. Those skilled in the art should understand that the setting of framework generation limiting information is entirely under the user's control. This invention only provides the underlying technical architecture supporting such custom settings. Its core objective is to ensure, through adaptability design, that the generated framework can accurately match the user's actual business scenarios and specific needs.
[0089] S604: If the model guidance text only includes multiple related texts, the corresponding target text is generated by calling the inference big model based on the user-selected target topic, the generated text framework, and the text generation restriction information input by the user; if the model guidance text includes multiple related texts and reference texts, the corresponding target text is generated by calling the inference big model based on the user-selected target topic, the generated text framework, the text generation restriction information input by the user, and the extraction information of the reference texts.
[0090] As those skilled in the art will know, the text generation restrictions can be set based on the user's actual needs, and this invention does not impose any particular limitations.
[0091] As will be known to those skilled in the art, both non-inference models and inference models can be existing open-source models.
[0092] Furthermore, the method provided in this embodiment of the invention further includes the following steps:
[0093] S700, the target text is visualized.
[0094] In this embodiment of the invention, the target text can be visualized through a preset visualization interface; wherein, the visualization interface includes, but is not limited to, table display, paragraph column layout, keyword highlighting, and supports user customization of the text font, font size, color and display layout, so that users can view the target text content more intuitively and clearly.
[0095] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in this invention.
[0096] This invention also provides a computer-readable storage medium storing computer-executable instructions for performing the methods described in this invention.
[0097] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this invention can be achieved, and this is not limited herein.
[0098] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A text generation method based on a large model, characterized in that, The method includes the following steps: S100, Obtain input information from the user, the input information including the event topic or including the event topic and reference text; S200, based on the event topic, retrieve multiple related texts associated with the event topic from the text library; the text library stores the main text and extracted information of multiple texts, the extracted information including summaries and knowledge graphs; S300: If the input information only includes the event topic, multiple related texts will be used as model guidance texts; if the input information includes the event topic and reference texts, multiple related texts and reference texts will be used as model guidance texts. S400, obtain the first feature value, second feature value, and third feature value of the model-guided text; wherein, the first feature value is used to represent the text size, the second feature value is used to represent the number of entities in the text, and the third feature value is used to represent the number of entity relations in the text; S500, compare the first feature value, second feature value and third feature value of the obtained model-guided text with the preset scale threshold, entity number threshold and entity relationship number threshold respectively, and determine the current text generation method based on the comparison results. The text generation method includes a first generation method and a second generation method. The first generation method is to directly generate a text using a large model based on the input model-guided text. The second generation method is to generate a text using a large model based on the extracted information of the input model-guided text. S600: Based on the determined current text generation method and model-guided text, the target text corresponding to the input information is generated using a large model.
2. The method according to claim 1, characterized in that, S500 specifically includes: if the first feature value is less than or equal to a preset scale threshold, and the second feature value is less than or equal to a preset entity number threshold, and the third feature value is less than or equal to a preset entity relationship number threshold, then determine to use the first generation method as the current text generation method; otherwise, determine to use the second generation method as the current text generation method.
3. The method according to claim 1, characterized in that, S200 specifically includes: S201, based on m text retrieval algorithms, obtain the similarity between the event topic and the body text of each text in the text library, and obtain m first similarity sets, wherein the i-th first similarity set includes the similarity between the event topic obtained based on the i-th text retrieval algorithm and the body text of all texts in the text library; the value of i is from 1 to m; S202, based on m text retrieval algorithms, obtain the similarity between the event topic and the summary of each text in the text library, and obtain m second similarity sets, wherein the i-th second similarity set includes the similarity between the event topic obtained based on the i-th text retrieval algorithm and the summaries of all texts in the text library; S203, based on m first similarity sets and m second similarity sets, obtain the multiple related texts.
4. The method according to claim 3, characterized in that, S203 specifically includes: S2031, Set counter j=1; S2032, if j≤m, execute S2033; otherwise, execute S2034. S2033, add the text and text ID corresponding to all similarities greater than the j-th similarity threshold in the j-th first similarity set as candidate text records to the candidate text record set, and add the text and text ID corresponding to all similarities greater than the j-th similarity threshold in the j-th second similarity set as candidate text records to the candidate text record set, set j=j+1, and execute S2032; the initial value of the candidate text record set is empty; S2034, Perform deduplication on the candidate text records in the candidate text record set to obtain the deduplicated candidate text record set, which is used as the target candidate text set; Execute S2035; S2035, take each text in the target candidate text set as a target text, and input all the target texts and the event topic into the reordering model to obtain the multiple related texts.
5. The method according to claim 3, characterized in that, S203 specifically includes: S20, based on m first similarity sets and m second similarity sets, obtain the fusion similarity S of the r-th text in the text library. r =w1×∑ m i=1 (w) i ×s1 ri )+w2×∑ m i=1 (w) i ×s2 ri ), where w1 is the weight of the main body of the text, w2 is the weight of the summary of the text, w1+w2=1, w i Let ∑ be the weight of the i-th text recall algorithm. m i=1 w i =1, s1 ri Let s2 be the similarity between the body of the r-th text and the event topic obtained based on the i-th text retrieval algorithm. ri Let r be the similarity between the summary of the r-th text obtained based on the i-th text retrieval algorithm and the event topic; r takes values from 1 to n, where n is the number of texts in the text library; S21, Sort the n fusion similarities in descending order to get the sorted n fusion similarities; S22, take the texts corresponding to the top L fusion similarities among the sorted n fusion similarities as the multiple associated texts, where L≥1.
6. The method according to claim 3, characterized in that, S203 may specifically include: S30, based on m first similarity sets and m second similarity sets, obtain the fusion similarity S of the r-th text in the text library. r =w1×∑ m i=1 (w) i ×s1 ri )+w2×∑ m i=1 (w) i ×s2 ri ), where w1 is the weight of the main body of the text, w2 is the weight of the summary of the text, w1+w2=1, w i Let ∑ be the weight of the i-th text recall algorithm. m i=1 w i =1, s1 ri Let s2 be the similarity between the body of the r-th text and the event topic obtained based on the i-th text retrieval algorithm. ri Let r be the similarity between the summary of the r-th text obtained based on the i-th text retrieval algorithm and the event topic; r takes values from 1 to n, where n is the number of texts in the text library; S31, sort the n obtained fusion similarities in descending order to obtain the sorted n fusion similarities; S32, take the texts corresponding to the top L1 fusion similarities among the sorted n fusion similarities as candidate texts; S33, Input the candidate texts and the event topics into the re-ranking model to obtain the relevance between each candidate text and the event topic; S34, sort all the obtained relevance scores in descending order, and select the candidate texts corresponding to the top L relevance scores as the multiple related texts, 1≤L≤L1.
7. The method according to claim 1, characterized in that, The S600 specifically includes: S601, If the current text generation method is the first generation method, use the model guidance text as the model instruction information and execute S602; If the current text generation method is the second generation method, and the model guidance text only includes multiple related texts, use the extracted information of the model guidance text as the model instruction information and execute S602; If the current text generation method is the second generation method, and the model guidance text includes multiple related texts and reference texts, use the extracted information of the multiple related texts as the model instruction information and execute S602. S602, Based on the model indication information and the user-input topic, generate restriction information, and call the non-inference large model to generate multiple candidate topics; execute S603; S603, in response to the user selecting a target topic from the plurality of candidate topics, based on the model indication information, the target topic selected by the user, and the framework input by the user, constraint information is generated, and the non-inference large model is called to generate the corresponding text framework; S604 is executed; S604: If the model guidance text only includes multiple related texts, the corresponding target text is generated by calling the inference big model based on the user-selected target topic, the generated text framework, and the text generation restriction information input by the user; if the model guidance text includes multiple related texts and reference texts, the corresponding target text is generated by calling the inference big model based on the user-selected target topic, the generated text framework, the text generation restriction information input by the user, and the extraction information of the reference texts.
8. The method according to claim 1, characterized in that, The event described is a news event.
9. An electronic device, characterized in that, Including processor and memory; The processor executes the steps of the method as described in any one of claims 1 to 8 by invoking programs or instructions stored in the memory.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a program or instructions that cause a computer to perform the steps of the method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
CN118468863A
CN119179775A