CN117540012B - Text generation method and system - Google Patents

Text generation method and system Download PDF

Info

Publication number
CN117540012B
CN117540012B CN202410016455.6A CN202410016455A CN117540012B CN 117540012 B CN117540012 B CN 117540012B CN 202410016455 A CN202410016455 A CN 202410016455A CN 117540012 B CN117540012 B CN 117540012B
Authority
CN
China
Prior art keywords
text
sample data
component
instruction
scoring
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.)
Active
Application number
CN202410016455.6A
Other languages
Chinese (zh)
Other versions
CN117540012A (en
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.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Cloud Computing 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 Alibaba Cloud Computing Ltd filed Critical Alibaba Cloud Computing Ltd
Priority to CN202410016455.6A priority Critical patent/CN117540012B/en
Publication of CN117540012A publication Critical patent/CN117540012A/en
Application granted granted Critical
Publication of CN117540012B publication Critical patent/CN117540012B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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/338Presentation of query results
    • 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/3331Query processing
    • G06F16/334Query execution
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Machine Translation (AREA)

Abstract

The embodiment of the specification provides a text generation method and a system, wherein the text generation method comprises the following steps: determining an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task; responding to the text scoring instruction through the scoring component, calculating a text evaluating score of a sample data set corresponding to the initial prompt text, and selecting negative sample data in the sample data set based on the text evaluating score; analyzing the negative sample data by an analysis component in response to the text analysis instruction to generate negative information of the negative sample data; and responding to the text analysis instruction through the optimization component, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.

Description

Text generation method and system
Technical Field
The embodiment of the specification relates to the technical field of artificial intelligence, in particular to a text generation method and a text generation system.
Background
With the development of artificial intelligence technology, large-scale language models (Large Language Model, LLM) are gradually applied to accomplish various tasks in the field of natural language processing due to their strong learning and reasoning capabilities. How to guide the model to generate accurate results becomes a key problem, and prompt text (prompt) learning is often used to guide the model to achieve different tasks. At the heart of the promt learning is to design a proper promt guiding model to generate a desired output, and the training cost and the data requirement of the model are reduced by using a promt learning method. At present, a certain experience is required for designing the suitable promtt and labor is consumed, so how to more quickly and efficiently design the more suitable promtt is a problem to be solved at present.
Disclosure of Invention
In view of this, the present embodiment provides a text generation method. One or more embodiments of the present specification relate to a text generating system, a text generating apparatus, a computing device, a computer-readable storage medium, and a computer program that solve the technical drawbacks of the related art.
According to a first aspect of embodiments of the present specification, there is provided a text generation method applied to a text generation system, the system including an optimizing component, a scoring component and an analyzing component, including:
Determining an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task;
calculating a text evaluation score of the initial prompt text corresponding to the sample data set by the evaluation component in response to the text evaluation instruction, and selecting negative sample data in the sample data set based on the text evaluation score;
Analyzing the negative sample data by the analysis component in response to the text analysis instruction, and generating negative information of the negative sample data;
And responding to the text analysis instruction through the optimizing component, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
According to a second aspect of embodiments of the present specification, there is provided a text generation method, including:
Determining an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, and calculating a text evaluation score corresponding to the initial prompt text and the sample data set;
negative sample data is selected from the sample data set based on the text evaluation score, and error analysis is carried out on the negative sample data to obtain negative information of the negative sample data;
And optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
According to a third aspect of embodiments of the present specification, there is provided a text generation system comprising a management component, an optimization component, a scoring component and an analysis component, wherein,
The management component determines an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, acquires a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task, sends the text optimization instruction to the optimization component, sends the text scoring instruction to the scoring component and sends the text analysis instruction to the analysis component;
The scoring component is used for responding to the text scoring instruction to calculate a text evaluating score of the initial prompt text corresponding to the sample data set, and selecting negative sample data in the sample data set based on the text evaluating score;
the analysis component is used for responding to the text analysis instruction to analyze the negative sample data and generating negative information of the negative sample data;
And the optimizing component is used for responding to the text analysis instruction and optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
According to a fourth aspect of embodiments of the present specification, there is provided a text generating apparatus applied to a text generating system including an optimizing component, a scoring component and an analyzing component, comprising:
The determining module is configured to determine an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task;
A scoring module configured to calculate, by the scoring component in response to the text scoring instruction, a text scoring score for the initial prompt text corresponding to the sample dataset, and select negative sample data in the sample dataset based on the text scoring score;
an analysis module configured to analyze the negative-sample data by the analysis component in response to the text analysis instruction, generating negative-information of the negative-sample data;
and the optimizing module is configured to respond to the text analysis instruction through the optimizing component, optimize the initial prompt text based on the negative information and generate a target prompt text corresponding to the target task.
According to a fifth aspect of embodiments of the present specification, there is provided a text generating apparatus comprising:
The scoring module is configured to determine an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, and calculate a text evaluation score corresponding to the sample data set of the initial prompt text;
The analysis module is configured to select negative sample data in the sample data set based on the text evaluation score, and perform error analysis on the negative sample data to obtain negative information of the negative sample data;
And the optimizing module is configured to optimize the initial prompt text based on the negative information and generate a target prompt text corresponding to the target task.
According to a sixth aspect of embodiments of the present specification, there is provided a computing device comprising:
a memory and a processor;
the memory is configured to store computer-executable instructions that, when executed by the processor, perform the steps of the text generation method described above.
According to a seventh aspect of embodiments of the present specification, there is provided a computer-readable storage medium storing computer-executable instructions which, when executed by a processor, implement the steps of the text generation method described above.
According to an eighth aspect of embodiments of the present specification, there is provided a computer program, wherein the computer program, when executed in a computer, causes the computer to perform the steps of the above-described text generation method.
The present specification provides a text generation method applied to a text generation system, the system including an optimization component, a scoring component, and an analysis component, the method comprising: determining an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task; calculating a text evaluation score of the initial prompt text corresponding to the sample data set by the evaluation component in response to the text evaluation instruction, and selecting negative sample data in the sample data set based on the text evaluation score; analyzing the negative sample data by the analysis component in response to the text analysis instruction, and generating negative information of the negative sample data; and responding to the text analysis instruction through the optimizing component, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
According to the method, the device and the system, the text evaluation score of the initial prompt text for the sample data set is calculated through the scoring component according to the text scoring instruction, negative sample data are selected from the sample data set based on the text evaluation score, so that sample data with poor performance of the initial prompt text are screened out, negative sample data are analyzed through the analysis component according to the text analysis instruction, negative information is generated, the optimization component can optimize the initial prompt text based on the negative information in response to the text analysis instruction, and target prompt texts which are more in line with target tasks are generated. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.
Drawings
FIG. 1 is a schematic diagram of a text generation method according to an embodiment of the present disclosure;
FIG. 2 is a flow chart of a text generation method provided by one embodiment of the present description;
FIG. 3 is a process flow diagram of a text generation method provided by one embodiment of the present disclosure;
FIG. 4 is a flow chart of a text generation method provided by one embodiment of the present description;
FIG. 5 is a schematic diagram of a text generation system according to one embodiment of the present disclosure
Fig. 6 is a schematic structural view of a text generating apparatus according to an embodiment of the present disclosure;
fig. 7 is a schematic structural view of a text generating apparatus according to an embodiment of the present disclosure;
FIG. 8 is a block diagram of a computing device provided in one embodiment of the present description.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. This description may be embodied in many other forms than described herein and similarly generalized by those skilled in the art to whom this disclosure pertains without departing from the spirit of the disclosure and, therefore, this disclosure is not limited by the specific implementations disclosed below.
The terminology used in the one or more embodiments of the specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the specification. As used in this specification, one or more embodiments and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that, although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first may also be referred to as a second, and similarly, a second may also be referred to as a first, without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" depending on the context.
Furthermore, it should be noted that, user information (including, but not limited to, user equipment information, user personal information, etc.) and data (including, but not limited to, data for analysis, stored data, presented data, etc.) according to one or more embodiments of the present disclosure are information and data authorized by a user or sufficiently authorized by each party, and the collection, use, and processing of relevant data is required to comply with relevant laws and regulations and standards of relevant countries and regions, and is provided with corresponding operation entries for the user to select authorization or denial.
In one or more embodiments of the present description, a large model refers to a deep learning model with large scale model parameters, typically including hundreds of millions, billions, trillions, and even more than one billion model parameters. The large Model can be called as a Foundation Model, a training Model is performed by using a large-scale unlabeled corpus, a pre-training Model with more than one hundred million parameters is produced, the Model can adapt to a wide downstream task, and the Model has better generalization capability, such as a large-scale language Model (Large Language Model, LLM), a multi-modal pre-training Model (multi-modal pre-training Model) and the like.
When the large model is actually applied, the pretrained model can be applied to different tasks by only slightly adjusting a small number of samples, the large model can be widely applied to the fields of natural language processing (Natural Language Processing, NLP for short), computer vision and the like, and particularly can be applied to the tasks of the computer vision fields such as vision question and answer (Visual Question Answering, VQA for short), image description (IC for short), image generation and the like, and the tasks of the natural language processing fields such as emotion classification based on texts, text abstract generation, machine translation and the like, and main application scenes of the large model comprise digital assistants, intelligent robots, searching, online education, office software, electronic commerce, intelligent design and the like.
First, terms related to one or more embodiments of the present specification will be explained.
LLM: a large-scale language model (Large Language Model, LLM), which is an artificial intelligence model, is intended to understand and generate human language. Training can be performed on a large amount of text data, and a wide range of tasks can be performed, including text summarization, translation, emotion analysis, and the like.
Agent: an Agent may be understood as a system capable of autonomously understanding, planning and executing complex tasks, or may be an entity or program capable of perceiving an environment, understanding input information, and making decisions and actions according to preset targets and rules, and at present, an LLM Agent is an Agent based on a large model (LargeLanguageModel-basedAgent).
Prompt: input text or questions provided to the large model are used to guide the model in generating specific responses or outputs.
The current large model shows strong capability in multiple fields and is gradually applied to completing various tasks in the field of natural language processing. When a large model is used to complete a specific task, a good template is often required to be written to obtain a satisfactory model generation result, but the written template requires a certain experience and consumes a great deal of manpower.
Based on this, in the present specification, a text generation method is provided for automatically optimizing the campt by using the job division cooperation among different components, so as to obtain better campt. The present specification relates to a text generating system, a text generating apparatus, a computing device, and a computer-readable storage medium, one by one, in the following embodiments.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a text generation method provided according to an embodiment of the present disclosure, in which an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, and text optimization instructions, text scoring instructions, and text analysis instructions corresponding to the target task are determined, where each instruction is used to make a corresponding component perform a decision and an action of a corresponding target. The scoring component calculates a text evaluation score for each sample data in the sample data set corresponding to the initial prompt text in response to the text scoring instruction and selects negative sample data in the sample data set according to the text evaluation score. The analysis component responds to the text analysis instruction to analyze the negative sample data to generate corresponding negative information, namely, an analysis reason for determining why the answer of the initial prompt text to the negative information of the negative sample data is incorrect and the description of the prompt text is inaccurate. After the negative information is sent to the optimizing component, the optimizing component can optimize the initial prompt text according to the negative information to generate a target prompt text which more accurately accords with the target task, and correspondingly, the scoring component can be used for scoring the target prompt text aiming at the sample data set, iterative optimization updating of the prompt text is continued, and the prompt text meeting the requirements of the target task is generated. The method and the device realize automatic optimization of the prompt text through the division cooperation among the components.
Referring to fig. 2, fig. 2 shows a flowchart of a text generation method according to an embodiment of the present specification, where the method is applied to a text generation system, and the system includes an optimization component, a scoring component, and an analysis component, and specifically includes the following steps.
Step 202: and determining an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task.
The target task may be understood as a specific task that needs to be completed by the large model, for example, a mathematical task, a text translation task, a dialogue task, etc., where task requirements corresponding to different tasks are different. For example, a large model is required to have the capability of solving mathematical questions in a mathematical question task, and a text translation task requires the large model to have the text translation capability. In order to enable a large model to train the ability of the corresponding task, a better prompt text needs to be designed. The prompt text is the prompt, and the role of the prompt is mainly to prompt the model for the context of the input information and the parameter information of the input model. When training the model, the prompt can help the model to better understand the input intention and respond accordingly. In general, the prompt may provide a "hint" or "guideline" to the model to help the model better understand and complete tasks. Therefore, an excellent prompt text is extremely important, and in order to design a prompt text suitable for a model to complete a specific task, a person with experience needs to continuously adjust the prompt text, but the manual time is relatively consumed, so in the text generation method provided by the specification, the cost of the manual time consumed by acquiring the prompt text is reduced by means of automatically optimizing and updating the prompt text. The sample data set corresponding to the initial prompt text may be understood as a set of training sample data for use in training the model in the target task.
In practical application, a text generation system is provided to realize automatic optimization of prompt text, and the text generation system comprises an optimization component, a scoring component and an analysis component, wherein the components can be understood as agents based on a large model. Each component provides corresponding data and tools, such as a calculator tool interface to the component for enabling the component to perform corresponding mathematical calculations, and a text translation tool interface to the component for enabling the component to perform corresponding text translations. In specific implementation, the optimizing component is responsible for generating new prompt texts, the scoring component is responsible for scoring the prompt texts, and the analyzing component is responsible for analyzing the results of the prompt texts on specific tasks and giving reasons possibly causing errors. Thus, in order for each component to be able to achieve its own goal, it is necessary to set a corresponding instruction for each component, i.e. the optimizing component is configured with a text optimizing instruction, the scoring component is configured with a text scoring instruction, and the analyzing component is configured with a text analyzing instruction, so that the component can act according to the intended goal and output a corresponding result by the component in response to the instruction.
In a specific embodiment of the present disclosure, an initial prompt text and a sample data set of a target task are determined, the target task is a mathematical problem task, the sample data set includes sample training data of a plurality of different mathematical problems, that is, a large model needs to be trained to have the capability of solving the mathematical problems, a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task are determined, the text optimization instruction includes description and optimization target description of the mathematical problem task, the text optimization instruction is "please refer to the mathematical problem task, and 3 new simplets" capable of achieving better accuracy are generated by referring to the existing simplets and evaluation results and defects thereof; the text scoring instruction comprises description and target description of the task of the mathematical questions, wherein the text scoring instruction is used for evaluating the promt of the mathematical questions and giving scoring scores, and outputting samples with high scores and incorrect results; the text analysis instruction contains descriptions of the promt and the error sample and descriptions of the target, and the text analysis instruction is "i are writing the promt of the mathematical task, but some error reasons are encountered in actual use, indicating the shortfall of the promt. Through the instructions, the corresponding components can be caused to perform corresponding actions and output expected information.
Further, since the target task has some initial prompt, in order to reduce the processing complexity of the component, a part of the prompt may be selected as the initial prompt text, and specifically, the initial prompt text of the target task is determined, including: acquiring a task data set and a sample data set corresponding to a target task, and performing data screening in the task data set according to a preset selection strategy; and determining an initial prompt text of the target task according to the screening result.
The task data set can be understood as a prompt text set corresponding to the target task, when the initial prompt text of the target task is determined, the task data set of the target task can be selected, and the selected prompt text is used as the initial prompt text, so that evaluation analysis and optimization of a plurality of prompt texts are realized at one time. Correspondingly, because the data volume of the sample data set corresponding to the target task is large, the sample data set can be selected from the initial sample data set of the target task later when the sample data set is determined, for example, K samples are randomly selected as an evaluation subset, and training data in the evaluation subset are combined to generate the sample data set.
In practical application, data screening is performed in a task data set, an initial prompt text is determined to be capable of being operated by a scoring component according to a screening result, after the scoring component selects the initial prompt text from the task data set, performance of each initial prompt text can be evaluated, and it is noted that the initial prompt text is a provided sample water lifting text in a first iteration round, and the initial prompt text can be a target prompt text generated in an iteration process in a subsequent iteration round, so that continuous iteration is realized and prompt texts with higher evaluation scores are obtained.
In a specific embodiment of the present disclosure, referring to the above example, a task data set and a sample data set corresponding to a mathematical task are obtained, where the sample data set includes sample data corresponding to the mathematical task, and the sample data may include text information such as a question, a solution mode, an answer, and the like. The task data set comprises prompt texts corresponding to mathematical problem tasks, such as description texts of associated problems in the prompt texts or directly solving requirements on the problems. After data screening is performed in the task data set according to a preset selection strategy, an initial prompt text of the target task can be determined according to a screening result.
Based on the method, the prompt text corresponding to the current iteration round can be screened out from the task data set to serve as an initial prompt text according to a preset selection strategy, and training of the current iteration round is started.
Further, in order to accurately generate an instruction conforming to a target task, so that a component can perform related processing on the target task, the instruction needs to be generated according to the target task, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task are specifically determined, including: acquiring an initial text optimization instruction, an initial text scoring instruction and an initial text analysis instruction; updating the initial text optimizing instruction, the initial text scoring instruction and the initial text analysis instruction according to the target task to obtain a text optimizing instruction, a text scoring instruction and a text analysis instruction corresponding to the target task.
The initial text optimizing instruction, the initial text scoring instruction and the initial text analyzing instruction can be understood as general instructions applicable to different tasks, and the general instructions are required to be updated according to the target task, so that the text optimizing instruction, the text scoring instruction and the text analyzing instruction belonging to the target task are generated.
In practical application, a corresponding general instruction may be provided, for example, the general optimization instruction is "please target task, refer to current simplet and error information, generate a simplet which can reach higher accuracy", and after updating according to the target task, generate a text optimization instruction belonging to the target task, for example, the target task is a mathematical problem task, and the text optimization instruction is "please target mathematical problem task, refer to existing simplet and evaluation result and deficiency thereof, generate 3 new simplets which can reach better accuracy". In the specific implementation, the instruction corresponding to the target task can be designed directly by manpower, so that a more accurate instruction can be generated for generating the prompt text in the target task.
In a specific embodiment of the present disclosure, an initial text optimization instruction, an initial text scoring instruction, and an initial text analysis instruction are obtained, and the initial text optimization instruction, the initial text scoring instruction, and the initial text analysis instruction are updated according to a target task, for example, the initial text scoring instruction is "evaluate for a sample of a task, and an error sample" is output, and the updated text scoring instruction is "evaluate for a sample of a mathematical task, and an error sample" is output.
Based on this, by updating based on the target task on the basis of the general instruction, the text optimizing instruction, the text analyzing instruction, and the text scoring instruction conforming to the target task can be obtained.
Further, in order to facilitate management of workflows and interactive communications between the components, a management component may be configured to be responsible for management, and specifically, the system further includes a management component, and after determining a text optimization instruction, a text scoring instruction, and a text analysis instruction corresponding to the target task, the method further includes: and sending the text optimizing instruction to the optimizing component through the management component, sending the text scoring instruction to the scoring component and sending the text analyzing instruction to the analyzing component.
The management component can be understood as a component for managing and monitoring the execution process of the whole text generation task by the system, can be responsible for managing the iteration process, monitors each component to execute actions according to instruction requirements, and can command the management component to redo when the requirements are not met. Therefore, the scoring component, the analysis component and the optimizing component can be continuously controlled to act through the management component, so that continuous iteration of text generation is realized until the generated new prompt text meets the preset requirement or the iteration turns reach the preset requirement.
In practical application, after the instructions corresponding to each component are designed, the respective instructions can be respectively sent to the corresponding components through the management component.
In a specific embodiment of the present disclosure, the management component sends the text optimization instructions to the optimization component, the text scoring instructions to the scoring component, and the text analysis instructions to the analysis component.
Based on the analysis of the responsible instructions by the management component, each component can respond to corresponding actions according to the instructions to complete the respective responsible tasks, so that the cooperation of the multiple components is realized, and the automatic optimization of the prompt text is realized. It should be noted that, the instructions of the components may also be directly given when the components are created, without being sent by the management component.
Step 204: and responding to the text scoring instruction through the scoring component, calculating a text scoring score of the initial prompt text corresponding to the sample data set, and selecting negative sample data in the sample data set based on the text scoring score.
The text evaluation score may be understood as a score output after the evaluation of the prompt text by the scoring component according to the sample data set of the target task, that is, by solving the questions in the sample data according to the prompt text, a similarity score between the predicted answer output by the prompt text and the standard answer in the sample data is determined, for example, in the mathematical task, the accuracy of the predicted answer corresponding to the prompt text compared with the standard answer may be calculated and taken as a score. After calculating the text evaluation score for the corresponding sample dataset of the initial prompt text, negative sample data may be selected in the sample dataset based on the text evaluation score. Negative sample data can be understood as all sample data corresponding to the prompt text in the sample data set, and evaluating sample data with lower score.
In practical application, the sample data set includes a plurality of sample data, each sample data can be evaluated by using the prompt text, the evaluation score of the prompt text relative to each sample data is determined, the sample data with high score can be output as better positive sample data according to the score, and the sample data with lower score can be output as negative sample data. And analyzing the negative sample data through an analysis component to find out why the prompt text has low evaluation score for the negative sample data. In the implementation, multiple initial prompt texts are used for evaluating the sample data set at the same time, and then one prompt text with high evaluation score is selected from the initial prompt texts according to the evaluation score and used as a follow-up optimized prompt text.
In a specific embodiment of the present disclosure, in response to a text scoring instruction by a scoring component, an evaluation score of an initial prompt text for each sample data in a sample data set is calculated, then sample data with a lower evaluation score is selected from all sample data as negative sample data according to the evaluation score, and a reason analysis is required for why the low score occurs for the sample data for the prompt text.
Further, in order to accurately calculate the evaluation score of each sample data, the calculation may be performed according to the answer text corresponding to the sample data, specifically, by the evaluation component responding to the text scoring instruction, calculating the text evaluation score corresponding to the sample data set by the initial prompt text includes: responding to the text scoring instruction through the scoring component, and generating a predicted answer text corresponding to the sample data set according to the initial prompt text; and obtaining a standard answer text corresponding to the sample data set, and calculating a text evaluation score corresponding to the sample data set by using the standard answer text and the predicted answer text.
The predicted answer text may be understood as an answer for solving and predicting a question in the sample data based on the initial prompt text, for example, in a mathematical question task, the predicted answer text may be a question answer text obtained by solving a question for a mathematical question in the sample data, and in a text translation task, the predicted answer text may be a translation text obtained after translating a text required to be translated for the sample data. Each sample data has a corresponding standard answer text, the standard answer text can be understood as a correct answer text corresponding to the sample data, and the text evaluation score of the initial prompt text for the sample data can be calculated through the standard answer text and the predicted answer text.
In practical application, the calculation modes for calculating the text evaluation scores in different tasks are also different, for example, the predicted answer text in the mathematical problem task only has a difference from a mistake, so the text evaluation scores can be 0 and 1; in the text translation task, the predicted answer text is a translation text, and the text evaluation score can be calculated based on the text similarity by predicting the text similarity of the answer text and the standard answer text. In the implementation, the description of the prompt text is inaccurate or is not suitable for the sample data, so that the text evaluation score of the sample data is possibly low, and therefore, the prompt text needs to be optimized, so that a more suitable prompt text is found.
In a specific embodiment of the present disclosure, a scoring component responds to a text scoring instruction, and utilizes an initial prompt text to answer a mathematical question in sample data to obtain a predicted answer text, wherein the predicted answer text is an answer text corresponding to the mathematical question in the sample data, a standard answer text corresponding to the sample data is obtained, and a text evaluation score of the initial prompt text is calculated according to the standard answer text and the predicted answer text, which can be calculated as a score by calculating the accuracy of the predicted answer text compared with the standard answer text and rounding. Specific sample data are "question: girls in one classroom are 3 times larger than boys, 10 boys are known to ask about how many students in total in the classroom? Answering: the math subject in the sample data is "3 times as many as girls in a classroom, 10 men are known to be present, please ask about how many students are in total in the classroom? And solving the digital questions by using the initial prompt text 'solve questions' to obtain a predicted answer text. And then calculating the text evaluation score of the initial prompt text for the sample data according to the predicted answer and the standard answer of the mathematical question.
Based on the text evaluation scores, the text evaluation scores of the sample data corresponding to the initial prompt text can be calculated by using the standard answer text and the predicted answer text, and better positive sample data and worse negative sample data can be selected based on the text evaluation scores.
Further, in order to correctly select negative sample data, it is necessary to sort the negative sample data based on a text evaluation score, specifically, selecting the negative sample data in the sample data set based on the text evaluation score includes: determining a target evaluation score corresponding to each sample sub-data in the sample data set; and sequencing each sample sub-data based on the target evaluation score corresponding to each sample sub-data, and selecting negative sample data in the sample data set according to the sequencing result.
The sample sub-data may be understood as training samples contained in the sample data set, each sample sub-data corresponds to a respective target evaluation score, the sample sub-data is sorted according to the target evaluation score of each sample sub-data, the sample sub-data may be sorted according to the score from high to low, then the sample sub-data with higher score may be selected as positive sample data according to the sorting result, and the sample sub-data with lower score may be selected as negative sample data.
In a specific embodiment of the present disclosure, a target evaluation score corresponding to each sample sub-data in the sample data set is determined, that is, a target evaluation score calculated after each sample sub-data is evaluated by using an initial prompt text is determined, then the sample sub-data is ranked according to the target evaluation score from high to low, and then the sample sub-data with a relatively low score is selected as negative sample data.
Based on the above, by sorting according to the evaluation scores, the negative sample data with low scores can be accurately selected for subsequent analysis of the negative sample data.
Step 206: and responding to the text analysis instruction through the analysis component, analyzing the negative sample data, and generating negative information of the negative sample data.
The negative information may be understood as information of a cause of a problem occurring by predicting the sample data using the initial prompt text, and the negative information may include an error in an answer predicted using the initial prompt text and a cause of the error. By analyzing the obtained negative information, the subsequent optimizing component can utilize the negative information to optimize the initial prompt text, thereby avoiding similar errors from appearing again and further generating the prompt text with better quality.
In a specific embodiment of the present disclosure, the analysis component may analyze the negative sample data to obtain negative information of the initial prompt text for the negative sample data, where the negative information includes a predicted error answer and an analysis of a cause of the error.
Further, in order to accurately analyze the negative information, it is required to determine, by using task requirement information of a target task, specifically, analyzing, by the analysis component, the negative sample data in response to the text analysis instruction, to generate the negative information of the negative sample data, including: determining task demand information corresponding to the target task by the analysis component in response to the text analysis instruction; and selecting deviation data from the negative sample data according to the task demand information and the initial prompt text, and generating negative information of the negative sample data by utilizing the deviation data.
The task demand information may be understood as task objective description information of a target task, for example, task demand information in a math task may be a primary task, deviation data may be selected from negative sample data according to the task demand information, the deviation data may be text data with errors in the negative sample data, the negative information of the negative sample data may be generated by using the deviation data, for example, the sample data is a math task, and the errors are not in accordance with the primary task.
In practical application, the relevant conditions of the prompt text of the target task can be obtained through the task demand information, a place with an error can be found from the sample data according to the task demand information, and the error data, the initial prompt text and the task demand information are utilized to generate the reason for the error. In the specific implementation, negative information is also associated with the prompt text, if the description of the prompt text is inaccurate, a question solving mode is not limited in the prompt text, so that a question solving process is complex and does not meet task requirements, and the text evaluation score of the sample data is low.
In a specific embodiment of the present disclosure, the target task is a mathematical task, the task requirement information is a task of solving a problem by adopting a primary school problem solving mode, the initial prompt text is "solving a problem answer by using addition and subtraction", and then deviation data can be selected from negative sample data according to the task requirement and the initial prompt text, the deviation data includes that an operation symbol in the mathematical problem in the negative sample data is a multiplication number, and the problem type is a judgment problem, and then corresponding negative information can be generated according to the deviation data.
Step 208: and responding to the text analysis instruction through the optimizing component, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
After negative information of negative sample data in the iterative optimization is obtained, the initial prompt text can be optimized by utilizing the negative information, and an optimized target prompt text is generated. The target prompt text can be understood as the prompt text obtained after the iterative optimization of the round.
In practical application, the negative information is obtained by predicting sample data through an initial prompt text, comparing a predicted result with a standard result to calculate a text evaluation score, selecting negative sample data through the text evaluation score, and analyzing the negative sample data. Therefore, after the negative information is determined, the initial prompt text can be optimized by utilizing the negative information, so that the problem of prediction deviation of the optimized initial prompt text on the sample data can not occur later.
In a specific embodiment of the present disclosure, the optimizing component is configured to optimize the initial prompt text based on the negative information in response to the text analysis instruction to generate a target prompt text for the target task. Specifically, the negative information is that the answer does not give a specific reasoning process and is easy to cause errors, and the target prompt text is generated after the initial prompt text is optimized based on the negative information, and the target prompt text is that the answer gives a detailed reasoning process, so that the correct answer is ensured to be calculated.
Further, after generating the target prompt text corresponding to the target task, the method further includes: acquiring optimized attribute information corresponding to the target prompt text through the management component, and determining a component response strategy based on the optimized attribute information; and respectively sending response instructions to the optimizing component, the scoring component and the analyzing component according to the component response strategy.
The optimization attribute information may be understood as optimization information corresponding to the target prompt text, the optimization attribute information may include an evaluation score corresponding to the target prompt text, or may include an iteration round corresponding to the target prompt text, a component response policy may be determined according to the optimization attribute information, the component response policy may be understood as a policy for controlling whether the component continues to execute a corresponding action, and the group price response policy may include a continuation response policy and a stop response policy.
In practical application, the management component can monitor each component to execute actions according to requirements, and after generating a target prompt text of a target task, the management component can acquire the optimized attribute information of the target prompt text and judge whether to continue to execute iterative optimization or not based on the optimized attribute information. The corresponding component response strategy is specifically determined, each component sends a response instruction, and under the condition that the optimization needs to be continuously executed, the response instruction sent to each component is a continuous response instruction; under the condition that the optimization does not need to be continuously executed, the response instruction sent to each component is a stop response instruction, so that the management component has the function of controlling iteration rounds.
In a specific embodiment of the present disclosure, the management component obtains the optimized attribute information of the target prompt text, where the optimized attribute information includes 5 iteration rounds corresponding to the target prompt text, and when the iteration rounds have reached a preset iteration round, it is determined that the component response policy is a stop response policy, and a stop response instruction is sent to each component.
Based on this, the management component can determine whether to continue performing iterative optimization according to the evaluation score and the iteration round of the target prompt text, so as to generate a proper prompt text.
Further, in order to accurately determine whether the iterative optimization needs to be continued, the judgment needs to be performed according to a preset condition, specifically, determining, by the management component, a component response policy based on the optimization attribute information includes: acquiring preset optimization conditions through the management component; under the condition that the optimization attribute information meets the preset optimization condition, determining that the component response strategy is a continuous response strategy; and under the condition that the optimized attribute information does not meet the preset optimized condition, determining that the component response strategy is a stop response strategy.
The preset optimization condition can be understood as a condition for stopping iteration set in advance, and the preset optimization condition can be that the evaluation score of the target prompt text reaches a preset evaluation score or that the iteration turn corresponding to the target prompt text reaches a preset iteration turn. And determining the component response strategy as a continuous response strategy under the condition that the optimization attribute information meets the preset optimization condition, and determining the component response strategy as a stop response strategy under the condition that the optimization attribute information does not meet the preset optimization condition.
In practical application, when the component response policy is a continue response policy, the management component may send a continue response instruction to each component, and each component may continue to execute a respective action; in the case where the component response policy is a stop response policy, the management component may send a stop response instruction to each component, and each component does not continue to perform its own action, thereby stopping iterative optimization.
In a specific embodiment of the present disclosure, the management component obtains a preset optimization condition, the current iteration round in the optimization attribute information is 5, and when the preset iteration round has been reached, the group price response policy is a stop response policy, and sends a stop response instruction to each component.
Based on the method, the response strategy of the component is judged by the management component according to the preset optimization condition, so that the iteration process is managed, and the high-quality prompt text can be automatically and rapidly generated.
Further, the component response policy is the continue response policy; after sending response instructions to the optimizing component, the scoring component and the analyzing component according to the continuous response strategy, the method further comprises: the scoring component continues to execute steps responsive to the text scoring instruction based on the response instruction; the analysis component continues to execute steps responsive to the text analysis instructions based on the response instructions; the optimization component continues executing steps in response to the text optimization instructions based on the response instructions.
In practical application, when the component response strategy is a continuous response strategy, the response instruction sent by the management component is a continuous response instruction, and when each component receives the response instruction, the next optimization iteration round can be entered, so that the prompt text is continuously optimized.
In a specific embodiment of the present disclosure, the scoring component scores the target prompt text in response to the text scoring instruction, obtains a text evaluation score of the target prompt text for each sample data, then selects negative sample data with a lower score from the sample data, and then the analysis component analyzes the negative sample data in response to the text analysis instruction, so as to find out negative information. And the optimizing component optimizes the initial prompt text by utilizing the negative information to generate a new target prompt text.
The present specification provides a text generation method applied to a text generation system, the system including an optimization component, a scoring component, and an analysis component, the method comprising: determining an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task; calculating a text evaluation score of the initial prompt text corresponding to the sample data set by the evaluation component in response to the text evaluation instruction, and selecting negative sample data in the sample data set based on the text evaluation score; analyzing the negative sample data by the analysis component in response to the text analysis instruction, and generating negative information of the negative sample data; and responding to the text analysis instruction through the optimizing component, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task. According to the method, the device and the system, the text evaluation score of the initial prompt text for the sample data set is calculated according to the text scoring instruction through the scoring component, negative sample data are selected from the sample data set based on the text evaluation score, so that sample data with poor performance of the initial prompt text are screened, the negative sample data are analyzed according to the text analysis instruction through the analysis component to generate negative information, the optimization component can optimize the initial prompt text based on the negative information in response to the text analysis instruction, and the target prompt text which is more in line with a target task is generated. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.
The text generation method provided in the present specification will be further described with reference to fig. 3 by taking an application of the text generation method to text translation as an example. Fig. 3 shows a flowchart of a processing procedure of a text generating method according to an embodiment of the present disclosure, which specifically includes the following steps.
Step 302: and acquiring a task data set and a sample data set corresponding to the target task, screening data in the task data set according to a preset selection strategy, and determining an initial prompt text of the target task according to a screening result.
In one implementation, the target task is a text translation task, the task data set includes a plurality of prompt texts, and the sample data includes pre-translated question text and post-translated answer text, such as "hello world". The Hello word "", the prompt text includes prompt information for the target task, such as please translate into english. And data screening is carried out in the task data set according to a preset selection strategy, and an initial prompt text of the target task is selected, wherein the initial prompt text comprises a plurality of initial prompt sub-texts.
Step 304: and acquiring an initial text optimization instruction, an initial text scoring instruction and an initial text analysis instruction.
In one implementation, generic text optimization instructions, text scoring instructions, and text analysis instructions are obtained.
Step 306: updating the initial text optimizing instruction, the initial text scoring instruction and the initial text analyzing instruction according to the target task to obtain the text optimizing instruction, the text scoring instruction and the text analyzing instruction corresponding to the target task.
In one implementation, the general instructions are updated according to the text translation task, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the text translation task are obtained. The text optimizing instruction is "aiming at a text translation task, 3 prompt texts which can reach higher accuracy are generated by referring to the existing prompt texts and negative information thereof", the text scoring instruction is "evaluating the prompt texts aiming at the text translation task, calculating evaluation scores and outputting initial prompt sub-texts with high text evaluation scores and negative sample data with lower text evaluation scores corresponding to the initial prompt sub-texts", and the text analyzing instruction is "I write the prompt texts of the text translation task, but some errors occur in use, please analyze error reasons".
Step 308: and responding to the text scoring instruction through the scoring component, and generating a predicted answer text corresponding to the sample data set according to the initial prompt text.
In one implementation, a text scoring instruction is executed by a scoring component, each sample data in the initial prompt text and sample data set is input into a large model, the large model is obtained to predict the sample data based on the initial prompt text, and the output predicted answer text, which may be translated text.
Step 310: and obtaining a standard answer text corresponding to the sample data set, and calculating a text evaluation score of the sample data set corresponding to the initial prompt text by using the standard answer text and the predicted answer text.
In one implementation manner, a standard answer text of the initial prompt text is obtained, the standard answer text is that a correct answer text of the initial prompt text is 'I Love China', and a text evaluation score corresponding to the initial prompt text is calculated by using the correct answer text and the predicted answer text.
Step 312: and determining a target evaluation score corresponding to each sample sub-data in the sample data set.
In one implementation, a target evaluation score corresponding to each sample sub-data in the sample data set is determined, and each target evaluation score is used to represent the accuracy of the initial prompt text for each sample sub-data.
Step 314: and sorting each sample sub-data based on each target evaluation score, and selecting negative sample data in the sample data set according to the sorting result.
In one implementation, the sample sub-data in the sample data set is ranked according to each target evaluation score, and negative sample data with a lower score is selected according to the ranking result.
Step 316: and determining task demand information corresponding to the target task by the analysis component in response to the text analysis instruction.
In one implementation, task demand information for a text translation task is determined, the task demand information being a correct translation of the topic text.
Step 318: and selecting deviation data from the negative sample data according to the task demand information and the initial prompt text, and generating negative information of the negative sample data by using the deviation data.
In one implementation manner, deviation data is selected from negative sample data according to task demand information and an initial prompt text, the deviation data is text data with translation errors, negative information of the negative sample data is generated by using the deviation data, and the negative information is ' love translation errors ' and is translated into like '.
Step 320: and responding to the text analysis instruction through the optimization component, optimizing the initial prompt text based on the negative information, and generating the target prompt text corresponding to the target task.
The text generation method is characterized in that a scoring component calculates text evaluation scores of initial prompt texts on a sample data set according to text scoring instructions, negative sample data are selected from the sample data set based on the text evaluation scores, so that sample data with poor initial prompt texts are screened out, then negative sample data are analyzed according to text analysis instructions through an analysis component to generate negative information, and an optimization component can optimize the initial prompt texts based on the negative information in response to the text analysis instructions to generate target prompt texts more conforming to target tasks. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.
Referring to fig. 4, fig. 4 shows a flowchart of a text generating method according to an embodiment of the present disclosure, which specifically includes:
Step 402: and determining an initial prompt text of the target task and a sample data set corresponding to the initial prompt text, and calculating a text evaluation score corresponding to the initial prompt text and the sample data set.
In a specific embodiment of the present specification, the functions of each component may be implemented in a black box manner, so as to perform the text generation method provided in the present specification.
Step 404: and selecting negative sample data in the sample data set based on the text evaluation score, and performing error analysis on the negative sample data to obtain negative information of the negative sample data.
Step 406: and optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
Further, each step in the text generation method may also be implemented by various component agents, and specifically calculating a text evaluation score of the initial prompt text corresponding to the sample data set, including: calculating a text evaluation score of the initial prompt text corresponding to the sample data set through a scoring component; correspondingly, performing error analysis on the negative sample data to obtain negative information of the negative sample data, including: performing error analysis on the negative sample data through an analysis component to obtain negative information of the negative sample data; correspondingly, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task, including: and optimizing the initial prompt text based on the negative information by an optimization component to generate a target prompt text corresponding to the target task.
Wherein, the scoring component is responsible for scoring the prompt text, and the analysis component is responsible for analyzing the predicted result of the prompt text on the sample data of the specific task, and giving the cause of possible error. The optimizing component is responsible for optimizing the current prompt text and generating a new prompt text. The corresponding functions are completed through each component according to the respective running instructions, and the aim of the component to cooperate with the automatic optimization prompt text is achieved.
The specification provides a text generation method, which comprises the steps of determining an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, and calculating a text evaluation score corresponding to the initial prompt text; negative sample data is selected from the sample data set based on the text evaluation score, and error analysis is carried out on the negative sample data to obtain negative information of the negative sample data; and optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task. According to the method, the device and the system, the text evaluation score of the initial prompt text for the sample data set is calculated according to the text scoring instruction through the scoring component, negative sample data are selected from the sample data set based on the text evaluation score, so that sample data with poor performance of the initial prompt text are screened, the negative sample data are analyzed according to the text analysis instruction through the analysis component to generate negative information, the optimization component can optimize the initial prompt text based on the negative information in response to the text analysis instruction, and the target prompt text which is more in line with a target task is generated. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.
The above is an exemplary scheme of a text generation method of the present embodiment. It should be noted that, the technical solution of the text generating method and the technical solution of the text generating method belong to the same conception, and details of the technical solution of the text generating method, which are not described in detail, can be referred to the description of the technical solution of the text generating method.
Referring to fig. 5, fig. 5 illustrates a schematic diagram of a text generation system provided in accordance with one embodiment of the present specification, the system including a management component 502, a scoring component 504, an analysis component 506, and an optimization component 508, wherein,
The management component 502 determines an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, acquires a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task, sends the text optimization instruction to the optimization component, sends the text scoring instruction to the scoring component and sends the text analysis instruction to the analysis component.
In one implementation manner, the management component may determine an initial prompt text of the target task, obtain a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task, and send the instructions to the corresponding components respectively through the management component, so that each component responds to the respective component to perform the action.
The scoring component 504 calculates a text scoring score for the initial prompt text corresponding to the sample dataset in response to the text scoring instruction and selects negative sample data in the sample dataset based on the text scoring score.
The analysis component 506, in response to the text analysis instructions, analyzes the negative-sample data, generating negative information for the negative-sample data.
The optimizing component 508 is configured to optimize the initial prompt text based on the negative information in response to the text analysis instruction, and generate a target prompt text corresponding to the target task.
The specification provides a text generation system, wherein the management component determines an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, acquires a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task, sends the text optimization instruction to the optimization component, sends the text scoring instruction to the scoring component and sends the text analysis instruction to the analysis component; the scoring component is used for responding to the text scoring instruction to calculate a text evaluating score of the initial prompt text corresponding to the sample data set, and selecting negative sample data in the sample data set based on the text evaluating score; the analysis component is used for responding to the text analysis instruction to analyze the negative sample data and generating negative information of the negative sample data; and the optimizing component is used for responding to the text analysis instruction and optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task. According to the method, the device and the system, the text evaluation score of the initial prompt text for the sample data set is calculated according to the text scoring instruction through the scoring component, negative sample data are selected from the sample data set based on the text evaluation score, so that sample data with poor performance of the initial prompt text are screened, the negative sample data are analyzed according to the text analysis instruction through the analysis component to generate negative information, the optimization component can optimize the initial prompt text based on the negative information in response to the text analysis instruction, and the target prompt text which is more in line with a target task is generated. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.
The above is an exemplary scheme of a text generation system of the present embodiment. It should be noted that, the technical solution of the text generating system and the technical solution of the text generating method belong to the same conception, and the details of the technical solution of the text generating system, which are not described in detail, can be referred to the description of the technical solution of the text generating method.
Corresponding to the method embodiment, the present disclosure further provides an embodiment of a text generating device, and fig. 6 shows a schematic structural diagram of the text generating device provided in one embodiment of the present disclosure. As shown in fig. 6, the apparatus is applied to a text generation system, the system including an optimizing component, a scoring component, and an analyzing component, including:
A determining module 602 configured to determine an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction, and a text analysis instruction corresponding to the target task;
A scoring module 604 configured to calculate a text scoring score for the initial prompt text corresponding to the sample dataset in response to the text scoring instruction by the scoring component and select negative sample data in the sample dataset based on the text scoring score;
An analysis module 606 configured to analyze the negative-sample data by the analysis component in response to the text analysis instructions, generating negative-information of the negative-sample data;
An optimization module 608 is configured to respond to the text analysis instruction through the optimization component, optimize the initial prompt text based on the negative information, and generate a target prompt text corresponding to the target task.
Optionally, the determining module 602 is further configured to obtain a task data set and a sample data set corresponding to the target task, and perform data screening in the task data set according to a preset selection policy; and determining an initial prompt text of the target task according to the screening result.
Optionally, the determining module 602 is further configured to obtain an initial text optimization instruction, an initial text scoring instruction, and an initial text analysis instruction; updating the initial text optimizing instruction, the initial text scoring instruction and the initial text analysis instruction according to the target task to obtain a text optimizing instruction, a text scoring instruction and a text analysis instruction corresponding to the target task.
Optionally, the scoring module 604 is further configured to generate, by the scoring component, a predicted answer text corresponding to the sample data set according to the initial prompt text in response to the text scoring instruction; and obtaining a standard answer text corresponding to the sample data set, and calculating a text evaluation score corresponding to the sample data set by using the standard answer text and the predicted answer text.
Optionally, the scoring module 604 is further configured to determine a target score for each sample sub-data in the sample data set; and sorting each sample sub-data based on each target evaluation score, and selecting negative sample data in the sample data set according to sorting results.
Optionally, the analysis module 606 is further configured to determine, by the analysis component in response to the text analysis instruction, task demand information corresponding to the target task; and selecting deviation data from the negative sample data according to the task demand information and the initial prompt text, and generating negative information of the negative sample data by utilizing the deviation data.
Optionally, the optimizing module 608 is further configured to send, by the managing component, the text optimizing instruction to the optimizing component, the text scoring instruction to the scoring component, and the text analyzing instruction to the analyzing component.
Optionally, the optimizing module 608 is further configured to obtain, by the management component, optimized attribute information corresponding to the target prompt text, and determine a component response policy based on the optimized attribute information; and respectively sending response instructions to the optimizing component, the scoring component and the analyzing component according to the component response strategy.
Optionally, the optimizing module 608 is further configured to obtain, by the management component, a preset optimizing condition; under the condition that the optimization attribute information meets the preset optimization condition, determining that the component response strategy is a continuous response strategy; and under the condition that the optimized attribute information does not meet the preset optimized condition, determining that the component response strategy is a stop response strategy.
Optionally, the optimizing module 608 is further configured to the scoring component to continue executing the step of responding to the text scoring instruction based on the response instruction; the analysis component continues to execute steps responsive to the text analysis instructions based on the response instructions; the optimization component continues executing steps in response to the text optimization instructions based on the response instructions.
The text generation device provided by the specification is applied to a text generation system, and the system comprises an optimization component, a scoring component and an analysis component, and comprises: the determining module is configured to determine an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task; a scoring module configured to calculate, by the scoring component in response to the text scoring instruction, a text scoring score for the initial prompt text corresponding to the sample dataset, and select negative sample data in the sample dataset based on the text scoring score; an analysis module configured to analyze the negative-sample data by the analysis component in response to the text analysis instruction, generating negative-information of the negative-sample data; and the optimizing module is configured to respond to the text analysis instruction through the optimizing component, optimize the initial prompt text based on the negative information and generate a target prompt text corresponding to the target task. The method comprises the steps of calculating text evaluation scores of initial prompt texts on a sample data set according to text evaluation instructions through a scoring component, selecting negative sample data on the sample data set based on the text evaluation scores, screening out sample data with poor performance of the initial prompt texts, analyzing the negative sample data through an analysis component according to text analysis instructions to generate negative information, and enabling an optimization component to respond to the text analysis instructions to optimize the initial prompt texts based on the negative information to generate target prompt texts more conforming to target tasks. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.
The above is an exemplary scheme of a text generating apparatus of the present embodiment. It should be noted that, the technical solution of the text generating device and the technical solution of the text generating method belong to the same conception, and the details of the technical solution of the text generating device, which are not described in detail, can be referred to the description of the technical solution of the text generating method.
Corresponding to the method embodiment, the present disclosure further provides an embodiment of a text generating device, and fig. 7 shows a schematic structural diagram of the text generating device provided in one embodiment of the present disclosure. As shown in fig. 7, the apparatus includes:
A scoring module 702 configured to determine an initial prompt text of a target task and a sample dataset corresponding to the initial prompt text, and calculate a text evaluation score for the initial prompt text corresponding to the sample dataset;
An analysis module 704 configured to select negative sample data in the sample data set based on the text evaluation score and perform error analysis on the negative sample data to obtain negative information of the negative sample data;
And the optimizing module 706 is configured to optimize the initial prompt text based on the negative information and generate a target prompt text corresponding to the target task.
Optionally, the scoring module 702 is further configured to calculate, by a scoring component, a text-scoring score for the initial prompt text corresponding to the sample dataset;
optionally, the analysis module 704 is further configured to perform error analysis on the negative sample data by an analysis component to obtain negative information of the negative sample data;
Optionally, the optimizing module 706 is further configured to optimize, by an optimizing component, the initial prompt text based on the negative information, and generate a target prompt text corresponding to the target task.
The text generation device provided in the present specification includes: the scoring module is configured to determine an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, and calculate a text evaluation score corresponding to the sample data set of the initial prompt text; the analysis module is configured to select negative sample data in the sample data set based on the text evaluation score, and perform error analysis on the negative sample data to obtain negative information of the negative sample data; and the optimizing module is configured to optimize the initial prompt text based on the negative information and generate a target prompt text corresponding to the target task. The method comprises the steps of calculating text evaluation scores of initial prompt texts on a sample data set according to text evaluation instructions through a scoring component, selecting negative sample data on the sample data set based on the text evaluation scores, screening out sample data with poor performance of the initial prompt texts, analyzing the negative sample data through an analysis component according to text analysis instructions to generate negative information, and enabling an optimization component to respond to the text analysis instructions to optimize the initial prompt texts based on the negative information to generate target prompt texts more conforming to target tasks. Through the division cooperation of a plurality of components, the automatic optimization of the prompt text is realized, and the resources and manpower consumed by manually adjusting the prompt text are reduced.
The above is an exemplary scheme of a text generating apparatus of the present embodiment. It should be noted that, the technical solution of the text generating device and the technical solution of the text generating method belong to the same conception, and the details of the technical solution of the text generating device, which are not described in detail, can be referred to the description of the technical solution of the text generating method.
Fig. 8 illustrates a block diagram of a computing device 800 provided in accordance with one embodiment of the present description. The components of computing device 800 include, but are not limited to, memory 810 and processor 820. Processor 820 is coupled to memory 810 through bus 830 and database 850 is used to hold data.
Computing device 800 also includes access device 840, access device 840 enabling computing device 800 to communicate via one or more networks 860. Examples of such networks include public switched telephone networks (PSTN, public Switched Telephone Network), local area networks (LAN, local Area Network), wide area networks (WAN, wide Area Network), personal area networks (PAN, personal Area Network), or combinations of communication networks such as the internet. The access device 840 may include one or more of any type of network interface, wired or wireless, such as a network interface card (NIC, network interface controller), such as an IEEE802.11 wireless local area network (WLAN, wireless Local Area Network) wireless interface, a worldwide interoperability for microwave access (Wi-MAX, worldwide Interoperability for Microwave Access) interface, an ethernet interface, a universal serial bus (USB, universal Serial Bus) interface, a cellular network interface, a bluetooth interface, near Field Communication (NFC).
In one embodiment of the present description, the above-described components of computing device 800, as well as other components not shown in FIG. 8, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device illustrated in FIG. 8 is for exemplary purposes only and is not intended to limit the scope of the present description. Those skilled in the art may add or replace other components as desired.
Computing device 800 may be any type of stationary or mobile computing device including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smart phone), wearable computing device (e.g., smart watch, smart glasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or personal computer (PC, personal Computer). Computing device 800 may also be a mobile or stationary server.
Wherein the processor 820 is configured to execute computer-executable instructions that, when executed by the processor, perform the steps of the text generation method described above.
The foregoing is a schematic illustration of a computing device of this embodiment. It should be noted that, the technical solution of the computing device and the technical solution of the text generating method belong to the same concept, and details of the technical solution of the computing device, which are not described in detail, can be referred to the description of the technical solution of the text generating method.
An embodiment of the present disclosure also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of the text generation method described above.
The above is an exemplary version of a computer-readable storage medium of the present embodiment. It should be noted that, the technical solution of the storage medium and the technical solution of the text generation method belong to the same concept, and details of the technical solution of the storage medium, which are not described in detail, can be referred to the description of the technical solution of the text generation method.
An embodiment of the present specification also provides a computer program, wherein the computer program, when executed in a computer, causes the computer to perform the steps of the above-described text generation method.
The above is an exemplary version of a computer program of the present embodiment. It should be noted that, the technical solution of the computer program and the technical solution of the text generating method belong to the same conception, and details of the technical solution of the computer program, which are not described in detail, can be referred to the description of the technical solution of the text generating method.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The computer instructions include computer program code that may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the content of the computer readable medium can be increased or decreased appropriately according to the requirements of the patent practice, for example, in some areas, according to the patent practice, the computer readable medium does not include an electric carrier signal and a telecommunication signal.
It should be noted that, for simplicity of description, the foregoing method embodiments are all expressed as a series of combinations of actions, but it should be understood by those skilled in the art that the embodiments are not limited by the order of actions described, as some steps may be performed in other order or simultaneously according to the embodiments of the present disclosure. Further, those skilled in the art will appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily all required for the embodiments described in the specification.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to the related descriptions of other embodiments.
The preferred embodiments of the present specification disclosed above are merely used to help clarify the present specification. Alternative embodiments are not intended to be exhaustive or to limit the invention to the precise form disclosed. Obviously, many modifications and variations are possible in light of the teaching of the embodiments. The embodiments were chosen and described in order to best explain the principles of the embodiments and the practical application, to thereby enable others skilled in the art to best understand and utilize the invention. This specification is to be limited only by the claims and the full scope and equivalents thereof.

Claims (14)

1. A text generation method applied to a text generation system, the system comprising an optimization component, a scoring component, and an analysis component, the method comprising:
Determining an initial prompt text of a target task, a sample data set corresponding to the initial prompt text, and a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task;
calculating a text evaluation score of the initial prompt text corresponding to the sample data set by the evaluation component in response to the text evaluation instruction, and selecting negative sample data in the sample data set based on the text evaluation score;
analyzing the negative sample data by the analysis component in response to the text analysis instruction to generate negative information of the negative sample data, wherein the analysis of the negative sample data by the analysis component in response to the text analysis instruction includes determining task demand information corresponding to the target task by the analysis component in response to the text analysis instruction; selecting deviation data from the negative sample data according to the task demand information and the initial prompt text, and generating negative information of the negative sample data by utilizing the deviation data;
And responding to the text analysis instruction through the optimizing component, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
2. The method of claim 1, determining an initial prompt text for a target task and a sample dataset corresponding to the initial prompt text, comprising:
acquiring a task data set and a sample data set corresponding to a target task, and performing data screening in the task data set according to a preset selection strategy;
and determining an initial prompt text of the target task according to the screening result.
3. The method of claim 1, determining text optimization instructions, text scoring instructions, and text analysis instructions corresponding to the target task, comprising:
Acquiring an initial text optimization instruction, an initial text scoring instruction and an initial text analysis instruction;
Updating the initial text optimizing instruction, the initial text scoring instruction and the initial text analysis instruction according to the target task to obtain a text optimizing instruction, a text scoring instruction and a text analysis instruction corresponding to the target task.
4. The method of claim 1, calculating, by the scoring component in response to the text scoring instruction, a text scoring score for the initial prompt text corresponding to the sample dataset, comprising:
responding to the text scoring instruction through the scoring component, and generating a predicted answer text corresponding to the sample data set according to the initial prompt text;
and obtaining a standard answer text corresponding to the sample data set, and calculating a text evaluation score corresponding to the sample data set by using the standard answer text and the predicted answer text.
5. The method of claim 1, selecting negative sample data in the sample data set based on the text evaluation score, comprising:
Determining a target evaluation score corresponding to each sample sub-data in the sample data set;
And sequencing each sample sub-data based on the target evaluation score corresponding to each sample sub-data, and selecting negative sample data in the sample data set according to the sequencing result.
6. The method of claim 1, the system further comprising a management component, after determining text optimization instructions, text scoring instructions, and text analysis instructions corresponding to the target task, the method further comprising:
and sending the text optimizing instruction to the optimizing component through the management component, sending the text scoring instruction to the scoring component and sending the text analyzing instruction to the analyzing component.
7. The method of claim 6, further comprising, after generating the target prompt text corresponding to the target task:
Acquiring optimized attribute information corresponding to the target prompt text through the management component, and determining a component response strategy based on the optimized attribute information;
And respectively sending response instructions to the optimizing component, the scoring component and the analyzing component according to the component response strategy.
8. The method of claim 7, determining, by the management component, a component response policy based on the optimization attribute information, comprising:
Acquiring preset optimization conditions through the management component;
Under the condition that the optimization attribute information meets the preset optimization condition, determining that the component response strategy is a continuous response strategy;
and under the condition that the optimized attribute information does not meet the preset optimized condition, determining that the component response strategy is a stop response strategy.
9. The method of claim 8, the component response policy being the continue response policy;
After sending response instructions to the optimizing component, the scoring component and the analyzing component according to the continuous response strategy, the method further comprises:
the scoring component continues to execute steps responsive to the text scoring instruction based on the response instruction;
the analysis component continues to execute steps responsive to the text analysis instructions based on the response instructions;
the optimization component continues executing steps in response to the text optimization instructions based on the response instructions.
10. A text generation method, comprising:
Determining an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, and calculating a text evaluation score corresponding to the initial prompt text and the sample data set;
Selecting negative sample data in the sample data set based on the text evaluation score, analyzing the negative sample data, and generating negative information of the negative sample data, wherein the negative sample data is analyzed, and generating the negative information of the negative sample data comprises determining task demand information corresponding to the target task; selecting deviation data from the negative sample data according to the task demand information and the initial prompt text, and generating negative information of the negative sample data by utilizing the deviation data;
And optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
11. The method of claim 10, calculating a text evaluation score for the initial prompt text corresponding to the sample dataset, comprising:
Calculating a text evaluation score of the initial prompt text corresponding to the sample data set through a scoring component;
Correspondingly, performing error analysis on the negative sample data to obtain negative information of the negative sample data, including:
performing error analysis on the negative sample data through an analysis component to obtain negative information of the negative sample data;
Correspondingly, optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task, including:
And optimizing the initial prompt text based on the negative information by an optimization component to generate a target prompt text corresponding to the target task.
12. A text generation system comprising a management component, an optimization component, a scoring component, and an analysis component, wherein,
The management component determines an initial prompt text of a target task and a sample data set corresponding to the initial prompt text, acquires a text optimization instruction, a text scoring instruction and a text analysis instruction corresponding to the target task, sends the text optimization instruction to the optimization component, sends the text scoring instruction to the scoring component and sends the text analysis instruction to the analysis component;
The scoring component is used for responding to the text scoring instruction to calculate a text evaluating score of the initial prompt text corresponding to the sample data set, and selecting negative sample data in the sample data set based on the text evaluating score;
The analysis component is used for responding to the text analysis instruction to analyze the negative sample data and generating negative information of the negative sample data, wherein responding to the text analysis instruction to analyze the negative sample data and generating the negative information of the negative sample data comprises responding to the text analysis instruction and determining task demand information corresponding to the target task; selecting deviation data from the negative sample data according to the task demand information and the initial prompt text, and generating negative information of the negative sample data by utilizing the deviation data;
And the optimizing component is used for responding to the text analysis instruction and optimizing the initial prompt text based on the negative information, and generating a target prompt text corresponding to the target task.
13. A computing device, comprising:
a memory and a processor;
the memory is configured to store computer executable instructions, the processor being configured to execute the computer executable instructions, which when executed by the processor, implement the steps of the method of any one of claims 1 to 11.
14. A computer readable storage medium storing computer executable instructions which when executed by a processor implement the steps of the method of any one of claims 1 to 11.
CN202410016455.6A 2024-01-04 2024-01-04 Text generation method and system Active CN117540012B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410016455.6A CN117540012B (en) 2024-01-04 2024-01-04 Text generation method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410016455.6A CN117540012B (en) 2024-01-04 2024-01-04 Text generation method and system

Publications (2)

Publication Number Publication Date
CN117540012A CN117540012A (en) 2024-02-09
CN117540012B true CN117540012B (en) 2024-04-30

Family

ID=89794146

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410016455.6A Active CN117540012B (en) 2024-01-04 2024-01-04 Text generation method and system

Country Status (1)

Country Link
CN (1) CN117540012B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116050405A (en) * 2022-12-26 2023-05-02 阿里巴巴(中国)有限公司 Text processing, question-answer text processing and text processing model training method
CN116484879A (en) * 2023-04-04 2023-07-25 上海墨百意信息科技有限公司 Prompt message generation method and device, electronic equipment and storage medium
WO2023185971A1 (en) * 2022-03-31 2023-10-05 阿里巴巴(中国)有限公司 Task optimization method and apparatus
WO2023197613A1 (en) * 2022-04-15 2023-10-19 苏州浪潮智能科技有限公司 Small sample fine-turning method and system and related apparatus
CN116959433A (en) * 2023-09-18 2023-10-27 腾讯科技(深圳)有限公司 Text processing method, device, electronic equipment and storage medium
CN117332072A (en) * 2023-12-01 2024-01-02 阿里云计算有限公司 Dialogue processing, voice abstract extraction and target dialogue model training method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023185971A1 (en) * 2022-03-31 2023-10-05 阿里巴巴(中国)有限公司 Task optimization method and apparatus
WO2023197613A1 (en) * 2022-04-15 2023-10-19 苏州浪潮智能科技有限公司 Small sample fine-turning method and system and related apparatus
CN116050405A (en) * 2022-12-26 2023-05-02 阿里巴巴(中国)有限公司 Text processing, question-answer text processing and text processing model training method
CN116484879A (en) * 2023-04-04 2023-07-25 上海墨百意信息科技有限公司 Prompt message generation method and device, electronic equipment and storage medium
CN116959433A (en) * 2023-09-18 2023-10-27 腾讯科技(深圳)有限公司 Text processing method, device, electronic equipment and storage medium
CN117332072A (en) * 2023-12-01 2024-01-02 阿里云计算有限公司 Dialogue processing, voice abstract extraction and target dialogue model training method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Topic-DPR: Topic-based Prompts for Dense Passage Retrieval;Xiao, Q et al.;arxiv;20231231;全文 *
基于对抗训练的文本表示和分类算法;张晓辉;于双元;王全新;徐保民;;计算机科学;20200615(S1);全文 *

Also Published As

Publication number Publication date
CN117540012A (en) 2024-02-09

Similar Documents

Publication Publication Date Title
CN107562863A (en) Chat robots reply automatic generation method and system
CN110991195B (en) Machine translation model training method, device and storage medium
CN111339292A (en) Training method, system, equipment and storage medium of text classification network
CN110399467A (en) The method and apparatus of training data for natural language question answering system is provided
KR20190130212A (en) Engineering big data-driven design expert system and design method thereof
CN110765241B (en) Super-outline detection method and device for recommendation questions, electronic equipment and storage medium
Datta et al. Improving classification through weak supervision in context-specific conversational agent development for teacher education
CN117540012B (en) Text generation method and system
CN117291185A (en) Task processing method, entity identification method and task processing data processing method
CN116361655A (en) Model training method, standard problem prediction method, device, equipment and medium
Han An evaluation method of English online learning behaviour based on feature mining
Cui et al. Cognitive Linguistic Corpus Classification and Terminology Database Design Based on Multimedia Technology.
CN117556264B (en) Training method and device for evaluation model and electronic equipment
CN117634867B (en) RPA flow automatic construction method and system combining large language model and reinforcement learning
CN117608997B (en) Evaluation method, classification evaluation method, sorting evaluation method and sorting evaluation device
CN116414965B (en) Initial dialogue content generation method, device, medium and computing equipment
CN117972058A (en) Implicit knowledge guided dialogue generation method and system based on dialogue thinking chain
Rieser et al. Developing dialogue managers from limited amounts of data
CN117669726A (en) Natural language problem processing method, electronic device and computer readable storage medium
Shibata et al. Evaluation of Automatic Collaborative Learning Process Coding Using Deep Learning Methods Based on Multi-Dimensional Coding Scheme
CN117436825A (en) Intelligent interview method, device, equipment and computer storage medium
Schuh et al. Toward Responsible Use Of Digital Technologies In Manufacturing Companies Through Regulation
Pakalapati et al. The Convergence of AI/ML and DevSecOps: Revolutionizing Software Development
Oladipo Artificial Intelligence and Law
KR20230050906A (en) Test score prediction and learning content provision system using explainable artificial intelligence

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant