Method and device for generating text meeting format requirements based on large model and medium

Through joint generation and discriminant model architecture, we ensure that the text content generated by the large language model is both semantic and meets the format requirements, which solves the problem of inconsistent format of the generation results of the large language model.

CN119476506AInactive Publication Date: 2025-02-18SHANDONG INSPUR SCI RES INST CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510059775.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-15
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

Smart Images

  • Figure CN119476506A_ABST
    Figure CN119476506A_ABST
Patent Text Reader

Abstract

The invention discloses a method and equipment for generating a text meeting format requirements based on a large model and a medium, belongs to the technical field of natural languages, and is used for solving the technical problem that output of an existing large language model may not meet specified format requirements. The method comprises the steps of obtaining task description and a target format; inputting the task description and the target format into a generative model to obtain initial text content; inputting the initial text content and the target format into a discrimination model, and determining whether the initial text content meets the target format; if yes, determining the initial text content as target text content, and outputting the target text content; and if not, repeatedly executing the process until the initial text content meets the target format. The target text content output through the method meets the semantic requirement corresponding to the task description and the target format required by the user at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and in particular to a method, device and medium for generating text that meets format requirements based on a large model. Background Art

[0002] In recent years, large language models have achieved remarkable results in various natural language processing tasks, including machine translation, text generation, question-answering systems, etc. However, despite the excellent performance of large language models in generating semantic content, their output format often does not meet user expectations. In particular, when users require the model to generate results in a specific format, such as JavaScript Object Notation (JSON) format or Structured Query Language (SQL) format, the generated results may only be natural language strings, making it impossible for downstream tasks to parse and use these results.

[0003] The traditional method is to implement it through prompt engineering and constrained decoding. However, the prompt engineering method also has the possibility of not outputting as required. When constrained decoding is applied, the generated text may be reduced in diversity. At the same time, when multiple constraints act at the same time, there may be conflicts between the conditions, making it difficult for the model to generate text that meets all conditions.

[0004] For example, when a user wants a large language model to output a response that conforms to a specific JSON format, the model may generate a string of natural language descriptions rather than valid JSON format text, which will cause parsing errors and affect the execution of the task. Therefore, how to ensure that the large language model not only meets the semantic requirements when generating content, but also meets the specified format requirements has become an urgent problem to be solved. Summary of the invention

[0005] The present invention provides a method, device and medium for generating text that meets format requirements based on a large model, so as to solve the technical problem that the output of the existing large language model may not meet the specified format requirements.

[0006] In a first aspect, the present invention provides a method for generating text that meets format requirements based on a large model, comprising: Get the task description and target format; Inputting the task description and target format into the generation model to obtain initial text content; Inputting the initial text content and the target format into a discriminant model to determine whether the initial text content satisfies the target format; If yes, the initial text content is determined as the target text content, and the target text content is output; If not, the above process is repeated until the initial text content meets the target format.

[0007] In a feasible implementation manner, before inputting the task description and the target format into the generation model to obtain the initial text content, the method further includes: Determining a maximum likelihood estimation loss as a loss function of the generative model; The generative model is trained based on the loss function of the generative model.

[0008] In a feasible implementation, the task description and target format are input into a generation model to obtain initial text content, including: The task description and the target format are input into a large language model to obtain initial text content, wherein the large language model includes at least one of GPT, T5 and Qwen.

[0009] In a feasible implementation manner, before inputting the initial text content and the target format into the discriminant model to determine whether the initial text content satisfies the target format, the method further includes: Determining a cross entropy loss function as the loss function of the discriminant model; The discriminant model is trained based on the loss function of the discriminant model.

[0010] In a feasible implementation manner, the initial text content and the target format are input into a discriminant model to determine whether the initial text content satisfies the target format, including: The initial text content and the target format are input into a deep learning-based classification model to determine whether the initial text content meets the target format.

[0011] In a feasible implementation manner, before inputting the initial text content and the target format into a deep learning-based classification model to determine whether the initial text content satisfies the target format, the method further includes: Based on the target format, the pre-trained large language model is fine-tuned to obtain the deep learning-based classification model, the pre-trained large language model includes at least one of BERT and RoBERTa, and the target format includes at least one of JSON format and SQL format.

