Text generation method, server, storage medium and program product
By determining the outline and obtaining relevant materials, the pre-trained model was fine-tuned and quality screened, which solved the problem of input length limitation in the text generation algorithm and achieved high-quality text generation.
Patent Information
- Application Number
- CN202410310061.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-18
- Publication Date
- 2025-09-23
AI Technical Summary
Existing text generation algorithms are limited by the input length, resulting in less reference material and low text generation quality.
By determining the outline of the target text, obtaining outline-related materials, fine-tuning the pre-trained model, obtaining a text generation model, and screening the materials for quality, the target text is generated.
While keeping the input length short, the quality of text generation is improved, and domain knowledge of a large amount of relevant materials is referenced to generate high-quality target text.
Smart Images

Figure CN120688449A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to computer technology, and in particular to a text generation method, a server, a storage medium, and a program product. Background Art
[0002] In industries like publishing and media, text workers face significant productivity disadvantages compared to AI-based text generation algorithms. AI-based text generation algorithms are a major research area in natural language processing (NLP) and hold promising application prospects in industry.
[0003] Current text generation algorithms mostly rely on artificial intelligence models to generate target text based on relevant material. However, current AI models have input length limitations, which restricts the length of relevant material that can be fed into the AI models, resulting in low text generation quality. Summary of the Invention
[0004] The present application provides a text generation method, server, storage medium and program product to improve the quality of text generation.
[0005] In a first aspect, the present application provides a text generation method, comprising:
[0006] Determine the outline of the target text to be generated according to the given subject information;
[0007] Obtaining relevant materials of the outline, and fine-tuning the pre-trained model based on the relevant materials of the outline to obtain a text generation model;
[0008] Performing quality screening on materials related to the outline to obtain preferred materials related to the outline;
[0009] The target text is generated according to the preferred materials related to the outline through the text generation model.
[0010] In a second aspect, the present application provides a server comprising: 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, and the instructions are executed by the at least one processor to enable the server to execute the method provided in the first aspect.
[0011] In a third aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the method provided in the first aspect is implemented.
[0012] In a fourth aspect, the present application provides a computer program product, comprising a computer program, which implements the method provided in the first aspect when executed by a processor.
[0013] The text generation method, server, storage medium and program product provided by the present application determine the outline of the target text to be generated based on given subject information, obtain relevant materials of the outline, and fine-tune the pre-trained model based on the relevant materials of the outline to obtain a text generation model. The domain knowledge contained in a large amount of relevant materials of the outline can be stored in the text generation model in a parameterized form, thereby injecting the domain knowledge contained in a large amount of relevant materials into the text generation model, so that the text generation model learns more domain knowledge; further, the relevant materials of the outline are quality screened to obtain a small amount of high-quality preferred materials related to the outline, and the text generation model is used to generate the target text based on the preferred materials. When generating the target text, not only the domain knowledge contained in a small amount of high-quality preferred materials is referred to, but also the domain knowledge contained in a large amount of relevant materials of the outline is referred to, thereby improving the quality of text generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0015] Figure 1 A schematic diagram of an exemplary system architecture applicable to this application;
[0016] Figure 2 A flowchart of a text generation method provided for an exemplary embodiment of the present application;
[0017] Figure 3 A detailed flow chart of a text generation method provided for an exemplary embodiment of the present application;
[0018] Figure 4 An exemplary framework diagram of a text generation method provided by an exemplary embodiment of the present application;
[0019] Figure 5 A schematic diagram of the structure of a server provided in an embodiment of the present application.
[0020] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0021] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0022] It should be noted that the user information (including but not limited to user device information, user attribute information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0023] First, let’s explain the terms involved in this application:
[0024] Source: The text fragments provided to the model for generating the target text are the content source of the target text to be generated. In this embodiment, the source can be text fragments extracted from documents, pictures, presentations, webpage data, etc.
[0025] Outline: This refers to the overall content framework of the target text to be generated. For example, the outline may include the text's main chapters, subtopics, core content, etc. In this embodiment, the outline includes one or more levels of key points of the target text, providing a content framework and guidance for subsequent target text generation, ensuring the target text's logic and coherence.
[0026] Internet search engine: A tool used to retrieve information on the Internet, usually within the scope of publicly available data visible on the public network.
[0027] BERT (Bidirectional Encoder Representations from Transformer): is a bidirectional encoder representation model based on Transformer and a pre-trained language representation model.
[0028] Visual question answering task: Given an input image and a question, determine the answer to the question from the visual information of the input image.
[0029] Image description task: Generate description text for the input image.
[0030] Visual entailment task: predict the semantic relevance of an input image and text, i.e., entailment, neutrality, or contradiction.
[0031] Referential expression and comprehension task: locate the image area corresponding to the input text in the input image based on the input text.
[0032] Image generation task: Generate an image based on the input description text.
[0033] Text-based sentiment classification task: predict the sentiment classification information of the input text.
[0034] Text summarization task: Generate summary information of the input text.
[0035] Multimodal tasks: refers to downstream tasks whose input and output data involve multiple modal data such as images and text, such as visual question answering tasks, image description tasks, visual implication tasks, referential expression and understanding tasks, image generation tasks, etc.
[0036] Multimodal pre-trained model: refers to a pre-trained model whose input and output data involve multiple modal data such as images and text. After fine-tuning and training, it can be applied to multimodal task processing.
[0037] Pre-trained language model: A pre-trained model obtained by pre-training a large-scale language model (LLM).
[0038] Large models refer to deep learning models with large-scale model parameters, typically containing hundreds of millions, tens of billions, or even hundreds of billions of model parameters. Large models, also known as foundation models (FMs), are pre-trained on large amounts of unlabeled corpora, producing pre-trained models with parameters exceeding 100 million. These models are adaptable to a wide range of downstream tasks and exhibit good generalization capabilities, such as large language models (LLMs) and multi-modal pre-training models.
[0039] When large models are used in practice, only a small number of samples are needed to fine-tune the pre-trained model and it can be applied to different tasks. Large models can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, they can be applied to computer vision tasks such as visual question answering (VQA), image caption (IC), and image generation, as well as natural language processing tasks such as text-based sentiment classification, text summary generation, and machine translation. The main application scenarios of large models include digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design.
[0040] Most existing text generation algorithms utilize text generation models to generate text around a given topic based on a configured prompt template and a small amount of matching material. The text generation model can be any language model with text generation capabilities, such as various large-scale language models (LLMs) and BERT-based text generation models. Regardless of the type of text generation model, the maximum length of the input data is limited, thereby limiting the length of the material content input to the text generation model. A text generation model can only generate target text based on a small amount of input material, with limited reference source material and low text generation quality.
[0041] The present application provides a text generation method, which determines the outline of a target text to be generated based on given subject information, obtains relevant materials for the outline, and fine-tunes a pre-trained model based on the relevant materials for the outline to obtain a text generation model; further, the relevant materials for the outline are quality-screened to obtain preferred materials related to the outline; and through the text generation model, generates a target text based on the preferred materials related to the outline.
[0042] Among them, the pre-training model can use any existing text generation model, specifically but not limited to various large-scale language models LLM, BERT-based text generation models, etc.
[0043] The method of this embodiment, by using a large amount of relevant materials of the outline, fine-tunes the pre-trained model for generating text to obtain a text generation model. The domain knowledge contained in the large amount of materials related to the outline can be stored in the text generation model in a parameterized form, that is, the domain knowledge contained in the large amount of relevant materials is injected into the text generation model, so that the text generation model learns more domain knowledge and can adapt to different fields. Further, the quality of the relevant materials of the outline is screened to obtain a small amount of high-quality preferred materials related to the outline, and the fine-tuned text generation model is used to generate the target text based on the small amount of high-quality preferred materials. When the text generation model generates the target text, it not only refers to the domain knowledge contained in the small amount of high-quality preferred materials after quality screening, but also refers to the domain knowledge contained in the large amount of relevant materials, which can improve the quality of text generation. By inputting less material (keeping the input short), a high-quality target text can be generated, which can reduce the impact of the model input length limit on the text generation quality and improve the quality of text generation.
[0044] Figure 1 This is a schematic diagram of an example system architecture applicable to this application. Figure 1As shown, the system architecture includes a server and a terminal device. There is a communication link between the server and the terminal device, which can realize the communication connection between the server and the terminal device.
[0045] The server is a device with computing power deployed in the cloud or locally, such as a cloud cluster. The server stores a pre-trained model for text generation. This pre-trained model can generate target text based on a given description text and given material. The given description text can be user-provided information describing the target text to be generated, such as the subject, title, abstract, key points, etc.
[0046] End-side devices can be electronic devices that run downstream applications. Specifically, they can be hardware devices with network communication, computing, and information display capabilities. These include, but are not limited to, smartphones, tablets, desktop computers, local servers, and cloud servers. For example, end-side devices can be servers or user terminals in various industries such as publishing and media that provide online text generation functions such as online copywriting, online writing, and online editing. When a user needs to generate a target text using an online text generation system, they can transmit the user-specified topic information to the server through the end-side device.
[0047] The server receives the subject information given by the user transmitted by the terminal device, determines the outline of the target text to be generated based on the given subject information, obtains relevant materials for the outline, fine-tunes the pre-trained model based on the relevant materials of the outline, and obtains a text generation model to inject the domain knowledge contained in a large amount of relevant materials into the text generation model.
[0048] Furthermore, the server performs quality screening on the materials related to the outline, obtains preferred materials related to the outline, and generates target text based on the preferred materials related to the outline through a text generation model.
[0049] Furthermore, the server may return the generated target text to the end-side device, and the end-side device outputs the target text to the user.
[0050] based on Figure 1 The system architecture shown uses an online writing scenario as an example. In this scenario, the client device can be an electronic device running an AI writing assistant. When a user wants to write an article on a specific topic, they enter the topic information on the client device. The client device then sends a text generation request to the server, which carries the topic information.
[0051] In response to receiving a text generation request, the server determines the outline of the target article to be generated based on the given topic information, obtains relevant materials for the outline, and fine-tunes the pre-trained model based on the relevant materials to obtain a text generation model. Furthermore, the server performs quality screening on the relevant materials for the outline, obtains preferred materials related to the outline, and generates the target article based on the preferred materials related to the outline using the text generation model. The server returns the generated target article to the client device, which then outputs the generated target article to the user.
[0052] It should be noted that the pre-trained model and the text generation model after fine-tuning can be stored and run on another server. When carrying out the fine-tuning training of the pre-trained model, the server responsible for text generation sends the relevant material for fine-tuning training to another server, so that the other server performs fine-tuning training on the pre-trained model based on the relevant material and obtains the text generation model. The other server provides the application programming interface (Application Program Interface, abbreviated API) of the text generation model after fine-tuning to the server responsible for text generation. The server responsible for text generation, when needing to use the text generation model, calls the text generation model to generate text by calling the API of the text generation model. In response to the calling of the API of the text generation model, the other server generates text based on the input data and returns the generated result.
[0053] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0054] Figure 2 This is a flowchart of a text generation method provided by an exemplary embodiment of the present application. The execution subject of this embodiment is the server in the aforementioned system architecture. Figure 2 As shown, the specific steps of this method are as follows:
[0055] Step S201: Determine the outline of the target text to be generated according to given subject information.
[0056] The given subject information refers to information provided by the user that describes the subject of the target text to be generated, such as text describing the central theme or core content of the target text. The given subject information can be a simple topic or keyword, or a more detailed description of the subject, without specific limitation.
[0057] The given subject information may be text information directly input by the user, or text obtained by performing voice recognition on the collected audio input by the user, or text obtained by performing image recognition on the collected image, which is not specifically limited here.
[0058] For example, a user may directly input a title of an article to be generated through a terminal device, and the terminal device sends the title of the article to be generated to a server. The server receives the article title sent by the terminal device as given subject information.
[0059] For example, a user can input a voice message describing the core content of the article to be generated through a client-side device, which then sends the user voice message to a server. The server receives the user voice message sent by the client-side device, converts the user voice message into text, and obtains the topic information given by the user.
[0060] In this embodiment, the server automatically determines the outline of the target text to be generated based on the given subject information. Based on the given subject information, the server creates or selects a structured outline or outline to guide and organize the target text to be generated. The outline refers to the overall content framework of the target text to be generated, including one or more levels of content highlights of the target text. For example, the outline can include the main chapters, subtopics, core content, etc. of the text, providing a content framework and guidance for the subsequent generation of the target text, ensuring the logic and coherence of the target text.
[0061] Optionally, the server can generate an outline for the target text using a pre-trained model based on the given subject information and a configured outline generation prompt template. Specifically, the given subject information is entered into the outline generation prompt template to obtain outline generation prompt information. The outline generation prompt information is then input into the pre-trained model, and the pre-trained model generates an outline based on the outline generation prompt information, thereby obtaining an outline for the target text.
[0062] Among them, the pre-trained model used by the server to generate the outline of the target text can be any existing text generation model that generates an outline based on the main body or title, specifically various large language models LLM or BERT-based text generation models, which are not specifically limited here.
[0063] Optionally, the server may select at least one outline template from a configured outline template library based on the given subject information as a candidate outline for the target text to be generated. Furthermore, the server may output the candidate outlines for the target text via an outline selection interface on the front end, allowing the user to select one of the candidate outlines as the outline for the target text. In response to the user selecting any of the candidate outlines displayed on the outline selection interface, the selected outline is used as the outline for the target text.
[0064] Optionally, the server can generate a candidate outline for the target text using a pre-trained model based on the given topic information and the configured outline generation template. Simultaneously, the server selects at least one outline template from the configured outline template library based on the given topic information as a candidate outline for the target text to be generated.
[0065] Furthermore, the server outputs all candidate outlines through the outline selection interface of the front end. The outline selection interface also provides editing and selection operations for the displayed candidate outlines. Through the outline selection interface, the user can edit the displayed candidate outline and modify the candidate outline to an outline that he or she is more satisfied with. In response to the editing operation on any candidate outline, the server updates the edited candidate outline and stores the candidate outline edited by the user. Furthermore, the user can select any displayed candidate outline (which can be an edited outline) as the outline of the target text. In response to the user's selection operation on any candidate outline, the server uses the selected candidate outline as the outline of the target text.
[0066] Step S202: Obtain relevant materials of the outline.
[0067] After determining the outline of the target text, the server obtains the outline's related materials. These materials are materials related to the outline's content. These materials can be text snippets extracted from documents, images, presentations, webpages, and the like.
[0068] For example, the server may obtain the relevant materials of the outline in at least one of the following ways:
[0069] Call an Internet search engine to search for relevant materials of the outline; call a local search engine to search for relevant materials of the outline in a local database; obtain relevant materials of the outline input by the user.
[0070] The Internet search engine may be a third-party Internet search engine. The server may obtain a large amount of relevant materials of the outline by calling the Internet search engine and searching for materials related to the outline within the scope of public data visible on the public network.
[0071] A local search engine is a search engine owned by the provider of the text generation system. It can search a local database for materials related to the outline. For example, the text generation system might be used internally by a radio station, which has a large collection of internal manuscripts, such as interview transcripts and press releases, and thus can build a local database. The local search engine can be used to search the local database for materials related to the outline content to obtain relevant materials.
[0072] In addition, the method of this embodiment also supports users submitting materials related to the outline. For example, the server outputs the outline via a material submission interface. This interface displays the outline content and a material submission area. Users can edit or upload materials related to the outline online in the material submission area within the outline content.
[0073] In this embodiment, the server can combine the above-mentioned multiple methods to obtain relevant materials of the outline, and can obtain a large amount of relevant materials of the outline more comprehensively and accurately, provide richer materials for generating the target text, and improve the generation quality of the target text.
[0074] Step S203: Fine-tune the pre-trained model based on relevant materials of the outline to obtain a text generation model.
[0075] After obtaining a large amount of relevant materials of the outline, the pre-trained model used to generate the target text is fine-tuned based on the relevant materials of the outline to obtain a text generation model. The domain knowledge contained in the large amount of relevant materials of the outline can be stored in the text generation model in a parameterized form, thereby injecting the domain knowledge contained in the large amount of relevant materials into the text generation model, allowing the text generation model to learn more domain knowledge and improve the text generation quality of the text generation model.
[0076] The pre-trained model can be any existing text generation model, specifically various large language models (LLMs) or BERT-based text generation models, which are not specifically limited here.
[0077] Optionally, in this step, the server may use all relevant materials of the outline obtained in the above steps to fine-tune the pre-trained model to obtain a text generation model.
[0078] Optionally, in this step, the server may use some relevant materials of the outline obtained in the above step to fine-tune the pre-trained model to obtain a text generation model, so as to improve the efficiency of model fine-tuning training and thus improve the efficiency of text generation.
[0079] Specifically, the server can filter the relevant materials of the outline according to the configured first basic related condition to obtain a screening result. The number of materials in the screening result is less than the total amount of all relevant materials. The screening result is used as the material for fine-tuning training to reduce the complexity of fine-tuning training. The materials included in the screening result are used to fine-tune the pre-trained model to obtain a text generation model. In addition, the number of materials in the screening result should be greater than the number of preferred materials to ensure the effect of fine-tuning training and improve the generation quality of the text generation model.
[0080] Among them, the first basic relevant condition refers to the pre-configured condition for coarse screening of the relevant materials of the outline. Compared with the quality screening of the relevant materials in the subsequent steps, the first basic relevant condition performs a coarse-grained screening of the relevant materials of the outline from the aspects of relevance and / or timeliness of the materials, so as to appropriately reduce the number of materials used for fine-tuning training, while ensuring that the text generation model learns a large amount of domain knowledge of relevant materials and ensures the effect of fine-tuning training.
[0081] For example, the first basic relevance condition may include at least one of the following: a relevance assessment value between the relevant material and the outline is greater than or equal to a first relevance threshold, and a timeliness assessment value of the relevant material is greater than or equal to a first timeliness threshold. The first relevance threshold and the first timeliness threshold are both relatively low thresholds. The specific values can be configured and adjusted by relevant technical personnel based on the needs and experience of actual application scenarios and are not specifically limited here.
[0082] When the server uses the relevant materials of the outline (all or part) to fine-tune the pre-trained model, it adopts the next token prediction fine-tuning method. Based on the first i-1 word segmentation results (tokens) of the input material, it can be expressed as <x0,x1,…,x (i-1) >, to predict the next word segmentation result (token) x′ i , the predicted result x′ of the next word segmentation result i and the actual next word segmentation result x i By comparing and performing backpropagation, the model can learn the domain knowledge contained in the outline-related materials, improve the model's adaptability to different fields, and thus improve the quality of text generation in various professional fields.
[0083] In this step, the server uses the relevant materials of the outline (all or part) to fine-tune the pre-trained model. When obtaining the text generation model, the server can use parameter-efficient fine-tuning (PEFT) fine-tuning methods, such as low-rank adaptation (LoRA) and p-tuning, to quickly fine-tune the pre-trained model to improve the efficiency of model fine-tuning training, thereby improving the efficiency of text generation.
[0084] For example, in an optional embodiment, the server can use the low-rank adaptive LoRA method to fine-tune the pre-trained model. Specifically, by adding new parameters (trainable rank decomposition matrix) to the pre-trained model, a text generation model to be fine-tuned is constructed; based on the relevant materials of the outline (all or part), the parameters added to the text generation model are fine-tuned to obtain a trained text generation model. During the fine-tuning training process, the original parameters of the pre-trained model are kept unchanged, and only a small number of newly added parameters are trained, which can greatly improve the efficiency of fine-tuning training, thereby improving the efficiency of text generation.
[0085] Specifically, the idea behind LoRA is simple: the newly added parameters are two low-rank matrices A and B, which are used to simulate the update (ΔW) of the original model parameters (represented by W0). The original model parameters W0 are fixed, and only the two low-rank matrices A and B are fine-tuned. Before LoRA fine-tuning, the inference of the pre-trained model can be expressed as: W0x. After LoRA fine-tuning, the inference of the text generation model can be expressed as: W0x+BAx.
[0086] In addition, the server can also use PEFT fine-tuning methods other than LoRA, such as P-Tuning, P-Tuningv2 and other training methods, which are not specifically limited here.
[0087] Optionally, in this step, the server uses the relevant materials of the outline (all or part) to fine-tune the pre-trained model. When obtaining the text generation model, it can also use fine-tuning methods other than PEFT to fine-tune all parameters of the pre-trained model, which can also improve the quality of text generation and may have a certain impact on the efficiency of text generation.
[0088] The method of this embodiment uses a large amount of relevant materials of the outline to fine-tune the pre-trained model, and stores the domain knowledge contained in the large amount of relevant materials in a parameterized form into the model structure. In this way, more domain knowledge can be injected into the text generation model without extending the input length of the model, which can greatly improve the quality of text generation.
[0089] Step S204: perform quality screening on materials related to the outline to obtain preferred materials related to the outline.
[0090] In this step, the relevant materials of the outline are screened for quality to obtain a small amount of high-quality preferred materials related to the outline.
[0091] In this embodiment, the server may evaluate the outline's related materials based on at least one of timeliness, authority, and relevance to obtain quality evaluation results for each related material. Based on the quality evaluation results for each related material, a first number of relatively high-quality related materials may be selected as preferred materials for the outline.
[0092] Timeliness represents the impact of time on satisfaction with material requirements. Timeliness typically includes sudden timeliness, periodic timeliness, and general timeliness. Timeliness intensity can be categorized into several levels, such as strong, medium, general, and none. Different levels of timeliness intensity are mapped to different timeliness evaluation values.
[0093] Authoritativeness refers to the user's trust in the content and their willingness to question the resulting output. The authority of a piece of material can be determined based on its source (e.g., different creative teams, publishing organizations / websites / platforms, etc.). For example, material with a higher-level source is more authoritative.
[0094] Relevance represents the textual and semantic relatedness between the outline and related materials.
[0095] Specifically, the server can evaluate the quality of the outline's related materials based on timeliness, authority, and relevance, obtaining a timeliness evaluation value, an authority evaluation value, and a relevance evaluation value for the related materials. The server then determines the quality evaluation value of the related materials by combining the timeliness evaluation value, authority evaluation value, and relevance evaluation value of the related materials.
[0096] The authority rating can be determined based on factors such as the source level of the material. For example, materials with higher-level sources have higher authority ratings. For example, different levels of material sources can be pre-configured, with different levels mapped to different authority ratings. The authority rating value mapped to the source level of the material is used as the material's authority rating.
[0097] The timeliness evaluation value can be determined when determining the timeliness label of the relevant material. For example, while determining the timeliness label based on the creation time of the material and user behavior (such as clicks, readings, forwarding, comments, etc.), the timeliness evaluation values of the timeliness labels "strong", "medium", "general", and "none" are determined respectively. Specifically, any existing method for determining the timeliness of text information can be used to determine the timeliness evaluation value of the relevant material of the outline, and no specific limitation is made here.
[0098] The relevance evaluation value can be obtained by evaluating the relevance of the outline's related materials to the outline using existing text relevance algorithms. Specific text relevance algorithms that can be used include, but are not limited to, best match algorithms such as BM25 and the Term Frequency-Inverse Document Frequency (TF-IDF) algorithm.
[0099] Optionally, the server performs a weighted summation of the timeliness evaluation value, authority evaluation value, and relevance evaluation value of the relevant material as the quality evaluation value of the relevant material.
[0100] Optionally, the server can also evaluate the timeliness of the relevant materials (expressed as Score 时效 ), authoritative evaluation value (expressed as Score 权威 ) and correlation evaluation value (expressed as Score 相关性 ), use the following formula to calculate and determine the quality evaluation value of the relevant material (expressed as F score ):
[0101] Score i ∈{Score 时效 ,Score 权威 ,Score 相关性}
[0102] Among them, Score 时效 ,Score 权威 ,Score 相关性 The value range of k is [0,1]. i and β i is the weight parameter of the evaluation value of different dimensions. The weight parameter k of the evaluation value of any two different dimensions i The weight parameter β of the evaluation values of any two different dimensions can be different or the same i The values of the weight parameters of the evaluation values of each dimension are configured and adjusted according to the needs of the actual application scenario and experience, and are not specifically limited here.
[0103] Furthermore, based on the quality evaluation values of the relevant materials, at least one relevant material with a higher quality evaluation value is selected as the preferred material for the outline. The number of preferred materials retained for the outline can be configured and adjusted based on factors such as the input length of the text generation model in actual application scenarios, and is not specifically limited here.
[0104] In an optional embodiment, the server can output the outline's preferred materials through a material editing interface. The material editing interface also provides a display and editing area for the preferred materials. Users can edit and save any preferred material in the outline through the material editing interface. In response to a user's editing operation on any preferred material in the material editing interface, the preferred material is updated and saved. In addition, when outputting the preferred material, source information of the preferred material can also be output, so that users can understand the source of the preferred material and can filter and intervene in the preferred material.
[0105] In this embodiment, step S203 and step S204 may be executed in parallel or in sequence in any order, which is not specifically limited here.
[0106] Step S205: Generate target text based on the preferred materials related to the outline through the text generation model.
[0107] After quality screening of the outline's related materials and obtaining a small amount of high-quality preferred materials related to the outline, the server inputs the outline and the outline's related preferred materials into a text generation model, and generates target text based on the outline and the preferred materials through the text generation model.
[0108] For example, the outline and preferred materials can be filled into the text generation prompt template to obtain text generation prompt information. The text generation prompt information is input into the text generation model, and the text generation model generates detailed content text corresponding to the outline based on the text generation prompt information to obtain the target text.
[0109] Illustratively, an example of a text generation prompt template for generating a target text based on an outline and preferred materials is as follows: "Known information: {preferred material}. Based on the above known information, analyze and answer the outline concisely and professionally. If you cannot get an answer from it, please say "The question cannot be answered based on the known information" or "Not enough relevant information is provided." It is not allowed to add fabricated elements to the answer, and please use Chinese to answer. The outline is {outline}." Among them, "{outline}" is filled with the outline of the target text, and "{preferred material}" is filled with the preferred material related to the outline.
[0110] In an optional embodiment, the target text may include a body and a title. The server generates the body of the target text according to the outline and related preferred materials, and then generates the title according to the body of the target text.
[0111] Specifically, the outline and related preferred materials are filled into the content generation prompt template to obtain content generation prompt information, the content generation prompt information is input into the text generation model, and the text generation model generates the main text corresponding to the outline according to the content generation prompt information to obtain the main text of the target text.
[0112] For example, an example of a content generation prompt template is as follows: "Known information: {Preferred material} Based on the above known information, analyze and answer the outline concisely and professionally. If you cannot get an answer from it, please say "The question cannot be answered based on the known information" or "Not enough relevant information is provided." It is not allowed to add fabricated elements to the answer, and the answer should be in Chinese. The outline is {outline}". Among them, "{outline}" is filled with the outline of the target text, and "{preferred material}" is filled with the preferred material related to the outline.
[0113] Furthermore, the body of the target text is filled into the title generation prompt template to obtain title generation prompt information. The title generation prompt information is input into the text generation model, and the text generation model generates the title of the target text based on the title generation prompt information.
[0114] For example, an example of a title generation prompt template is as follows: "As a journalist, please summarize the title of the following article {Main text}, with no more than 30 words." The "{Main text}" is filled with the main text of the target article.
[0115] The method of this embodiment determines the outline of the target text to be generated based on given subject information, obtains a large amount of relevant materials for the outline, and uses the large amount of relevant materials for the outline to fine-tune the pre-trained model used to generate the text to obtain a text generation model. The domain knowledge contained in the large amount of materials related to the outline can be stored in the text generation model in a parameterized form, that is, the domain knowledge contained in the large amount of relevant materials is injected into the text generation model, so that the text generation model learns more domain knowledge and can adapt to different fields. Furthermore, the relevant materials of the outline are quality-screened to obtain a small amount of high-quality preferred materials related to the outline. The fine-tuned text generation model is used to generate the target text based on the small amount of high-quality preferred materials. Since the text generation model learns the domain knowledge contained in a large amount of relevant materials, when generating the target text, it not only refers to the domain knowledge contained in the small amount of high-quality preferred materials after quality screening, but also refers to the domain knowledge contained in the large amount of relevant materials, which can improve the quality of text generation. By inputting less preferred materials (keeping the input short), a high-quality target text can be generated, which can reduce the impact of the model input length limit on the text generation quality and improve the quality of text generation.
[0116] In an optional implementation, after the target text is generated based on the preferred materials related to the outline using the text generation model, the server can also verify the authenticity of the generated target text based on the preferred materials related to the outline. If the authenticity verification of the main content of the content points fails, the main content of the content points is revised.
[0117] Optionally, based on the preferred materials related to the outline, the generated target text is verified for authenticity. This can be achieved in the following ways:
[0118] The triple extraction model extracts triple information from the target text and the preferred material. It then identifies whether there is a conflict between the triple information in the preferred material and the target text. If the identification result indicates a conflict, the authenticity check for the target text fails. If the identification result indicates no conflict, the authenticity check for the target text passes. By extracting triple information from the target text and the preferred material and comparing them at a fine-grained level, content conflicts between the target text and the preferred material can be quickly and accurately located, supplementing the authenticity check for triple information that is not covered by the knowledge graph.
[0119] Among them, the triple information extracted from the target text and the preferred material is a triple containing the three parts <subject, predicate, object>, that is, a Subject-Predication-Object triple, referred to as SPO triple. Any two triples conflict means that any two parts of the two triples are consistent and the remaining part is inconsistent. For example, the subject and predicate in the two triples are consistent, but the object is inconsistent; or the predicate and object in the two triples are consistent, but the subject is inconsistent; or the subject and object in the two triples are consistent, but the predicate is inconsistent, indicating that the relationship between the two entities of the subject and the object is inconsistent.
[0120] Optionally, based on the preferred materials related to the outline, the generated target text is verified for authenticity. This can be achieved in the following ways:
[0121] The conflict identification model identifies whether the target text conflicts with the preferred materials associated with the outline. If the identification result indicates a conflict, the target text fails the authenticity check. If the identification result indicates no conflict, the target text passes the authenticity check. Leveraging model reasoning capabilities, content conflicts between the target text and the preferred materials can be quickly identified.
[0122] The conflict identification model may be any large language model (LLM), which utilizes the reasoning capability of the large model to perform reasoning verification on whether there is a conflict between the generated target text and the content of the referenced preferred material.
[0123] Optionally, the target text and the preferred material are entered into a conflict identification prompt template to obtain conflict identification prompt information, which is then input into a conflict identification model to identify whether there is a content conflict between the target text and the preferred material based on the conflict identification prompt information.
[0124] For example, an example of a conflict identification prompt template is as follows: "As an experienced writer, please judge whether the summary of {outline} is inconsistent with the original material based on the given descriptive text {outline}, combined with the original material {preferred material} and the generated summary {target text}. If there is a contradiction, please point it out and give an explanation.", where "{outline}" is used to fill in the outline, "{preferred material}" is used to fill in the preferred material related to the outline, and "{target text}" is used to fill in the generated target text.
[0125] For example, another example of the conflict identification prompt template is as follows: "As an experienced writer, please judge whether the summary is inconsistent with the original material based on the original material {preferred material} and the generated summary {target text}. If there is a contradiction, please point it out and give an explanation.", where "{preferred material}" is used to fill in the preferred material related to the outline, and "{target text}" is used to fill in the generated target text.
[0126] Optionally, the target text and preferred material are entered into a conflict identification prompt template to obtain conflict identification prompt information. The conflict identification prompt information is input into a conflict identification model, which then uses the conflict identification prompt information to perform sentence-level relationship judgment on the target text and the preferred material, determining whether the relationship between the two is inclusive, contradictory, or neutral. If the relationship judgment result is contradictory, the authenticity check of the target text fails. If the recognition result is inclusive or neutral, the authenticity check of the target text passes.
[0127] For example, an example conflict identification prompt template is as follows: "As an experienced linguist, please determine whether the relationship between the given {preferred material} and the generated {result} is one of the following: inclusion, contradiction, or neutrality, and output it in JSON format. If unsure, please output {}." The "{preferred material}" field is used to fill in the preferred material related to the outline, and the "{result}" field is used to fill in the generated target text.
[0128] Optionally, the server can also use the knowledge graph to verify the authenticity of the generated target text. Specifically, the triple extraction model is used to extract the triple information contained in the target text; the triple information contained in the target text is compared with the triples in the knowledge graph to identify whether there is a conflict between the triple information contained in the target text and the triples in the knowledge graph. If the recognition result is that there is a conflict, the authenticity verification of the target text fails; if the recognition result is that there is no conflict, the authenticity verification of the target text passes. Among them, the triple information extracted from the target text and the preferred material is a triple containing the three parts <subject, predicate, object>. A conflict between any two triples means that any two parts of the two triples are consistent and the remaining part is inconsistent. In addition, the knowledge graph used for authenticity verification may include a domain knowledge graph and / or an open source knowledge graph. The domain knowledge graph is a knowledge graph constructed by the owner of the text generation system based on the knowledge in the field. The open source knowledge graph can be an open source knowledge graph that has been established in the industry.
[0129] Optionally, a named entity recognition (NER) model is used to perform entity recognition on the target text. The candidate set of named entities can be configured and adjusted according to the needs of the actual application scenario, and is not specifically limited here. For example, the recognized named entities include but are not limited to names of people, places, organizations, meetings, job levels, time, and quantity. The target text is divided into sentences, and a mapping relationship between entities and their sentences is established. Based on the mapping relationship between entities and sentences, the entities in the sentences are used as answers, and the answers in the sentences are masked to construct questions. The question-answering model is used to generate answers to questions based on the preferred materials. If there is a conflict between the answer to at least one question and the corresponding answer, the authenticity check of the target text fails. The question-answering model can be implemented by any existing large language model, and is not specifically limited here.
[0130] For example, consider a sentence in the target text: "Xiao Ming attended a meeting on January 10, 2024." The entities identified are: Xiao Ming, January 10, 2024, and meeting. Questions such as "Who attended the meeting on January 10, 2024?" and "What meeting did Xiao Ming attend?" can be constructed. If the answer to the first question generated by the question-answering model based on the selected material includes Xiao Ming, and the answer to the second question includes the meeting on January 10, 2024, and there is no conflict with the masked answer, then the target text passes the authenticity check.
[0131] Furthermore, the target text can be corrected in the following ways:
[0132] Through the text generation model, the target text is regenerated based on the preferred materials and target text related to the outline, as well as the conflict information determined by the authenticity verification of the target text.
[0133] Specifically, the outline, its associated preferred materials, the target text, and any conflicting information identified during the authenticity check of the target text are entered into a correction prompt template to generate correction prompt information. This correction prompt information is then fed into a text generation model, which then regenerates the target text based on the correction prompt information, eliminating the conflicting information in the target text.
[0134] For example, an example of a correction prompt template is as follows: "As a senior writer, the original material {preferred material}, the generated summary {target text}, please re-combine the outline {outline} to generate a summary based on the contradictions {conflicting information} you found. If you can't get an answer from it, please say "The question cannot be answered based on the known information" or "Not enough relevant information is provided." It is not allowed to add fabricated elements to the answer, and please use Chinese for the answer." Among them, "{outline}" is used to fill in the outline, "{preferred material}" is used to fill in the preferred material related to the outline, and "{target text}" is used to fill in the generated target text. "{conflicting information}" is used to fill in the conflict information determined by the authenticity verification of the target text, which can be conflicting triple information, contradictory content, etc.
[0135] Optionally, the target text can be corrected by outputting the target text and conflict information between the target text and the preferred material through the correction interface. The user can manually correct the target text based on the conflict information between the target text and the preferred material to obtain a corrected target text.
[0136] In this embodiment, the target text can be verified by combining the aforementioned multiple authenticity verification methods, which can quickly and accurately locate the content conflict between the target text and the preferred material, and correct the target text based on the conflict information, thereby improving the quality of the target text.
[0137] In an optional embodiment, the outline of the target text includes at least one level of content points. For example, Figure 3 Detailed flow chart of the text generation method provided by an exemplary embodiment of the present application. Figure 3 As shown, the specific implementation steps of this method are as follows:
[0138] Step S301: Determine an outline of a target text to be generated according to given subject information, where the outline includes at least one level of content highlights.
[0139] The specific implementation principle and technical effects of this step can be found in the relevant content of step S201 in the above embodiment, which will not be repeated here.
[0140] Step S302: Obtain relevant materials for each content point included in the outline to obtain relevant materials for the outline.
[0141] In this embodiment, the outline includes at least one level of content points. When obtaining relevant materials for the outline, relevant materials for each content point included in the outline are obtained respectively.
[0142] In this step, the server can obtain the relevant materials for each content point by at least one of the following methods:
[0143] Call an Internet search engine to search for relevant materials for each content point; call a local search engine to search for relevant materials for each content point in a local database; and obtain relevant materials for any content point input by a user.
[0144] The Internet search engine may be a third-party Internet search engine. The server may obtain a large amount of relevant materials for each content point by calling the Internet search engine and searching for relevant materials for each content point within the scope of public data visible on the public network.
[0145] A local search engine is a search engine owned by the provider of the text generation system. It searches a local database for materials related to each content point. For example, the text generation system might be used internally by a radio station, which has a large collection of internal manuscripts, such as interview transcripts and press releases, and thus could build a local database. The local search engine searches the local database for materials related to each content point, obtaining relevant materials for each content point.
[0146] In addition, the method of this embodiment also supports users submitting relevant materials for each key point. For example, the server outputs each key point of the outline via a material submission interface. This material submission interface provides a material submission area for each key point of the outline. Users can edit or upload relevant materials for each key point online in the material submission area.
[0147] In this embodiment, the server can combine the above-mentioned multiple methods to obtain relevant materials for each content point included in the outline, and can obtain a large amount of relevant materials for each content point more comprehensively and accurately, providing richer materials for generating the target text, and improving the generation quality of the target text.
[0148] Step S303: Fine-tune the pre-trained model based on relevant materials of the outline to obtain a text generation model.
[0149] In this step, the server fine-tunes the pre-trained model based on a large amount of relevant materials for each content point contained in the outline to obtain a text generation model. The domain knowledge contained in the large amount of relevant materials related to each content point can be stored in the text generation model in a parameterized form, thereby injecting the domain knowledge contained in the large amount of relevant materials into the text generation model, so that the text generation model can learn more domain knowledge and improve the text generation quality of the text generation model.
[0150] The pre-trained model can be any existing text generation model, specifically various large language models (LLMs) or BERT-based text generation models, which are not specifically limited here.
[0151] Optionally, in this step, the server may use all relevant materials of each content point obtained in the above steps to fine-tune the pre-trained model to obtain a text generation model.
[0152] Optionally, in this step, the server can use some relevant materials of each content point obtained in the above steps to fine-tune the pre-trained model to obtain a text generation model to improve the efficiency of model fine-tuning training, thereby improving the efficiency of text generation.
[0153] Specifically, the server can filter the relevant materials for each content point based on the configured second basic related condition to obtain a screening result. The number of materials in the screening result is less than the total amount of materials related to the content point. The screening result is used as the material for fine-tuning training to reduce the complexity of fine-tuning training. The materials included in the screening result are used to fine-tune the pre-trained model to obtain a text generation model. In addition, the number of materials in the screening result should be greater than the number of preferred materials for the content point to ensure the effectiveness of fine-tuning training and improve the generation quality of the text generation model.
[0154] Among them, the second basic relevant condition refers to the pre-configured condition for coarse screening of relevant materials of content points. Compared with the quality screening of relevant materials of each content point in the subsequent steps, the second basic relevant condition performs a coarse-grained screening of relevant materials of content points from the aspects of relevance and / or timeliness of the materials, so as to appropriately reduce the number of materials used for fine-tuning training, while ensuring that the text generation model learns a large amount of domain knowledge of relevant materials and ensures the effect of fine-tuning training.
[0155] For example, the second basic relevance condition may include at least one of the following: a relevance evaluation value between the relevant material and the content key points is greater than or equal to a second relevance threshold, and a timeliness evaluation value of the relevant material is greater than or equal to a second timeliness threshold. The second relevance threshold and the second timeliness threshold are both relatively low thresholds, and their specific values can be configured and adjusted by relevant technical personnel based on the needs and experience of actual application scenarios, and are not specifically limited here.
[0156] In this embodiment, the server uses the relevant materials (all or part) of each content point to fine-tune the pre-trained model. When obtaining the text generation model, the server can use the parameter-efficient fine-tuning (PEFT) fine-tuning method, such as low-rank adaptation (LoRA), p-tuning and other fine-tuning methods, to quickly fine-tune the pre-trained model to improve the efficiency of model fine-tuning training, thereby improving the efficiency of text generation.
[0157] For example, in an optional embodiment, the server can use the low-rank adaptive LoRA method to fine-tune the pre-trained model. Specifically, by adding new parameters (trainable rank decomposition matrix) to the pre-trained model, a text generation model to be fine-tuned is constructed; based on the relevant materials (all or part) of each content point, the parameters added to the text generation model are fine-tuned to obtain a trained text generation model. During the fine-tuning training process, the original parameters of the pre-trained model are kept unchanged, and only a small number of newly added parameters are trained, which can greatly improve the efficiency of fine-tuning training, thereby improving the efficiency of text generation. In addition, the server can also use PEFT fine-tuning methods other than LoRA, such as P-Tuning, P-Tuning v2 and other training methods, which are not specifically limited here.
[0158] Optionally, in this step, the server uses the relevant materials (all or part) of each content point to fine-tune the pre-trained model. When obtaining the text generation model, it can also use fine-tuning methods other than PEFT to fine-tune all parameters of the pre-trained model, which can also improve the quality of text generation and may have a certain impact on the efficiency of text generation.
[0159] The method of this embodiment uses a large amount of relevant materials for each content point to fine-tune the pre-trained model, and stores the domain knowledge contained in the large amount of relevant materials in a parameterized form into the model structure. In this way, more domain knowledge can be injected into the text generation model without extending the model input length, which can greatly improve the quality of text generation.
[0160] Step S304: perform quality screening on the relevant materials of each content point to obtain the preferred materials related to each content point.
[0161] In this step, the quality of the relevant materials for each content point in the outline is screened separately to obtain a small amount of high-quality preferred materials related to each content point.
[0162] Specifically, the relevant materials of each content point are evaluated from at least one dimension of timeliness, authority and relevance to obtain quality evaluation results of the relevant materials of each content point; based on the quality evaluation results of the relevant materials of each content point, the relevant materials of each content point are screened to obtain preferred materials related to each content point.
[0163] Relevance represents the textual and semantic relevance between the main point and related materials. This relevance value can be obtained by evaluating the relevance between the main point and the related materials using existing text relevance algorithms. Specific text relevance algorithms include, but are not limited to, best fit algorithms such as BM25 and the TF-IDF algorithm.
[0164] The meanings of timeliness and authority, as well as the calculation methods of the timeliness evaluation values and authority evaluation values of relevant materials are consistent with those in the aforementioned embodiments. Please refer to the relevant contents in the aforementioned embodiments for details and will not be repeated here.
[0165] In this step, the server can perform quality evaluation on the relevant materials of the content points in terms of timeliness, authority and relevance, and obtain the timeliness evaluation value, authority evaluation value and relevance evaluation value of the relevant materials. The timeliness evaluation value, authority evaluation value and relevance evaluation value of the relevant materials are comprehensively evaluated to determine the quality evaluation value of the relevant materials of the content points. Furthermore, based on the quality evaluation value of the relevant materials of the content points, at least one relevant material with a larger quality evaluation value is screened out as the preferred material of the content points. For the specific implementation principle and technical effects, please refer to the relevant content of step S204 in the aforementioned embodiment, which will not be repeated here.
[0166] In an optional embodiment, the server can output the preferred materials for each content point included in the outline through a material editing interface. The material editing interface also provides a display and editing area for the preferred materials related to each content point. The user can edit and save any preferred material related to any content point through the material editing interface. In response to the user's editing operation on any preferred material related to any content point in the material editing interface, the preferred material is updated and saved. In addition, when outputting the preferred materials related to the content points, the source information of the preferred materials can also be output, so that the user can know the source of the preferred materials and can filter and intervene in the preferred materials.
[0167] In this embodiment, the outline contains at least one level of key points. When generating the target text, the server generates the corresponding body content for each key point based on the preferred materials associated with each key point. The body content of each key point in the outline is organized hierarchically to produce the target text. This is achieved specifically through the following steps S305-S306.
[0168] Step S305: For any content key points included in the outline, fill the content key points and related preferred materials into the content generation prompt template to obtain content generation prompt information, input the content generation prompt information into the text generation model, and generate the main content of the content key points based on the content generation prompt information through the text generation model.
[0169] In this step, the server generates the main content for each key point in the outline. Specifically, the key points and their associated preferred materials are populated into a text generation prompt template to obtain text generation prompt information. This text generation prompt information is then input into a text generation model, which then generates the main content of the key points based on the text generation prompt information.
[0170] Illustratively, an example of a text generation prompt template for generating content points based on content points and preferred materials related to the content points is as follows: "Known information: {preferred material}. Based on the above known information, analyze and answer the content points concisely and professionally. If you cannot get an answer from it, please say "The question cannot be answered based on the known information" or "Not enough relevant information is provided." It is not allowed to add fabricated elements to the answer, and please use Chinese to answer. The content point is {content point}." Among them, "{content point}" is filled with the content point, and "{preferred material}" is filled with the preferred material related to the content point.
[0171] In an optional embodiment, for any content point, after generating the main content of the content point, the server can also verify the authenticity of the main content of the content point based on the preferred materials related to the content point, and if the authenticity verification of the main content of the content point fails, the server can modify the main content of the content point.
[0172] Optionally, based on the preferred materials related to the main points of the content, the authenticity of the main content of the content can be verified. This can be achieved in the following ways:
[0173] Through the triple extraction model, the triple information contained in the main text of the content points and the triple information contained in the preferred materials related to the content points are extracted; the triple information contained in the preferred materials related to the content points is identified to see whether there is a conflict with the triple information contained in the main text of the content points; if the identification result is that there is a conflict, the authenticity verification of the main text of the content points fails; if the identification result is that there is no conflict, the authenticity verification of the main text of the content points passes. By extracting the triple information from the main text of the content points and the related preferred materials, and through fine-grained triple information comparison, the content conflict between the main text of the generated content points and the preferred materials can be quickly and accurately located, which can supplement the authenticity verification of triple information that cannot be covered by the knowledge graph.
[0174] The triple information extracted from the main text of the key points and the selected materials is a triple consisting of <subject, predicate, object>. A conflict between any two triples means that any two parts of the two triples are consistent, while the remaining part is inconsistent. For example, if the subject and predicate in the two triples are consistent, but the objects are inconsistent; or if the predicate and object in the two triples are consistent, but the subject is inconsistent; or if the subject and object in the two triples are consistent, but the predicate is inconsistent, this indicates that the relationship between the two entities of the subject and object is inconsistent.
[0175] Optionally, based on the preferred materials related to the key points, the authenticity of the main content of the key points can be verified, which can also be achieved in the following ways:
[0176] The conflict identification model is used to identify whether there is a conflict between the main content of the content points and the content of the preferred materials related to the content points. If the identification result is that there is a conflict, the authenticity verification of the main content of the content points will fail. If the identification result is that there is no conflict, the authenticity verification of the main content of the content points will pass. The model's reasoning capabilities can be used to quickly identify content conflicts and contradictions between the main content of the content points and the preferred materials. The conflict identification model can be any large language model (LLM). The reasoning capabilities of the large model are used to perform reasoning and verification on whether there is a conflict between the main content of the generated content points and the content of the referenced preferred materials.
[0177] Optionally, the main content of the content point and the preferred materials related to the content point are entered into a conflict identification prompt template to obtain conflict identification prompt information. The conflict identification prompt information is input into a conflict identification model, and the conflict identification model uses the conflict identification prompt information to identify whether there is a conflict between the main content of the content point and the content of the preferred materials.
[0178] For example, an example of a conflict identification prompt template is as follows: "As an experienced writer, please judge whether the summary of {content points} is inconsistent with the original material based on the given descriptive text {content points}, combined with the original material {preferred material} and the generated summary {main content}. If there is a contradiction, please point it out and give an explanation.", where "{content points}" is used to fill in the content points, "{preferred material}" is used to fill in the preferred material related to the content points, and "{main content}" is used to fill in the main content of the content points.
[0179] For example, another example of the conflict identification prompt template is as follows: "As an experienced writer, please judge whether the summary is inconsistent with the original material based on the original material {preferred material} and the generated summary {main content}. If there is a contradiction, please point it out and give an explanation.", where "{preferred material}" is used to fill in the preferred material related to the outline, and "{main content}" is used to fill in the main content of the content points.
[0180] Optionally, the main content of the content points and the preferred materials related to the content points are filled into the conflict identification prompt template to obtain conflict identification prompt information. The conflict identification prompt information is input into the conflict identification model, and the conflict identification model performs sentence-level relationship judgment on the main content of the content points and the preferred materials based on the conflict identification prompt information to determine whether the relationship between the two is inclusion, contradiction, or neutrality. If the relationship judgment result is contradiction, the authenticity check of the main content of the content points fails. If the recognition result is inclusion or neutrality, the authenticity check of the main content of the content points passes.
[0181] For example, an example conflict identification prompt template is as follows: "As an experienced linguist, please determine whether the relationship between the given {preferred material} and the generated {result} is one of the following: inclusion, contradiction, or neutrality, and output it in JSON format. If unsure, please output {}." The "{preferred material}" field is used to fill in the preferred material related to the outline, and the "{result}" field is used to fill in the main text of the generated content points.
[0182] Optionally, the server can also use the knowledge graph to verify the authenticity of the main content of the content points. Specifically, the triple extraction model is used to extract the triple information contained in the main content of the content points; the triple information contained in the main content of the content points is compared with the triples in the knowledge graph to identify whether there is a conflict between the triple information contained in the main content of the content points and the triples in the knowledge graph. If the identification result is that there is a conflict, the authenticity verification of the main content of the content points fails; if the identification result is that there is no conflict, the authenticity verification of the main content of the content points passes. Among them, the triple information extracted from the main content of the content points and the preferred materials is a triple containing the three parts <subject, predicate, object>. Any two triples conflict means that any two parts of the two triples are consistent and the remaining part is inconsistent. In addition, the knowledge graph used for authenticity verification can include domain knowledge graphs and / or open source knowledge graphs. The domain knowledge graph is a knowledge graph constructed by the owner of the text generation system based on the knowledge in the field. The open source knowledge graph can be an open source knowledge graph that has been established in the industry.
[0183] Optionally, a Named Entity Recognition (NER) model is used to perform entity recognition on the main content of the content highlights. The candidate set of named entities can be configured and adjusted according to the needs of the actual application scenario, and is not specifically limited here. For example, named entities include but are not limited to names of people, places, organizations, meetings, job levels, time, and quantity. The main content of the content highlights is divided into sentences, and a mapping relationship between entities and their corresponding sentences is established. Based on the mapping relationship between entities and sentences, the entities in the sentences are used as answers, and the answers in the sentences are masked to construct questions. The question-answering model is used to generate answers to questions based on the preferred materials. If there is a conflict between the answer to at least one question and the corresponding answer, the authenticity check of the main content of the content highlights fails. The question-answering model can be implemented by any existing large language model, and is not specifically limited here.
[0184] Furthermore, the main content of the content can be modified in the following ways:
[0185] The text generation model is used to regenerate the main content of the content points based on the preferred materials and main content of the content points, as well as conflict information determined by authenticity verification of the main content of the content points.
[0186] Optionally, the main content of the key points can be modified in the following ways:
[0187] Specifically, the content key points, preferred materials related to the content key points, the main body of the content key points, and conflicting information determined by authenticity verification of the main body of the content key points are entered into a correction prompt template to obtain correction prompt information. The correction prompt information is then input into a text generation model, which then regenerates the main body of the content key points based on the correction prompt information, eliminating the conflicting information in the main body of the content key points.
[0188] Optionally, the main content of the key points can be modified by outputting the main content of the key points through the modification interface, along with information on conflicts between the main content of the key points and the preferred material. Based on this information, the user can manually modify the main content of the key points to obtain the modified main content of the key points.
[0189] In this embodiment, the main content of the content points can be verified in combination with the aforementioned multiple authenticity verification methods, so that the content conflict between the main content of the content points and the preferred materials related to the content points can be quickly and accurately located, and the main content of the content points can be corrected based on the conflict information, thereby improving the quality of the main content of the content points.
[0190] Step S306: Generate the main text of the target text based on the main text of the key points at each level included in the outline.
[0191] After obtaining the main text content of the key points of each level contained in the outline, the main text content of the key points of each level contained in the outline is organized and spliced according to the level to obtain the main text of the target text.
[0192] Step S307: Fill the main text of the target text into the title generation prompt template to obtain title generation prompt information, input the title generation prompt information into the text generation model, and generate the title of the target text according to the title generation prompt information through the text generation model.
[0193] After obtaining the body of the target text, the server generates a title of the target text according to the body of the target text.
[0194] Specifically, the server fills the target text's body into a title generation prompt template to obtain title generation prompt information, inputs the title generation prompt information into a text generation model, and generates the target text's title based on the title generation prompt information through the text generation model.
[0195] For example, an example of a title generation prompt template is as follows: "As a journalist, please summarize the title of the following article {Main text}, with no more than 30 words." The "{Main text}" is filled with the main text of the target article.
[0196] In another optional embodiment, the server may replace the main text of the target text with the main text of each content point and fill it into the title generation prompt template to obtain title generation prompt information. The title generation prompt information is input into the text generation model, and the text generation model generates the title of the target text based on the title generation prompt information.
[0197] Step S308: Output the title and body of the target text.
[0198] After obtaining the title and body of the target text, the server outputs the title and body of the target text to the end-side device. The end-side device outputs the title and body of the target text to the user.
[0199] The method of this embodiment determines the outline of the target text to be generated based on given subject information. The outline includes at least one level of content points. A large amount of relevant materials for each content point is obtained. The pre-trained model is fine-tuned using the large amount of relevant materials for each content point to obtain a text generation model. The domain knowledge contained in the large amount of materials related to each content point can be stored in a parameterized form in the text generation model. That is, the domain knowledge contained in the large amount of relevant materials is injected into the text generation model, so that the text generation model learns more domain knowledge and can adapt to different fields. Furthermore, the relevant materials for each content point are quality-screened to obtain a small amount of high-quality preferred materials related to each content point. The fine-tuned text generation model is used to generate the main content of each content point based on the small amount of high-quality preferred materials related to each content point. The main content of each content point is organized hierarchically to generate the main text of the target text. The text generation model generates a title based on the main text of the target text. Because the text generation model learns domain knowledge from a large amount of relevant material, it not only considers the domain knowledge contained in a small amount of high-quality, quality-screened, selected material when generating the target text, but also references the domain knowledge contained in a larger amount of relevant material, which can improve the quality of text generation. By inputting fewer selected materials (keeping the input short), high-quality target text can be generated, which can reduce the impact of the model input length limit on text generation quality and improve text generation quality.
[0200] For example, Figure 4 An example framework diagram of a text generation method provided by an exemplary embodiment of the present application. Figure 4 As shown, the text generation model consists of the following stages: outline determination, material processing, model fine-tuning, text generation, and verification and confirmation. In the outline determination stage, based on the user-entered topic information of the target text to be generated, the model automatically generates an outline. It also retrieves the configured outline templates as candidate outlines, allowing users to edit and select candidate outlines, thereby allowing users to manually select an outline.
[0201] During the material processing stage, based on the selected outline, a large amount of relevant materials of the outline are obtained through various means such as Internet search engines, local search engines, and manual input; the quality of the relevant materials is evaluated in terms of relevance, authority, and timeliness, and a small amount of high-quality preferred materials for the outline are screened out.
[0202] During the model fine-tuning phase, the pre-trained model is fine-tuned based on the extensive material from the syllabus to produce a text generation model. The domain knowledge contained in this extensive material is parameterized and stored in the text generation model. This in turn allows the model to learn more domain knowledge and improve its text generation quality.
[0203] In the text generation stage, based on the outline and the outline's preferred materials and a pre-configured unified prompt template (Prompt), a text generation model is used to summarize the content of the preferred materials to generate the target text.
[0204] In the verification and confirmation stage, the authenticity of the text generation results is verified by verifying the authenticity of the SPO triples between the generated results and the preferred materials, verifying the authenticity of the SPO triples between the generated results and the knowledge graph, and checking the content conflicts between the generated results and the preferred materials using the model reasoning capability... If the authenticity verification fails, the text generation results are corrected through automatic correction by the large model or manual correction confirmation.
[0205] The text generation framework of this embodiment uses artificial intelligence models to assist in text creation, combines the induction and reasoning capabilities of large models, and combines search engines, knowledge graphs, entity recognition and other technologies to propose a comprehensive text generation solution. It uses the induction and reasoning capabilities of large models to generate outlines, and uses the powerful retrieval capabilities of search engines to quickly search for materials related to the outline; conducts comprehensive quality evaluation of materials in terms of timeliness, authority, relevance and other dimensions, and screens out a small amount of high-quality preferred materials; uses large models to summarize and summarize the content of the materials to generate target text; uses knowledge graphs, named entity recognition, and large model reflective reasoning and other technologies to verify and correct the generated results, thereby providing a complete set of intelligent text generation solutions for the publishing and media industries and improving the quality of text generation.
[0206] Figure 5 This is a schematic diagram of the structure of a server provided in an embodiment of the present application. Figure 5As shown, the server includes a memory 501 and a processor 502. Memory 501 is used to store computer-executable instructions and can be configured to store various other data to support operations on the server. Processor 502 is communicatively connected to memory 501 and is used to execute the computer-executable instructions stored in memory 501 to implement the technical solutions provided by any of the above-mentioned method embodiments. The specific functions and technical effects achieved are similar and will not be further described here.
[0207] Optional, such as Figure 5 As shown, the server also includes: a firewall 503, a load balancer 504, a communication component 505, a power supply component 506 and other components. Figure 5 Only some components are shown schematically, which does not mean that the server only includes Figure 5 Components shown. Figure 5 The server is only taken as a cloud server deployed in the cloud as an example for exemplary description. The server can also be deployed locally, and this embodiment is not specifically limited here.
[0208] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When a processor executes the computer-executable instructions, the method of any of the aforementioned embodiments is implemented. The specific functions and technical effects that can be achieved are not repeated here.
[0209] The present application also provides a computer program product, including a computer program. When executed by a processor, the computer program implements the method of any of the aforementioned embodiments. The computer program is stored in a readable storage medium. At least one processor of a server can read the computer program from the readable storage medium. The at least one processor executes the computer program, causing the server to perform the technical solution provided by any of the aforementioned method embodiments. The specific functions and technical effects achieved are not further described here.
[0210] The present application provides a chip comprising: a processing module and a communication interface. The processing module is capable of executing the technical solution of the server in the aforementioned method embodiments. Optionally, the chip further comprises a storage module (e.g., a memory) configured to store instructions, and the processing module configured to execute the instructions stored in the storage module. Execution of the instructions stored in the storage module causes the processing module to execute the technical solution provided by any of the aforementioned method embodiments.
[0211] The above-mentioned integrated module implemented in the form of a software functional module can be stored in a computer-readable storage medium. The above-mentioned software functional module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0212] It should be understood that the above-mentioned processor can be a processing unit (Central Processing Unit, referred to as CPU), or it can be other general-purpose processors, digital signal processors (Digital Signal Processor, referred to as DSP), application specific integrated circuits (Application Specific Integrated Circuit, referred to as ASIC), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the application can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor. The memory may include high-speed random access memory (Random Access Memory, referred to as RAM), and may also include non-volatile storage, such as at least one disk storage, and can also be a USB flash drive, a mobile hard disk, a read-only memory, a disk or an optical disk, etc.
[0213] The above storage may be an object storage service (OSS).
[0214] The above-mentioned memory can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0215] The above-mentioned communication component is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as a mobile hotspot (WiFi), a second-generation mobile communication system (2G), a third-generation mobile communication system (3G), a fourth-generation mobile communication system (4G) / Long Term Evolution (LTE), a fifth-generation mobile communication system (5G) and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared technology, ultra-wide band (UWB) technology, Bluetooth technology and other technologies.
[0216] The power supply assembly provides power to various components of the device in which the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.
[0217] The storage medium may be implemented by any type of volatile or non-volatile memory device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0218] An exemplary storage medium is coupled to a processor, such that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and storage medium can be located in an application-specific integrated circuit. Of course, the processor and storage medium can also exist as discrete components in an electronic device or a host control device.
[0219] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0220] The order of the above-mentioned embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. In addition, in some of the processes described in the above-mentioned embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or in parallel. They are only used to distinguish between different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit "first" and "second" to different types. The meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0221] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of each embodiment of the present application.
[0222] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of this application and include common knowledge or customary techniques in the art that are not disclosed herein.
[0223] The above are only preferred embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A text generation method, characterized in that: include: Determine the outline of the target text to be generated according to the given subject information; Obtaining relevant materials of the outline, and fine-tuning the pre-trained model based on the relevant materials of the outline to obtain a text generation model; Performing quality screening on materials related to the outline to obtain preferred materials related to the outline; The target text is generated according to the preferred materials related to the outline through the text generation model.
2. The method according to claim 1, characterized in that Fine-tuning the pre-trained model based on the relevant materials of the outline to obtain a text generation model includes: Add new parameters to the pre-trained model to build a text generation model to be fine-tuned; Based on the relevant materials of the outline, the parameters added to the text generation model are fine-tuned and trained to obtain a trained text generation model.
3. The method according to claim 1 or 2, characterized in that Fine-tuning the pre-trained model based on the relevant materials of the outline to obtain a text generation model includes: According to the configured basic related conditions, relevant materials of the outline are screened to obtain a screening result, wherein the number of materials in the screening result is greater than the number of the preferred materials; The pre-trained model is fine-tuned using the materials included in the screening results to obtain a text generation model.
4. The method according to claim 1, wherein Determining the outline of the target text to be generated according to the given subject information includes: Generate an outline of the target text using the pre-trained model according to the outline generation prompt template and the given topic information; The outline generated by the pre-trained model and at least one pre-configured outline template are used as candidate outlines, and the candidate outlines are output; In response to an editing operation on any candidate outline, updating the edited candidate outline; In response to the user selecting any candidate outline, the selected candidate outline is used as the outline of the target text.
5. The method according to claim 1, wherein The outline includes at least one level of content points. The obtaining of the relevant materials of the outline includes: Respectively obtain relevant materials for each of the key points contained in the outline; The quality screening of the materials related to the outline to obtain the preferred materials related to the outline includes: The quality of the materials related to each of the content points is screened to obtain the preferred materials related to each of the content points.
6. The method according to claim 5, characterized in that Generating the target text according to the preferred materials related to the outline by the text generation model includes: For any content point included in the outline, the content point and related preferred materials are filled into a content generation prompt template to obtain content generation prompt information, the content generation prompt information is input into the text generation model, and the text generation model generates the main content of the content point based on the content generation prompt information; The main text of the target text is generated according to the main text content of each level of content included in the outline.
7. The method according to claim 6, characterized in that Generating the target text according to the preferred materials related to the outline by the text generation model includes: Filling the body of the target text into a title generation prompt template to obtain title generation prompt information; The title generation prompt information is input into the text generation model, and the title of the target text is generated according to the title generation prompt information by the text generation model.
8. The method according to claim 5, characterized in that For any of the content points, after generating the body content of the content point, the method further includes: Verify the authenticity of the main content of the content points based on the selected materials related to the content points; In the case where the authenticity check of the main content of the content points fails, the main content of the content points is corrected.
9. The method according to claim 8, characterized in that The authenticity verification of the main content of the content points based on the preferred materials related to the content points includes: Extracting triplet information contained in the main text of the content points and triplet information contained in the preferred materials related to the content points through a triplet extraction model; Identify whether triple information included in the preferred material related to the content key points conflicts with triple information included in the main text of the content key points; If the identification result shows that there is a conflict, the authenticity check of the main content of the content point will fail; If the identification result shows that there is no conflict, the authenticity of the main content of the content points is verified.
10. The method according to claim 8, characterized in that The authenticity verification of the main content of the content points based on the preferred materials related to the content points includes: Using a conflict identification model, identifying whether there is a conflict between the main text of the content point and the content of the preferred material related to the content point; If the identification result shows that there is a conflict, the authenticity check of the main content of the content point will fail; If the identification result shows that there is no conflict, the authenticity of the main content of the content points is verified.
11. The method according to claim 9 or 10, characterized in that The amendment to the main content of the key points includes: The text generation model is used to regenerate the main content of the content points based on the preferred materials and main content of the content points, as well as conflict information determined by authenticity verification of the main content of the content points.
12. The method according to claim 5, characterized in that The step of respectively obtaining relevant materials for each of the key points of the outline includes at least one of the following: Use an Internet search engine to search for relevant materials for each of the aforementioned content points; Invoke a local search engine to search the local database for relevant materials for each of the aforementioned content points; Obtain relevant materials for any of the content points input by the user.
13. The method according to claim 1, wherein The quality screening of the materials related to the outline to obtain the preferred materials related to the outline includes: Evaluate the relevant materials of the outline based on at least one dimension of timeliness, authority, and relevance to obtain a quality evaluation result of the relevant materials; According to the quality evaluation results of the relevant materials, the relevant materials are screened to obtain preferred materials related to the outline.
14. The method according to claim 1 or 13, characterized in that Also includes: Outputting the preferred materials related to each outline; In response to a user's editing operation on any preferred material, the preferred material is updated.
15. A server, characterized in that: include: at least one processor; as well as a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the server to execute the method according to any one of claims 1 to 14.
16. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method according to any one of claims 1 to 14 is implemented.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 14 is implemented.
Citation Information
Cited By
Content generation method and device
CN121412373A