Content generation method and device
By extracting the text features input by the user and the search technology of index matching, prompt information is generated to guide the text generation model, the problem of inaccurate text generation in the existing technology is solved, and the relevance and user experience of generated text are improved.
Patent Information
- Application Number
- CN202410928377.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-11-12
AI Technical Summary
In actual application, existing text generation models are difficult to accurately output to meet user needs, resulting in poor user experience.
By extracting the text features entered by the user, determining the matching index, retrieving similar text samples from the preset database, and using these samples to generate prompt information, instructing the text generation model to generate target text, ensuring the correlation of the generated text and quality.
It improves the accuracy and user experience of text generation, ensures that the generated text is relevant to the content input by users, and meets the specific needs and customized requirements of users.
Smart Images

Figure CN118939792A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification relate to the field of natural language processing technology, and in particular to a content generation method and device. Background Art
[0002] With the rapid development of artificial intelligence and natural language processing technology, text generation and content customization services are gradually becoming a reality. Through the text generation model, the quality and fluency of machine-generated text can be improved.
[0003] Currently, although text generation models can be used to generate corresponding texts in many natural language processing tasks, in actual application scenarios, when generating text, there is still the problem of being unable to accurately output text that meets user needs and poor user experience. Summary of the invention
[0004] In view of this, the embodiments of this specification provide a content generation method. One or more embodiments of this specification also relate to a content generation device, a text generation model training method, a computing device, a computer-readable storage medium, and a computer program product to solve the technical defects existing in the prior art.
[0005] According to a first aspect of an embodiment of this specification, there is provided a content generation method, including:
[0006] Extract features of text content input by a user to obtain a first feature; determine a target index matching the first feature from an index in a preset database, the index being obtained in advance based on a second feature of the text in the preset database; obtain text similar to the text content from the preset database based on the target index to form a reference text sample; generate prompt information using the text content and the reference text sample, the prompt information being used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample; input the prompt information into the text generation model, so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0007] According to a second aspect of an embodiment of this specification, a content generation method is provided, which is applied to a client device, including:
[0008] Sending text content input by a user to a server so that the server extracts features of the text content input by the user to obtain a first feature; determining a target index matching the first feature from an index of a preset database, wherein the index is pre-obtained based on a second feature of the text in the preset database; obtaining text similar to the text content from the preset database based on the target index to form a reference text sample; generating prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to an example of the reference text sample; inputting the prompt information into the text generation model so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information;
[0009] The target text returned by the server is obtained.
[0010] According to a third aspect of the embodiments of this specification, a text generation model training method is provided, including:
[0011] Selecting a target training sample from the historical input and output data of the text generation model, wherein the target training sample includes a positive training sample and / or a negative training sample, wherein the positive training sample includes historical output data with positive user feedback information and historical input data corresponding to the historical output data, and the negative training sample includes historical output data with negative user feedback information and historical input data corresponding to the historical output data;
[0012] The text generation model is trained using the target training sample.
[0013] According to a fourth aspect of the embodiments of this specification, there is provided a content generation device, including:
[0014] A first feature extraction module, used to extract features of the text content input by the user to obtain a first feature;
[0015] A target index determination module, used to determine a target index matching the first feature from an index in a preset database, wherein the index is obtained in advance based on a second feature of the text in the preset database;
[0016] A text sample forming module, used for obtaining text with similar content to the text from the preset database based on the target index to form a reference text sample;
[0017] A prompt information generation module, used to generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample;
[0018] The target text generation module is used to input the prompt information into the text generation model, so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0019] According to a fifth aspect of an embodiment of this specification, a computing device is provided, including:
[0020] Memory and processor;
[0021] The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the above-mentioned content generation method and / or the steps of the text generation model training method are implemented.
[0022] According to the sixth aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned content generation method and / or the steps of the text generation model training method.
[0023] According to the seventh aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned content generation method and / or the steps of the text generation model training method.
[0024] An embodiment of the present specification implements a content generation method, including: extracting features of text content input by a user to obtain a first feature; determining a target index matching the first feature from an index of a preset database, the index being obtained in advance based on a second feature of text in the preset database; obtaining text similar to the text content from the preset database based on the target index to form a reference text sample; generating prompt information using the text content and the reference text sample, the prompt information being used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample; and inputting the prompt information into the text generation model so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0025] First, features are extracted from the text content input by the user, and the index matching the feature in the preset database is determined. Then, text similar to the text content input by the user is retrieved from the preset database to form a reference text sample. By retrieving text similar to the text content input by the user through the index, the retrieval efficiency can be improved. In addition, prompt information is generated based on the reference text sample and the text content to instruct the text generation model to generate the target text according to the example of the reference text sample. Since the reference text sample is a text similar to the text content, the relevance of the generated target text to the text content input by the user can be guaranteed, which is more in line with user needs, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a system architecture diagram of an application content generation method provided by an embodiment of this specification;
[0027] Figure 2 is a flow chart of a content generation method provided by an embodiment of this specification;
[0028] Figure 3 is a schematic diagram of a content generation method provided by an embodiment of this specification;
[0029] Figure 4 is a flow chart of a content generation method provided by an embodiment of this specification;
[0030] Figure 5 is a schematic diagram of a content generation method provided by an embodiment of this specification;
[0031] Figure 6 is a flow chart of a content generation method provided by an embodiment of this specification;
[0032] Figure 7 is a flowchart of a text generation model training method provided by an embodiment of this specification;
[0033] Figure 8 is a structural diagram of a content generation device provided by an embodiment of this specification;
[0034] Fig. 9 It is a structural block diagram of a computing device provided by an embodiment of this specification. DETAILED DESCRIPTION
[0035] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0036] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0037] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0038] In addition, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this specification 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 the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0039] In one or more embodiments of this specification, a large model refers to a deep learning model with large-scale model parameters, which usually contains hundreds of millions, tens of billions, hundreds of billions, trillions, or even more than 10 trillion model parameters. A large model can also be called a foundation model / foundation model. The large model is pre-trained with large-scale unlabeled corpus to produce a pre-trained model with more than 100 million parameters. This model can adapt to a wide range of downstream tasks, and the model has good generalization ability, such as a large-scale language model (LLM, Large Language Model), a multi-modal pre-training model, etc.
[0040] When the big model is 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. The big model can be widely used in natural language processing (NLP), computer vision and other fields. Specifically, it can be applied to computer vision tasks such as visual question answering (VQA), image description (IC, Image Caption), 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 the big model include digital assistants, intelligent robots, search, online education, office software, e-commerce, intelligent design, etc.
[0041] First, the terms involved in one or more embodiments of this specification are explained.
[0042] Retrieval technology: Retrieval technology is a method of obtaining relevant information by querying a certain storage system (such as a database or a document collection). Retrieval technology aims to quickly and efficiently find and obtain specific information from a large amount of data. Through retrieval technology, information that matches the query conditions can be identified, selected and extracted from the data set. In the field of information retrieval, retrieval technology generally refers to the use of various algorithms and tools to find information related to user queries from a large amount of data and return it to the user. These technologies can include methods based on keyword matching (such as the BM25 algorithm), methods based on vector similarity (such as the K nearest neighbor algorithm), and methods based on machine learning (such as neural network models).
[0043] BM25 (Best Match 25) algorithm: is a statistics-based algorithm used to evaluate the relevance between queries and documents. Core principles: Word segmentation: First, the query and document are segmented to obtain the query word set and the document word set. Frequency calculation: Calculate the frequency of each query word in the document (term frequency, tf) and the frequency of each query word in the entire document collection (corpus term frequency). Inverse document frequency (IDF): Inverse document frequency is an indicator of the rarity of terms, which is used to reduce the weight of common terms and increase the weight of rare terms. It is an efficient and widely used text similarity algorithm that calculates the relevance score between documents and queries by combining term frequency (TF) and inverse document frequency (IDF).
[0044] K nearest neighbor algorithm: Based on the idea that if most of the k most similar samples (i.e. the nearest neighbors) in the feature space belong to a certain category, then the sample also belongs to this category. Calculation process: Calculate the distance: First, calculate the distance between the sample to be classified and each sample in the training set (common distance metrics include Euclidean distance, Manhattan distance, etc.). Select neighbors: Then, select the k samples with the smallest distance as the neighbors of the sample to be classified. Determine the category: Finally, according to the categories of these k nearest neighbor samples, determine the category of the sample to be classified by majority voting or other methods.
[0045] Prompt Engine: The Prompt Engine is a system based on pre-designed text prompts and generative language models for generating text with specific context and intent. The Prompt Engine embeds user-provided prompts into the language model to guide the model to generate expected text output. This approach can control the style, content, and structure of the generated results through the design of the prompt without explicit fine-tuning, so that the model can better adapt to the needs of specific tasks or scenarios.
[0046] Large language model: Generative Pre-trained Transformer, large pre-trained language model, referred to as "large language model", refers to a deep learning model with a large number of parameters and the ability to perform large-scale natural language processing tasks. It is a deep learning model pre-trained with large-scale text data. These models are usually composed of billions or even tens of billions of parameters and are pre-trained on a large scale to learn the grammar, semantics of the language and the relationship between texts. These models have achieved remarkable results in various natural language processing tasks, can understand the deep semantics of text, and support various natural language processing tasks such as text generation, text classification, text understanding, semantic understanding, translation, etc.
[0047] Customized production solution: refers to a customized production solution designed for specific needs or scenarios, which may include workflow, process optimization, customized tools, etc., aiming to improve production efficiency and product quality.
[0048] Text content positioning: refers to the process of locating and identifying specific information or key content in text data. This may involve technologies such as text analysis, information extraction, and keyword recognition.
[0049] NLP (Natural Language Processing) is an interdisciplinary subject in the fields of artificial intelligence and linguistics, which aims to enable computers to understand and process human language. NLP technology enables computers to perform various tasks, such as text classification, sentiment analysis, information extraction, machine translation, speech recognition, question-answering systems, etc.
[0050] A sparse vector is a vector in which most of its elements are zero and only a few elements are non-zero values.
[0051] Dense vector is the opposite of sparse vector, which refers to a vector in which most or all elements have non-zero values. In applications such as machine learning, data analysis, and deep learning, dense vectors are used to represent data with continuous values or dense features.
[0052] The Bag of Words (BoW) model treats text as a collection of words, regardless of word order and grammatical structure, and converts the text into a fixed-length numerical vector.
[0053] TF-IDF (Term Frequency-Inverse Document Frequency) is a text feature extraction method that calculates the importance of a word in a text.
[0054] Exact match: This is a matching method that requires the input string to be exactly the same as the predefined pattern or target string. In an exact match, any small difference, such as spaces, uppercase and lowercase letters, punctuation marks, etc., may cause the match to fail.
[0055] Fuzzy matching: A matching method that allows a certain difference between the input string and the predefined pattern or target string. This difference can be a spelling error, synonym, abbreviation, variant, etc. Fuzzy matching determines whether there is a match by calculating the similarity between the input string and the target string.
[0056] Cosine Similarity: It evaluates the similarity by measuring the cosine value of the angle between two vectors. The value range is [-1,1], where 1 means completely similar, 0 means dissimilar, and -1 means completely opposite.
[0057] Euclidean distance: used to measure the straight-line distance between two points (in multidimensional space). In two-dimensional and three-dimensional space, the Euclidean distance is the "straight-line" or "diagonal" distance between two points.
[0058] ICL (In-Context Learning): is a technique that embeds contextual information into the model to dynamically adjust model parameters or fine-tune the model while the model is running. ICL allows the model to adjust the generated results based on the information in the current context when processing different contextual situations to make it more suitable for the current situation. This method can improve the model's adaptability to specific tasks or scenarios, thereby improving the performance of the model and the quality of the generated results.
[0059] Prompt engineering: is a technique that guides the model to generate expected output by designing appropriate prompt text. In Prompt engineering, designers need to carefully design the prompt text, including the length, structure, and language style of the prompt text, to ensure that the model can accurately understand the task and generate expected results.
[0060] With the rapid development of artificial intelligence and natural language processing technologies, text generation and content customization services have gradually become a reality. In particular, large pre-trained language models have greatly improved the quality and fluency of machine-generated text. However, these models still have certain limitations when generating customized content, especially when considering domain expertise, accurate information matching, and user personalized needs. Although traditional direct generation methods can generate coherent text based on a small amount of input, they may lack pertinence and accuracy.
[0061] At present, although large pre-trained language models have demonstrated powerful text understanding and generation capabilities in many NLP tasks. These models have achieved remarkable results in a variety of tasks, such as text summarization, dialogue generation, text classification, etc. However, in actual application scenarios, especially when customized text generation that meets the needs of specific industries, user groups or scenarios is required, it often faces the challenge of not being able to output in a targeted and accurate manner. This manual integrates information retrieval with large pre-trained language models, combines advanced information retrieval technology to screen and refine the required information, and then uses the powerful understanding and generation capabilities of large pre-trained language models to solve this limitation. Its goal is to find the most relevant information fragments in existing big data resources, and on this basis, generate new content that is highly in line with the specific needs of users. In addition, an efficient and accurate intelligent retrieval and matching system is built: the system is designed to quickly and accurately lock relevant information in a large-scale database based on complex, multi-dimensional keywords and query conditions provided by users. The system requires not only fast retrieval speed, but more importantly, high relevance of retrieval results, ensuring that subsequent language models can operate based on the most valuable data sources, thereby generating high-quality text that can meet the immediate needs of users and comply with the style and writing standards specified by specific fields or users. In addition, there are dynamic adaptation and optimization generation strategies. In order to continuously improve user experience and satisfaction, the content generation scheme in this manual is not completed in one go, but has the ability of iterative optimization. By collecting real-time feedback from users and analyzing their historical query and usage behavior data, the system can dynamically learn and update the generation strategy, so that the generated content evolves as user needs change, always maintaining a high degree of fit with user expectations, and further improving the practicality and acceptance of the generated content. In addition, it is possible to locate and extract text content and customize its generation: first, through an efficient retrieval mechanism, quickly locate text paragraphs containing important information from massive data. Secondly, with the help of a carefully designed Prompt engine, guide large pre-trained language models to extract knowledge, comb logic, and reshape context on the located basic materials, and finally generate highly customized new text content. This process ensures that the generated content contains both the core points in the original data and has been intelligently processed to meet the personalized needs of users in specific situations, realizing an integrated solution from data retrieval to content customization.
[0062] That is, in order to solve the problem of how to quickly and accurately locate the required information in large-scale text data and generate highly customized content based on it, this manual integrates retrieval technology and the Prompt engine to locate and extract text content under a customized production plan, combining the powerful indexing and filtering functions of information retrieval technology and the guiding role of the Prompt engine on large language models, aiming to accurately extract information from massive data and convert it into high-quality text content that matches user needs. By combining the Prompt engineering mechanism of retrieval technology and large-scale pre-trained language models, methods such as interactive continuous learning (ICL) can be used to significantly enhance the accuracy of text retrieval, ensure that the system can capture the deep semantic associations behind user queries, and find the most relevant information sources based on this. At the retrieval level, improvements are made to the limitations of traditional keyword matching, so that the system can understand complex query intentions, and go beyond the simple keyword comparison stage to deeply analyze the intrinsic meaning of the text, thereby greatly improving the relevance and accuracy of the retrieval results. In response to different users' customized needs for text format and structured information, the integrated intelligent technology can effectively identify and extract structured data in the text, and then automatically filter out text content that meets specific format requirements according to the specifications set by the user. Through the design and fine-tuning of the pre-trained language model, it can not only accurately retrieve the required information, but also achieve text style migration and personalized adjustment while keeping the original theme unchanged, further broadening the scope of application and expressiveness of the retrieval system.
[0063] In this specification, a content generation method is provided. This specification also involves a text generation model training method, a content generation device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0064] See also Figure 1 , Figure 1 This is a system architecture diagram of an application content generation method provided by an embodiment of this specification. It may include a client device and a server. Among them, the client device can be a terminal device such as a mobile phone, a tablet computer, a desktop computer, etc., and the server includes but is not limited to a physical server and a cloud server.
[0065] The server is used to receive text content input by a user and sent by a client, extract features of the text content input by the user, and obtain a first feature; determine a target index matching the first feature from an index of a preset database, wherein the index is pre-obtained based on a second feature of the text in the preset database; obtain text similar to the text content from the preset database based on the target index to form a reference text sample; generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample; and input the prompt information into the text generation model so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0066] The client device is used to obtain the text content input by the user based on a preset graphical interactive interface, send the text content input by the user to the server, and obtain the target text returned by the server.
[0067] Taking the application scenario of intelligent writing as an example, the client device obtains the text content input by the user based on the text input window of the preset graphical interactive interface: the subject keywords of the writing, and sends it to the server. The server receives the subject keywords of the writing, extracts the first feature, retrieves the text content similar to the subject keywords of the writing from the index-based search of the preset database, forms a reference text sample, generates a prompt information input text generation model, and the text generation model generates the target article corresponding to the subject keywords of the writing based on the instructions of the prompt information. In this way, the content generation method of this manual is integrated into the writing tool, and the author can enter his own writing ideas or subject keywords as prompts, and the system retrieves and organizes reference materials and writing materials in related fields to help the author efficiently create high-quality articles.
[0068] The system applying the content generation method may include multiple client devices and a server, wherein the client device may be understood as a terminal device and the server may be understood as a cloud device. A communication connection may be established between multiple client devices through the server. In a dynamic data processing scenario, the server may be used to provide content generation services between multiple client devices. Multiple client devices may serve as a sender or a receiver, respectively, and achieve communication through the server.
[0069] Users can interact with the server through client devices to receive data sent by other client devices, or send data to other client devices, etc. In the content generation service scenario, users can send text content to the server through client devices, and the server generates target text based on the text content based on the text generation model, and pushes the target text to the client device that establishes communication with it.
[0070] The client device and the server are connected via a network. The network provides a medium for the communication link between the client device and the server. The network may include various connection types, such as wired or wireless communication links or optical fiber cables. The data transmitted by the client device may need to be encoded, transcoded, compressed, etc. before being released to the server.
[0071] The client can be a browser, an APP (Application), or a web application such as an H5 (HyperTextMarkup Language5, Hypertext Markup Language Version 5) application, or a light application (also known as a mini-program, a lightweight application) or a cloud application, etc. The client can be based on the software development kit (SDK, Software Development Kit) of the corresponding service provided by the server, such as based on the real-time communication (RTC, Real Time Communication) SDK development and acquisition. The client can be deployed in an electronic device (i.e., a client device), and needs to rely on the device to run or some APPs in the device to run. For example, the electronic device can have a display screen and support information browsing, such as a personal mobile terminal such as a mobile phone, a tablet computer, a personal computer, etc. Various other types of applications can also be configured in the electronic device, such as human-computer dialogue applications, model training applications, text processing applications, web browser applications, shopping applications, search applications, instant messaging tools, mailbox clients, social platform software, etc.
[0072] The server may include servers that provide various services, such as servers that provide communication services to multiple clients, servers that provide background training to support models used on clients, and servers that process data sent by clients. It should be noted that the server can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. The server can also be a server for a distributed system, or a server combined with a blockchain. The server can also be a cloud server for basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network), and big data and artificial intelligence platforms, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology.
[0073] The application scenarios of this specification may include but are not limited to intelligent writing, intelligent customer service system, legal consulting services, knowledge graph construction and question-answering system, personalized news recommendation, internal knowledge management of enterprises, educational counseling and online learning, etc. Intelligent customer service system: In the customer service scenario, the system can generate accurate prompts based on the natural language expression of user questions, quickly locate the corresponding solutions or product information in the database through retrieval technology, and provide immediate feedback to users to improve response speed and service quality. Legal consulting services: Legal expert systems can use this solution to locate relevant content in laws, regulations, precedents and other legal texts, customize retrieval prompts for specific legal issues, quickly extract relevant clauses and explanations, and assist lawyers or ordinary users in answering questions. Knowledge graph construction and question-answering system: When constructing a domain knowledge graph, key entities and relationships in massive documents, reports, and network texts are retrieved and extracted through customized prompts to form structured knowledge units, which are used for subsequent knowledge questions and answers and reasoning. Personalized news recommendation: News media platforms can set customized prompts based on user interest preferences, integrate retrieval technology to select and push content that is highly consistent with user preferences from a large amount of news materials, and realize personalized recommendation of news content. Internal knowledge management: Within the enterprise, employees can use customized prompts to search for company policies, project documents, technical manuals, etc. The search engine can accurately locate the required information, improve team collaboration efficiency and information sharing. Educational guidance and online learning: The education platform can customize prompts based on students' learning goals and course outlines, quickly retrieve and extract relevant textbook fragments, courseware content, and extended reading materials, and help students conduct targeted self-study.
[0074] This embodiment, when faced with complex semantics and context-related retrieval requests, can also locate text content with high precision, and the retrieval results have a high depth of relevance, which can perfectly meet the actual information needs of users. It has structured and format adaptability, and will not ignore the format specifications and chapter organization characteristics of the text in a specific application scenario, and effectively mines and provides text fragments that meet the user's specified format requirements and structural standards. In addition, it has the ability of personalization and style transfer, and has the ability to intelligently perceive and distinguish text styles. When responding to the user's needs for a specific expression style or context atmosphere, it can specifically screen and output high-quality text materials that match it. In addition, it has flexibility and diversified service capabilities. When faced with rapidly changing multiple application scenarios and user needs, it realizes efficient screening and reorganization of a large number of heterogeneous text resources through a variety of retrieval strategies and modes, and quickly provides rich and diverse customized text content that can meet the needs of specific situations.
[0075] See also Figure 2 , Figure 2A flow chart of a content generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0076] Step 202: extracting features of the text content input by the user to obtain a first feature.
[0077] The text content input by the user can be understood as text that represents the content of the user's needs, including but not limited to keywords, sentences, paragraphs, and articles. For example, financial report review articles.
[0078] Features can be understood as information extracted from text content that can describe or represent the content, structure or attributes of the text. In this specification, features may include but are not limited to keywords, vectors, etc., and vectors may include sparse vectors and / or dense vectors. For example, extract the vector of a financial report review article.
[0079] In an optional implementation of the present specification, keywords and vectors of the text content input by the user may be extracted to obtain the first feature. In another optional implementation of the present specification, vectors of the text content input by the user may be extracted to obtain the first feature.
[0080] In this embodiment, one or more keyword extraction strategies including but not limited to the following may be used to extract keywords: based on word frequency, the word with the highest word frequency is used as a keyword; words with a specified part of speech are used as keywords, for example, nouns; keywords are determined based on rules, and some rules may be defined to extract keywords. For example, in the field of news, nouns and verbs in the title, subtitle, and the first paragraph may be extracted as keywords. If the text content input by the user is a keyword, the text content input by the user may be directly used as a keyword.
[0081] Moreover, in this embodiment, one or more sparse feature vector extraction strategies including but not limited to the following may be used to extract sparse vectors: extracting sparse vectors of text content based on a bag-of-words model; extracting sparse vectors of text content based on a TF-IDF method. Further, in this embodiment, a deep learning model may be used to extract dense vectors of text content. For example, the deep learning model may be a large prediction model.
[0082] In this specification, keywords and vectors, or vectors, of the text content input by the user are extracted, and subsequent searches are performed based on the keywords and vectors, or vectors. Since keywords and vectors have less data volume than text, searching by keywords and vectors can improve search efficiency.
[0083] Step 204: Determine a target index that matches the first feature from an index in a preset database, where the index is pre-obtained based on a second feature of the text in the preset database.
[0084] Among them, the preset database can be understood as a database containing a large amount of text. The text can be filtered based on the preset filtering rules and saved to the database. In addition, new texts that meet the preset filtering rules are regularly updated to the database, wherein the preset filtering rules may include but are not limited to quality indicators, relevance indicators, uniqueness indicators, the source of the text, and filtering rules corresponding to the content style, so as to obtain high-quality text materials closely related to the target topic. By evaluating the quality, relevance and uniqueness of the text, it can be ensured that the selected text can not only cover a variety of application scenarios, but also accurately reflect the needs of specific content styles. Regularly updating the database and realizing real-time updating of the database can better serve the application needs of various information retrieval and content generation.
[0085] The index can be understood as information used to locate text in a preset database. In this embodiment, the second feature may include but is not limited to keywords, vectors, etc., and the vector may include sparse vectors and / or dense vectors. In an optional implementation of the present specification, the keywords and vectors of the text in the preset database can be extracted to obtain the second feature. In another optional implementation of the present specification, the vectors of the text in the preset database can be extracted to obtain the second feature. Accordingly, in an optional implementation of the present specification, the index may include keywords, sparse vectors, and dense vectors. The index may also be a sparse vector or a dense vector, or a keyword and a sparse vector, or a keyword and a dense vector. This embodiment can pre-calculate the index corresponding to the text in the preset database.
[0086] In an optional embodiment, the database may also include an inverted index, which implements an inverted mapping of keywords to documents by mapping each keyword in the text to a list of documents containing the keyword. The inverted index includes a keyword dictionary and a document list. The keyword dictionary stores all keywords that appear in the text and their related information, such as word frequency, position, etc. For each keyword in the dictionary, there is a corresponding document list, which contains the identifiers of all texts containing the keyword. In this way, when a user enters one or more keywords for search, the keyword can be quickly found from the keyword dictionary, and the text containing the keyword can be located through the document list.
[0087] Matching can be understood as the process of determining an index similar to the first feature from the index of the preset database as the target index. When the first features all contain keywords, accurate matching and / or fuzzy matching of the characters between the keywords can be performed to obtain the target index. When the first feature and the second feature both contain vectors, the similarity between the vectors can be calculated, and the target index can be determined based on the similarity, such as a preset number of indexes with the highest similarity as the target index.
[0088] For example, a target index that matches the vector of a financial report review article may be determined from an index of a preset database.
[0089] Step 206: Based on the target index, a text with similar content to the text is obtained from the preset database to form a reference text sample.
[0090] In this embodiment, text similar to the text content can be understood as other texts that are similar to the text content in terms of content, theme, semantics, structure or style. The reference text sample can be understood as a text sample that instructs the model to generate the target text according to the example of the reference text sample. For example, the vector of the financial report review article corresponds to the financial report review paragraph.
[0091] In an optional embodiment of the present specification, the first feature includes keywords, sparse vectors and dense vectors, and determining a target index matching the first feature from an index of a preset database includes: determining a target index matching the first feature by matching keywords in the first feature with keywords in an index of the preset database; correspondingly, obtaining text similar to the text content from the preset database based on the target index includes: determining a similarity between a sparse vector in the first feature and a sparse vector in the target index to obtain a first similarity; determining a similarity between a dense vector in the first feature and a dense vector in the target index to obtain a second similarity; and obtaining text similar to the text content from the preset database based on the first similarity and the second similarity.
[0092] Among them, keyword matching can be understood as an exact match and / or fuzzy match of characters between keywords. It can be a match between the keywords in the first feature and the keywords in the keyword dictionary in the inverted index, or a match between the keywords that are not in the keyword dictionary in the inverted index. That is, in this embodiment, an inverted index may be used or not.
[0093] The first similarity and the second similarity may include, but are not limited to, cosine similarity, a similarity score converted from the Euclidean distance, etc. For example, 1 minus the normalized Euclidean distance may be used as the similarity score.
[0094] In an optional implementation of this embodiment, the first similarity and the second similarity can be sorted, and texts corresponding to a preset number of vectors with the highest similarity, or a preset proportion of vectors, are selected to obtain texts similar to the text content. If the first similarity and the second similarity are obtained in different ways, this embodiment can normalize the first similarity and the second similarity before sorting them.
[0095] In another optional implementation of this embodiment, the first similarities and the second similarities may be sorted respectively, and texts corresponding to a preset number of vectors or a preset proportion of vectors with the highest similarity are selected respectively to obtain texts similar to the text content.
[0096] In this embodiment, keyword matching is performed first to quickly locate the target index for keyword matching, and then the sparse vectors and dense vectors are sorted by similarity. Through keywords and sparse vectors, it is possible to ensure that texts that are literally similar to the text content are retrieved, and through dense vectors, it is possible to ensure that texts that are semantically similar to the text content are retrieved.
[0097] In another optional implementation of this embodiment, the keywords in the first feature can be matched with the keywords in the index of the preset database to determine the target index that matches the first feature; accordingly, obtaining text similar to the text content from the preset database based on the target index includes: determining the similarity between the sparse vector in the first feature and the sparse vector in the target index to obtain a first similarity; and obtaining text similar to the text content from the preset database based on the first similarity.
[0098] In another optional implementation of this embodiment, the keywords in the first feature can be matched with the keywords in the index of the preset database to determine the target index that matches the first feature; accordingly, obtaining text similar to the text content from the preset database based on the target index includes: determining the similarity between the dense vector in the first feature and the dense vector in the target index to obtain a second similarity; and obtaining text similar to the text content from the preset database based on the second similarity.
[0099] In another optional implementation of this embodiment, the sparse vector in the first feature can be matched with the sparse vector in the index of the preset database to determine the target index that matches the first feature; accordingly, obtaining text similar to the text content from the preset database based on the target index includes: determining the similarity between the dense vector in the first feature and the dense vector in the target index to obtain a second similarity; and obtaining text similar to the text content from the preset database based on the second similarity.
[0100] In another optional implementation of this embodiment, the first feature and the second feature are both sparse vectors, and the first feature can be used to match the index in a preset database to determine a target index that matches the first feature; accordingly, obtaining text similar to the text content from the preset database based on the target index includes: obtaining text corresponding to the target index to obtain text similar to the text content.
[0101] In another optional implementation of this embodiment, the first feature and the second feature are both dense vectors, and the first feature can be used to match the index in a preset database to determine a target index that matches the first feature; accordingly, obtaining text similar to the text content from the preset database based on the target index includes: obtaining text corresponding to the target index to obtain text similar to the text content.
[0102] In another optional implementation of this embodiment, the database may also include an inverted index, which can extract keywords and vectors of the text content input by the user to obtain a first feature, use the keywords and the inverted index to determine the identifier of the text containing the keywords, and use the index corresponding to the identifier as the target index, and obtain text similar to the text content from the preset database based on the similarity between the vector in the first feature and the target index vector. The vector can be a sparse vector or a dense vector.
[0103] That is, this manual provides a variety of search solutions to meet the diverse search needs of users.
[0104] Furthermore, in this embodiment, a text similar to the text content can be obtained from the preset database based on the target index, and a reference text sample can be formed based on a sample forming strategy, wherein the sample forming strategy can include:
[0105] A first text is selected from a first text set, and the first text constitutes a reference text sample; wherein the text in the first text set is a text obtained from the preset database and is similar to the text content; or, a first text is selected from the first text set, and a reference text sample is formed based on the first text and a second text; wherein the second text includes a text sample input by a user and / or a text similar to the text content obtained from historical input and output data corresponding to the generated text model according to user feedback information.
[0106] Among them, the sample formation strategy can be understood as a strategy for forming reference text samples based on text. Positive feedback texts similar to the text content can be obtained from the historical input and output data of the generated text model according to user feedback information. The user feedback information can represent the user's satisfaction with the output data of the generated text model, such as the evaluation text entered by the user, or whether the user has performed a regeneration operation, whether the user has liked it, etc.
[0107] Generative text models can be understood as machine learning models that can generate natural language text, including but not limited to large language models and generative adversarial networks.
[0108] In this embodiment, the reference text samples are composed of texts similar to the text content obtained from the preset database, and the user does not need to input the text samples, which reduces the complexity of the user operation and improves the user experience. The user can also input the text sample to meet the user's customized needs. Of course, the positive text can also be obtained according to the user feedback information, thereby improving the quality of the generated target text and making it more meet the user's expectations.
[0109] In an optional implementation of the present specification, the reference text sample may include an output text sample, wherein the output text sample may be understood as the text output by the expected text generation model, and the model may be instructed to generate text according to the output text sample.
[0110] In another optional implementation manner of the present specification, the reference text sample includes: an input text sample and an output text sample corresponding to the input text sample.
[0111] The input text sample can be understood as a text sample input to the text generation model, and the output text sample can be understood as the text output by the expected text generation model based on the input text sample. For example, the input text sample is the text of the financial report review, and the output text sample is a similar text of the financial report review.
[0112] Step 208: Generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample.
[0113] The prompt information can be understood as information used to guide the model to generate specific outputs or perform specific tasks. It can be text, questions, instructions or other forms of information that can activate relevant knowledge and capabilities in the model to produce a desired response.
[0114] In an optional implementation of the present specification, the reference text sample may include: an input text sample and an output text sample corresponding to the input text sample. Accordingly, the prompt information is used to instruct the text generation model to perform context learning based on the input text sample and the output text sample to generate a target text corresponding to the text content.
[0115] Among them, context learning can be understood as the process of learning the correlation and information between the input text sample and the output text sample. In addition, in the context learning process, the model can adjust the parameters or not.
[0116] In an optional implementation of the present specification, prompt information can be generated based on a preset text structure and using the text content and the reference text sample. For example, the structure of the prompt information can be task instructions + reference text sample + style requirements. The task instruction can be to generate an article similar to the financial report review article using the reference text sample. The financial report review article is the text content input by the user.
[0117] In this embodiment, prompt information is generated based on reference text samples including input text samples and output text samples. In this way, output that satisfies the user can be achieved based on a small number of samples, thereby improving the user experience.
[0118] In an optional implementation of the present specification, the generating prompt information by using the text content and the reference text sample may include: receiving style requirement information input by a user; and generating prompt information by using the style requirement information, the text content and the reference text sample.
[0119] Among them, the style requirement information can be understood as the requirements for the specific style that the generated text should present during the text generation process. It includes any one or more aspects of the text's language characteristics, expression methods, emotional color, target readers, cultural background, etc., so as to ensure that the generated text can meet the specific context, purpose and audience needs. Among them, language characteristics can include vocabulary selection, sentence structure, grammar usage, etc., requiring the text to follow a specific style in language expression, such as formal, informal, colloquial, written, etc. Expression methods can include narrative methods, argumentation methods, rhetorical techniques, etc., requiring the text to use a specific method in expression, such as direct narration, indirect narration, comparative argumentation, causal argumentation, parallelism, metaphor, etc. Emotional color requires the text to reflect a specific color in emotional expression, such as positive, negative, humorous, serious, etc., to meet the readers' emotional needs and the purpose of the text. Target readers can be understood as targeting a specific reader group, requiring the text to conform to the characteristics of the reader's age, gender, occupation, cultural background, etc. in style to ensure the readability and attractiveness of the text. Cultural background can take into account the cultural environment in which the text is located, requiring the text to conform to local cultural traditions, values, social customs, etc. in style to avoid cultural conflicts and misunderstandings. Industry norms are the norms and standards of the industry. In some professional fields, such as news, advertising, and law, there are specific industry norms and standards, requiring the text to conform to these norms and standards in style to ensure the authority and credibility of the text. Personalized requirements: In some cases, there may also be personalized style requirements, such as the writing style of a specific author, requiring the text to remain consistent and unique in style.
[0120] For example, the style requirement information may include sentence structure, length, writing style, etc.
[0121] In this embodiment, when generating prompt information, the style requirement information is taken into consideration, so that the generated target text can be guaranteed to meet the style requirements of the user and realize customized generation.
[0122] Step 210: Input the prompt information into the text generation model, so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0123] In this embodiment, when the reference text sample includes an output text sample, the prompt information instructs the model to generate a target text corresponding to the text content according to the output text sample. When the reference text sample includes an input text sample and an output text sample corresponding to the input text sample, the prompt information instructs the text generation model to perform context learning based on the input text sample and the output text sample to generate a target text corresponding to the text content. When the prompt information also includes style requirement information, the prompt information instructs the text generation model to generate a target text that meets the style requirements based on the reference text sample and the style requirement information.
[0124] Furthermore, in an optional implementation of the present description, after inputting the prompt information into the text generation model so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information, it also includes: calculating the similarity between the target text and the text content and the text in the review text library to obtain a third similarity; if the third similarity is higher than a preset similarity threshold, returning the target text to the client device.
[0125] Among them, the review text library can be understood as a text library consisting of texts that meet the quality and / or style requirements. The texts can be collected in advance, and the texts include input sample texts and output sample texts corresponding to the input sample texts expected to be generated by the model, forming an initial review text library. Afterwards, the model input data and output data with positive user feedback information can be added to the review text library.
[0126] In an optional embodiment of the present specification, the target text and text content can be calculated with the model input data and model output data in the review text library. For example, the target text and text content generate a first vector, and the similarity between the first vector and the second vector corresponding to the model input data and model output data in the review text library is calculated to obtain a third similarity. If the third similarity is higher than a preset similarity threshold, the target text is returned to the client device. If the third similarity is not higher than the preset similarity threshold, the prompt information is input into the text generation model again, so that the text generation model generates the target text corresponding to the text content based on the instruction of the prompt information.
[0127] In this embodiment, the target text generated by the model is reviewed by reviewing the text library to ensure that the target text that meets the requirements is returned to the client device, which can improve the user's satisfaction with the target text.
[0128] In an optional implementation of this specification, it may also include:
[0129] Select target training samples from the historical input and output data of the text generation model, the target training samples include positive training samples and / or negative training samples, the positive training samples include historical output data with positive user feedback information and historical input data corresponding to the historical output data, and the negative training samples include historical output data with negative user feedback information and historical input data corresponding to the historical output data; use the target training samples to train the text generation model.
[0130] The historical input and output data can be understood as the historical text content output by the user and the historical target text corresponding to the historical text content generated by the text generation model. Positive can be understood as the emotional type of the user feedback information is positive, and negative can be understood as the emotional type of the user feedback information is negative.
[0131] In an optional implementation of the present specification, when the target training sample includes a positive training sample and a negative training sample, training the text generation model using the target training sample may include: inputting historical input data in the positive training sample into the text generation model to obtain text generated by the model, calculating a first loss based on the text and historical output data in the positive training sample, inputting historical input data in the negative training sample into the text generation model to obtain text generated by the model, calculating a second loss based on the text and historical output data in the negative training sample, and updating parameters of the text generation model based on the first loss and the second loss.
[0132] In an optional implementation of the present specification, when the target training sample includes a positive training sample, training the text generation model using the target training sample may include: inputting historical input data in the positive training sample into the text generation model to obtain text generated by the model, calculating a first loss based on the text and the historical output data in the positive training sample, and updating the parameters of the text generation model based on the first loss.
[0133] In an optional implementation of the present specification, when the target training sample includes a negative training sample, training the text generation model using the target training sample may include: inputting historical input data in the negative training sample into the text generation model to obtain text generated by the model, calculating a second loss based on the text and the historical output data in the negative training sample, and updating the parameters of the text generation model based on the second loss.
[0134] In this embodiment, the text generation model is trained based on the historical input and output data of the text generation model and user feedback information. As the historical input and output data accumulates, the text generation model can be continuously optimized, thereby improving the model performance.
[0135] In this embodiment, features are first extracted from the text content input by the user, and an index matching the feature in a preset database is determined. Then, text similar to the text content input by the user is retrieved from the preset database to form a reference text sample. By retrieving text similar to the text content input by the user through the index, the retrieval efficiency can be improved. In addition, prompt information is generated based on the reference text sample and the text content to instruct the text generation model to generate the target text according to the example of the reference text sample. Since the reference text sample is a text similar to the text content, the relevance of the generated target text to the text content input by the user can be guaranteed, which is more in line with user needs, thereby improving the user experience.
[0136] See also Figure 3 , Figure 3 A schematic diagram of a content generation method provided according to an embodiment of the present specification is shown. In this embodiment, it can include the construction and maintenance of a theme library (i.e., a preset database), multimodal fusion retrieval based on a vector model, and text generation based on a large model, specifically using the precise retrieval and generation of content driven by a Few-shot large model. Among them, in the process of theme library construction and maintenance, text data collected from different channels can be input, and the screening mechanism evaluates the quality and relevance of the text. The text obtained after screening is processed, including data cleaning and standardization, text segmentation and feature extraction, and inverted index construction, index compression and storage. When dynamic new data appears, data cleaning and standardization are also performed, text segmentation and feature extraction are performed, and the existing index is adjusted, and index compression and storage are performed, and the dynamically updated index structure is output. In the multimodal fusion retrieval based on the vector model, the text entered into the library can be vectorized, and the vectorization can be performed before the retrieval. The query text entered by the user is matched with keywords. The query text entered by the user can be vectorized in a vectorized manner, and the text similarity calculation is performed with the vector of the text in the library, and the output is a text set sorted by similarity. Generate text based on the big model. The query and requirements entered by the user, samples, and a collection of texts sorted by similarity constitute the promotion. The big language model is input and the retrieval result text, i.e. the target text, is output. If the quality does not meet the requirements, you can try again, that is, the big language model will regenerate the retrieval result text corresponding to the promotion.
[0137] Among them, the construction and maintenance of the subject library: first of all, text resources are collected and screened. In order to build and maintain a high-quality subject library, high-quality text materials closely related to the subject are first widely collected from multiple authoritative and reliable sources. In this process, a strict screening mechanism is established, which systematically evaluates the quality, relevance and uniqueness of each text to ensure that the selected text can not only cover a variety of application scenarios, but also accurately reflect the needs of specific content styles. At the same time, various text resources will be carefully reviewed and integrated regularly. Once new data that meets the conditions for entry is found, it will be added to the subject library in a timely manner and updated in real time. This continuous update mechanism helps to ensure that the content in the subject library is always fresh, covers a wide range, and keeps up with current events, so as to better serve various information retrieval and content generation application needs. In addition, the subject library index is constructed and optimized: after the collected text resources are strictly screened and included in the subject library, the first step is to deeply clean and standardize each text in the library. This process covers multiple links such as removing irrelevant noise, correcting errors, and unifying formats to ensure that the text data meets the consistency and accuracy requirements. Next, in order to facilitate efficient retrieval and utilization of these text resources, the index structure will be carefully constructed according to the preset logic and rules to quickly locate the required content. At the same time, in order to ensure the timeliness and comprehensiveness of the subject library, a dynamic indexing function is specially designed. This function enables the index to automatically and adaptively update as the data continues to grow and time passes, ensuring that the latest text content is always reflected. Especially in areas where information is updated quickly, such as news reports, user content on social media, etc., the update frequency of the index system will be optimized to a higher level to ensure that these time-sensitive data can be frequently and timely indexed and refreshed, thereby improving the response speed and content effectiveness of the entire subject library service.
[0138] The retrieval process based on the vector model includes: Text vectorization stage: Use deep learning models (such as BERT, etc.) to map the stored and user-input text into high-dimensional vector representations. Build and maintain a text vector database for fast retrieval and comparison. Multimodal fusion retrieval stage: Convert user-input text into vector form and perform similarity search in dense vector space. In parallel, use sparse indexing methods to find text records that match keywords. Combine the results of the two retrieval methods, sort by similarity score, and preliminarily screen out text collections that may meet the requirements.
[0139] The process of accurate content retrieval and generation driven by a few-shot large model can include: User retrieval intention analysis and sample configuration: Analyze the user's retrieval intention and accurately identify the core theme of the content to be obtained and its specific style requirements. Intelligently select a small number of high-quality sample texts that highly match the user's needs from the huge subject library and other authoritative data sources as training reference samples for the retrieval model. Model customization fine-tuning and adaptation: Using the few-shot learning method, combined with the selected representative samples, the large-scale pre-trained model is fine-tuned in a targeted manner, so that the model can quickly understand and simulate the corresponding theme and style characteristics, thereby achieving accurate retrieval and effective generation of similar types of content. Real-time content generation and quality control: The fine-tuned and optimized model will generate new text content in real time according to the user's clear needs, whether it is the main body of the article, title extraction, or report summary. Various forms can be flexibly responded to. The last key process is to strictly review the quality and style of the automatically generated content to ensure that it fully meets the standards of the actual application scenario. Only the content that has passed this review process will be finally delivered to the user, thus achieving a high degree of fit and satisfactory delivery from retrieval intention to content generation.
[0140] In this embodiment, the retrieval technology is closely combined with the Prompt engine to accurately locate the relevant information fragments in the text under the background of customized production solutions. Based on the algorithm and process design of this retrieval technology, it can be effectively applied to various complex scenarios, quickly lock the text content that closely matches the user's customized needs, and ensure the comprehensiveness and accuracy of the retrieval results. The advanced retrieval technology is deeply integrated with the intelligent Prompt engine, and the query prompts (Prompts) that meet the customized needs are generated by accurately guiding the model. Involving the customized construction and optimization process of the Prompt engine, effective Prompts can be dynamically generated according to specific retrieval tasks, and the collaborative work between Prompt and the retrieval algorithm is realized. A set of text content positioning and extraction systems suitable for different customized production environments is designed, which can flexibly respond to diverse and personalized customer needs. It has personalized configuration capabilities and specific strategies for text content identification, screening, and extraction, as well as ensuring the effectiveness and consistency of the extraction results while meeting the customization requirements. After locating and extracting the text content, it also includes an optimization and post-processing stage, using integrated retrieval results and original text to produce high-quality customized text materials. Improve the quality and adaptability of text content, such as integrating algorithms to ensure the fit between extracted information and the overall customization solution, and further improving the extracted text content through editing, reconstruction, and other means.
[0141] This embodiment has efficient retrieval capability: by integrating the retrieval technology of this solution, it is possible to locate the required information in large-scale text data more quickly and accurately, reduce invalid searches and omissions, and thus greatly improve the retrieval efficiency. It can be highly customized: it realizes the deep integration of the Prompt engine, and can dynamically generate personalized and highly targeted query instructions according to specific business scenarios and user needs, making the retrieval process more flexible and accurate. In addition, it is automated and intelligent: it reduces the need for manual intervention, and automatically completes the identification, screening and extraction of text content with the help of machine learning and artificial intelligence technology, reducing labor costs and improving work efficiency. Multi-dimensional adaptation: it can operate under different customized production schemes, can handle various types and diversified text resources, and enhance the versatility and scope of application of the system. Enhance user experience: because it can provide customized text solutions that are highly in line with the actual needs of users, it can significantly improve user satisfaction and user experience, and provide higher value services for enterprises or individuals. Resource integration and optimization: through the text content fusion and post-processing mechanism, it can better integrate and optimize the retrieval results, ensuring that the extracted text content not only maintains the original meaning but also has higher structure and readability, which is convenient for subsequent production and analysis.
[0142] In this embodiment, by integrating retrieval technology, key content related to customized production solutions can be quickly found from a large amount of text data more accurately, greatly improving the accuracy and efficiency of text content positioning and extraction, avoiding information redundancy and omissions, and making information acquisition more accurate and efficient. Enhanced personalized customization capabilities: Combined with the Prompt engine, appropriate retrieval instructions can be dynamically generated according to the specific needs of different users, so that the retrieval results are closer to the user's true intentions, thereby achieving a high degree of customization of text content and meeting the needs of diversified and personalized application scenarios. Improved intelligence and automation levels: The traditional manual retrieval and screening process is greatly simplified, the manual burden is reduced, and complex text processing tasks are automatically completed through intelligent means, which significantly improves the automation level of the entire production plan, which is conducive to large-scale deployment and wide application. In addition, due to the integrated retrieval and customized production capabilities, it has a wide range of applicability and the possibility of cross-domain expansion, and can be applied to news aggregation, data analysis, academic research, intelligent writing, education and training and other fields.
[0143] Furthermore, with the development of artificial intelligence and natural language processing technologies, automated text content generation has become an important research and application field. Automated text generation can not only improve the efficiency of content creation, but also achieve personalized and customized content output in specific scenarios. In the content production process, the needs of personalization and customization are often difficult to be effectively met, especially when dealing with large-scale data and diverse user needs. Although large pre-trained language models (LLMs) have demonstrated powerful capabilities in text generation, how to closely integrate them with the specific needs of users to generate high-quality customized content remains a technical challenge.
[0144] At present, when generating text content, there are problems such as insufficient content relevance, difficulty in meeting writing paradigm requirements, insufficient content style requirements, and insufficient flexibility and diversity.
[0145] See also Figure 4 , Figure 4 A flow chart of a content generation method provided according to an embodiment of the present specification is shown, which specifically includes the following steps.
[0146] Step 402: Acquire text similar to the text input by the user to form a reference text sample, wherein the reference text sample includes: an input text sample and an output text sample corresponding to the input text sample.
[0147] Step 404: Generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to perform context learning based on the input text sample and the output text sample to generate a target text corresponding to the text content.
[0148] Step 406: Input the prompt information into the text generation model, so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0149] In an optional implementation of the present specification, the generating prompt information by using the text content and the reference text sample may include: receiving style requirement information input by a user; and generating prompt information by using the style requirement information, the text content and the reference text sample.
[0150] In an optional implementation of the present specification, the obtaining of text similar to the text content input by the user includes any one or more of the following obtaining steps: obtaining text similar to the text content input by the user from a preset database; obtaining a text sample input by the user to obtain text similar to the text content input by the user; obtaining text similar to the text content from historical input and output data corresponding to the generated text model based on user feedback information.
[0151] In an optional implementation of the present specification, the obtaining of text similar to the text content input by the user from a preset database may include: extracting the features of the text content input by the user to obtain a first feature; determining a target index matching the first feature from an index of the preset database, the index being obtained in advance based on a second feature of the text in the preset database; obtaining text corresponding to the target index from the preset database, and obtaining text similar to the text content from the preset database based on the target index. For details, please refer to the contents disclosed in the aforementioned embodiments, which will not be described here in detail.
[0152] In an optional implementation of the present specification, target training samples can also be selected from the historical input and output data of the text generation model, the target training samples include positive training samples and / or negative training samples, the positive training samples include historical output data with positive user feedback information and historical input data corresponding to the historical output data, the negative training samples include historical output data with negative user feedback information and historical input data corresponding to the historical output data; the text generation model is trained using the target training samples.
[0153] In this embodiment, a reference text sample including an input text sample and an output text sample corresponding to the input text sample is used to generate prompt information, instructing the text generation model to perform context learning based on the input text sample and the output text sample to generate a target text corresponding to the text content, which can achieve output that satisfies the user based on a small number of samples, thereby improving the user experience. In addition, the reference text sample is formed based on text with similar content to the text input by the user, which can ensure the relevance of the generated target text to the text content input by the user, and better meet the user's needs, thereby improving the user experience.
[0154] When generating text, in response to the problem of insufficient content relevance, this specification uses retrieval technology to accurately retrieve information that is highly relevant to the text content, and combines it with a large pre-trained language model to generate targeted and personalized content. In this way, the relevance and uniqueness between the generated content and the original content can be effectively improved. In response to the problem that the writing paradigm requirements are difficult to meet, this specification not only considers the content of the article, but also fully considers the specific output format or writing requirements, such as sentence structure, length, writing style, etc. By deeply analyzing the original text and extracting important information, high-quality content can be generated according to specific writing paradigm requirements to meet the detailed needs of users. In response to the problem of insufficient content style requirements, this specification combines the generation capabilities of a large pre-trained language model with the style requirements of the article content, and continuously optimizes the generated content through user feedback and historical query records to meet the user's requirements for specific content styles. In response to the problem of insufficient flexibility and diversity, this specification takes into account that a text content may require the generation of multiple styles, so a content generation method based on retrieval technology is adopted to achieve batch and flexible generation of diverse high-quality content. The retrieval system can accurately retrieve relevant information, and combined with a large pre-trained language model, it can generate content in various styles according to different usage scenarios, providing more flexible and diverse choices.
[0155] See also Figure 5 As shown, Figure 5A schematic diagram of a content generation method provided according to an embodiment of the present specification is shown. The corresponding subject body content can be generated from the example paragraph / subject requirement body. A subject library (i.e., a database) can be constructed using high-quality body text, including index construction, user input content, similar text can be searched from the database, reference text samples can be obtained, and prompt information is generated according to the prompt structure of the reference text sample and the user input content, and the LLM is input to obtain the body output. Among them, the subject library index construction: the subject library (i.e., the database) contains a large number of high-quality texts that meet the subject requirements. These texts are carefully selected and sorted from relevant data sources, which not only ensures their quality and relevance, can cover similar usage scenarios in retrieval, but also ensures content flexibility and diversity to meet users' requirements for specific content styles. The subject library content supports dynamic updates and can continuously evolve and improve over time and with the accumulation of data. This update mechanism is crucial to maintaining the timeliness and relevance of the subject library, especially in areas where information changes rapidly, such as news, social media, and online content creation. Vector model training: Dense vector retrieval uses deep learning technology to convert text into vectors in a high-dimensional space, and then retrieves information by calculating the similarity between the user input content vector and the vector in the database. This method can capture complex semantic relationships between texts, such as semantic search and fuzzy query. Since dense vectors can represent richer information, this method can be better generalized to unseen data. Data retrieval: In the process of generating text content online, the system will receive the text of the article or paragraph entered by the user. The retrieval system will use information retrieval technology to retrieve relevant information from the established subject library based on the content of the input article. During the retrieval process, the system may use multiple retrieval strategies for multi-way retrieval, usually including dense vector retrieval and sparse inverted retrieval. During the retrieval process, the system uses multiple retrieval recall strategies to ensure that the retrieval content only matches the article content entered by the user literally, and is consistent in deep logical deduction and writing style, so that article content with similar core topics and writing style can be retrieved. For example, in the specific generation of text content of a certain theme from the financial report commentary, the core topic usually refers to the specific industry in which the company is located, the company's profitability, financial health, business growth strategy, market competitiveness, etc. The writing style involves data listing, professional terms, analysis and prediction, etc.
[0156] In addition, this embodiment is based on Few-shot large model generation: In the context of large model generation, the "Few-shot" method is an efficient learning strategy that allows the model to quickly adapt to new tasks or styles by observing a small number of examples (i.e., "few shots"). Generating content, such as titles or other texts, in a few-shot manner has the following significant advantages: Fast adaptation: Few-shot learning allows the model to quickly adapt to new tasks or fields after seeing very few samples. This means that the model can quickly learn a specific style or theme without requiring a large amount of training data. Flexibility: The Few-shot method provides a high degree of flexibility, allowing the model to cope with changing tasks and environments. This is particularly useful for application scenarios that require rapid switching between different fields or styles. Personalization: Few-shot technology can be used to generate personalized content because the model can be adjusted for a small number of specific samples to generate output that conforms to specific user preferences or brand styles. Real-time update: In scenarios where content needs to be updated in real time, such as news headline generation or social media content creation, the few-shot method can quickly respond to the latest trends and style changes. Improve innovation: Since the few-shot method relies on a small number of samples for learning, it encourages innovation and experimentation, because developers can try different sample combinations to explore new styles and expressions. Deal with data scarcity: In some areas, such as financial reports in a specific industry, it may be difficult to obtain a large amount of labeled data. Few-shot learning provides an effective solution for these areas, allowing effective content generation even when data is scarce. Specifically, the process of "Few-shot large model generation" includes the following steps: Retrieval integration: The system will integrate the retrieved relevant text information, and can splice the retrieved information. Large model instructions: Tell the large model that it is a task to generate text in a certain field and to follow the sample requirements. For example, in the task of generating financial report comments on the main business, the large model instructions are, for example, "You are a financial analyst. Please output the corresponding paragraph text based on the paragraph content of the financial report comments. The paragraph text is a commentary on the important content. The above are 5 examples." This embodiment improves the relevance and accuracy of content generation through ICL and Prompt engineering technology. Enhances the personalization and customization capabilities of content generation. It improves user experience and meets diverse content needs.
[0157] It can be seen that this embodiment is based on retrieval technology and integrates ICL and Prompt projects to produce customized content. It integrates information retrieval and content generation technology, can solve the limitations of existing text content generation technology, and provides a method for efficiently and accurately generating specific types of content to achieve personalized customization and mass production of content. Under the premise of ensuring efficiency and accuracy, it can use retrieval technology and content production technology to generate content that meets specific needs for users. It not only ensures that the generated content accurately reflects user needs, but also meets specific writing style and writing standard requirements to improve the quality and usability of the generated content, thereby enhancing the user experience.
[0158] When implementing the content generation method of this specification, first establish an efficient retrieval system that can accurately retrieve relevant information from a huge data set based on keywords or query conditions provided by the user. Then, use natural language processing technology, combined with a large pre-trained language model, to analyze and process the retrieved information to generate content that meets user needs. At the same time, in order to meet the personalized needs of different users, the solution can also continuously optimize and adjust the generated content based on user feedback and historical query records to enhance user experience and meet changes in user needs. The customized content production solution based on retrieval technology provides users with a new content generation solution that can not only ensure the accuracy and efficiency of the content, but also meet the personalized needs of users.
[0159] In this embodiment, through the information retrieval and integration mechanism, information retrieval technology can be used to retrieve information highly related to the input text from a large number of data sources before generating the text. This mechanism can not only improve the relevance and accuracy of text production, but also introduce more background knowledge and context information to enrich and optimize the generated text content. Through a highly customized generation model, the large pre-trained language model used is specially fine-tuned and customized to meet the specific needs of content generation. Including optimizing the model to improve its efficiency in utilizing the retrieved information and enhancing the innovation and diversity of its generated text. The training and fine-tuning method for the specific topic text generation task of the large language model includes but is not limited to the selection and preprocessing of training data, the adjustment of the model architecture, etc. Through ICL technology and prompt engineering, and through Few-shot large model generation, combined with specially screened high-quality text content and fine-tuned prompt, the quality of the corresponding topic text content generation and the degree of style retention can be greatly improved.
[0160] In this embodiment, the retrieval technology and content generation technology are combined, and the model parameters are dynamically adjusted through the ICL technology to adapt to different contextual situations, and effective prompt engineering technology is designed to guide the model to generate customized content that meets expectations, and provide a new content customization production solution to solve the problems of generated text in content relevance, writing paradigm requirements, content style requirements, and flexibility diversity, thereby improving user experience and meeting user personalized needs. Beneficial effects may include: Improved accuracy: By combining information retrieval and large language model generation, the core content of the article can be captured more accurately and a title that is highly relevant to it can be generated. Enhanced relevance: The information retrieval stage ensures that the generated title can reflect the key information and theme of the article. High flexibility: The Few-shot method provides a high degree of flexibility, allowing the model to cope with changing tasks and environments. This is particularly useful for application scenarios that require rapid switching between different fields or styles. Developers can try different sample combinations to explore new styles and expressions. Fast adaptation: Few-shot learning allows the model to quickly adapt to new tasks or fields after seeing a very small number of samples. This means that the model can quickly learn a specific style or theme without a large amount of training data. In some areas, such as financial reports for specific industries, it may be difficult to obtain a large amount of labeled data. Few-shot learning provides an effective solution for these areas, enabling effective content generation even when data is scarce.
[0161] This embodiment is applicable to various content creation scenarios, including but not limited to the following aspects: Paragraph body: Generate high-quality content for each paragraph of a long article, thereby improving the readability of the entire article. Article body: Generate content that is highly relevant to the original topic for academic papers, news reports, blog posts, etc., maintaining the original style and tone. Social media platform text: Generate articles that conform to the author's original style for content on social media platforms, thereby maintaining user stickiness. By flexibly applying various retrieval models and large language models, it is possible to quickly generate content that maintains the original style in different content creation scenarios, meeting a wide range of application needs. This technology not only improves the work efficiency of content creators, but also optimizes the presentation quality and user experience of the final content.
[0162] See also Figure 6 , Figure 6 A flow chart of a content generation method provided according to an embodiment of the present specification is shown, which is applied to a client device and specifically includes the following steps:
[0163] Step 602: Send the text content input by the user to the server so that the server extracts the features of the text content input by the user to obtain a first feature; determine a target index matching the first feature from an index of a preset database, wherein the index is pre-obtained based on a second feature of the text in the preset database; obtain text similar to the text content from the preset database based on the target index to form a reference text sample; generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample; input the prompt information into the text generation model so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0164] Step 604: Obtain the target text returned by the server.
[0165] In this embodiment, after obtaining the target text returned by the server, the method may further include: obtaining user feedback information corresponding to the target text through a preset graphic interaction interface; and sending the user feedback information to the server.
[0166] In this embodiment, features are extracted from the text content input by the user, and an index matching the feature in a preset database is determined, and then text similar to the text content input by the user is retrieved from the preset database to form a reference text sample. Retrieving text similar to the text content input by the user through the index can improve the retrieval efficiency, and prompt information is generated based on the reference text sample and the text content to instruct the text generation model to generate the target text according to the example of the reference text sample. Since the reference text sample is a text similar to the text content, the relevance of the generated target text to the text content input by the user can be guaranteed, which is more in line with user needs, thereby improving the user experience.
[0167] See also Figure 7 , Figure 7 A flowchart of a text generation model training method provided according to an embodiment of the present specification is shown, which specifically includes the following steps:
[0168] Step 702: Select target training samples from the historical input and output data of the text generation model, wherein the target training samples include positive training samples and / or negative training samples, wherein the positive training samples include historical output data with positive user feedback information and historical input data corresponding to the historical output data, and the negative training samples include historical output data with negative user feedback information and historical input data corresponding to the historical output data.
[0169] Step 704: Train the text generation model using the target training sample.
[0170] In this embodiment, the text generation model is trained based on the historical input and output data of the text generation model and user feedback information. As the historical input and output data accumulates, the text generation model can be continuously optimized, thereby improving the model performance.
[0171] Corresponding to the above method embodiment, this specification also provides a content generation device embodiment, Figure 8 FIG. 1 shows a schematic diagram of the structure of a content generation device provided by an embodiment of the present specification. Figure 8 As shown, the device comprises:
[0172] A first feature extraction module 802 is used to extract features of the text content input by the user to obtain a first feature;
[0173] A target index determination module 804 is used to determine a target index matching the first feature from an index in a preset database, wherein the index is obtained in advance based on a second feature of the text in the preset database;
[0174] A text sample forming module 806, configured to obtain text with similar content to the text from the preset database based on the target index to form a reference text sample;
[0175] A prompt information generating module 808, configured to generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample;
[0176] The target text generation module 810 is used to input the prompt information into the text generation model, so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
[0177] Optionally, the first feature extraction module 802 can be specifically used to: extract keywords and vectors from the text content input by the user to obtain the first feature, or extract the vectors from the text content input by the user to obtain the first feature; wherein the vectors include sparse vectors and / or dense vectors.
[0178] Optionally, the target index determination module 804 may be specifically used to: when the first feature includes keywords, sparse vectors and dense vectors, match the keywords in the first feature with the keywords in the index of a preset database to determine the target index that matches the first feature.
[0179] Accordingly, the text sample forming module 806 may specifically include:
[0180] A first similarity determination submodule, used to determine the similarity between the sparse vector in the first feature and the sparse vector in the target index to obtain a first similarity;
[0181] A second similarity determination submodule, used to determine the similarity between the dense vector in the first feature and the dense vector in the target index to obtain a second similarity;
[0182] A similar text acquisition submodule is used to obtain text with similar content to the text from the preset database based on the first similarity and the second similarity.
[0183] Optionally, the text sample forming module 806 may be specifically used for:
[0184] Based on the target index, a text similar to the text content is obtained from the preset database, and a reference text sample is formed based on a sample forming strategy, wherein the sample forming strategy includes:
[0185] Selecting a first text from a first text set, and forming a reference text sample with the first text; wherein the text in the first text set is a text obtained from the preset database and having content similar to the text;
[0186] Or, select a first text from a first text set, and form a reference text sample based on the first text and a second text; wherein the second text includes a text sample input by a user and / or a text similar to the text content obtained from historical input and output data corresponding to the generated text model based on user feedback information.
[0187] Optionally, the reference text sample includes: an input text sample and an output text sample corresponding to the input text sample; accordingly, the prompt information is used to instruct the text generation model to perform context learning based on the input text sample and the output text sample to generate a target text corresponding to the text content.
[0188] Optionally, the prompt information generating module 808 specifically includes:
[0189] A style requirement information receiving module, used for receiving style requirement information input by a user;
[0190] The prompt information generation submodule is used to generate prompt information using the style requirement information, the text content and the reference text sample.
[0191] Optionally, the device may further include:
[0192] A third similarity calculation module, used to calculate the similarity between the target text and the text content and the text in the review text library to obtain a third similarity;
[0193] A similarity threshold determination module, used to determine whether the third similarity is higher than a preset similarity threshold;
[0194] The target text returning module is used for returning the target text to the client device if the similarity threshold determination module determines that the third similarity is higher than a preset similarity threshold.
[0195] Furthermore, the device may also include:
[0196] A model optimization module is used to select target training samples from the historical input and output data of the text generation model, the target training samples include positive training samples and / or negative training samples, the positive training samples include historical output data with positive user feedback information and historical input data corresponding to the historical output data, and the negative training samples include historical output data with negative user feedback information and historical input data corresponding to the historical output data; the text generation model is trained using the target training samples.
[0197] The above is a schematic solution of a content generation device of this embodiment. It should be noted that the technical solution of the content generation device and the technical solution of the above content generation method belong to the same concept, and the details not described in detail in the technical solution of the content generation device can be referred to the description of the technical solution of the above content generation method.
[0198] Fig. 9 The structure block diagram of a computing device 900 provided according to an embodiment of the present specification is shown. The components of the computing device 900 include but are not limited to a memory 910 and a processor 920. The processor 920 is connected to the memory 910 via a bus 930, and a database 950 is used to store data.
[0199] The computing device 900 also includes an access device 940 that enables the computing device 900 to communicate via one or more networks 960. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 940 may include one or more of any type of network interface (e.g., a network interface card (NIC)) that is wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a world-wide interoperability for microwave access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, and a near field communication (NFC).
[0200] In one embodiment of the present specification, the above components of the computing device 900 and Fig. 9 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Fig. 9 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0201] The computing device 900 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 900 may also be a mobile or stationary server.
[0202] Among them, the processor 920 is used to execute the following computer program / instructions, which, when executed by the processor, implement the steps of the above-mentioned content generation method and / or the steps of the above-mentioned text generation model training method.
[0203] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computing device embodiment, since it is basically similar to the content generation method embodiment and / or the generation model training method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the content generation method embodiment and / or the generation model training method embodiment.
[0204] An embodiment of the present specification also provides a computer-readable storage medium storing a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned content generation method and / or the steps of the above-mentioned text generation model training method.
[0205] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the computer-readable storage medium embodiment, since it is basically similar to the content generation method embodiment and / or the generation model training method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the content generation method embodiment and / or the generation model training method embodiment.
[0206] An embodiment of the present specification also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned content generation method and / or the steps of the above-mentioned text generation model training method.
[0207] The above is a schematic scheme of a computer program product of this embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the above-mentioned content generation method and / or generation model training method belong to the same concept, and the details not described in detail in the technical scheme of the computer program product can be referred to the description of the technical scheme of the above-mentioned content generation method and / or generation model training method.
[0208] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0209] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0210] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of this specification are not limited by the order of the actions described, because according to the embodiments of this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the embodiments of this specification.
[0211] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0212] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the embodiments of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the embodiments of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is only limited by the claims and their full scope and equivalents.
Claims
1. A content generation method, characterized in that: include: Extracting features of the text content input by the user to obtain a first feature; Determining a target index matching the first feature from an index in a preset database, wherein the index is obtained in advance based on a second feature of the text in the preset database; Based on the target index, a text similar to the text content is obtained from the preset database to form a reference text sample; Generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to an example of the reference text sample; The prompt information is input into the text generation model, so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
2. The method according to claim 1, characterized in that The step of extracting the feature of the text content input by the user to obtain the first feature includes: Extracting keywords and vectors from the text content input by the user to obtain a first feature, or extracting vectors from the text content input by the user to obtain a first feature; The vector includes a sparse vector and / or a dense vector.
3. The method according to claim 2, characterized in that The first feature includes a keyword, a sparse vector, and a dense vector, and the step of determining a target index matching the first feature from an index of a preset database includes: Using the keywords in the first feature to match the keywords in the index of the preset database, determine the target index that matches the first feature; Accordingly, obtaining text with similar content to the text from the preset database based on the target index includes: Determine the similarity between the sparse vector in the first feature and the sparse vector in the target index to obtain a first similarity; Determine a similarity between a dense vector in the first feature and a dense vector in the target index to obtain a second similarity; A text similar to the text content is obtained from the preset database based on the first similarity and the second similarity.
4. The method according to claim 1, characterized in that: The step of obtaining text with similar content to the text from the preset database based on the target index to form a reference text sample includes: Based on the target index, a text similar to the text content is obtained from the preset database, and a reference text sample is formed based on a sample forming strategy, wherein the sample forming strategy includes: Selecting a first text from a first text set, and forming a reference text sample with the first text; wherein the text in the first text set is a text obtained from the preset database and having content similar to the text; Or, select a first text from a first text set, and form a reference text sample based on the first text and a second text; wherein the second text includes a text sample input by a user and / or a text similar to the text content obtained from historical input and output data corresponding to the generated text model based on user feedback information.
5. The method according to claim 1, characterized in that: The reference text sample includes: an input text sample and an output text sample corresponding to the input text sample; Correspondingly, the prompt information is used to instruct the text generation model to perform context learning based on the input text sample and the output text sample to generate a target text corresponding to the text content.
6. The method according to claim 1, characterized in that The step of generating prompt information by using the text content and the reference text sample includes: Receive style requirement information input by the user; Prompt information is generated using the style requirement information, the text content, and the reference text sample.
7. The method according to claim 1, characterized in that After inputting the prompt information into the text generation model so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information, the method further includes: Calculating the similarity between the target text and the text content and the text in the review text library to obtain a third similarity; If the third similarity is higher than a preset similarity threshold, the target text is returned to the client device.
8. The method according to any one of claims 1 to 7, characterized in that: Also includes: Selecting a target training sample from the historical input and output data of the text generation model, wherein the target training sample includes a positive training sample and / or a negative training sample, wherein the positive training sample includes historical output data with positive user feedback information and historical input data corresponding to the historical output data, and the negative training sample includes historical output data with negative user feedback information and historical input data corresponding to the historical output data; The text generation model is trained using the target training sample.
9. A content generation method, characterized in that: Applied to client devices, including: Sending text content input by a user to a server so that the server extracts features of the text content input by the user to obtain a first feature; determining a target index matching the first feature from an index of a preset database, wherein the index is pre-obtained based on a second feature of the text in the preset database; obtaining text similar to the text content from the preset database based on the target index to form a reference text sample; generating prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to an example of the reference text sample; inputting the prompt information into the text generation model so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information; The target text returned by the server is obtained.
10. The method according to claim 9, characterized in that After obtaining the target text returned by the server, the method further includes: Obtaining user feedback information corresponding to the target text through a preset graphical interactive interface; The user feedback information is sent to the server.
11. A content generating device, characterized in that: include: A first feature extraction module, used to extract features of the text content input by the user to obtain a first feature; A target index determination module, used to determine a target index matching the first feature from an index in a preset database, wherein the index is obtained in advance based on a second feature of the text in the preset database; A text sample forming module, used for obtaining text with similar content to the text from the preset database based on the target index to form a reference text sample; A prompt information generation module, used to generate prompt information using the text content and the reference text sample, wherein the prompt information is used to instruct a text generation model to generate a target text based on the text content and according to the example of the reference text sample; The target text generation module is used to input the prompt information into the text generation model, so that the text generation model generates a target text corresponding to the text content based on the instruction of the prompt information.
12. A computing device, characterized in that: include: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, the steps of the content generation method according to any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium, characterized in that: It stores a computer program / instruction, which, when executed by a processor, implements the steps of the content generation method described in any one of claims 1 to 10.
14. A computer program product, characterized in that The invention comprises a computer program / instruction, which, when executed by a processor, implements the steps of the content generation method according to any one of claims 1 to 10.
Citation Information
Cited By
Text processing method, computer program product, equipment and computer medium
CN119357374A
Pavement disease detection method and equipment for slow road and storage medium
CN119475042A
Method and device for detecting pavement disease of sidewalk, and storage medium
CN119475042B
Text generation method, electronic equipment and computer readable storage medium
CN119862277A
Text generation method, electronic device, and computer-readable storage medium
CN119862277B
