CN117540703A - Text generation method, model training method, device and electronic equipment - Google Patents

Text generation method, model training method, device and electronic equipment Download PDF

Info

Publication number
CN117540703A
CN117540703A CN202311492567.0A CN202311492567A CN117540703A CN 117540703 A CN117540703 A CN 117540703A CN 202311492567 A CN202311492567 A CN 202311492567A CN 117540703 A CN117540703 A CN 117540703A
Authority
CN
China
Prior art keywords
text
sample
style
language model
prompt
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311492567.0A
Other languages
Chinese (zh)
Inventor
刘星言
王皓冉
陈默
陈祺
安东岳
杜楠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202311492567.0A priority Critical patent/CN117540703A/en
Publication of CN117540703A publication Critical patent/CN117540703A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/335Filtering based on additional data, e.g. user or group profiles
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Machine Translation (AREA)

Abstract

The embodiment of the application discloses a text generation method, a model training method, a device and electronic equipment, wherein the method comprises the following steps: the method comprises the steps of obtaining sample text and sample style information, combining the sample prompt text constructed by the sample style information with the sample text, inputting the sample text into a first large language model, rewriting the sample text into a tag text, and rewriting the sample text into a predicted text by utilizing a second large language model.

Description

Text generation method, model training method, device and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a text generating method, a model training device, and an electronic device.
Background
In the related art, a text style migration task is usually processed by adopting a conversion model, a text to be converted is input into a trained style migration model, and the text style of the text to be converted is migrated from a current style to a specified style based on the style migration model, wherein the style migration model is obtained by training based on a labeled training data set, and the text style migration task of various style types cannot be effectively processed due to insufficient generalization capability of the style migration model caused by the limited diversity of labeled data in the training data set, and the quality of text style migration results is lower.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The embodiment of the application provides a text generation method, a model training device and electronic equipment, which can effectively process text style migration tasks of various style types and can also improve the quality of text style migration results by processing the text style migration tasks through a second large language model with higher generalization performance.
In one aspect, an embodiment of the present application provides a text generating method, including:
acquiring sample text and sample style information, and constructing a sample prompt text according to the sample style information;
the sample prompt text and the sample text are combined and then input into a first large language model, style migration is carried out on the sample text, and a label text is generated;
the sample prompt text and the sample text are combined and then input into a second large language model, style migration is carried out on the sample text, and a predicted text is generated, wherein the parameter quantity of the first large language model is larger than the parameter quantity of the second large language model;
determining model loss according to the predicted text and the corresponding tag text, and training the second large language model according to the model loss;
and acquiring a text to be rewritten and target style information, constructing a target prompt text according to the target style information, combining the target prompt text and the text to be rewritten, inputting the combined text to be rewritten into the trained second large language model, and performing style migration on the text to be rewritten to generate a rewritten result text.
On the other hand, the embodiment of the application also provides a text generation device, which comprises:
The first acquisition module is used for acquiring sample texts and sample style information and constructing sample prompt texts according to the sample style information;
the first generation module is used for combining the sample prompt text and the sample text, inputting the combined sample prompt text and the combined sample text into a first large language model, and performing style migration on the sample text to generate a label text;
the second generation module is used for inputting the sample prompt text and the sample text into a second large language model after combining, and performing style migration on the sample text to generate a predicted text, wherein the parameter quantity of the first large language model is larger than that of the second large language model;
the first training module is used for determining model loss according to the predicted text and the label text, and training the second large language model according to the model loss;
and the third generation module is used for acquiring the text to be rewritten and the target style information, constructing a target prompt text according to the target style information, combining the target prompt text with the text to be rewritten, inputting the combined target prompt text and the text to be rewritten into the trained second large language model, and performing style migration on the text to be rewritten to generate a rewritten result text.
Further, the first obtaining module is specifically configured to:
constructing a first style constraint instruction for prompting style migration by referring to the sample style information, and taking the first style constraint instruction as a sample prompting text;
or, constructing a first style constraint instruction for prompting style migration by referring to the sample style information, recalling a first example text from a preset candidate recall library according to the sample style information, and combining the first style constraint instruction and the first example text to serve as a sample prompting text;
or recalling the first example text from a preset candidate recall library according to the sample style information, constructing a first prompt instruction for prompting style migration with reference to the style of the first example text, and combining the first prompt instruction and the first example text to serve as a sample prompt text.
Further, the first obtaining module is specifically configured to:
determining a first target recall library matched with the sample style information in a plurality of preset candidate recall libraries, wherein the first target recall library comprises a plurality of first original texts and reference rewritten texts corresponding to the first original texts;
Screening out first associated texts associated with the sample texts from the first original texts;
and combining the first associated text and the corresponding reference rewritten text to obtain a first example text.
Further, the first obtaining module is specifically configured to:
screening out first associated texts similar to the sample texts from the first original texts;
or determining a first keyword according to the sample text, and screening out a first associated text containing the first keyword from each first original text.
Further, the first obtaining module is specifically configured to:
respectively creating candidate nodes for the combined result of each first original text and the corresponding reference rewritten text to obtain a knowledge graph;
calculating the relevance between any two first original texts to obtain a first relevance score between the two corresponding candidate nodes;
respectively calculating the relevance between each first original text and each sample text to obtain a second relevance score between each candidate node and each sample text;
determining a primary node in each candidate node according to the second relevance score, and determining a relevant node in other candidate nodes according to the first relevance score between the primary node and other candidate nodes;
And taking the first original text corresponding to the primary node and the first original text corresponding to the association node as first association text.
Further, the third generating module is specifically configured to:
constructing a second style constraint instruction for prompting style migration by referring to the target style information, and taking the second style constraint instruction as a target prompt text;
or, constructing a second style constraint instruction for prompting style migration by referring to the target style information, recalling a second example text from a preset candidate recall library according to the target style information, and combining the second style constraint instruction and the second example text to serve as a target prompt text;
or, acquiring a second example text matched with the target style information, constructing a second prompt instruction for prompting style migration with reference to the style of the second example text, and combining the second prompt instruction and the second example text to serve as the target prompt text.
Further, the third generating module is specifically configured to:
determining a second target recall library matched with the target style information in a plurality of preset candidate recall libraries, wherein the second target recall library comprises a plurality of second original texts and reference rewritten texts corresponding to the second original texts;
Screening out a second associated text associated with the text to be rewritten from each second original text;
and combining according to the second associated text and the corresponding reference rewritten text to obtain a second example text.
Further, the third generating module is specifically configured to:
in response to an input operation, obtaining a second example text that matches the target style information, which is input based on the input operation;
or recalling the second example text from a preset candidate recall library according to the target style information.
Further, the second generating module is specifically configured to:
determining a quality indicator of the tag text, wherein the quality indicator comprises at least one of a degree of fact consistency or a degree of text attraction, the degree of fact consistency being used to indicate consistency between the tag text and the corresponding sample text;
filtering the label text with the quality index smaller than or equal to an index threshold, and taking the sample text corresponding to the label text after filtering as a training text;
and combining the sample prompt text and the training text and then inputting the combined sample prompt text and the training text into a second large language model.
On the other hand, the embodiment of the application also provides a model training device, which comprises:
the second acquisition module is used for acquiring sample texts and sample style information and constructing sample prompt texts according to the sample style information;
a fourth generation module, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a first large language model, and perform style migration on the sample text to generate a tag text;
a fifth generation module, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a second large language model, and perform style migration on the sample text to generate a predicted text, where a parameter of the first large language model is greater than a parameter of the second large language model;
and the second training module is used for determining model loss according to the predicted text and the label text, and training the second large language model according to the model loss.
On the other hand, the embodiment of the application also provides electronic equipment, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the text generation method or the model training method when executing the computer program.
In another aspect, embodiments of the present application further provide a computer readable storage medium storing a computer program, where the computer program is executed by a processor to implement the above-described text generating method or implement the above-described model training method.
In another aspect, embodiments of the present application also provide a computer program product comprising a computer program stored in a computer readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program to cause the computer device to perform the text generation method described above or to implement the model training method described above.
The embodiment of the application at least comprises the following beneficial effects: the method comprises the steps of obtaining sample text and sample style information, then constructing a sample prompt text according to the sample style information, combining the sample prompt text and the sample text, inputting a first large language model for processing a text style migration task, rewriting the sample text into a tag text, combining the sample prompt text and the sample text, inputting a second large language model for processing the text style migration task, rewriting the sample text into a predicted text, and determining model loss according to the predicted text actually output by the second large language model and the tag text actually output by the second large language model in a training stage, wherein the parameter of the first large language model is larger than that of the second large language model, and the quality of a text style migration result generated by the first large language model is usually better; in the reasoning stage, the current style of the text to be rewritten can be migrated to the style designated by the target style information based on the trained second large language model, so that a rewritten result text is obtained, the text style migration task is processed through the second large language model with higher generalization performance, the text style migration tasks of various style types can be effectively processed, and the quality of the text style migration result can be improved.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application.
Drawings
The accompanying drawings are included to provide a further understanding of the technical aspects of the present application, and are incorporated in and constitute a part of this specification, illustrate the technical aspects of the present application and together with the examples of the present application, and not constitute a limitation of the technical aspects of the present application.
FIG. 1 is a schematic illustration of an alternative implementation environment provided by embodiments of the present application;
FIG. 2 is a schematic flow chart of an alternative text generation method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a first alternative flow of a second large language model training process provided in an embodiment of the present application;
FIG. 4 is a second alternative flow diagram of a second large language model training process provided in an embodiment of the present application;
FIG. 5 is a third alternative flow diagram of a second large language model training process provided in an embodiment of the present application;
FIG. 6 is a schematic flow chart of another alternative example text for recall provided by embodiments of the present application;
FIG. 7 is a schematic diagram of a first alternative flow chart of a second large language model reasoning process provided in an embodiment of the present application;
FIG. 8 is a second alternative flow diagram of a second large language model reasoning process provided in an embodiment of the present application;
FIG. 9 is a third alternative flow diagram of a second large language model reasoning process provided by an embodiment of the present application;
FIG. 10 is a schematic flow chart of an alternative model training method according to an embodiment of the present disclosure;
FIG. 11 is a schematic overall flow chart of an alternative text generation method according to an embodiment of the present application;
FIG. 12 is a schematic diagram of an alternative interface of a human-computer interaction interface according to an embodiment of the present disclosure;
FIG. 13 is a schematic view of another alternative interface of the human-computer interaction interface according to the embodiments of the present application;
fig. 14 is a schematic structural diagram of an alternative text generating device according to an embodiment of the present application;
FIG. 15 is a schematic view of an alternative structure of a model training device according to an embodiment of the present disclosure;
fig. 16 is a partial block diagram of a structure of a terminal according to an embodiment of the present application;
fig. 17 is a partial block diagram of a server according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
In the various embodiments of the present application, when related processing is performed according to data related to characteristics of a target object, such as attribute information or attribute information set of the target object, permission or consent of the target object is obtained first, and related laws and regulations and standards are complied with for collection, use, processing, and the like of the data. Wherein the target object may be a user. In addition, when the embodiment of the application needs to acquire the attribute information of the target object, the independent permission or independent consent of the target object is acquired through a popup window or a jump to a confirmation page or the like, and after the independent permission or independent consent of the target object is explicitly acquired, the necessary target object related data for enabling the embodiment of the application to normally operate is acquired.
In order to facilitate understanding of the technical solutions provided in the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:
cloud technology (Cloud technology) refers to a hosting technology for integrating hardware, software, network and other series resources in a wide area network or a local area network to realize calculation, storage, processing and sharing of data. The cloud technology is based on the general names of network technology, information technology, integration technology, management platform technology, application technology and the like applied by the cloud computing business mode, can form a resource pool, and is flexible and convenient as required. Cloud computing technology will become an important support. Background services of technical networking systems require a large amount of computing, storage resources, such as video websites, picture-like websites, and more portals. Along with the high development and application of the internet industry, each article possibly has an own identification mark in the future, the identification mark needs to be transmitted to a background system for logic processing, data with different levels can be processed separately, and various industry data needs strong system rear shield support and can be realized only through cloud computing.
Artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use the knowledge to obtain optimal results. In other words, artificial intelligence is an integrated technology of computer science that attempts to understand the essence of intelligence and to produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence, i.e. research on design principles and implementation methods of various intelligent machines, enables the machines to have functions of sensing, reasoning and decision. The artificial intelligence technology is a comprehensive subject, and relates to the technology with wide fields, namely the technology with a hardware level and the technology with a software level. Artificial intelligence infrastructure technologies generally include, for example, sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, pre-training model technologies, operation/interaction systems, mechatronics, and the like. The pre-training model is also called a large model and a basic model, and can be widely applied to all large-direction downstream tasks of artificial intelligence after fine adjustment. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
Machine Learning (ML) is a multi-domain interdisciplinary, and involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, and the like. It is specially studied how a computer simulates or implements learning behavior of a human to acquire new knowledge or skills, and reorganizes existing knowledge structures to continuously improve own performance. Machine learning is the core of artificial intelligence, a fundamental approach to letting computers have intelligence, which is applied throughout various areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, induction learning, teaching learning, and the like.
An application program interface (Application Programming Interface, API), which is a predefined interface (e.g., function, HTTP interface), or a convention that refers to the engagement of different components of a software system, is used to provide a set of routines that an application program and developer can access based on certain software or hardware without having to access source code or understand the details of the internal operating mechanisms.
In the related art, a text style migration task is usually processed by adopting a conversion model, a text to be converted is input into a trained style migration model, and the text style of the text to be converted is migrated from a current style to a specified style based on the style migration model, wherein the style migration model is obtained by training based on a labeled training data set, and the text style migration task of various style types cannot be effectively processed due to insufficient generalization capability of the style migration model caused by the limited diversity of labeled data in the training data set, and the quality of text style migration results is lower.
Based on the above, the embodiment of the application provides a text generation method, a model training device and electronic equipment, which can effectively process text style migration tasks of various style types and can also improve the quality of text style migration results by processing the text style migration tasks through a second large language model with higher generalization performance.
Referring to fig. 1, fig. 1 is a schematic diagram of an alternative implementation environment provided in an embodiment of the present application, where the implementation environment includes a terminal 101 and a server 102, where the terminal 101 and the server 102 are connected through a communication network.
For example, server 102 may obtain sample text and sample style information, and construct sample prompt text from the sample style information; the method comprises the steps of combining a sample prompt text and a sample text, inputting the combined sample prompt text and the sample text into a first large language model, and performing style migration on the sample text to generate a label text; the method comprises the steps of combining a sample prompt text and a sample text, inputting the combined sample prompt text and the sample text into a second large language model, and performing style migration on the sample text to generate a predicted text, wherein the parameter quantity of the first large language model is larger than that of the second large language model; determining model loss according to the predicted text and the corresponding label text, and training a second large language model according to the model loss; the server 102 may obtain the text to be rewritten and the target style information sent by the terminal 101, construct a target prompt text according to the target style information, combine the target prompt text and the text to be rewritten, input the combined text to the trained second biggest language model, perform style migration on the text to be rewritten, generate a rewritten result text, and send the rewritten result text to the terminal 101.
The server 102 constructs a sample prompt text according to sample style information by acquiring the sample text and the sample style information, then combines the sample prompt text and the sample text and inputs the sample prompt text into a first large language model for processing a text style migration task, rewrites the sample text into a tag text, and inputs the sample prompt text and the sample text into a second large language model for processing the text style migration task after combining the sample prompt text and the sample text, rewrites the sample text into a predicted text, and because the parameter quantity of the first large language model is larger than that of the second large language model, the quality of a text style migration result generated by the first large language model is usually better, the tag text is used as expected output of the second large language model, model loss is determined according to the predicted text actually output by the second large language model and the tag text which is expected to be output in a training stage, and the second large language model is trained through model loss, so that the second large language model can inherit the advantages of the first large language model on the text style migration task, and the quality of the text style migration result is improved; in the reasoning stage, the current style of the text to be rewritten can be migrated to the style designated by the target style information based on the trained second large language model, so that a rewritten result text is obtained, the text style migration task is processed through the second large language model with higher generalization performance, the text style migration tasks of various style types can be effectively processed, and the quality of the text style migration result can be improved.
The server 102 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs (Content Delivery Network, content delivery networks), basic cloud computing services such as big data and artificial intelligence platforms, and the like. In addition, server 102 may also be a node server in a blockchain network.
The terminal 101 may be, but is not limited to, a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, and the like. The terminal 101 and the server 102 may be directly or indirectly connected through wired or wireless communication, which is not limited herein in this embodiment.
The method provided by the embodiment of the application can be applied to various scenes, including but not limited to cloud technology, artificial intelligence, intelligent traffic, auxiliary driving and other scenes.
Referring to fig. 2, fig. 2 is a schematic flowchart of an alternative text generating method provided in an embodiment of the present application, where the text generating method may be performed by a server, or may be performed by a terminal, or may be performed by the server in conjunction with the terminal, and the text generating method includes, but is not limited to, the following steps 201 to 205.
Step 201: and acquiring sample text and sample style information, and constructing a sample prompt text according to the sample style information.
Where sample text refers to fact text to be stylized rewritten, sample text may specifically be text of usage scenes of news, advertisements, academic papers, etc., sample style information may be used to indicate text style, text style may include aspects of morphology, emotion, complexity, fluency, tense, mood, etc., as style requirements of different usage scenes on text may generally be different, e.g., news scene may include that mood is objective, complexity is concise, etc., advertisement scene may include that mood is friendly, emotion is positive, complexity is concise, etc., text style corresponding to each usage scene is different, sample style information may be used to indicate text style of a scene used by sample text after stylized rewritten, sample style information may be used to indicate text style of a specific usage scene, e.g., sample style information may be used to indicate text style of a news scene, sample style information may also be used to indicate text style of several specific aspects, e.g., sample style information may be used to indicate text style of a particular aspect, e.g., sample style information is friendly and emotion is dominant and is concise, etc.
Specifically, in the text style, the morphology may include sentence structure, punctuation use, etc., the emotion may include positive, negative, neutral, etc., the complexity may include sentence length, difficulty in using words, etc., the tense may include past, present, future, etc., and the mood may include humour, serious, friendly, curiosity, etc.
Because the sample Prompt text is constructed by the sample style information, the sample Prompt text can contain Prompt information for rewriting the style of the to-be-stylized rewritten text into the target text style indicated by the sample style information, and rewriting the style of the to-be-stylized rewritten text into the target text style indicated by the sample style information is equivalent to performing style migration on the to-be-stylized rewritten text, the sample Prompt text can be used as a Prompt instruction (Prompt), the Prompt instruction can be understood as a mode for starting a large language model, the Prompt instruction can guide the large language model to generate specific types, subjects or formats of output, the large language model is started by using the Prompt instruction, and the Prompt information of the sample Prompt text can be temporarily injected into the large language model without retraining the large language model, so that the large language model can store the sample style information.
Specifically, the sample text may be derived from an existing resource, for example, the existing resource may include a bullet screen, a comment, a game comment, a news article, an academic paper, and the like, and the sample text may also be derived from data actively provided by a related person, for example, the related person may manually input the sample text through a keyboard, a mouse, and the like, the related person may input the sample speech through a microphone, then recognize the sample text in the sample speech through an automatic speech recognition (Automatic Speech Recognition, ASR) technology, and the related person may recognize the sample text in the sample image through an optical character recognition (Optical Character Recognition, OCR) technology.
Step 202: and combining the sample prompt text and the sample text, inputting the combined sample prompt text and the sample text into a first large language model, and performing style migration on the sample text to generate a label text.
Wherein the first large language model belongs to a large language model (Large Language Model, LLM), which is a deep learning model trained using a large amount of text data, which can generate natural language text or understand the meaning of the language text; the large language model generally adopts a cyclic neural network (RNN) or a variant, such as a long and short time memory network (LSTM) and a gate control cyclic unit (GRU), so as to capture context information in a text sequence, thereby realizing the tasks of natural language text generation, language model evaluation, text classification, emotion analysis and the like; in the field of natural language processing, large language models have been widely used, such as speech recognition, machine translation, automatic abstracts, dialog systems, intelligent questions and answers, and the like.
Based on the above, the first large language model can generate the text of the target task matched with the task demand information, and in the style migration task, the combined result of the sample prompt text and the sample text is equivalent to the task demand information, so after the sample prompt text and the sample text are combined and input into the first large language model, the style migration can be performed on the sample text based on the first large language model to obtain the label text, and the label text is a stylized rewritten text, so that the text style of the label text is the same as the style of the target text indicated by the sample style information.
Step 203: and combining the sample prompt text and the sample text, inputting the combined sample prompt text and the sample text into a second large language model, and performing style migration on the sample text to generate a predicted text.
The parameter quantity of the first large language model is larger than that of the second large language model, and the second large language model also belongs to the large language model, so that the second large language model is the same as the principle of the first large language model, a text of a target task matched with task demand information can be generated by the second large language model, in a style migration task, a combined result of a sample prompt text and a sample text is equivalent to the task demand information, therefore, after the sample prompt text and the sample text are combined and then input into the second large language model, style migration can be carried out on the sample text based on the second large language model to obtain a predicted text, and the predicted text is a stylized rewritten text, so that the text style of the predicted text is the same as the target text style indicated by the sample style information.
Based on this, since the parameter amount of the first large language model is larger than the parameter amount of the second large language model, the first large language model may refer to a large language model with a larger scale, the second large language model may refer to a large language model with a smaller scale, since the large language model with a larger scale has a large number of parameters, the first large language model generally requires a large amount of computing resources, the first large language model may be deployed on a cloud server, and the large language model with a smaller scale requires relatively less computing resources, so the second large language model may be deployed on a local device, which may include a personal computer, a mobile device, a local server, and the like, and it is seen that the second large language model is generally local data processed in the local device, and has the advantages of good privacy and high security.
Specifically, for the first large language model, the remote device may access the first large language model through an application programming interface (Application Programming Interface, API) of the first large language model provided by the cloud server, the remote device may combine the sample prompt text and the sample text and then input the combined sample prompt text into the first large language model, and the remote device may further obtain a tag text generated by the first large language model; for the second large language model, the local device can access the second large language model through an API of the second large language model, the local device can input the sample prompt text and the sample text into the second large language model after combining, and the local device can also acquire the prediction text generated by the second large language model.
In general, a first large language model with a larger rule has wider universality, can process various natural language processing tasks, such as text generation, automatic translation, text analysis and the like, a second large language model with a smaller scale is generally used for processing natural language processing tasks in a specific field, in particular, the second large language model provided by the embodiment of the application can process a text style migration task, and the text style migration task specifically refers to converting an original text into stylized rewritten text in a specified style on the premise of not changing text meaning, and likewise, the first large language model provided by the embodiment of the application can process the text style migration task, and because the first large language model deployed on a cloud server is generally trained and optimized on a large scale, the quality of a text style migration result generated by the first large language model is generally better when the text style migration task is processed, and then a label text can be used as expected output of the second large language model to train the second large language model, for example, and supervision (Supervised Fine Tuning, t) can enable the second large language model to inherit the text style migration result on the first large language model to represent the text style migration task on the large language model of the large language model.
Specifically, the effect evaluation index of the predicted text includes, but is not limited to: the fact consistency degree and the attraction degree refer to consistency between the text meaning of the predicted text and the text meaning of the sample text, the higher the fact consistency degree of the predicted text, the better the effect of the predicted text, the lower the consistency between the text meaning of the predicted text and the text meaning of the sample text, the lower the fact consistency degree of the predicted text, the worse the effect of the predicted text, the attraction degree can be evaluated based on the aspects of the fluency, the audience adaptation degree or the vocabulary enrichment degree of the predicted text, for example, the higher the fluency of the predicted text, the higher the attraction degree of the predicted text, the better the effect of the predicted text, and the lower the fluency of the predicted text, the lower the attraction degree of the predicted text and the worse the effect of the predicted text.
Step 204: model loss is determined according to the predicted text and the corresponding tag text, and a second largest language model is trained according to the model loss.
The model loss is used for representing the accuracy of style migration of the second large language model, in general, the smaller the model loss value is, the higher the accuracy of style migration of the second large language model is, and in the training process, the model loss needs to be continuously optimized, so that the second large language model reaches an optimal state.
The model Loss may be calculated using one of a variety of Loss functions, for example, the Loss function may include a cross entropy Loss function (Cross Entropy Loss Function), a mean square error (Mean Squared Error, MSE) Loss function, a square absolute error Loss function, a maximum Likelihood Loss (LHL) function, and the like, and may be other Loss functions, and embodiments of the present application are not limited herein.
Specifically, the tag text may include one or more words, each word in the tag text may be used as a real word, a labeling probability value of the real word may be set to 100%, then, similarly, the predicted text may include one or more words, when the second large language model generates the predicted text, a predicted probability value of each word in the predicted text as a corresponding real word may be determined, which corresponds to an expected output of the tag text as the second large language model, then, a model loss may be determined based on a difference between the predicted probability value and the labeling probability value, for example, a cross entropy loss function may be calculated, a training target is to minimize a difference between the labeling probability value and the predicted probability value, so that the predicted text is as identical as possible to the tag text, and essentially, a distillation process is performed, so that the second large language model may inherit advantages of the first large language model on a text style migration task, and accuracy of style migration of the second large language model is improved.
In one possible implementation manner, the labeling probability value of each word in the tag text may be set to 100%, then the prediction probability value of each word in the predicted text is determined as the corresponding real word, the prediction probability value of each word may be multiplied to be used as the prediction probability value of the predicted text, and further, the negative log likelihood loss value is calculated on the prediction probability value of the predicted text, and the obtained negative log likelihood loss value is used as the model loss, and specifically, the calculation formula of the negative log likelihood loss value is as follows:
l= -lopP (predictive label |sample text)
Where P (predictive label|sample text) is the predictive probability value of the predictive text and L is the negative log likelihood loss value.
Step 205: and acquiring the text to be rewritten and target style information, constructing a target prompt text according to the target style information, combining the target prompt text and the text to be rewritten, inputting the combined text to be rewritten into a trained second large language model, and performing style migration on the text to be rewritten to generate a rewritten result text.
The text to be rewritten can be data in existing resources, for example, the text to be rewritten is determined from existing resources such as a barrage, comments, game comments, news articles, academic papers and the like, or can be data actively provided by related personnel, for example, the related personnel can manually input the text to be rewritten through a keyboard, a mouse and the like, and the specific acquisition mode of the text to be rewritten in the embodiment of the application is not limited; the target style information can be required by a use scene or input by related personnel, the use scene can comprise scenes such as news, advertisements, academic papers and the like, and the specific target style information can be determined by the requirement of the use scene on the style requirement because the style requirement of different use scenes on the text is usually different.
Based on the method, the current style of the text to be rewritten is migrated to the style designated by the target style information based on the trained second large language model, so that a rewritten result text is obtained, the text style migration task is processed through the second large language model with higher generalization performance, the text style migration task of various style types can be effectively processed, the quality of the text style migration result can be improved, after the second large language model is correspondingly configured, the second large language model can automatically generate rewritten texts of various text styles, the user can interact with the user more personally, the use experience of the user is improved, the manual editing requirement can be greatly reduced by the automated text style migration, the content generation speed can be accelerated, and therefore, the method can be applied to multiple industries such as news, advertisements, social media, education, entertainment and electronic commerce in a business level, and has very high market expansibility.
In one possible implementation manner, a sample prompt text is constructed according to sample style information, specifically, a first style constraint instruction for prompting style migration by referring to the sample style information is constructed, and the first style constraint instruction is used as the sample prompt text;
Or, constructing a first style constraint instruction for prompting style migration with reference to sample style information, recalling a first example text from a preset candidate recall library according to the sample style information, and combining the first style constraint instruction and the first example text to serve as a sample prompting text;
or recalling the first example text from a preset candidate recall library according to the sample style information, constructing a first prompt instruction for prompting style migration with reference to the style of the first example text, and combining the first prompt instruction and the first example text to serve as a sample prompt text.
In the training process, the input of the first large language model and the input of the second large language model are the combined result of the sample prompt text and the sample text, the sample prompt text can prompt the large language model to carry out style migration on the sample text, the sample prompt text can be obtained through one of the three construction modes, and the sample prompt text can also be obtained through other construction modes, which is not limited herein.
Specifically, referring to fig. 3, fig. 3 is a schematic diagram of a first alternative flow of a second large language model training process provided in an embodiment of the present application;
In a first construction mode of the sample prompt text, a first style constraint for prompting the large language model to perform style migration on the sample text by referring to sample style information is constructed, then a first style constraint instruction is directly used as the sample prompt text, for example, when the sample style information is used for indicating a text style of a news scene, the first style constraint instruction is used for prompting the large language model to rewrite the style of the sample text into the text style of the news scene, at this time, a model input form of the first large language model or the second large language model is a 'first style constraint instruction+the sample text', in a training stage, the first large language model can generate a tag text based on the model input, the second large language model can generate a predicted text based on the model input, model loss can be determined through the tag text and the predicted text, and then the second large language model can be trained according to the model loss.
Based on the above, the first construction mode has the advantages that the appointed sample style information is directly implanted into the large language model, so that the reasoning efficiency of the large language model is improved.
The splicing result of the first style constraint instruction and the sample text may be input as a model, or the first style constraint instruction and the sample text may be filled into a preset prompting template, and then the filling result is input as the model.
Specifically, referring to fig. 4, fig. 4 is a schematic diagram of a second alternative flow of a second large language model training process provided in an embodiment of the present application;
in a second construction mode of the sample prompt text, a first style constraint for prompting a large language model to perform style migration on the sample text by referring to sample style information is constructed, then a first example text is recalled in a candidate recall library, the first example text is a text containing an original text and a reference text, the reference text is a stylized rewritten text corresponding to the original text and corresponds to a first example text containing style migration knowledge, the first example text can be used as a reference example of a text style migration task, a first style constraint instruction and the first example text are combined and then used as the sample prompt text, at this time, a model input form of the first large language model or the second large language model is a model input form of 'first style constraint instruction+first example text+sample text', in a training stage, the first large language model can generate a tag text based on model input, the second large language model can generate a predicted text based on model input, model loss can be determined through the tag text and the predicted text, and further the second large language model can be trained according to model loss.
Based on the method, on the basis of using the first style constraint as a text generation prompt, the first example text is also used as the text generation prompt, a large language model learning task is enabled through a plurality of examples or instructions organized in a demonstration form, and style migration knowledge contained in the first example text is temporarily inserted into the large language model, so that the large language model can better understand the current text style migration task, and an accurate stylized rewritten text is generated; the simple understanding is that through a plurality of complete examples, a large language model can better understand the current text style migration task and can make more accurate predictions, so that stylized rewritten text with better effect is obtained; the second construction mode has the advantages that the large language model can perform style migration by referring to the examples on the basis of implanting the appointed sample style information, and for the ambiguous style definition, the examples can provide specific reference information, so that the quality of text style migration results can be improved, and the self-adaptive generalization performance of the second large language model can be further improved by introducing the recalled first example text.
The splicing result of the first style constraint instruction, the first example text and the sample text may be input as a model, or the first style constraint instruction, the first example text and the sample text may be filled in a preset prompt template, and then the filling result is input as the model.
Specifically, referring to fig. 5, fig. 5 is a schematic diagram of a third alternative flow chart of a second large language model training process provided in an embodiment of the present application;
in a third construction method of the sample prompt text, a first example text is recalled in a candidate recall library, a first prompt instruction for prompting a large language model to perform style migration with reference to a style of the first example text may be constructed, for example, the first prompt instruction is "please refer to a rewritten sample, a style of a last given text is rewritten to a rewritten text style of the rewritten sample", the first prompt instruction and the first example text are combined and used as the sample prompt text, at this time, a model input form of the first large language model or the second large language model is "the first prompt instruction+the first example text+the sample text", in a training stage, the first large language model can generate a tag text based on the model input, the second large language model can generate a predicted text based on the model input, model loss can be determined through the tag text and the predicted text, and the second large language model is trained according to the model loss.
Based on this, in the training stage, the input of the first large language model or the second large language model is determined by a set of sample prompt text and sample text, and the sample prompt text is constructed according to the sample style information, which is equivalent to that of the first large language model or the second large language model, which is determined by a set of sample style information and sample text.
The splicing result of the first prompt instruction, the first example text and the sample text can be used as a model to be input, or the first prompt instruction, the first example text and the sample text can be filled into a preset prompt template, and then the filling result is used as the model to be input, which is not limited in the embodiment of the application; the third construction mode has the advantages of high universality, and for styles which cannot be defined by labels, the large language model can refer to examples for style migration, so that the quality of text style migration results is improved.
Specifically, the candidate recall library may store text pairs of an original text and a reference text, the reference text refers to a stylized rewritten text corresponding to the original text, a text style of the reference text can be determined in the candidate recall library, the text pairs corresponding to each original text and the reference text have corresponding migration style labels, a first example text is recalled from a preset candidate recall library according to sample style information, specifically, a target text pair is determined in each text pair in advance, the text style indicated by the migration style label of the target text pair is the same as the text style indicated by the sample style information, then a first example text is recalled in the target text pair, and the number of recalled first example texts can be one or more.
In one possible implementation manner, the first example text is recalled from a preset candidate recall library according to the sample style information, specifically, a first target recall library matched with the sample style information is determined in a plurality of preset candidate recall libraries, wherein the first target recall library comprises a plurality of first original texts and reference rewritten texts corresponding to the first original texts; screening out first associated texts associated with the sample texts from the first original texts; the first associated text and the corresponding reference rewritten text are combined to be used as a first example text.
In the training stage, each candidate recall library may be stored in different databases, or may be stored in the same database, a first target recall library may be determined in each candidate recall library through a corresponding index, the candidate recall library may store one or more text pairs of an original text and a reference text, the reference text refers to a stylized rewritten text corresponding to the original text, reference texts of different text styles are respectively stored in different candidate recall libraries, reference texts of the same text style are stored in the same candidate recall library, a migration style tag corresponding to each candidate recall library is a migration style tag of each text pair in the candidate recall library, the migration style tag is corresponding to an index of the candidate recall library, a first target recall library may be determined in each candidate recall library, the text indicated by the migration style tag of the first target recall library is the same as the text indicated by sample style information, each text pair in the first target recall text pair may be regarded as the corresponding text of the first target recall text, and the first reference text pair may be associated with the first text corresponding to the first sample text, and the first target recall text pair is associated with the first text corresponding to the first sample text, and the first reference text is a rewritten text pair is a first example text corresponding to the first example text, and the first reference text is associated with the first text is rewritten text of the first example text corresponding to the first text pair, and the first example text is associated with the reference text is written to the first text list: [ first associated text; reference rewrite text ], or a spliced text of the first associated text, the preset prompt and the corresponding reference rewrite text is used as a first example text, for example, the first example text is: first associated text→reference rewritten text ].
Based on the above, the style migration knowledge contained in each pair of the first original text and the reference rewritten text in the first target recall library is usually specific, and the first associated text associated with the sample text is screened out from each first original text, so that a certain correlation can be ensured between the first associated text and the sample text, therefore, a certain correlation also exists between the first example text determined by the first associated text and the sample text, the style migration knowledge contained in the first original text and the reference rewritten text combined into the first example text can be used as the style migration knowledge contained in the first example text, the style migration knowledge contained in the first example text can enable a large language model to effectively learn a specific text style migration task, and the text style migration task is to migrate the text style of the sample text into the specific text style indicated by the sample information, so that the quality of the text style migration result is improved.
In one possible implementation manner, the first associated text associated with the sample text is screened out from each first original text, which may be specifically that the first associated text similar to the sample text is screened out from each first original text;
Or determining the first keywords according to the sample texts, and screening out first associated texts containing the first keywords from the first original texts.
Based on the method, the first associated text similar to the sample text can be screened out from each first original text, and the first associated text is similar to the sample text and corresponds to higher correlation between the first example text and the sample text, and the first associated text containing the first keyword can be screened out from each first original text, and the first keyword is determined by the sample text, so that the first associated text has higher correlation with the sample text, namely corresponds to higher correlation between the first example text and the sample text, so that the large language model can improve the quality of text style migration results; in addition, after the first associated text containing the first keyword is screened out, the first associated text similar to the sample text can be further screened out from the screened first associated text, so that the correlation between the first example text and the sample text can be further improved.
The sample text may include one or more first keywords, for example, characters, places, time, etc. mentioned in the sample text may be used as the first keywords.
In one possible implementation manner, first associated texts similar to the sample text are screened out from the first original texts, specifically, the sample text is input into a pre-trained natural language processing model to be encoded, and sample semantic vectors of the sample text are obtained; inputting each first original text into a natural language processing model for coding processing to obtain candidate semantic vectors of each first original text; and respectively calculating the similarity between each candidate semantic vector and the sample semantic vector, and screening out the first associated text from each first original text according to the similarity.
Based on this, the pre-trained natural language processing model can effectively extract the semantic features of the text, so that the sample semantic vector of the sample text and the candidate semantic vector of the first original text can be extracted through the natural language processing model, in general, the higher the similarity between the candidate semantic vector and the sample semantic vector is, the more similar the first original text and the sample text is represented, that is, the higher the correlation between the first example text and the sample text is, the greater the promotion of the first example text with higher correlation on the large language model learning specific text style migration task is, whereas the lower the similarity between the candidate semantic vector and the sample semantic vector is, the less similar the first original text and the sample text is represented, that is, the lower the correlation between the first example text with lower correlation is, the smaller the promotion of the first example text with lower correlation on the large language model learning specific text style migration task is, and even no promotion is.
Specifically, referring to fig. 6, fig. 6 is another alternative flow diagram of recall example text provided by an embodiment of the present application;
the maximum number of the first associated texts can be limited, so that the data processing efficiency is improved, for example, the maximum number of the first associated texts is preset to be k on the assumption that the number of the first original texts is larger than k, after the similarity between each candidate semantic vector and the sample semantic vector is calculated, the first original texts can be ranked according to the sequence from large to small according to the corresponding similarity, and then the first original texts with the k first original texts before being ranked are used as the first associated texts, so that the overall similarity degree of the first associated texts can be improved, and the large language model can improve the quality of text style migration results;
the similarity obtained through sequential calculation is respectively compared with a preset similarity threshold value, whether each candidate semantic vector is similar to the sample semantic vector or not is sequentially determined, candidate samples corresponding to k candidate semantic vectors which are determined to be similar first are used as first associated texts, and the first associated texts can be rapidly screened out, so that the overall processing efficiency is improved.
Specifically, after the similarity between each first original text and the sample text is calculated, the first original text with the similarity greater than or equal to the preset similarity threshold may be regarded as similar to the sample text, the first original text with the similarity smaller than the similarity threshold may be regarded as dissimilar to the sample text, and in general, the similarity range is between 0 and 1, and the value range of the similarity threshold is also between 0 and 1, for example, the similarity threshold is set to 0.9, so that a suitable first associated text can be effectively screened.
The sample text and the first original text can be texts with different language types, before the sample text is encoded by using a natural language processing model, if the language type of the sample text is the same as the language type of the first original text, the sample text can be directly encoded to obtain a sample semantic vector, and if the language type of the sample text is different from the language type of the first original text, the language type of the sample text needs to be converted first, so that the language type of the sample text is the same as the language type of the first original text, then the sample text is encoded by using the natural language processing model after the language type is converted to obtain a corresponding sample semantic vector, and after the language type of the sample text and the language type of the first original text are unified, the accuracy of a similarity calculation result between the sample semantic vector and a candidate semantic vector can be improved.
In another possible implementation manner, the first example text is recalled from a preset candidate recall library according to the sample style information, specifically, a first target recall library matched with the sample style information is determined in a plurality of preset candidate recall libraries, wherein the first target recall library comprises a plurality of first original texts and reference rewritten texts corresponding to the first original texts; determining a second keyword based on the sample style information; screening out a first rewritten text containing a second keyword from each reference rewritten text; the first rewritten text and the corresponding first original text are combined to be used as a first example text.
Based on the above, the first rewritten text containing the second keyword can be screened out from each reference rewritten text, and because the second keyword is determined based on the sample style information, the correlation between the first rewritten text and the sample style information is higher, namely, the correlation between the first example text and the sample style information is higher, so that the large language model can improve the quality of the text style migration result; in addition, after the first rewritten text containing the second keyword is screened out, a first associated text similar to the sample text can be further screened out from the first original text corresponding to the first rewritten text, and then the first associated text and the corresponding first rewritten text are combined to be used as the first example text, so that the correlation between the first example text and the sample text can be further improved.
Wherein the keywords of interest for the different sample style information are generally different, the sample style information may determine one or more second keywords, and illustratively, when the text style indicated by the sample style information is the text style of a news scene, the second keywords determined based on the sample style information include a mood word, date, time, city, and the like.
In one possible implementation manner, first associated texts associated with the sample texts are screened out from the first original texts, specifically, candidate nodes are respectively created for the combined result of the first original texts and the corresponding reference rewritten texts, so as to obtain a knowledge graph; calculating the relevance between any two first original texts to obtain a first relevance score between the two corresponding candidate nodes; respectively calculating the relevance between each first original text and the sample text to obtain second relevance scores between each candidate node and the sample text; determining a primary node in each candidate node according to the second relevance score, and determining associated nodes in other candidate nodes according to the first relevance score between the primary node and the other candidate nodes; and taking the first original text corresponding to the primary node and the first original text corresponding to the association node as the first association text.
The first target recall library may store data including a graph structure, specifically, after a combination of a first original text and a corresponding reference rewritten text, a combination result may be used as one candidate node, further candidate nodes are respectively created for each combination result, and an undirected edge is created for each two candidate nodes to obtain a knowledge graph, in the knowledge graph, a first relevance score between two candidate nodes may be obtained by calculating relevance between two first original texts, that is, a first relevance score of a corresponding candidate undirected edge is obtained, when the first relevance text is determined, a second relevance score between the candidate nodes and the sample text may be obtained by calculating relevance between the first original text and the sample text, then primary nodes are determined in each candidate node according to the second relevance score, for example, each candidate node is ordered according to a sequence from big to small, then n1 candidate nodes are used as primary nodes, n1 is a positive integer smaller than or equal to the number of candidate nodes, and further the first relevance score corresponding to the primary nodes is used as a first relevance migration text, so that the first relevance of the first relevance text can be improved, and the relevance of the first relevance text can be greatly improved.
Further, according to the first relevance score between the primary node and other candidate nodes, the relevant nodes are determined in the other candidate nodes, which is equivalent to screening target undirected edges from all candidate undirected edges corresponding to the primary node, for example, the candidate undirected edges corresponding to the primary node are ordered according to the sequence from big to small according to the corresponding first relevance score, then the candidate undirected edges of n2 before the arrangement are used as target undirected edges, n2 is a positive integer less than or equal to the number of the candidate undirected edges, then the candidate nodes corresponding to the target undirected edges are used as relevant nodes, and then the first original text corresponding to the relevant nodes is used as the first relevant text, so that the overall relevance of the first relevant text can be improved, and the large language model can improve the quality of text style migration results.
Based on the above, the text generation method provided by the embodiment of the application can quickly screen out the primary nodes and the associated nodes which are higher in correlation with the sample text through the knowledge graph, so that the first associated text can be quickly determined, and the data processing efficiency can be effectively improved.
In one possible implementation manner, a target prompt text is constructed according to the target style information, specifically, a second style constraint instruction for prompting style migration with reference to the target style information is constructed, and the second style constraint instruction is used as the target prompt text;
Or, constructing a second style constraint instruction for prompting style migration with reference to the target style information, recalling a second example text from a preset candidate recall library according to the target style information, and combining the second style constraint instruction and the second example text to serve as a target prompt text;
or, acquiring a second example text matched with the target style information, constructing a second prompt instruction for prompting style migration with reference to the style of the second example text, and combining the second prompt instruction and the second example text to serve as the target prompt text.
In the reasoning stage, the input of the second large language model is the combined result of the target prompt text and the text to be rewritten, the target prompt text can prompt the second large language model to carry out style migration on the text to be rewritten, and the target prompt text can be obtained through one of the three construction modes.
Referring to fig. 7, fig. 7 is a schematic flow diagram of a first alternative of a second large language model reasoning process provided in an embodiment of the present application;
in the first construction mode of the target prompt text, a second style constraint for prompting the second large language model to perform style migration on the text to be rewritten according to the target style information is constructed, then a second style constraint instruction is directly used as the target prompt text, for example, when the target style information is used for indicating the text style of a news scene, the second style constraint instruction is used for prompting the second large language model to rewrite the style of the text to be rewritten into the text style of the news scene, at this time, the model input form of the second large language model is "the second style constraint instruction+the text to be rewritten", and in the reasoning stage, the second large language model can generate a rewritten result text based on the model input.
Based on the above, the first construction mode has the advantages that the appointed target style information is directly implanted into the second large language model, so that the reasoning efficiency of the second large language model is improved.
The splicing result of the second style constraint instruction and the text to be rewritten can be used as a model input, or the second style constraint instruction and the text to be rewritten can be filled into a preset prompting template, and then the filling result is used as the model input.
Referring to fig. 8, fig. 8 is a second alternative flowchart of a second large language model reasoning process provided in an embodiment of the present application;
in a second construction mode of the target prompt text, a second style constraint for prompting a second large language model to perform style migration on a text to be rewritten according to target style information is constructed, then a second example text is recalled in a candidate recall library, the second example text is a text containing an original text and a reference text, the reference text is a stylized rewritten text corresponding to the original text and corresponds to the second example text, style migration knowledge is contained in the second example text, the second example text can be used as a reference example of a text style migration task, a second style constraint instruction and the second example text are combined to be used as the target prompt text, at this time, a model input form of the second large language model is 'second style constraint instruction+second example text+text to be rewritten', and in an reasoning stage, the second large language model can generate a rewritten result text based on model input.
Based on the method, on the basis of using the second style constraint as a text generation prompt, the second example text is also used as the text generation prompt, a second large language model learning task is enabled through a plurality of examples or instructions organized in a demonstration form, and style migration knowledge contained in the second example text is temporarily inserted into the second large language model, so that the second large language model can better understand the current text style migration task, and an accurate stylized rewritten text is generated; the method has the advantages that the second large language model can better understand the current text style migration task through a plurality of complete examples, and more accurate prediction can be made, so that stylized rewritten text with better effect is obtained; the second construction mode has the advantages that the second large language model can refer to the examples to carry out style migration on the basis of implanting the appointed target style information, and for the more fuzzy style definition, the examples can provide specific reference information, so that the prediction text with better effect can be generated.
The splicing result of the second style constraint instruction, the second example text and the text to be rewritten can be used as a model input, or the second style constraint instruction, the second example text and the text to be rewritten can be filled into a preset prompting template, and then the filling result is used as the model input.
Referring to fig. 9, fig. 9 is a schematic flow diagram of a third alternative of a second large language model reasoning process provided in an embodiment of the present application;
in a third construction manner of the target prompt text, a second example text matched with the target style information is acquired first, and then a second prompt instruction for prompting the second large language model to perform style migration with reference to the style of the second example text may be constructed, for example, the second prompt instruction is "please refer to the following rewrite sample, the style of the last given text is rewritten into the rewritten text style of the rewrite sample", the second prompt instruction and the second example text are combined and then used as the target prompt text, at this time, the model input form of the second large language model is "the second prompt instruction+the second example text+the text to be rewritten", and in the reasoning stage, the second large language model can generate the rewritten result text based on the model input.
Based on the above, in the training stage, the input of the second large language model is determined by a group of target prompt texts and texts to be rewritten, the target prompt texts are constructed by target style information, and the target prompt texts can be constructed by selecting one of the three construction modes; in general, when a candidate recall library matched with the text style indicated by the target style information exists, the second construction mode can be selected, and the second large language model can generate a predicted text with better effect; when a candidate recall library matched with the text style indicated by the target style information does not exist, the third construction mode can be selected, and the second large language model can generate a predicted text with good effect; when the number of the texts to be rewritten is multiple, the number of the corresponding target style information is also multiple, a small amount of target style information can be randomly selected, and then the corresponding target prompt text is randomly constructed by selecting the first construction mode, so that the generalization capability of the second large language model can be improved; the target prompt text may also be constructed by other construction methods, which are not limited herein.
The splicing result of the second prompting instruction, the second example text and the text to be rewritten can be used as a model to be input, or the second prompting instruction, the second example text and the text to be rewritten can be filled into a preset prompting template, and then the filling result is used as the model to be input, and the embodiment of the application is not limited; the third construction mode has the advantages of high universality, and when the text style indicated by the target style information cannot be defined by the labels, the second large language model can refer to the examples to perform style migration, so that the predicted text with good effect is generated.
Specifically, the candidate recall library may store text pairs of an original text and a reference text, the reference text refers to a stylized rewritten text corresponding to the original text, a text style of the reference text can be determined in the candidate recall library, the text pairs corresponding to each original text and the reference text have corresponding migration style labels, a second example text is recalled from a preset candidate recall library according to target style information, specifically, the target text pair is determined in each text pair in advance, the text style indicated by the migration style label of the target text pair is the same as the text style indicated by the target style information, then a second example text is recalled in the target text pair, and the number of recalled second example texts can be one or more.
In one possible implementation manner, the second example text is recalled from a preset candidate recall library according to the target style information, specifically, a second target recall library matched with the target style information is determined in a plurality of preset candidate recall libraries, wherein the second target recall library comprises a plurality of second original texts and reference rewritten texts corresponding to the second original texts; screening out second associated texts associated with the text to be rewritten from each second original text; and combining the second associated text and the corresponding reference rewritten text to obtain a second example text.
In the reasoning stage, each candidate recall library may be stored in different databases, or may be stored in the same database, a second target recall library may be determined in each candidate recall library through a corresponding index, the candidate recall library may store one or more text pairs of original text and reference text, the reference text refers to a stylized rewritten text corresponding to the original text, reference text of different text styles is respectively stored in different candidate recall libraries, reference text of the same text style is stored in the same candidate recall library, a migration style tag corresponding to each candidate recall library is a migration style tag of each text pair in the candidate recall library, the migration style tag is corresponding to an index of the candidate recall library, a second target recall library may be determined in each candidate recall library, the text indicated by the migration style tag of the second target recall library is the same as the text indicated by the target style information, each text pair in the second target recall library may be associated with the corresponding text of the corresponding target text pair, and the second target recall text pair may be associated with the corresponding text of the second target text, and the reference text pair in the second target recall text is the original text, and the second target recall text is associated with the corresponding text pair, and the reference text is the corresponding to the original text of the target text, and the reference text is associated with the text of the corresponding text in the example, and the reference text is rewritten text is a corresponding to the text of the second text pair, and the reference text is associated to the text is rewritten text: [ second associated text; reference rewrite text ], or a spliced text of the second associated text, the preset prompt and the corresponding reference rewrite text is used as a second example text, for example, the second example text is: second associated text→reference rewrite text ].
Based on the above, the style migration knowledge contained in each pair of the second original text and the reference rewritten text in the second target recall library is usually specific, the second associated text associated with the text to be rewritten is screened out from each second original text, and a certain correlation can be ensured between the second associated text and the text to be rewritten, so that a certain correlation is also provided between the second example text determined by the second associated text and the text to be rewritten, the style migration knowledge contained in the second original text and the reference rewritten text combined into the second example text can be used as the style migration knowledge contained in the second example text, and the style migration knowledge contained in the second example text can enable the second large language model to effectively learn a specific text style migration task, wherein the text style migration task is to migrate the text style of the text to be rewritten into the specific text style indicated by the target style information, and the predicted text with good effect is generated.
Specifically, the data size of the candidate recall library used in the reasoning stage may be larger than the data size of the candidate recall library used in the training stage, for example, compared with the training stage, the number of the candidate recall libraries used in the reasoning stage is larger, which is equivalent to that more types of migration style labels exist, for example, compared with the training stage, the data samples in the candidate recall library used in the reasoning stage are larger, which is equivalent to that the candidate recall library can store more text pairs of original texts and reference texts, by increasing the data size of the candidate recall library used in the reasoning stage, the second large language model can generate a predicted text with better effect, when the second large language model needs to process a text style migration task with a specific style, the existing candidate recall library can be expanded in a small scale, and the flexibility and the application range of the second large language model can be effectively improved on the premise that the second large language model maintains a higher performance level.
The method comprises the steps of selecting a first original text, selecting a second associated text, and selecting a second associated text, wherein the first associated text is similar to the first associated text, the second original text is also subjected to coding processing through a pre-trained natural language processing model, and then similarity between two coding results is calculated, and the second associated text similar to the text to be rewritten is selected from the second original texts.
In one possible implementation manner, a second example text matched with the target style information is obtained, specifically, the second example text matched with the target style information and input based on the input operation is obtained in response to the input operation;
or recalling the second example text from a preset candidate recall library according to the target style information.
Based on the above, when the candidate recall library matched with the text style indicated by the target style information does not exist, the related personnel can directly input a second example text matched with the target style information when the text style indicated by the target style information cannot be defined by using the label, and when the candidate recall library matched with the text style indicated by the target style information exists, the second example text is further taken as an example of a text style migration task, and the second example text can guide a second large language model to carry out more accurate style migration, so that a predicted text with better effect is generated.
In one possible implementation manner, the sample prompt text and the sample text are combined and then input into the second large language model, which may specifically be determining a quality index of the tag text, where the quality index includes at least one of a fact consistency degree or a text attraction degree, and the fact consistency degree is used for indicating consistency between the tag text and the corresponding sample text; filtering the label text with the quality index smaller than or equal to the index threshold, and taking a sample text corresponding to the filtered residual label text as a training text; the sample prompt text and the training text are combined and input into a second largest language model.
Based on the above, in the style migration task, after the sample prompt text and the sample text are combined and then input into the first large language model, style migration can be performed on the sample text based on the first large language model to obtain the tag text, and since the number of the sample text can be multiple, the number of the sample prompt text can also be multiple, which is equivalent to the number of the combined result of the sample prompt text and the sample text, the first large language model can generate multiple tag texts, the quality index of each tag text can be determined by analyzing the quality of the tag text, after the quality index of each tag text is determined, the tag text with lower quality can be filtered, specifically, an index threshold can be set, the tag text with the quality index smaller than or equal to the index threshold is filtered, then a high-quality tag text is reserved, and the corresponding sample text with high quality is used as training data of a group, at this time, the sample text with high quality is used as training text, the training text is input data of the first large language model, the tag text is output data of the first large language model, which is equivalent to the training text with high-quality tag text is output data of the first large language model, and after the quality index data of the second language model with high-quality can be determined, the second language model can be migrated, which is equivalent to the training data with high-quality data can be increased.
Specifically, the fact consistency degree can be used as a quality index, the tag text and the sample text can both provide corresponding fact information, if the fact information provided by the tag text and the fact information provided by the sample text are similar, the consistency between the tag text and the corresponding sample text is higher, namely the fact consistency degree of the tag text is higher, the quality of the tag text is higher, otherwise, if the fact information provided by the tag text and the fact information provided by the sample text are not similar, the consistency between the tag text and the corresponding sample text is lower, namely the fact consistency degree of the tag text is lower, the quality of the tag text is lower, the tag text with the fact consistency degree smaller than or equal to the consistency threshold can be filtered out by setting the consistency threshold, the tag text with high quality is reserved, and the training effect of the second large language model can be improved;
the text attraction degree can be used as a quality index, a specific numerical value of the text attraction degree of the tag text can be calculated through an attraction degree calculation rule, if the text attraction degree of the tag text is higher, namely the quality of the tag text is higher, otherwise, if the text attraction degree of the tag text is lower, namely the quality of the tag text is lower, the tag text with the text attraction degree smaller than or equal to the attraction threshold can be filtered out by setting the attraction threshold, the tag text with high quality is reserved, and the training effect of the second large language model can be improved;
The tag texts with the fact consistency degree smaller than or equal to the consistency threshold value and the text attraction degree smaller than or equal to the attraction threshold value can be filtered out by taking the fact consistency degree and the text attraction degree as quality indexes, and the tag texts with high quality are reserved; other indexes may be used as the quality index, and the embodiment of the present application is not limited herein.
The sample prompt text and the training text are combined and then input into the second large language model, specifically, a splicing result of the sample prompt text and the training text can be used as a model input of the second large language model, or the sample prompt text and the training text can be filled into a preset prompt template, and then the filling result is used as a model input.
In addition, referring to fig. 10, fig. 10 is an optional flowchart of a model training method provided in an embodiment of the present application, where the model training method may be performed by a server, or may be performed by a terminal, or may be performed by a server in conjunction with the terminal, and the model training method includes, but is not limited to, the following steps 1001 to 1004.
Step 1001: acquiring sample text and sample style information, and constructing a sample prompt text according to the sample style information;
Step 1002: the method comprises the steps of combining a sample prompt text and a sample text, inputting the combined sample prompt text and the sample text into a first large language model, and performing style migration on the sample text to generate a label text;
step 1003: the method comprises the steps of combining a sample prompt text and a sample text, inputting the combined sample prompt text and the sample text into a second large language model, and performing style migration on the sample text to generate a predicted text, wherein the parameter quantity of the first large language model is larger than that of the second large language model;
step 1004: model loss is determined according to the predicted text and the corresponding tag text, and a second largest language model is trained according to the model loss.
The questioning text is used for questioning the text type of the sample text, and the sample tag is used for indicating the text type of the sample text.
The model training method and the text generation method are based on the same invention conception, so that the model training method constructs a sample prompt text according to sample style information by acquiring sample text and sample style information, then combines the sample prompt text and the sample text and inputs the sample prompt text into a first large language model for processing a text style migration task, rewrites the sample text into a tag text, combines the sample prompt text and the sample text and inputs the sample text into a second large language model for processing the text style migration task, rewrites the sample text into a predicted text, and because the parameter quantity of the first large language model is larger than that of the second large language model, the quality of a text style migration result generated by the first large language model is generally better, the tag text is used as expected output of the second large language model, model loss is determined according to the predicted text actually output by the second large language model and the tag text which is expected to be output in a training stage, and the second large language model is trained through the model loss, so that the second large language model can inherit the advantage of the first large language model on the text style migration task, the performance of the second large language model on the text style migration task is improved, and the quality of the text style migration task is improved, and the result of the quality is improved; in the reasoning stage, the current style of the text to be rewritten can be migrated to the style designated by the target style information based on the trained second large language model, so that a rewritten result text is obtained, the text style migration task is processed through the second large language model with higher generalization performance, the text style migration tasks of various style types can be effectively processed, and the quality of the text style migration result can be improved.
The detailed principles of the steps 1001 to 1004 may be referred to the previous explanation of the steps 201 to 204, and will not be repeated here.
The complete process of the text generation method is described in detail below.
Referring to fig. 11, fig. 11 is an optional overall flowchart of a text generating method according to an embodiment of the present application.
First, a sample text and corresponding sample style information are obtained.
Then, a first style constraint instruction for prompting style migration by referring to the sample style information is constructed, and the first style constraint instruction is used as a sample prompting text;
or, constructing a first style constraint instruction for prompting style migration by referring to sample style information, and then determining a first target recall library matched with the sample style information in a plurality of preset candidate recall libraries, wherein the first target recall library comprises a plurality of first original texts and reference rewritten texts corresponding to the first original texts; then, first associated texts associated with the sample texts are screened out from the first original texts; then, combining the first associated text and the corresponding reference rewritten text to serve as a first example text; then, combining the first style constraint instruction and the first example text to serve as a sample prompt text;
Or then determining a first target recall library matched with the sample style information in a plurality of preset candidate recall libraries, wherein the first target recall library comprises a plurality of first original texts and reference rewritten texts corresponding to the first original texts; then, first associated texts associated with the sample texts are screened out from the first original texts; then, combining the first associated text and the corresponding reference rewritten text to serve as a first example text; then, constructing a first prompt instruction for prompting style migration with reference to the style of the first example text; then, combining the first prompt instruction and the first example text to serve as a sample prompt text;
in one possible implementation manner, screening out first associated text associated with the sample text from each first original text includes: screening out first associated texts similar to the sample text from the first original texts; or determining the first keywords according to the sample texts, and screening out first associated texts containing the first keywords from the first original texts;
in another possible implementation manner, screening the first associated text associated with the sample text from each first original text includes: creating candidate nodes for the combined result of each first original text and the corresponding reference rewritten text respectively to obtain a knowledge graph; calculating the relevance between any two first original texts to obtain a first relevance score between the two corresponding candidate nodes; respectively calculating the relevance between each first original text and the sample text to obtain second relevance scores between each candidate node and the sample text; determining a primary node in each candidate node according to the second relevance score, and determining associated nodes in other candidate nodes according to the first relevance score between the primary node and the other candidate nodes; and taking the first original text corresponding to the primary node and the first original text corresponding to the association node as the first association text.
And then, the sample prompt text and the sample text are combined and then input into a first large language model, and style migration is carried out on the sample text to generate a label text.
Then, a quality indicator of the tag text is determined, wherein the quality indicator includes at least one of a degree of factual consistency or a degree of text attraction, the degree of factual consistency being indicative of consistency between the tag text and the corresponding sample text.
And then filtering the label text with the quality index smaller than or equal to the index threshold value, and taking the sample text corresponding to the filtered residual label text as a training text.
And then, combining the sample prompt text and the training text and inputting the combined sample prompt text and the training text into a second large language model, wherein the parameter quantity of the first large language model is larger than that of the second large language model.
Model loss is then determined from the predicted text and the corresponding tag text, and a second largest language model is trained from the model loss.
Then, the text to be rewritten and the target style information are acquired.
Then, constructing a second style constraint instruction for prompting style migration with reference to the target style information, and taking the second style constraint instruction as a target prompt text;
or, constructing a second style constraint instruction for prompting style migration with reference to the target style information, recalling a second example text from a preset candidate recall library according to the target style information, and combining the second style constraint instruction and the second example text to serve as a target prompt text;
Or, acquiring a second example text matched with the target style information, constructing a second prompt instruction for prompting style migration with reference to the style of the second example text, and combining the second prompt instruction and the second example text to serve as the target prompt text;
specifically, recall the second example text from a preset candidate recall library according to the target style information, including: determining a second target recall library matched with the target style information in a plurality of preset candidate recall libraries, wherein the second target recall library comprises a plurality of second original texts and reference rewritten texts corresponding to the second original texts; screening out second associated texts associated with the text to be rewritten from each second original text; combining the second associated text and the corresponding reference rewritten text to obtain a second example text;
specifically, obtaining a second example text that matches the target style information includes: in response to the input operation, obtaining a second example text that matches the target style information, which is input based on the input operation; or recalling the second example text from a preset candidate recall library according to the target style information.
And then, after combining the target prompt text and the text to be rewritten, inputting the target prompt text and the text to be rewritten into a trained second large language model, and performing style migration on the text to be rewritten to generate a rewritten result text.
Based on the method, sample text and sample style information are obtained, then a sample prompt text is constructed according to the sample style information, the sample prompt text and the sample text are combined and then input into a first large language model for processing a text style migration task, the sample text is rewritten into a tag text, the sample prompt text and the sample text are combined and then input into a second large language model for processing the text style migration task, the sample text is rewritten into a predicted text, and the quality of a text style migration result generated by the first large language model is usually better because the parameter quantity of the first large language model is larger than that of the second large language model, so that the tag text is used as expected output of the second large language model, model loss is determined according to the predicted text actually output by the second large language model and the tag text which is expected to be output in a training stage, the second large language model is trained through model loss, so that the second large language model can inherit the advantages of the first large language model on the text style migration task, the quality of the second large language model on the text style migration task is improved, and the quality of the text style migration result is improved; in the reasoning stage, the current style of the text to be rewritten can be migrated to the style designated by the target style information based on the trained second large language model, so that a rewritten result text is obtained, the text style migration task is processed through the second large language model with higher generalization performance, the text style migration tasks of various style types can be effectively processed, and the quality of the text style migration result can be improved.
The text generation method provided by the embodiment of the application can be applied to various scenes.
For example, referring to fig. 12, fig. 12 is an optional interface schematic diagram of a man-machine interaction interface provided in an embodiment of the present application.
The man-machine interaction interface may display a usage scenario selection control 1201, a first text input control 1202 and a first text display control 1203 in an interaction scenario serving as a style migration assistant of an application program, may select a specific usage scenario by triggering the usage scenario selection control 1201, for example, the usage scenario may include a news scenario, an advertisement scenario, an academic paper scenario, a social media scenario, and the like, after the usage scenario is selected, may obtain target style information for indicating a text style of the selected usage scenario, may obtain a text to be rewritten after inputting the text to be rewritten in the first text input control 1202, then may construct a target prompt text according to the target style information, may input a trained second large language model after the target prompt text and the text to be rewritten are combined, may generate a rewrite result text by performing style migration on the text to be rewritten, may copy the rewrite result text displayed in the first text display control 1203, may further process a text migration task by using a second large language model with higher performance based on the use of the usage scenario, may further effectively process various types of text migration task, and may also be capable of improving the quality of the text migration task.
Taking the example of selecting a social media scenario, assume that the text to be rewritten entered is "the weekend will hold a cool event welcome people to participate before, will provide delicates, music and games-! The generated rewritten result text can be' the weekend, the super cool activity is to be cheered!Food, music, games, all of which are all-! Quick participation in bar-! />Therefore, in the social media scene, the simple and clear phrases and emoticons can be used for attracting the attention of young people, and the text style migration result is high in quality.
For another example, referring to fig. 13, fig. 13 is another alternative interface schematic diagram of a man-machine interaction interface provided in an embodiment of the present application.
In the interaction scenario of the question and answer assistant as the application program, the man-machine interaction interface may display a answer style selection control 1301, a second text input control 1302 and a second text display control 1303, a specific answer style may be selected by triggering the answer style selection control 1301, the answer style may include formal, humor, romantic, ancient wind, and the like, after the answer style is selected, target style information for indicating the text style of the selected answer style may be obtained, after the question text is input in the second text input control 1302, the question and answer assistant may generate a corresponding initial answer text based on the question text, then use the initial answer text as a text to be rewritten, then construct a target prompt text according to the target style information, input a trained second large language model after the target prompt text and the text to be rewritten, perform style migration on the text to be rewritten, generate a rewritten result text, use the result text as a target answer text, display the second text in the second text display control 1303, based on this, the second large language model with higher performance is processed, and the task style quality can be further improved.
Taking the answer style of humor as an example, assume that the question text entered is "please ask me what should be noted before traveling? The initial answer text generated by the question assistant based on the question text may be "suggest to check weather forecast before traveling to ensure you have proper clothing. The style migration is carried out on the initial reply text, and the generated target reply text can be' before traveling, the weather is required to be inquired first, so that the slippers are prevented from being washed into snow piles. As can be seen, the target answer text generated by the question and answer assistant adds entertainment through the exaggeration and humor expression mode, so that readers can feel happy, and the quality of the text style migration result is higher.
It will be appreciated that, although the steps in the flowcharts described above are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited in order unless explicitly stated in the present embodiment, and may be performed in other orders. Moreover, at least some of the steps in the flowcharts described above may include a plurality of steps or stages that are not necessarily performed at the same time but may be performed at different times, and the order of execution of the steps or stages is not necessarily sequential, but may be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.
Referring to fig. 14, fig. 14 is an optional structural schematic diagram of a text generating apparatus provided in an embodiment of the present application, where the text generating apparatus 1400 includes:
a first obtaining module 1401, configured to obtain a sample text and sample style information, and construct a sample prompt text according to the sample style information;
a first generating module 1402, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a first large language model, and perform style migration on the sample text to generate a tag text;
a second generating module 1403, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a second large language model, and perform style migration on the sample text to generate a predicted text, where the parameter amount of the first large language model is greater than the parameter amount of the second large language model;
a first training module 1404 for determining model loss from the predicted text and the tag text, training a second large language model from the model loss;
the third generating module 1405 is configured to obtain the text to be rewritten and the target style information, construct a target prompt text according to the target style information, combine the target prompt text and the text to be rewritten, and input the combined text to the trained second large language model, and perform style migration on the text to be rewritten to generate a rewritten result text.
Further, the first acquiring module 1401 is specifically configured to:
constructing a first style constraint instruction for prompting style migration by referring to sample style information, and taking the first style constraint instruction as a sample prompting text;
or, constructing a first style constraint instruction for prompting style migration with reference to sample style information, recalling a first example text from a preset candidate recall library according to the sample style information, and combining the first style constraint instruction and the first example text to serve as a sample prompting text;
or recalling the first example text from a preset candidate recall library according to the sample style information, constructing a first prompt instruction for prompting style migration with reference to the style of the first example text, and combining the first prompt instruction and the first example text to serve as a sample prompt text.
Further, the first acquiring module 1401 is specifically configured to:
determining a first target recall library matched with sample style information in a plurality of preset candidate recall libraries, wherein the first target recall library comprises a plurality of first original texts and reference rewritten texts corresponding to the first original texts;
screening out first associated texts associated with the sample texts from the first original texts;
The first associated text and the corresponding reference rewritten text are combined to be used as a first example text.
Further, the first acquiring module 1401 is specifically configured to:
screening out first associated texts similar to the sample text from the first original texts;
or determining the first keywords according to the sample texts, and screening out first associated texts containing the first keywords from the first original texts.
Further, the first acquiring module 1401 is specifically configured to:
creating candidate nodes for the combined result of each first original text and the corresponding reference rewritten text respectively to obtain a knowledge graph;
calculating the relevance between any two first original texts to obtain a first relevance score between the two corresponding candidate nodes;
respectively calculating the relevance between each first original text and the sample text to obtain second relevance scores between each candidate node and the sample text;
determining a primary node in each candidate node according to the second relevance score, and determining associated nodes in other candidate nodes according to the first relevance score between the primary node and the other candidate nodes;
and taking the first original text corresponding to the primary node and the first original text corresponding to the association node as the first association text.
Further, the third generating module 1405 is specifically configured to:
constructing a second style constraint instruction for prompting style migration with reference to the target style information, and taking the second style constraint instruction as a target prompt text;
or, constructing a second style constraint instruction for prompting style migration with reference to the target style information, recalling a second example text from a preset candidate recall library according to the target style information, and combining the second style constraint instruction and the second example text to serve as a target prompt text;
or, acquiring a second example text matched with the target style information, constructing a second prompt instruction for prompting style migration with reference to the style of the second example text, and combining the second prompt instruction and the second example text to serve as the target prompt text.
Further, the third generating module 1405 is specifically configured to:
determining a second target recall library matched with the target style information in a plurality of preset candidate recall libraries, wherein the second target recall library comprises a plurality of second original texts and reference rewritten texts corresponding to the second original texts;
screening out second associated texts associated with the text to be rewritten from each second original text;
And combining the second associated text and the corresponding reference rewritten text to obtain a second example text.
Further, the third generating module 1405 is specifically configured to:
in response to the input operation, obtaining a second example text that matches the target style information, which is input based on the input operation;
or recalling the second example text from a preset candidate recall library according to the target style information.
Further, the second generating module 1403 is specifically configured to:
determining a quality index of the tag text, wherein the quality index comprises at least one of a fact consistency degree or a text attraction degree, and the fact consistency degree is used for indicating consistency between the tag text and a corresponding sample text;
filtering the label text with the quality index smaller than or equal to the index threshold, and taking a sample text corresponding to the filtered residual label text as a training text;
the sample prompt text and the training text are combined and input into a second largest language model.
The above-mentioned text generation device 1400 and the text generation method are based on the same inventive concept, by acquiring sample text and sample style information, then constructing a sample prompt text according to the sample style information, combining the sample prompt text and the sample text, inputting a first large language model for processing a text style migration task, rewriting the sample text into a tag text, and inputting a second large language model for processing the text style migration task after combining the sample prompt text and the sample text, rewriting the sample text into a predicted text, wherein the quality of a text style migration result generated by the first large language model is generally better because the parameter amount of the first large language model is greater than that of the second large language model, and therefore, the tag text is used as a desired output of the second large language model, model loss is determined according to the predicted text actually output by the second large language model and the tag text as the desired output in a training stage, and the second large language model is trained through the model loss, so that the second large language model can inherit the advantage of the first large language model on the text style migration task, and the performance quality of the second large language model on the text style migration task is improved, thereby improving the quality of the migration result of the text style on the text style migration task; in the reasoning stage, the current style of the text to be rewritten can be migrated to the style designated by the target style information based on the trained second large language model, so that a rewritten result text is obtained, the text style migration task is processed through the second large language model with higher generalization performance, the text style migration tasks of various style types can be effectively processed, and the quality of the text style migration result can be improved.
Referring to fig. 15, fig. 15 is an optional structural schematic diagram of a model training device provided in an embodiment of the present application, where the model training device 1500 includes:
a second obtaining module 1501, configured to obtain sample text and sample style information, and construct a sample prompt text according to the sample style information;
a fourth generating module 1502, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a first large language model, and perform style migration on the sample text to generate a label text;
a fifth generating module 1503, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a second large language model, and perform style migration on the sample text to generate a predicted text, where the parameter amount of the first large language model is greater than the parameter amount of the second large language model;
a second training module 1504 is configured to determine model loss based on the predicted text and the tag text and train a second large language model based on the model loss.
The model training device 1500 and the model training method are based on the same inventive concept, by acquiring sample text and sample style information, then constructing a sample prompt text according to the sample style information, combining the sample prompt text and the sample text, inputting a first large language model for processing a text style migration task, rewriting the sample text into a tag text, and inputting a second large language model for processing the text style migration task after combining the sample prompt text and the sample text, rewriting the sample text into a predicted text, wherein the quality of a text style migration result generated by the first large language model is generally better because the parameter amount of the first large language model is greater than that of the second large language model, and determining model loss by taking the tag text as a desired output of the second large language model according to the predicted text actually output by the second large language model and the tag text actually output in a training stage, so that the second large language model can inherit the advantage of the first large language model on the text style migration task through model loss, and the performance of the second large language model on the text style migration task is improved, thereby improving the quality of the text style migration result generated by the first large language model; in the reasoning stage, the current style of the text to be rewritten can be migrated to the style designated by the target style information based on the trained second large language model, so that a rewritten result text is obtained, the text style migration task is processed through the second large language model with higher generalization performance, the text style migration tasks of various style types can be effectively processed, and the quality of the text style migration result can be improved.
The electronic device for executing the text generation method or the model training method provided in the embodiment of the present application may be a terminal, and referring to fig. 16, fig. 16 is a partial block diagram of the terminal provided in the embodiment of the present application, where the terminal includes: camera assembly 1610, memory 1620, input unit 1630, display unit 1640, sensor 1650, audio circuitry 1660, wireless fidelity (wireless fidelity, abbreviated as WiFi) module 1670, processor 1680, and power supply 1690. It will be appreciated by those skilled in the art that the terminal structure shown in fig. 16 is not limiting of the terminal and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
The camera assembly 1610 may be used to capture images or video. Optionally, camera assembly 1610 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal and the rear camera is disposed on the rear surface of the terminal. In some embodiments, the at least two rear cameras are any one of a main camera, a depth camera, a wide-angle camera and a tele camera, so as to realize that the main camera and the depth camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize a panoramic shooting and Virtual Reality (VR) shooting function or other fusion shooting functions.
The memory 1620 may be used to store software programs and modules, and the processor 1680 performs various functional applications of the terminal and data processing by executing the software programs and modules stored in the memory 1620.
The input unit 1630 may be used to receive input numerical or character information and generate key signal inputs related to the setting and function control of the terminal. In particular, the input unit 1630 may include a touch panel 1631 and other input devices 1632.
The display unit 1640 may be used to display input information or provided information and various menus of the terminal. The display unit 1640 may include a display panel 1641.
Audio circuitry 1660, speakers 1661, and microphone 1662 may provide an audio interface.
The power supply 1690 may be an alternating current, a direct current, a disposable battery, or a rechargeable battery.
The number of sensors 1650 may be one or more, the one or more sensors 1650 including, but not limited to: acceleration sensors, gyroscopic sensors, pressure sensors, optical sensors, etc. Wherein:
the acceleration sensor may detect the magnitudes of accelerations on three coordinate axes of a coordinate system established with the terminal. For example, an acceleration sensor may be used to detect the components of gravitational acceleration in three coordinate axes. The processor 1680 may control the display unit 1640 to display the user interface in a lateral view or a longitudinal view according to the gravitational acceleration signal collected by the acceleration sensor. The acceleration sensor may also be used for the acquisition of motion data of a game or a user.
The gyroscope sensor can detect the body direction and the rotation angle of the terminal, and the gyroscope sensor can be cooperated with the acceleration sensor to collect the 3D action of the user on the terminal. Processor 1680 can implement the following functions based on the data collected by the gyroscopic sensor: motion sensing (e.g., changing UI according to a tilting operation by a user), image stabilization at shooting, game control, and inertial navigation.
The pressure sensor may be provided at a side frame of the terminal and/or a lower layer of the display unit 1640. When the pressure sensor is disposed at a side frame of the terminal, a grip signal of the terminal by a user may be detected, and the processor 1680 performs left-right hand recognition or quick operation according to the grip signal collected by the pressure sensor. When the pressure sensor is provided at the lower layer of the display unit 1640, the processor 1680 controls the operability control on the UI interface according to the pressure operation of the display unit 1640 by the user. The operability controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
The optical sensor is used to collect the ambient light intensity. In one embodiment, the processor 1680 may control the display brightness of the display unit 1640 based on the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display luminance of the display unit 1640 is turned up; when the ambient light intensity is low, the display brightness of the display unit 1640 is turned down. In another embodiment, the processor 1680 can also dynamically adjust the capture parameters of the camera assembly 1610 based on the intensity of ambient light collected by the optical sensor.
In this embodiment, the processor 1680 included in the terminal may perform the text generation method or the model training method of the previous embodiment.
The electronic device for executing the text generating method or the model training method provided in the embodiment of the present application may also be a server, and referring to fig. 17, fig. 17 is a partial block diagram of a server provided in the embodiment of the present application, where server 1700 may generate relatively large differences due to configuration or performance, and may include one or more central processing units (Central Processing Units, abbreviated as CPU) 1722 (e.g., one or more processors) and a memory 1732, and one or more storage media 1730 (e.g., one or more mass storage devices) storing application programs 1742 or data 1744. Wherein the memory 1732 and storage medium 1730 may be transitory or persistent storage. The program stored on the storage medium 1730 may include one or more modules (not shown), each of which may include a series of instruction operations on the server 1700. Further, the central processor 1722 may be arranged to communicate with a storage medium 1730 to execute a series of instruction operations in the storage medium 1730 on the server 1700.
The server 1700 may also include one or more power supplies 1726, one or more wired or wireless network interfaces 1750, one or more input/output interfaces 1758, and/or one or more operating systems 1741, such as Windows Server, mac OS XTM, unixTM, linuxTM, freeBSDTM, and the like.
The processor in server 1700 may be used to perform a text generation method or a model training method.
The embodiments of the present application also provide a computer readable storage medium storing a program code for executing the text generation method or the model training method of the foregoing embodiments.
Embodiments of the present application also provide a computer program product comprising a computer program stored in a computer readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program to cause the computer device to execute the text generation method or the model training method described above.
The terms "first," "second," "third," "fourth," and the like in the description of the present application and in the above-described figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that embodiments of the present application described herein may be capable of operation in sequences other than those illustrated or described herein, for example. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in this application, "at least one" means one or more, and "a plurality" means two or more. "and/or" for describing the association relationship of the association object, the representation may have three relationships, for example, "a and/or B" may represent: only a, only B and both a and B are present, wherein a, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship. "at least one of" or the like means any combination of these items, including any combination of single item(s) or plural items(s). For example, at least one (one) of a, b or c may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
It should be understood that in the description of the embodiments of the present application, the meaning of a plurality (or multiple) is two or more, and that greater than, less than, exceeding, etc. is understood to not include the present number, and that greater than, less than, within, etc. is understood to include the present number.
In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of elements is merely a logical functional division, and there may be additional divisions of actual implementation, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
It should also be appreciated that the various embodiments provided in the embodiments of the present application may be arbitrarily combined to achieve different technical effects.
While the preferred embodiments of the present application have been described in detail, the present application is not limited to the above embodiments, and various equivalent modifications and substitutions can be made by those skilled in the art without departing from the spirit and scope of the present application, and these equivalent modifications and substitutions are intended to be included in the scope of the present application as defined in the appended claims.

