Generated content optimization method and device, equipment and storage medium

By calculating the relevance, accuracy, coherence, and language quality evaluation indicators of text content, the text content generated by the language model is optimized, solving the problems of inaccurate and incoherent generated content in existing technologies and improving the quality of generated content.

CN118982006APending Publication Date: 2024-11-19HITACHI BUILDING TECH GUANGZHOU CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410997497.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

Existing text content generation methods produce inaccurate and disjointed content, failing to meet user needs.

Method used

By obtaining the original text generated by the language model, extracting the directory structure, and calculating relevance, accuracy, coherence, and language quality evaluation indicators, the text content is optimized and the text content in the original text is replaced.

Benefits of technology

It improves the quality of generated content, ensuring that the content is relevant to the background material, highly accurate, logically coherent, and of excellent language quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118982006A_ABST
    Figure CN118982006A_ABST
Patent Text Reader

Abstract

The invention discloses a generated content optimization method and device, equipment and a storage medium. The text content under each title in the directory architecture is classified; respectively calculating a correlation evaluation index for representing the content correlation between the text content and the input background material and the title, and an accuracy evaluation index for representing the content accuracy between the text content and the input background material; according to the method, a coherence evaluation index for representing logic coherence among paragraphs in text content and a language quality evaluation index for representing language expression quality of the text content are obtained, a comprehensive evaluation index is obtained by integrating the indexes, and the text content is optimized based on the comprehensive evaluation index. And replacing the text content under the title in the original text with the optimized text content. According to the method, the generated text content is optimized based on the content correlation, the content accuracy, the logic continuity and the language expression quality, and the quality of the generated content is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to content generation technology, and in particular to a method, device, equipment and storage medium for optimizing generated content. Background Art

[0002] Text content generation is an important task in natural language processing, which aims to generate natural and fluent text content based on input information.

[0003] The content generated by existing text content generation methods has problems such as inaccuracy and incoherence, and it is difficult to meet user needs. Summary of the invention

[0004] The present invention provides a generated content optimization method, device, equipment and storage medium to improve the quality of generated content.

[0005] In a first aspect, the present invention provides a method for generating content optimization, comprising:

[0006] Obtaining original text generated by the language model, and extracting a directory structure of the original text;

[0007] For the text content under each title in the directory structure, respectively calculating a relevance evaluation index used to characterize the content relevance of the text content with the input background material and the title, an accuracy evaluation index characterizing the content accuracy of the text content and the input background material, a coherence evaluation index characterizing the logical coherence between paragraphs in the text content, and a language quality evaluation index characterizing the language expression quality of the text content;

[0008] Combining the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain a comprehensive evaluation index;

[0009] Optimizing the text content based on the comprehensive evaluation index;

[0010] The optimized text content replaces the text content under the title in the original text.

[0011] Optionally, calculating a relevance evaluation index for characterizing the relevance of the text content with the input background material and the content of the title includes:

[0012] Vectorizing the text content, the background material and the title respectively to obtain a text vector, a background vector and a title vector;

[0013] Calculating the sum of the background vector and the title vector to obtain a first vector;

[0014] Calculate the dot product of the text vector and the first vector to obtain a first value;

[0015] Calculate the product of the modulus of the first vector and the modulus of the title vector to obtain a second value;

[0016] The quotient of the first value and the second value is calculated to obtain a correlation evaluation index.

[0017] Optionally, calculating an accuracy evaluation index for characterizing the accuracy of the text content and the input background material includes:

[0018] extracting facts from the text content and the background material respectively;

[0019] determining the number of facts in the text content that are identical to those in the background material;

[0020] The quotient of the number of identical facts and the total number of facts in the text content is calculated to obtain an accuracy evaluation index.

[0021] Optionally, calculating a coherence evaluation index for characterizing the logical coherence between paragraphs in the text content includes:

[0022] For a target paragraph in the text content, calculating keyword similarity, semantic similarity, and sentence structure similarity between the target paragraph and adjacent paragraphs;

[0023] The keyword similarity, the semantic similarity and the sentence structure similarity are weighted and summed to obtain a coherence evaluation index.

[0024] Optionally, calculating a language quality evaluation index for characterizing the language expression quality of the text content includes:

[0025] Performing error detection on the text content to determine the number of incorrect word segments in the text content;

[0026] The quotient of the number of incorrect segmented words and the total number of segmented words in the text content is calculated to obtain a language quality evaluation index.

[0027] Optionally, the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index are comprehensively combined to obtain a comprehensive evaluation index, including:

[0028] The relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index are weighted and summed to obtain a comprehensive evaluation index.

[0029] Optionally, optimizing the text content based on the comprehensive evaluation index includes:

[0030] Determine whether the comprehensive evaluation index is greater than a preset value;

[0031] If yes, stop the optimization;

[0032] If not, the background material and the prompt word newly input by the user are input into the language model, the text content corresponding to the title is regenerated, and the process returns to execute the steps of respectively calculating a relevance evaluation index for characterizing the content relevance between the text content and the input background material and the title, an accuracy evaluation index for characterizing the content accuracy of the text content and the input background material, a coherence evaluation index for characterizing the logical coherence between paragraphs in the text content, and a language quality evaluation index for characterizing the language expression quality of the text content, until the comprehensive evaluation index is greater than a preset value or the number of iterations reaches a maximum number.

[0033] In a second aspect, the present invention further provides a content generation optimization device, comprising:

[0034] An original text acquisition module, used to acquire the original text generated by the language model and extract the directory structure of the original text;

[0035] An evaluation index calculation module is used to calculate, for the text content under each title in the directory structure, a relevance evaluation index used to characterize the content relevance of the text content with the input background material and the title, an accuracy evaluation index used to characterize the content accuracy of the text content and the input background material, a coherence evaluation index used to characterize the logical coherence between paragraphs in the text content, and a language quality evaluation index used to characterize the language expression quality of the text content;

[0036] An evaluation index synthesis module, used to synthesize the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain a comprehensive evaluation index;

[0037] A text content optimization module, used for optimizing the text content based on the comprehensive evaluation index;

[0038] The text content replacement module is used to replace the text content under the title in the original text with the optimized text content.

[0039] In a third aspect, the present invention further provides an electronic device, comprising:

[0040] one or more processors;

[0041] A storage device for storing one or more programs;

[0042] When the one or more programs are executed by the one or more processors, the one or more processors implement the content generation optimization method provided in the first aspect of the present invention.

[0043] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for generating content optimization provided in the first aspect of the present invention.

[0044] The method for optimizing generated content provided by the present invention comprises: obtaining the original text generated by the language model, and extracting the directory structure of the original text, and respectively calculating, for the text content under each title in the directory structure, a correlation evaluation index for characterizing the content correlation between the text content and the input background material and the title, an accuracy evaluation index for characterizing the content accuracy between the text content and the input background material, a coherence evaluation index for characterizing the logical coherence between each paragraph in the text content, and a language quality evaluation index for characterizing the language expression quality of the text content, and comprehensively calculating the correlation evaluation index, the accuracy evaluation index, the coherence evaluation index, and the language quality evaluation index to obtain a comprehensive evaluation index, optimizing the text content based on the comprehensive evaluation index, and replacing the text content under the title in the original text with the optimized text content. The present invention optimizes the generated text content based on content correlation, content accuracy, logical coherence, and language expression quality, thereby improving the quality of the generated content.

[0045] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0047] Figure 1 A flowchart of a method for generating content optimization provided by an embodiment of the present invention;

[0048] Figure 2 A schematic diagram of the structure of a content optimization device provided by an embodiment of the present invention;

[0049] Figure 3 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.

[0050] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0051] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0052] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0053] Figure 1 This is a flowchart of a method for optimizing generated content provided by an embodiment of the present invention. This embodiment is applicable to optimizing generated text content to improve content quality. The method can be executed by a generated content optimization device provided by an embodiment of the present invention. The device can be implemented by software and / or hardware and is usually configured in an electronic device, such as Figure 1 As shown, the method for generating content optimization specifically includes the following steps:

[0054] S101. Obtain the original text generated by the language model, and extract the directory structure of the original text.

[0055] In an embodiment of the present invention, the background material is input into a pre-trained language model for processing, an original text is generated, and a directory structure of the original text is extracted. The directory structure may include multiple levels of titles, and each title has text content corresponding to the title.

[0056] Exemplarily, the language model processing process is as follows:

[0057] 1. Preprocessing

[0058] 1.1 Text cleaning

[0059] Preprocess the subject and background material input by the user, including removing stop words, punctuation marks and special characters. The main purpose of text cleaning is to remove noise from the input text in order to improve the accuracy of subsequent analysis. In the embodiment of the present invention, the nltk library is used for text cleaning. It mainly includes:

[0060] Remove punctuation and special characters: Use regular expressions to remove punctuation and special characters from text, while retaining letters, numbers, and spaces.

[0061] Remove stop words: Use the stop word list in nltk.corpus to filter out common meaningless words.

[0062] 1.2. Word segmentation

[0063] The word segmentation algorithm is used to segment the input text into words or phrases for subsequent analysis. In the embodiment of the present invention, the word segmentation process is performed using the word segmenter in the nltk.tokenize library. The main steps include:

[0064] Word segmentation: Input the cleaned text into the word segmentation algorithm to divide the text into words or phrases.

[0065] Generate word vectors: Convert the segmented text into word vector representation for further analysis.

[0066] 1.3. Vectorized processing:

[0067] Load the model and tokenizer: Use AutoTokenizer and AutoModel of the transformers library to load the Dmeta-embedding-zh model and tokenizer. Set the model_name parameter to the path or name of the Dmeta-embedding-zh model.

[0068] tokenizer=AutoTokenizer.from_pretrained(model_name,use_fast=True)

[0069] model=AutoModel.from_pretrained(model_name)

[0070] Define a vectorization function: Define a function get_embeddings, convert the input text into corresponding tokens through the tokenizer, and input these tokens into the model to obtain the word embedding vector. In the model, get the output of the last hidden state, and average the vector representations of all words through the average pooling operation to obtain the vector representation of the sentence.

[0071] In an embodiment of the present invention, the original text is generated based on the document template. Exemplarily, each preset template can be classified and labeled in advance, and the categories can include technical report category, project management category, business and commerce category, academic and research category, etc., which are not limited in the embodiment of the present invention. Corresponding labels and introduction content are added to each template. The labeling process can be based on the predefined label content, and it is vectorized by the above-mentioned vectorization technology. When generating text, a matching template can be automatically recommended, and then the generated content is filled in the position corresponding to the template. Exemplarily, the data after vectorization of the background material input by the user is then implemented through the semantic search function of milvus to achieve document template recommendation. The search parameters include metric_type set to METRIC_L2 (Euclidean distance), setting the value of the number of buckets of retrieval accuracy nprobe to 10, using the inverted index algorithm, fast approximate nearest neighbor search capability IVF_FLAT index, setting the number of lists of inverted files nlist to 1024, and achieving a balance between index construction time, memory consumption and search accuracy. The templates with the top 3 scores are recommended to the user for selection. If the user is not satisfied with the template recommended by the system, he or she can select or import a user-defined template.

[0072] When generating text, the generative pre-trained model built by the GPT algorithm is used as the base model. Before the system calls the large model, the user can set the parameters of the large model according to the language style, professional requirements, etc. Introduce the OpenAI package provided by openai, the introduction method is:

[0073] from openaiimport OpenAI

[0074] response=client.chat.completions.create(**paramers)

[0075] Parameters are provided to users through the interface. The optional parameters are as follows:

[0076] Temperature: Controls the randomness of the model output. The higher the value, the more random the output; the lower the value, the more certain the output. The default value is: 0.7.

[0077] Max Tokens: Sets the maximum length of text generated by the model. The default value is 1024.

[0078] Top P: kernel sampling, which determines the number of words to consider when generating the next word. The default value is 0.9.

[0079] FrequencyPenalty: controls the frequency of repeated use of specific words. The default value is 0.

[0080] Presence Penalty: Controls the repetitiveness of sentences or paragraphs. The default value is 0.

[0081] After the user sets the parameters of the large model and selects the template, the system obtains the directory of the template and the preset prompt words from the database, and starts to call the large model in a loop based on the background knowledge and prompt words provided by the user. The large model generates corresponding content based on the prompt words. It is filled in the corresponding title directory in turn to complete the generation of the full text content. The specific implementation steps are as follows:

[0082] 1. User sets parameters and selects template

[0083] The user interface (UI) allows the user to enter parameter settings (maximum generation length, temperature, top-k, top-p, etc.) and select a predefined template.

[0084] The front-end framework Vue.js is used to build the UI, and the springcloud microservice is used in the background to process the text entered by the user.

[0085] 2. Get templates and prompt words from the database

[0086] The database uses the relational database MySQL to store template information and preset prompt words. The backend obtains the template directory selected by the user and the corresponding prompt words through SQL query.

[0087] 3. Combine background materials and prompt words to call the large model

[0088] The combination chain chain and prompt word template PromptTemplates of the langchain framework are used to combine the background knowledge provided by the user with the prompt words obtained from the database to generate an input sequence. Use a natural language processing (NLP) library, such as the Transformers library of Hugging Face, to load a pre-trained large model.

[0089] 4. Fill in the corresponding title directory in sequence

[0090] The content generated by the large model is filled in sequence according to the directory structure of the template, and the generated content is inserted into the corresponding position according to the predefined rules of the template (directory hierarchy, paragraph division, etc.). The generated content is formatted and structured using the Jinja2 template engine. Jinja2 allows the definition of template formats and dynamic content filling through variable substitution.

[0091] S102. For the text content under each title in the directory structure, respectively calculate a relevance evaluation index for characterizing the content relevance between the text content and the input background material and the title, an accuracy evaluation index for characterizing the content accuracy of the text content and the input background material, a coherence evaluation index for characterizing the logical coherence between paragraphs in the text content, and a language quality evaluation index for characterizing the language expression quality of the text content.

[0092] In an embodiment of the present invention, the text content under each title in the directory structure is evaluated, and the evaluation indicators include: a relevance evaluation indicator for characterizing the content relevance of the text content with the input background material and the title, an accuracy evaluation indicator for characterizing the content accuracy of the text content and the input background material, a coherence evaluation indicator for characterizing the logical coherence between paragraphs in the text content, and a language quality evaluation indicator for characterizing the language expression quality of the text content.

[0093] In some embodiments of the present invention, the content can be evaluated by calculating the semantic similarity between the generated text and the background material and the title. Exemplarily, the calculation process of the relevance evaluation index is as follows:

[0094] 1. Vectorize the text content, background material and title respectively to obtain text vector, background vector and title vector. Exemplarily, in an embodiment of the present invention, the Dmeta-embedding-zh model is used to vectorize the text content, background material and title to obtain text vector, background vector and title vector.

[0095] 2. Calculate the sum of the background vector and the title vector to obtain the first vector.

[0096] 3. Calculate the dot product of the text vector and the first vector to obtain a first value.

[0097] 4. Calculate the product of the modulus of the first vector and the modulus of the title vector to obtain a second value.

[0098] 5. Calculate the quotient of the first value and the second value to obtain a correlation evaluation index.

[0099] Specifically, the calculation formula of the correlation evaluation index is as follows:

[0100]

[0101] C is the text vector, B is the background vector, and T is the title vector.

[0102] In some embodiments of the present invention, content accuracy is used to measure whether the generated text content is consistent with the facts and information in the background materials provided by the user. Content accuracy can be evaluated by comparing the facts in the generated text with the facts in the background materials. Exemplarily, the calculation process of the accuracy evaluation index is as follows:

[0103] 1. Extract facts from text content and background materials.

[0104] For example, all facts are extracted from the generated text content and background materials. The pre-trained model en_core_web_sm of the Spacy library is used to segment the text into sentences and extract all facts.

[0105] 2. Determine the number of facts in the text that are the same as those in the background material.

[0106] Verify whether the facts in the generated text content are consistent with the facts in the background material. Define the validate_facts function to compare the facts in the generated text content with the facts in the background material and count the number of correct facts, that is, the number of facts in the text content that are the same as those in the background material.

[0107] 3. Calculate the quotient of the number of identical facts and the total number of facts in the text content to obtain the accuracy evaluation index.

[0108] The quotient of the number of identical facts and the total number of facts in the text content is calculated to obtain the accuracy evaluation index.

[0109] Exemplarily, the calculation formula of the accuracy evaluation index is as follows:

[0110]

[0111] Among them, N Correct is the number of facts in the text that are the same as those in the background material, N total is the total number of facts in the text content.

[0112] In some embodiments of the present invention, logical coherence is used to measure whether the generated text content is logically coherent and reasonable. By analyzing the logical relationship between different parts (such as paragraphs under a title), it is evaluated whether the text content is logically self-consistent and fluent. The calculation process of the coherence evaluation index is as follows:

[0113] 1. For the target paragraph in the text content, calculate the keyword similarity, semantic similarity and sentence structure similarity between the target paragraph and the adjacent paragraphs.

[0114] In the embodiment of the present invention, for a target paragraph in the text content, the keyword similarity, semantic similarity and sentence structure similarity between the target paragraph and adjacent paragraphs (including the previous paragraph before the target paragraph and the next paragraph after the target paragraph) are calculated.

[0115] For example, the keyword similarity can be calculated by the intersection of the keyword sets of two paragraphs, and the calculation formula is as follows:

[0116]

[0117] Among them, K i Represents the keyword set of the target paragraph, K i+1 It indicates the keyword set of a paragraph after the target paragraph. It should be noted that, for a paragraph before the target paragraph, the keyword similarity calculation formula between the paragraph and the target paragraph is similar, and the embodiment of the present invention will not be repeated here.

[0118] For example, semantic similarity can be measured by calculating the cosine similarity of paragraph vectors. The calculation formula is as follows:

[0119]

[0120] Among them, V i is the vector representation of the target paragraph, V i+1 is the vector representation of a paragraph after the target paragraph. It should be noted that, for a paragraph before the target paragraph, the semantic similarity calculation formula between the paragraph and the target paragraph is similar, and the embodiment of the present invention will not be repeated here.

[0121] For example, sentence structure similarity can be calculated by dependency parsing, and the calculation formula is as follows:

[0122]

[0123] Among them, S i is the total number of nodes in the sentence structure tree of the target paragraph, S i+1 is the total number of nodes in the sentence structure tree of a paragraph after the target paragraph, |S i ∩S i+1 | is the number of similar nodes in the sentence structure trees of the two paragraphs. It should be noted that, for a paragraph before the target paragraph, the sentence structure similarity calculation formula of the paragraph is similar to that of the target paragraph, and the embodiments of the present invention will not be repeated here.

[0124] 2. Take the weighted sum of keyword similarity, semantic similarity and sentence structure similarity to obtain the coherence evaluation index.

[0125] In the embodiment of the present invention, the keyword similarity, semantic similarity and sentence structure similarity are weighted and summed to obtain the coherence evaluation index, and the calculation formula is as follows:

[0126]

[0127] Among them, α, β, and γ are weight values. It should be noted that, for a paragraph before the target paragraph, the calculation formula of the coherence evaluation index of the paragraph and the target paragraph is similar, and the embodiment of the present invention will not be repeated here.

[0128] In summary, the calculation formula of the coherence evaluation index is as follows:

[0129]

[0130] In some embodiments of the present invention, the quality of the generated text content in terms of language expression includes the correctness of grammar, spelling and word usage. The calculation process of the language quality evaluation index is as follows:

[0131] 1. Perform error detection on the text content to determine the number of incorrect word segmentations in the text content.

[0132] In the embodiment of the present invention, the NLTK library is used for text segmentation to segment the generated text into words and punctuation marks for subsequent error detection. A fine-tuned pre-trained language model specifically for error checking is used to detect grammar, spelling and word errors, and the model returns the wrong entities, phrases and numbers.

[0133] 2. Calculate the quotient of the number of incorrect segmented words and the total number of segmented words in the text content to obtain the language quality evaluation index.

[0134] Exemplarily, the calculation formula is as follows:

[0135]

[0136] Among them, N errors is the number of incorrect segmentations, N total_words The total number of words in the text content.

[0137] S103. Comprehensively combine the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain a comprehensive evaluation index.

[0138] In an embodiment of the present invention, in order to comprehensively evaluate the generated text content, the four indicators of relevance evaluation index, accuracy evaluation index, coherence evaluation index and language quality evaluation index can be combined to calculate a comprehensive evaluation index. Each indicator has a certain weight, and these weights can be adjusted according to the specific application scenario. Exemplarily, the calculation formula of the comprehensive evaluation index is:

[0139] Overall Score =δ×Relevance+ε×Accuracy+∈×Coherence+θ×Language_Quality

[0140] Among them, δ, ε, ∈, and θ are weight coefficients.

[0141] S104. Optimize text content based on comprehensive evaluation indicators.

[0142] In an embodiment of the present invention, the text content is optimized based on the comprehensive evaluation index. Exemplarily, the optimization process is as follows:

[0143] 1. Determine whether the comprehensive evaluation index is greater than the preset value.

[0144] 2. If yes, stop the optimization and use the current text content as the final text content.

[0145] 3. If not, the background material and the prompt word newly input by the user are input into the language model, the text content corresponding to the title is regenerated, and the steps of respectively calculating the relevance evaluation index used to characterize the content relevance of the text content with the input background material and the title, the accuracy evaluation index characterizing the content accuracy of the text content and the input background material, the coherence evaluation index characterizing the logical coherence between paragraphs in the text content, and the language quality evaluation index characterizing the language expression quality of the text content are returned to, and the comprehensive evaluation index is recalculated until the comprehensive evaluation index is greater than the preset value or the number of iterations reaches the maximum number.

[0146] For example, the maximum number of iterations can be set to 100, which means that within 100 iterations, if the comprehensive evaluation index still does not reach the preset value, the iteration is stopped and the current optimal result is output to avoid an infinite loop. In each iteration, the comprehensive evaluation index is gradually improved by adjusting the generated content and prompt words in small steps. This method can prevent fluctuations in the quality of the generated content caused by large changes.

[0147] S105: Replace the text content under the title in the original text with the optimized text content.

[0148] The optimized text content replaces the text content under the title in the original text. In this way, the text content under each title is optimized as described above, thereby optimizing the entire original text.

[0149] The generated content optimization method provided by the embodiment of the present invention comprises: obtaining the original text generated by the language model, and extracting the directory structure of the original text, for the text content under each title in the directory structure, respectively calculating the correlation evaluation index used to characterize the content correlation between the text content and the input background material and the title, the accuracy evaluation index characterizing the content accuracy of the text content and the input background material, the coherence evaluation index characterizing the logical coherence between each paragraph in the text content, and the language quality evaluation index characterizing the language expression quality of the text content, comprehensively calculating the correlation evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain the comprehensive evaluation index, optimizing the text content based on the comprehensive evaluation index, and replacing the text content under the title in the original text with the optimized text content. The present invention optimizes the generated text content based on content relevance, content accuracy, logical coherence and language expression quality, thereby improving the quality of the generated content.

[0150] The embodiment of the present invention also provides a device for generating content optimization. Figure 2 A schematic diagram of a structure of a content optimization device provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the content optimization device includes:

[0151] The original text acquisition module 201 is used to acquire the original text generated by the language model and extract the directory structure of the original text;

[0152] An evaluation index calculation module 202 is used to calculate, for each title in the directory structure, a relevance evaluation index for characterizing the content relevance of the text content with the input background material and the title, an accuracy evaluation index for characterizing the content accuracy of the text content and the input background material, a coherence evaluation index for characterizing the logical coherence between paragraphs in the text content, and a language quality evaluation index for characterizing the language expression quality of the text content;

[0153] An evaluation index synthesis module 203, used to synthesize the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain a comprehensive evaluation index;

[0154] A text content optimization module 204, configured to optimize the text content based on the comprehensive evaluation index;

[0155] The text content replacement module 205 is used to replace the text content under the title in the original text with the optimized text content.

[0156] In some embodiments of the present invention, the evaluation index calculation module 202 includes a relevance evaluation index evaluation submodule, which is used to calculate a relevance evaluation index used to characterize the relevance of the text content with the input background material and the content of the title, and the relevance evaluation index evaluation submodule includes:

[0157] A vectorization unit, used for vectorizing the text content, the background material and the title respectively to obtain a text vector, a background vector and a title vector;

[0158] A vector adding unit, used for calculating the sum of the background vector and the title vector to obtain a first vector;

[0159] A dot product unit, used to calculate the dot product of the text vector and the first vector to obtain a first value;

[0160] a product unit, used for calculating the product of the modulus of the first vector and the modulus of the title vector to obtain a second value;

[0161] The first quotient calculating unit is used to calculate the quotient of the first value and the second value to obtain a correlation evaluation index.

[0162] In some embodiments of the present invention, the evaluation index calculation module 202 includes an accuracy evaluation index calculation submodule, which is used to calculate an accuracy evaluation index used to characterize the accuracy of the content of the text content and the input background material. The accuracy evaluation index calculation submodule includes:

[0163] A fact extraction unit, used to extract facts from the text content and the background material respectively;

[0164] a quantity determination unit, configured to determine the number of facts in the text content that are identical to those in the background material;

[0165] The second quotient calculating unit is used to calculate the quotient of the number of identical facts and the total number of facts in the text content to obtain an accuracy evaluation index.

[0166] In some embodiments of the present invention, the evaluation index calculation module 202 includes a coherence evaluation index calculation submodule, which is used to calculate a coherence evaluation index used to characterize the logical coherence between paragraphs in the text content. The coherence evaluation index calculation submodule includes:

[0167] A similarity calculation unit, for calculating the keyword similarity, semantic similarity and sentence structure similarity between the target paragraph and adjacent paragraphs in the text content;

[0168] The weighted summing unit is used to perform weighted summing of the keyword similarity, the semantic similarity and the sentence structure similarity to obtain a coherence evaluation index.

[0169] In some embodiments of the present invention, the evaluation index calculation module 202 includes a language quality evaluation index calculation submodule, which is used to calculate a language quality evaluation index used to characterize the language expression quality of the text content. The language quality evaluation index calculation submodule includes:

[0170] An error detection unit, used to perform error detection on the text content and determine the number of incorrect word segments in the text content;

[0171] The third quotient calculating unit is used to calculate the quotient of the number of incorrect segmented words and the total number of segmented words in the text content to obtain a language quality evaluation index.

[0172] In some embodiments of the present invention, the evaluation index integration module 203 includes:

[0173] The weighted summation submodule is used to perform weighted summation on the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain a comprehensive evaluation index.

[0174] In some embodiments of the present invention, the text content optimization module 204 includes:

[0175] A judgment submodule, used to judge whether the comprehensive evaluation index is greater than a preset value;

[0176] A stop submodule, used to stop the optimization when the comprehensive evaluation index is greater than a preset value;

[0177] The return execution submodule is used to input the background material and the prompt word newly input by the user into the language model when the comprehensive evaluation index is not greater than the preset value, regenerate the text content corresponding to the title, and return to execute the steps of respectively calculating the relevance evaluation index used to characterize the content relevance of the text content with the input background material and the title, the accuracy evaluation index characterizing the content accuracy of the text content and the input background material, the coherence evaluation index characterizing the logical coherence between paragraphs in the text content, and the language quality evaluation index characterizing the language expression quality of the text content, until the comprehensive evaluation index is greater than the preset value or the number of iterations reaches the maximum number.

[0178] The above-mentioned generated content optimization device can execute the generated content optimization method provided by the embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the generated content optimization method.

[0179] Figure 3A schematic diagram of the structure of an electronic device provided for an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0180] like Figure 3 As shown, the electronic device includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0181] A number of components in the electronic device are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0182] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as generating a content optimization method.

[0183] In some embodiments, the method for generating content optimization may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for generating content optimization described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method for generating content optimization by any other appropriate means (e.g., by means of firmware).

[0184] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0185] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0186] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0187] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0188] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0189] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0190] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements the method for generating content optimization provided in any embodiment of the present application.

[0191] In the process of implementation, the computer program product can be written in one or more programming languages ​​or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).

[0192] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0193] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for optimizing generated content, characterized in that: include: Obtaining original text generated by the language model, and extracting a directory structure of the original text; For the text content under each title in the directory structure, respectively calculating a relevance evaluation index used to characterize the content relevance of the text content with the input background material and the title, an accuracy evaluation index characterizing the content accuracy of the text content and the input background material, a coherence evaluation index characterizing the logical coherence between paragraphs in the text content, and a language quality evaluation index characterizing the language expression quality of the text content; Combining the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain a comprehensive evaluation index; Optimizing the text content based on the comprehensive evaluation index; The optimized text content replaces the text content under the title in the original text.

2. The method for optimizing generated content according to claim 1, characterized in that: Calculating a relevance evaluation index for characterizing the relevance of the text content with the input background material and the content of the title, including: Vectorizing the text content, the background material and the title respectively to obtain a text vector, a background vector and a title vector; Calculating the sum of the background vector and the title vector to obtain a first vector; Calculate the dot product of the text vector and the first vector to obtain a first value; Calculate the product of the modulus of the first vector and the modulus of the title vector to obtain a second value; The quotient of the first value and the second value is calculated to obtain a correlation evaluation index.

3. The method for optimizing generated content according to claim 1, characterized in that: Calculating an accuracy evaluation index for characterizing the accuracy of the text content and the input background material, including: extracting facts from the text content and the background material respectively; determining the number of facts in the text content that are identical to those in the background material; The quotient of the number of identical facts and the total number of facts in the text content is calculated to obtain an accuracy evaluation index.

4. The method for optimizing generated content according to claim 1, characterized in that: Calculating a coherence evaluation index for characterizing the logical coherence between paragraphs in the text content, including: For a target paragraph in the text content, calculating keyword similarity, semantic similarity, and sentence structure similarity between the target paragraph and adjacent paragraphs; The keyword similarity, the semantic similarity and the sentence structure similarity are weighted and summed to obtain a coherence evaluation index.

5. The method for optimizing generated content according to claim 1, characterized in that: Calculating a language quality evaluation index for characterizing the language expression quality of the text content, including: Performing error detection on the text content to determine the number of incorrect word segments in the text content; The quotient of the number of incorrect segmented words and the total number of segmented words in the text content is calculated to obtain a language quality evaluation index.

6. The method for optimizing generated content according to any one of claims 1 to 5, characterized in that: The relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index are combined to obtain a comprehensive evaluation index, including: The relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index are weighted and summed to obtain a comprehensive evaluation index.

7. The method for optimizing generated content according to any one of claims 1 to 5, characterized in that: Optimizing the text content based on the comprehensive evaluation index includes: Determine whether the comprehensive evaluation index is greater than a preset value; If yes, stop the optimization; If not, the background material and the prompt word newly input by the user are input into the language model, the text content corresponding to the title is regenerated, and the process returns to execute the steps of respectively calculating a relevance evaluation index for characterizing the content relevance between the text content and the input background material and the title, an accuracy evaluation index for characterizing the content accuracy of the text content and the input background material, a coherence evaluation index for characterizing the logical coherence between paragraphs in the text content, and a language quality evaluation index for characterizing the language expression quality of the text content, until the comprehensive evaluation index is greater than a preset value or the number of iterations reaches a maximum number.

8. A content optimization device, characterized in that: include: An original text acquisition module, used to acquire the original text generated by the language model and extract the directory structure of the original text; An evaluation index calculation module is used to calculate, for the text content under each title in the directory structure, a relevance evaluation index used to characterize the content relevance of the text content with the input background material and the title, an accuracy evaluation index used to characterize the content accuracy of the text content and the input background material, a coherence evaluation index used to characterize the logical coherence between paragraphs in the text content, and a language quality evaluation index used to characterize the language expression quality of the text content; An evaluation index synthesis module, used to synthesize the relevance evaluation index, the accuracy evaluation index, the coherence evaluation index and the language quality evaluation index to obtain a comprehensive evaluation index; A text content optimization module, used for optimizing the text content based on the comprehensive evaluation index; The text content replacement module is used to replace the text content under the title in the original text with the optimized text content.

9. An electronic device, characterized in that: include: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the content generation optimization method as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the content generation optimization method as described in any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Multi-document abstract generation system and method based on event orientation

    CN119397011A

  • Text generation method and system based on large language model

    CN119962510A