[0012] In a feasible implementation manner, before inputting the task description and the target format into the generation model to obtain the initial text content, the method further includes: The generation model and the discrimination model are trained together by joint optimization.

[0013] In a feasible implementation, the generative model and the discriminative model are jointly trained by means of joint optimization, including: Determine a joint loss function based on the loss function of the generative model and the loss function of the discriminative model; Based on the joint loss function, the generative model and the discriminative model are jointly trained.

[0014] In a second aspect, the present invention provides a device for generating text that meets format requirements based on a large model, the device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, so that the at least one processor can execute the method for generating text that meets format requirements based on a large model as described in any of the above embodiments.

[0015] In a third aspect, the present invention provides a non-volatile computer storage medium, which is a non-volatile computer-readable storage medium, and the non-volatile computer-readable storage medium stores at least one program, each of which includes instructions, and when the instructions are executed by a terminal, the terminal executes the method for generating text that meets format requirements based on a large model as described in any of the above embodiments.

[0016] Compared with the prior art, the method, device and medium for generating text that meets format requirements based on a large model provided by the present invention have the following beneficial technical effects: (1) The present invention determines whether the initial text content output by the generation model satisfies the target format through a discriminant model. When the initial text content satisfies the target format, the initial text content is determined as the target text content and output. When the initial text content does not satisfy the target format, the generation model regenerates the initial text content until the initial text content satisfies the target format. In this way, it is ensured that the target text content output by the present invention meets both the semantic requirements corresponding to the task description and the target format required by the user.

[0017] (2) The generative model and the discriminative model are trained together through joint optimization. The entire training process ensures that the generative model can not only generate semantically correct content, but also generate content that meets the format requirements, while ensuring that the discriminative model can accurately determine whether the initially generated content meets the target format. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1A flowchart of a method for generating text that meets format requirements based on a large model provided by the present invention; Figure 2 A schematic diagram of a method for jointly training a generative model and a discriminative model provided by the present invention; Figure 3 A schematic diagram of the structure of a device for generating text that meets format requirements based on a large model provided by the present invention. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the specific embodiments of the present invention and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0020] The method provided by the present invention for generating text that meets format requirements based on a large model is a formatted output generation method based on a joint generation and discrimination model, and is particularly suitable for application scenarios in which a large language model generates output that meets a specific format (such as JSON format, SQL format, etc.). When generating content, existing large language models usually cannot guarantee that the output meets the specific format required by the user, resulting in the inability of downstream tasks to parse or process the generated results. The present invention proposes a joint generation and discrimination model architecture, in which the generation model generates text according to user tasks and format requirements, and the discrimination model performs format verification on the generated text to ensure that it meets the predetermined format requirements. By jointly training the generation model and the discrimination model, the present invention can simultaneously optimize semantic generation and format compliance, and solve the problem that the format output of the large language model does not meet the requirements.

[0021] The technical solution proposed by the present invention is described in detail below with reference to the accompanying drawings.

[0022] Figure 1 The flowchart of the method for generating text that meets format requirements based on a large model provided by the present invention. Figure 1 As shown, the method includes the following execution steps: S101. Obtain task description and target format.

[0023] The task description in the present invention is the user's requirement for the output task, corresponding to the user's semantic requirement for the output text content; the target format corresponds to the user's format requirement for the output text content, that is, the user requires the format of the output text content to be the target format.

[0024] S102: Input the task description and target format into the generation model to obtain initial text content.

[0025] The generation model in the present invention is used to generate content that meets semantic requirements according to the task description and the target format, that is, the initial text content.

[0026] As a possible implementation method, before inputting the task description and the target format into the generation model in S102 to obtain the initial text content, the method also includes: determining the maximum likelihood estimation loss as the loss function of the generation model; and training the generation model based on the loss function of the generation model.

[0027] As a possible implementation method, S102 inputs the task description and the target format into the generation model to obtain initial text content, including: The task description and target format are input into a large language model to obtain initial text content. The large language model includes at least one of a generative pre-trained transformer model (GPT), a text-to-text transfer transformer (T5), and Qwen.

[0028] S103: Input the initial text content and the target format into the discrimination model to determine whether the initial text content meets the target format.

[0029] The initial text content output by the generation model in the present invention may not meet the format requirements of the user for the output text content, that is, the format of the initial text content may not meet the target format. Therefore, in order to make the final output text content meet both the semantic requirements corresponding to the task description and the target format, after the generation model outputs the initial text content, the discriminant model is used to determine whether the initial text content meets the target format, that is, to determine whether the format of the initial text content output by the generation model is consistent with the target format required by the user.

[0030] As a possible implementation method, before inputting the initial text content and the target format into the discriminant model in S103 to determine whether the initial text content meets the target format, the method also includes: determining the cross entropy loss function as the loss function of the discriminant model; and training the discriminant model based on the loss function of the discriminant model.

[0031] As a possible implementation method, S103 inputs the initial text content and the target format into a discriminant model to determine whether the initial text content meets the target format, including: inputting the initial text content and the target format into a classification model based on deep learning to determine whether the initial text content meets the target format.

[0032] As a possible implementation method, before inputting the initial text content and the target format into a deep learning-based classification model to determine whether the initial text content meets the target format, the method also includes: based on the target format, fine-tuning the pre-trained large language model to obtain a deep learning-based classification model, the pre-trained large language model includes at least one of a bidirectional transformer model (Bidirectional Encoder Representations from Transformers, BERT) and a robustly optimized BERT (Robustly Optimized BERT Approach, RoBERTa), and the target format includes at least one of a JSON format and an SQL format.

[0033] As a possible implementation method, before inputting the task description and the target format into the generative model to obtain the initial text content, the method also includes: jointly training the generative model and the discriminative model through joint optimization.

[0034] The entire training process aims to ensure that the generative model can not only generate semantically correct content, but also generate content that meets format requirements, while ensuring that the discriminative model can accurately determine whether the generated content conforms to the specified format.

[0035] As a possible implementation method, the generative model and the discriminative model are jointly trained through joint optimization, including: determining a joint loss function based on the loss function of the generative model and the loss function of the discriminative model; and jointly training the generative model and the discriminative model based on the joint loss function.

[0036] In some embodiments, the joint loss function may be a weighted combination of the loss function of the generative model and the loss function of the discriminative model to ensure that the semantic correctness and format compliance of the generated content are simultaneously optimized during the training process.

[0037] That is, the joint loss function ,in, is the loss function of the generative model, is the loss function of the discriminant model, is a hyperparameter used to balance the weight of generation loss and discrimination loss.

[0038] S104: If yes, the initial text content is determined as the target text content, and the target text content is output.

[0039] If the discriminant model determines that the initial text content meets the target format, then the initial text content is text content that meets both the semantic requirements corresponding to the task description and the target format required by the user. At this time, the initial text content is determined as the target text content for output.

[0040] In this way, the generative model outputs the initial text content based on the task description and the target format. The discriminative model is used to determine whether the initial text content output by the generative model meets the target format. When the initial text content meets the target format, the initial text content is determined as the target text content for output. The output target text content meets both semantic requirements and format requirements.

[0041] If the discrimination result of the discrimination model is negative, that is, the initial text content output by the generation model does not meet the target format, the above process S102-S103 is repeatedly executed until the initial text content meets the target format.

[0042] That is, the generation model regenerates the initial text content, and the discrimination model determines whether the regenerated initial text content meets the target format. When the initial text content meets the target format, the initial text content is determined as the target text content and output.

[0043] In this way, when the initial text content output by the generation model does not meet the target format, the generation model regenerates the initial text content based on the discrimination result of the discrimination model until the initial text content meets the target format. This avoids the situation where the initial text content is directly output when the initial text content output by the generation model does not meet the target format, resulting in the output initial text content not meeting the target format required by the user.

[0044] The present invention can effectively generate output content that conforms to the specified format by introducing a joint generation and discrimination model architecture, and can ensure that the large language model meets the format requirements specified by the user when generating answers, such as JSON format, SQL format, XML format, etc., thereby solving the problem of inconsistent format of the results generated by the large language model. The details are as follows: 1. System architecture The core of the system design is to generate formatted output through two parts of input, that is, the target text content that meets both semantic requirements and format requirements. The two parts of input are task description and target format. Among them, the task description is the specific task that the user needs to complete (such as answering questions, generating code, etc.), and the target format is the output format specified by the user (such as JSON format, SQL format, etc.).

[0045] After receiving these two parts of input, the system generates a formatted output that meets the requirements through a joint generative and discriminative model architecture. The generative model generates content according to the task requirements, while the discriminative model is responsible for verifying whether the content conforms to the specified format.

[0046] 2. Joint generation and discrimination architecture The key to this system is the joint generation and discrimination model. The generation model is responsible for generating content that meets the semantic requirements according to the user's task, and the discrimination model is responsible for checking whether the generated content conforms to the specified format. The two are optimized through joint training.

[0047] Generative models are used to generate content for tasks based on large language models (such as Qwen, GPT, etc.). The generative model accepts the user's task input (i.e., task description) and format requirement input (i.e., target format), and generates corresponding content, i.e., initial text content, through a conditional generation process.

[0048] The discriminant model is used to check whether the initial text content generated by the generative model conforms to the format required by the user, that is, whether it meets the target format. The discriminant model is a classification model (such as Bert, RoBERTa, etc.), which receives the generation result and format requirements as input and outputs a binary classification result (conforms to the format / does not conform to the format).

[0049] 3. Training phase During the training phase, the generative model and the discriminative model are trained together through joint optimization. The entire training process aims to ensure that the generative model can not only generate semantically correct content, but also generate content that meets the format requirements, while ensuring that the discriminative model can accurately determine whether the generated content meets the specified format.

[0050] The generative model uses a large language model (such as Qwen, GPT), and its goal is to generate semantically correct output. The input of the generative model is the user's task and format requirements, that is, the task description and the target format, and the output is the generated text content, that is, the initial text content. In order for the generative model to generate text that conforms to the target format, the training process will introduce format requirement information to help the generative model learn to generate content that conforms to a specific format.

[0051] The loss function of the generative model is the Maximum Likelihood Estimate (MLE) loss, which is used to optimize the semantic correctness of the generated initial text content. The loss function of the generative model is shown in the following formula.

[0052]

[0053] in, is each word or symbol in the initial text content, and x is the task description and target format.

[0054] The discriminant model is used to verify whether the initial text content generated by the generative model conforms to the target format. The input of the discriminant model is the initial text content and the target format, and the output is a binary classification result ("conforms to the format" or "does not conform to the format"). The discriminant model is usually based on a pre-trained large language model (such as BERT, RoBERTa), and is fine-tuned on this basis. The discriminant model learns the format features of the text and determines whether the generated text conforms to a specific format (such as JSON format, SQL format, etc.).

[0055] The loss function of the discriminant model is the cross entropy loss function, which aims to optimize the binary classification task so that the discriminant model can accurately determine whether the generated text meets the format requirements. The loss function of the discriminant model is shown in the following formula.

[0056]

[0057] in, Represents the output of the discriminant model, 0 means "does not conform to the format", 1 means "conforms to the format", x is the initial text content, and F is the format requirement (such as JSON, SQL, etc.).

[0058] The loss functions of the generative model and the discriminative model will be weighted and combined into a joint loss function to ensure that the semantic correctness and format compliance of the generated content are optimized simultaneously during training. The joint loss function is shown in the following formula.

[0059]

[0060] in, is a hyperparameter used to balance the weight of the generation loss and the discrimination loss. By jointly optimizing the generation model and the discrimination model, the system is able to generate text that meets the semantic and format requirements.

[0061] Figure 2 A schematic diagram of a method for jointly training a generative model and a discriminative model provided by the present invention. Figure 2 As shown in the figure, during the training phase, the task input and format requirement input (task description and target format) are input into the joint generation and discrimination model composed of the generation model and the discrimination model. The generation model is a large language model, which is used to generate semantic content (initial text content), and the loss function is the maximum likelihood estimation loss; the discrimination model is a pre-trained language model, which is used to verify the format of the semantic content generated by the generation model, that is, the initial text content, that is, to determine whether the initial text content meets the target format, and the loss function is the cross entropy loss function. The joint loss function is determined based on the loss function of the generation model and the loss function of the discrimination model, and the generation model and the discrimination model are optimized based on the joint loss function.

[0062] 4. Reasoning stage In the reasoning phase, the user inputs specific questions and format requirements, that is, the task description and target format, and the system will generate results that conform to the format based on the trained joint model. The reasoning process includes the following steps.

[0063] Input processing: The system receives the user's task input and format requirement input as input to the model.

[0064] Generation process: The generation model generates initial text content based on the above input.

[0065] Format discrimination: The discriminative model performs format checks on the initial text content generated by the generative model.

[0066] If it does not meet the requirements, the generation model will regenerate the initial text content until the initial text content meets the requirements (that is, the discriminant model determines that the format of the generated initial text content is consistent with the target format required by the user).

[0067] In order to facilitate understanding of the present invention, a specific embodiment is given below, taking the scenario of SQL statement generation as an example to illustrate the method provided by the present invention.

[0068] Assume that the user needs to query the database through natural language, and requires that the generated SQL query statement must conform to a specific format. For example, the user wants to query the information of all employees in the "employee" table whose "age is greater than 30" and "position is 'manager'" from the database. The system will generate a SQL query statement (target text content) that meets the requirements based on the natural language question (task description) entered by the user and the required SQL format (target format).

[0069] User input includes task description and target format, where the task description is "Please provide information on all employees whose age is greater than 30 and whose position is 'Manager'." The format requirement is that the output result is a query statement that conforms to SQL syntax, that is, the target format is SQL format.

[0070] The system workflow includes the following steps: 1. User input and format requirement processing: The system receives the user's natural language question, that is, the task description: "Please provide information about all employees whose age is greater than 30 and whose position is 'manager'." The system also receives the output format required by the user, that is, the target format: "SQL format".

[0071] 2. In the joint generation and discrimination architecture, the generation model generates initial text content through the task description and target format (SQL format). Specifically, it generates SQL query statements that meet the task requirements based on the Qwen large language model.

[0072] The generated SQL query statement (initial text content) may be: SELECT * FROM employees WHERE age>30 AND position = 'Manager'; In the joint generation and discrimination architecture, the discrimination model receives the SQL query statement and target format (SQL format) generated by the generation model. The model is fine-tuned based on the BERT pre-trained model to check whether the SQL query statement conforms to the SQL grammar rules.

[0073] The discriminant model verifies the generated SQL statements. The output verification results include the following two cases.

[0074] Conforms to format: If the generated SQL query statement (initial text content) conforms to the SQL syntax, the discriminant model returns "conforms to format".

[0075] Not in conformity with format: If the generated SQL query statement (initial text content) has a syntax error or does not conform to the format requirements (such as missing a keyword or incorrect conditions), the discriminant model returns "Not in conformity with format".

[0076] 3. Feedback and optimization: If the generated SQL query statement (initial text content) is identified as "not in conformity with the format" by the discrimination model, the system will pass feedback information to the generation model, requiring the generation model to regenerate a SQL query statement that conforms to the format. The system continues to optimize the generated SQL query statement until the SQL query statement meets the format requirements, that is, conforms to the target format.

[0077] 4. Output results: Once the discriminant model confirms that the generated SQL query statement (initial text content) conforms to the target format, the system determines the initial text content as the target text content and outputs the target text content as the final result. The output target text content is shown below.

[0078] SELECT * FROM employees WHERE age>30 AND position = 'Manager'; Corresponding to the above-mentioned embodiment, the present invention also provides a device for generating text that meets format requirements based on a large model. Figure 3A structural diagram of a device for generating text that meets format requirements based on a large model provided in an embodiment of the present invention, the device may include: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, so that the at least one processor can execute the method for generating text that meets format requirements based on a large model as described in the above embodiment.

[0079] In one possible implementation of the present invention, the at least one processor is capable of executing, obtaining a task description and a target format; inputting the task description and the target format into a generation model to obtain initial text content; inputting the initial text content and the target format into a discrimination model to determine whether the initial text content meets the target format; if so, determining the initial text content as the target text content, and outputting the target text content; if not, repeating the above process until the initial text content meets the target format.

[0080] In a specific implementation, the present invention can also be provided as a non-volatile computer storage medium, wherein the storage medium is a non-volatile computer-readable storage medium, and the non-volatile computer-readable storage medium stores at least one program, each program includes instructions, and when the instructions are executed by a terminal, the terminal executes the method for generating a text that meets the format requirements based on a large model as described in the above embodiment.

[0081] In a possible implementation of the present invention, the aforementioned terminal executes to obtain a task description and a target format; the task description and the target format are input into a generation model to obtain initial text content; the initial text content and the target format are input into a discrimination model to determine whether the initial text content meets the target format; if so, the initial text content is determined as the target text content, and the target text content is output; if not, the above process is repeated until the initial text content meets the target format.

[0082] The various embodiments of the present invention are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0083] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0084] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for generating text that meets format requirements based on a large model, characterized in that: The method comprises: Get the task description and target format; Inputting the task description and target format into the generation model to obtain initial text content; Inputting the initial text content and the target format into a discriminant model to determine whether the initial text content satisfies the target format; If yes, the initial text content is determined as the target text content, and the target text content is output; If not, the above process is repeated until the initial text content meets the target format.

2. The method for generating text that meets format requirements based on a large model according to claim 1, characterized in that: Before inputting the task description and the target format into the generation model to obtain the initial text content, the method further includes: Determining a maximum likelihood estimation loss as a loss function of the generative model; The generative model is trained based on the loss function of the generative model.

3. The method for generating text that meets format requirements based on a large model according to claim 1, characterized in that: The task description and target format are input into the generation model to obtain the initial text content, including: The task description and the target format are input into a large language model to obtain initial text content, wherein the large language model includes at least one of GPT, T5 and Qwen.

4. The method for generating text that meets format requirements based on a large model according to claim 1, characterized in that: Before inputting the initial text content and the target format into the discriminant model to determine whether the initial text content satisfies the target format, the method further includes: Determining a cross entropy loss function as a loss function of the discriminant model; The discriminant model is trained based on the loss function of the discriminant model.

5. The method for generating text that meets format requirements based on a large model according to claim 1, characterized in that: Inputting the initial text content and the target format into a discriminant model to determine whether the initial text content satisfies the target format includes: The initial text content and the target format are input into a deep learning-based classification model to determine whether the initial text content meets the target format.

6. The method for generating text that meets format requirements based on a large model according to claim 5, characterized in that: Before inputting the initial text content and the target format into a deep learning-based classification model to determine whether the initial text content satisfies the target format, the method further includes: Based on the target format, the pre-trained large language model is fine-tuned to obtain the deep learning-based classification model, the pre-trained large language model includes at least one of BERT and RoBERTa, and the target format includes at least one of JSON format and SQL format.

7. The method for generating text that meets format requirements based on a large model according to claim 1, characterized in that: Before inputting the task description and the target format into the generation model to obtain the initial text content, the method further includes: The generation model and the discrimination model are trained together by joint optimization.

8. The method for generating text that meets format requirements based on a large model according to claim 7, characterized in that: The generative model and the discriminative model are jointly trained by means of joint optimization, including: Determine a joint loss function based on the loss function of the generative model and the loss function of the discriminative model; Based on the joint loss function, the generative model and the discriminative model are jointly trained.

9. A device for generating text conforming to format requirements based on a large model, characterized in that: The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, so that the at least one processor can execute the method for generating text that meets format requirements based on a large model according to any one of claims 1-8.

10. A non-volatile computer storage medium, characterized in that: The storage medium is a non-volatile computer-readable storage medium, which stores at least one program, each of which includes instructions, and when the instructions are executed by the terminal, the terminal executes the method for generating text that meets format requirements based on a large model according to any one of claims 1-8.

Citation Information

Patent Citations

  • Controllable generation method and device

    CN117077653A

  • Text display method and device, computer equipment and storage medium

    CN117369920A

  • Method for controlling model to output structured data

    CN117933234A

  • Picture object processing method and performance determination method and device of picture processing model

    CN119181084A

  • SQL (Structured Query Language) statement generation method and device based on large language model, equipment and medium

    CN119201966A