Claims (15)

1. A text generation method, comprising:
acquiring sample text and sample style information, and constructing a sample prompt text according to the sample style information;
the sample prompt text and the sample text are combined and then input into a first large language model, style migration is carried out on the sample text, and a label text is generated;
the sample prompt text and the sample text are combined and then input into a second large language model, style migration is carried out on the sample text, and a predicted text is generated, wherein the parameter quantity of the first large language model is larger than the parameter quantity of the second large language model;
determining model loss according to the predicted text and the corresponding tag text, and training the second large language model according to the model loss;
And acquiring a text to be rewritten and target style information, constructing a target prompt text according to the target style information, combining the target prompt text and the text to be rewritten, inputting the combined text to be rewritten into the trained second large language model, and performing style migration on the text to be rewritten to generate a rewritten result text.
2. The text generation method according to claim 1, wherein the constructing a sample hint text from the sample style information includes:
constructing a first style constraint instruction for prompting style migration by referring to the sample style information, and taking the first style constraint instruction as a sample prompting text;
or, constructing a first style constraint instruction for prompting style migration by referring to the sample style information, recalling a first example text from a preset candidate recall library according to the sample style information, and combining the first style constraint instruction and the first example text to serve as a sample prompting text;
or recalling the first example text from a preset candidate recall library according to the sample style information, constructing a first prompt instruction for prompting style migration with reference to the style of the first example text, and combining the first prompt instruction and the first example text to serve as a sample prompt text.
3. The text generation method according to claim 2, wherein recalling the first example text from a preset candidate recall library according to the sample style information comprises:
determining a first target recall library matched with the sample style information in a plurality of preset candidate recall libraries, wherein the first target recall library comprises a plurality of first original texts and reference rewritten texts corresponding to the first original texts;
screening out first associated texts associated with the sample texts from the first original texts;
and combining the first associated text and the corresponding reference rewritten text to obtain a first example text.
4. A text generation method according to claim 3, wherein said screening out first associated text associated with said sample text from each of said first original text comprises:
screening out first associated texts similar to the sample texts from the first original texts;
or determining a first keyword according to the sample text, and screening out a first associated text containing the first keyword from each first original text.
5. A text generation method according to claim 3, wherein said screening out first associated text associated with said sample text from each of said first original text comprises:
respectively creating candidate nodes for the combined result of each first original text and the corresponding reference rewritten text to obtain a knowledge graph;
calculating the relevance between any two first original texts to obtain a first relevance score between the two corresponding candidate nodes;
respectively calculating the relevance between each first original text and each sample text to obtain a second relevance score between each candidate node and each sample text;
determining a primary node in each candidate node according to the second relevance score, and determining a relevant node in other candidate nodes according to the first relevance score between the primary node and other candidate nodes;
and taking the first original text corresponding to the primary node and the first original text corresponding to the association node as first association text.
6. The text generation method according to claim 1, wherein the constructing a target hint text from the target style information includes:
Constructing a second style constraint instruction for prompting style migration by referring to the target style information, and taking the second style constraint instruction as a target prompt text;
or, constructing a second style constraint instruction for prompting style migration by referring to the target style information, recalling a second example text from a preset candidate recall library according to the target style information, and combining the second style constraint instruction and the second example text to serve as a target prompt text;
or, acquiring a second example text matched with the target style information, constructing a second prompt instruction for prompting style migration with reference to the style of the second example text, and combining the second prompt instruction and the second example text to serve as the target prompt text.
7. The text generation method according to claim 6, wherein recalling a second example text from a preset candidate recall library according to the target style information, comprises:
determining a second target recall library matched with the target style information in a plurality of preset candidate recall libraries, wherein the second target recall library comprises a plurality of second original texts and reference rewritten texts corresponding to the second original texts;
Screening out a second associated text associated with the text to be rewritten from each second original text;
and combining according to the second associated text and the corresponding reference rewritten text to obtain a second example text.
8. The text generation method of claim 6, wherein the obtaining the second example text that matches the target style information comprises:
in response to an input operation, obtaining a second example text that matches the target style information, which is input based on the input operation;
or recalling the second example text from a preset candidate recall library according to the target style information.
9. The text generation method according to claim 1, wherein the combining the sample prompt text and the sample text and inputting the combined sample prompt text into a second large language model comprises:
determining a quality indicator of the tag text, wherein the quality indicator comprises at least one of a degree of fact consistency or a degree of text attraction, the degree of fact consistency being used to indicate consistency between the tag text and the corresponding sample text;
filtering the label text with the quality index smaller than or equal to an index threshold, and taking the sample text corresponding to the label text after filtering as a training text;
And combining the sample prompt text and the training text and then inputting the combined sample prompt text and the training text into a second large language model.
10. A method of model training, comprising:
acquiring sample text and sample style information, and constructing a sample prompt text according to the sample style information;
the sample prompt text and the sample text are combined and then input into a first large language model, style migration is carried out on the sample text, and a label text is generated;
the sample prompt text and the sample text are combined and then input into a second large language model, style migration is carried out on the sample text, and a predicted text is generated, wherein the parameter quantity of the first large language model is larger than the parameter quantity of the second large language model;
determining model loss according to the predicted text and the label text, and training the second large language model according to the model loss.
11. A text generating apparatus, comprising:
the first acquisition module is used for acquiring sample texts and sample style information and constructing sample prompt texts according to the sample style information;
the first generation module is used for combining the sample prompt text and the sample text, inputting the combined sample prompt text and the combined sample text into a first large language model, and performing style migration on the sample text to generate a label text;
The second generation module is used for inputting the sample prompt text and the sample text into a second large language model after combining, and performing style migration on the sample text to generate a predicted text, wherein the parameter quantity of the first large language model is larger than that of the second large language model;
the first training module is used for determining model loss according to the predicted text and the label text, and training the second large language model according to the model loss;
and the third generation module is used for acquiring the text to be rewritten and the target style information, constructing a target prompt text according to the target style information, combining the target prompt text with the text to be rewritten, inputting the combined target prompt text and the text to be rewritten into the trained second large language model, and performing style migration on the text to be rewritten to generate a rewritten result text.
12. A model training device, comprising:
the second acquisition module is used for acquiring sample texts and sample style information and constructing sample prompt texts according to the sample style information;
a fourth generation module, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a first large language model, and perform style migration on the sample text to generate a tag text;
A fifth generation module, configured to combine the sample prompt text and the sample text, and then input the combined sample prompt text and the combined sample text into a second large language model, and perform style migration on the sample text to generate a predicted text, where a parameter of the first large language model is greater than a parameter of the second large language model;
and the second training module is used for determining model loss according to the predicted text and the label text, and training the second large language model according to the model loss.
13. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the text generation method of any of claims 1 to 9 or the model training method of claim 10 when executing the computer program.
14. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the text generation method of any one of claims 1 to 9 or the model training method of claim 10.
15. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the text generation method of any of claims 1 to 9 or the model training method of claim 10.
CN202311492567.0A 2023-11-08 2023-11-08 Text generation method, model training method, device and electronic equipment Pending CN117540703A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311492567.0A CN117540703A (en) 2023-11-08 2023-11-08 Text generation method, model training method, device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311492567.0A CN117540703A (en) 2023-11-08 2023-11-08 Text generation method, model training method, device and electronic equipment

Publications (1)

Publication Number Publication Date
CN117540703A true CN117540703A (en) 2024-02-09

Family

ID=89785400

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311492567.0A Pending CN117540703A (en) 2023-11-08 2023-11-08 Text generation method, model training method, device and electronic equipment

Country Status (1)

Country Link
CN (1) CN117540703A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118098274A (en) * 2024-04-19 2024-05-28 腾讯科技(深圳)有限公司 Model training method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118098274A (en) * 2024-04-19 2024-05-28 腾讯科技(深圳)有限公司 Model training method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US20190303768A1 (en) Community Question Answering-Based Article Recommendation Method, System, and User Device
CN111046275B (en) User label determining method and device based on artificial intelligence and storage medium
CN112836120A (en) Multi-mode knowledge graph-based movie recommendation method, system and terminal
CN115917535A (en) Recommendation model training method, recommendation device and computer readable medium
CN113010702A (en) Interactive processing method and device for multimedia information, electronic equipment and storage medium
CN116664719B (en) Image redrawing model training method, image redrawing method and device
CN112015896B (en) Emotion classification method and device based on artificial intelligence
CN111414506B (en) Emotion processing method and device based on artificial intelligence, electronic equipment and storage medium
KR20190053481A (en) Apparatus and method for user interest information generation
CN111858898A (en) Text processing method and device based on artificial intelligence and electronic equipment
CN117540703A (en) Text generation method, model training method, device and electronic equipment
CN112131345B (en) Text quality recognition method, device, equipment and storage medium
CN114201516B (en) User portrait construction method, information recommendation method and related devices
CN113392179A (en) Text labeling method and device, electronic equipment and storage medium
Birhane Automating ambiguity: Challenges and pitfalls of artificial intelligence
CN116956116A (en) Text processing method and device, storage medium and electronic equipment
CN114330704A (en) Statement generation model updating method and device, computer equipment and storage medium
CN115840796A (en) Event integration method, device, equipment and computer readable storage medium
CN117271745A (en) Information processing method and device, computing equipment and storage medium
CN116684688A (en) Live broadcast mode switching method and related device based on emotion of audience
CN113741759B (en) Comment information display method and device, computer equipment and storage medium
CN116955599A (en) Category determining method, related device, equipment and storage medium
CN113869518A (en) Visual common sense reasoning method and device, electronic equipment and storage medium
CN113821610A (en) Information matching method, device, equipment and storage medium
Chen et al. A novel sentiment analysis model of museum user experience evaluation data based on unbalanced data analysis technology

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication