Language large model updating method and device and structured content generating method and device

By comparing the parameters of the language model in structured output and unstructured output, and determining and updating the structured key parameters, the problem that the language model cannot stably output customized format content is solved, and the stability and convenience of model structured generation is achieved.

CN119831029APending Publication Date: 2025-04-15CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411672801.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

Current language models cannot stably output customized format content. Zero-Shot and Few-Shot methods are difficult to ensure accuracy when the model is small in size. In addition, the fine-tuning method of large-scale models requires a large amount of data and computing resources, which may lead to model overfitting and reducing generalization capabilities.

Method used

By obtaining the model parameters of the language model in structured output and unstructured output, comparing the two to determine the structured key parameters, and updating the model to obtain the target language model so that it can output structured content stably.

Benefits of technology

It reduces the difficulty of user prompt engineering design, and adaptively identify the structured key parameters in the large model by a small amount of comparison data, so as to achieve stable progress of model structured generation without the need for a large amount of high-quality labeled data for fine-tuning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119831029A_ABST
    Figure CN119831029A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a large language model updating method and device and a structured content generation method and device, and relates to the technical field of natural languages, and the large model updating method comprises the following steps: obtaining a first model parameter of a large language model during structured output and a second model parameter of the large language model during unstructured output; comparing the first model parameter with the second model parameter to determine a structured key parameter of the large language model, the structured key parameter being a differentiated model parameter representing the large language model between structured output and unstructured output; based on the structured key parameters, structured generation parameters of the large language model are determined, and the structured generation parameters are model parameters influencing a final layer vector structured format of the large language model; and based on the structured generation parameter and the structured generation parameter, updating the language large model to obtain a target language large model. According to the method and the device, the target language large model can be stably output in a structured manner for each structured format problem.
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 technology, and in particular to a language large model updating method, a structured content generating method, a language large model updating device and a structured content generating device. Background Art

[0002] The generation capability of the language big model is an artificial intelligence application based on deep learning technology, which can understand user input and answer corresponding questions. At present, most big models use the decoder structure, which encodes the input content and outputs the corresponding answer word by word. In different application scenarios, users need the big model to output content in different formats to meet application needs. Usually, the big model can understand user needs and complete customized output, but in most cases, the big model can only answer the corresponding questions and cannot output the corresponding format according to the user's requirements.

[0003] In order to customize the output of large models, prompt engineering is commonly used. Among them, the Zero-Shot method explains the task content through instruction description, so that the large model can understand user needs and output customized formats. However, when the model scale is small, the accuracy of the Zero-Shot method is often difficult to guarantee, and it is impossible to stably output the format expected by the user. The Few-Shot method provides a small number of examples in the input content to assist the model in understanding the requirements and guide customized output. However, when faced with complex tasks, the Few-Shot method also has limitations and cannot guarantee that large models can stably output customized formats.

[0004] To address the above challenges, current technologies use a large model fine-tuning method. This method constructs a dataset for a specific task and fine-tunes the large model to obtain model parameters that are more suitable for the current task. The fine-tuned model can stably output customized content under specific tasks. However, this fine-tuning method not only requires a large amount of data and computing resources, but also may cause the model to overfit, thereby reducing its generalization ability. Summary of the invention

[0005] The embodiment of the present invention provides a language large model updating method, structured content generating method and device to solve the problem that the current large model cannot stably output customized format content.

[0006] The embodiment of the present invention discloses a method for updating a large language model, comprising:

[0007] Obtaining a first model parameter of the language large model when the language large model is structured output and a second model parameter of the language large model when the language large model is unstructured output;

[0008] Comparing the first model parameter with the second model parameter to determine structural key parameters of the language model, wherein the structural key parameters are differential model parameters that characterize the language model between structured output and unstructured output;

[0009] Based on the structured key parameters, determining the structured generation parameters of the language model, wherein the structured generation parameters are model parameters that affect the structured format of the final layer vector of the language model;

[0010] Based on the structured generation parameters and the structured generation parameters, the language large model is updated to obtain a target language large model.

[0011] In some embodiments, comparing the first model parameter with the second model parameter to determine the structural key parameters of the language large model includes:

[0012] For each parameter position of the large language model, a first mean and a variance value of a difference between the first model parameter and the second model parameter are calculated, wherein the first model parameter includes a plurality of first sub-parameters corresponding to the plurality of parameter positions of the large language model when structured output is performed for a plurality of question data respectively, and the second model parameter includes a plurality of second sub-parameters corresponding to the plurality of parameter positions of the large language model when unstructured output is performed for a plurality of question data respectively;

[0013] The first means corresponding to several parameter positions whose first means are greater than a preset value and whose variance values ​​are the smallest are used as the structural key parameters.

[0014] In some embodiments, calculating a first mean and a variance of a difference between the first model parameter and the second model parameter for each parameter position of the large language model includes:

[0015] Calculating a difference between the first sub-parameter and the second sub-parameter based on the plurality of first sub-parameters and the plurality of second sub-parameters corresponding to the parameter position;

[0016] Based on all the differences corresponding to the parameter position, the mean and variance of the differences are calculated to obtain a first mean and variance corresponding to the parameter position.

[0017] In some embodiments, determining the structural generation parameters of the language large model based on the structural key parameters includes:

[0018] Based on the structured key parameters, updating the language macro model to obtain an intermediate language macro model;

[0019] Obtaining a first final layer vector of the intermediate language large model when outputting in a structured manner and a second final layer vector of the intermediate language large model when outputting in an unstructured manner;

[0020] Based on the first final layer vector and the second final layer vector, structured generation parameters of the language large model are determined.

[0021] In some embodiments, determining the structured generation parameters of the language large model based on the first final layer vector and the second final layer vector includes:

[0022] Calculating a second mean of the difference between the first final layer vector and the second final layer vector, the first final layer vector includes a plurality of vectors corresponding to when the intermediate language large model performs structured output for a plurality of question data respectively, and the second model parameter includes a plurality of vectors corresponding to when the language large model performs unstructured output for a plurality of question data respectively;

[0023] The second mean is used as a structured generation parameter of the large language model.

[0024] In some embodiments, the updating of the language large model based on the structured generation parameter and the structured generation parameter to obtain the target language large model includes:

[0025] Based on the structured generation parameters, the model weights of the language large model are updated, and based on the structured generation parameters, the final layer of the language large model is updated to obtain the target language large model.

[0026] In some embodiments, the step of obtaining a first model parameter of the language large model in structured output and a second model parameter of the language large model in unstructured output includes:

[0027] The structured question and answer data and the unstructured question and answer data are respectively input into the language big model, and the model parameters in the language big model are monitored to obtain the first model parameters when the language big model performs structured output for the structured question and answer data, and obtain the second model parameters when the language big model performs unstructured output for the unstructured question and answer data. The structured question and answer data are data that require the language big model to perform structured output for the target question content, and the unstructured question and answer data are data that do not require the language big model to perform structured output for the target question content.

[0028] The embodiment of the present invention also provides a structured content generation method, comprising:

[0029] Obtain question data, and process the question data based on a target language big model, and output structured format answer data corresponding to the question data, wherein the target language big model is a target language big model updated based on the above-mentioned big model updating method.

[0030] The embodiment of the present invention also provides a language large model updating device, including:

[0031] A first acquisition module is used to acquire structured output data and unstructured output data of the language large model;

[0032] A comparison module, used for comparing the structured output data and the unstructured output data to determine the structured key parameters of the language model, wherein the structured key parameters are model parameters that characterize the difference between the structured output and the unstructured output in the language model;

[0033] A determination module, configured to determine, based on the structured key parameters, structured generation parameters of the language model, wherein the structured generation parameters are model parameters that affect the structured format of the final layer vector of the language model;

[0034] An updating module is used to update the language macromodel based on the structured generation parameters and the structured generation parameters to obtain a target language macromodel.

[0035] The embodiment of the present invention further provides a structured content generating device, comprising:

[0036] The second acquisition module is used to acquire problem data;

[0037] The output module is used to process the question data based on the target language big model and output the structured format answer data corresponding to the question data. The target language big model is the target language big model updated based on the above-mentioned big model updating method.

[0038] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0039] The memory is used to store computer programs;

[0040] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.

[0041] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.

[0042] The embodiments of the present invention include the following advantages:

[0043] The present invention obtains a first model parameter of a language large model during structured output and a second model parameter during unstructured output, and compares the first model parameter with the second model parameter to determine the structured key parameter of the language large model, wherein the structured key parameter is a differential model parameter characterizing the structured output and the unstructured output of the language large model, thereby identifying the model parameter in the model structure of the language large model whose parameter changes significantly during structured output, that is, finding the model parameter in the language large model that affects the structured output; then, based on the structured key parameter, determining the structured generation parameter of the language large model, wherein the structured generation parameter is a model parameter that affects the structured format of the final layer vector of the language large model, so as to determine the specific value of the structured key parameter corresponding to each structured format problem; based on the structured generation parameter and the structured generation parameter, updating the language large model to obtain the target language large model, so that the target language large model can stably structure output for each structured format problem.

[0044] Compared with the Zero-Shot method, the Few-Shot method and the large model fine-tuning method, the present invention reduces the difficulty of user prompt engineering design. Different structured generation parameters can be selected according to the required generation format to make the structured output more stable. This method does not require a large amount of high-quality annotation data required for fine-tuning. For different models, a small amount of comparative data can be used to adaptively identify the key structured parameters in the large model, thereby achieving stable model structured generation from an engineering perspective. In addition, the present invention requires different structured content generation parameters. When the final layer vector generates content, different structured generation parameters are additionally added to enable the model to generate content with different structures, making it more convenient for users to obtain the required output format. In addition, the present invention can be used as a plug-and-play plug-in, so that large models of different scales can output structured content without modifying prompts or fine-tuning, which greatly improves the convenience of user use. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 is a flow chart of the steps of a method for updating a large language model provided in an embodiment of the present invention;

[0046] Figure 2 is a schematic diagram of a process for obtaining structured key parameters provided in an embodiment of the present invention;

[0047] Figure 3 is a schematic diagram of a flow chart of obtaining structured generation parameters provided in an embodiment of the present invention;

[0048] Figure 4is a schematic diagram of a flow chart of structured content generation provided in an embodiment of the present invention;

[0049] Figure 5 is a flowchart of a method for generating structured content provided in an embodiment of the present invention;

[0050] Figure 6 It is a structural block diagram of a language large model updating device provided in an embodiment of the present invention;

[0051] Figure 7 It is a structural block diagram of a structured content generating device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0053] As described in the background technology, the Zero-Shot method uses instruction description, for example:

[0054] Input: "Please extract the date, location, and event content from the following text and return it in JSON format. The text is February 5, 2024, the marathon event held in Shanghai went smoothly."

[0055] Output: "{'Date':'February 5, 2024','Location':'Shanghai','Event':'Marathon'}"

[0056] This method requires the large model to have sufficient computing power to complete customized output according to user requirements. When the model size is small, it is difficult to understand user needs.

[0057] The Few-Shot method allows large models to output in a fixed format, and users can provide a small number of examples in the input content to guide the model output. For example:

[0058] Input: "Please extract the date, location and event content from the following text and return it in JSON format.

[0059] Here are a few examples:

[0060] Text: In October 2013, a National Day gathering was held in Chaoyang District, Beijing.

[0061] Output: {'Date':'October 2013', 'Location':'Chaoyang District, Beijing', 'Activity':'National Day Gathering'}

[0062] Text: The next furniture expo will be held in Guangzhou. Citizens are welcome to attend in May this year.

[0063] Output: {'Date':'May this year', 'Location':'Guangzhou', 'Event':'Furniture Fair'}

[0064] Text: On February 5, 2024, the marathon event held in Shanghai went smoothly. ”

[0065] Output: "{'Date':'February 5, 2024','Location':'Shanghai','Event':'Marathon'}"

[0066] The model can assist in understanding based on the examples given by the user, and output in a customized format. However, when the task is complex, the few-shot method cannot make the large model stably output the required format. The large model fine-tuning method can solve the problem of complex tasks. By constructing a dataset for a specific task, the large model is fine-tuned to obtain model parameters that are more suitable for the current task, so that the model can output stably in the current mode. However, the large model fine-tuning method requires some carefully labeled data and training resources, which is difficult for most users.

[0067] To this end, an embodiment of the present invention proposes a language large model update method, which serves as a plug-and-play plug-in, so that large models of different scales can output structured content without modification prompts or fine-tuning, greatly improving user convenience.

[0068] Reference Figure 1 , Figure 1 A flowchart of a method for updating a large language model provided in an embodiment of the present invention is shown, which may specifically include steps S101 to S014, which are described in detail as follows:

[0069] Step S101, obtaining a first model parameter of a large language model in structured output and a second model parameter in unstructured output.

[0070] In this step, the language model is an algorithmic model based on artificial intelligence technology, which is specially designed to understand and generate natural language text. These models can capture the complexity and nuances of language through learning from a large amount of text data, and thus perform well in a variety of applications, such as text generation, machine translation, dialogue systems, content summarization, sentiment analysis, etc. The language model is composed of a stack of Transformer structure layers with an encoder structure. Models of different scales have different numbers of Transformer layers and attention heads. Transformer is a neural network architecture with a self-attention mechanism, which mainly consists of two parts: encoder and decoder. 1) Encoder: Receives the input text sequence and processes it through multiple layers of self-attention mechanism and feedforward neural network. The self-attention mechanism allows the model to focus on different parts of the input sequence to better understand the semantic and contextual information. Each layer of self-attention mechanism produces a vector representation, which is passed to the next layer after the feedforward neural network. 2) Decoder: Receives the vector representation generated by the encoder and generates an output text sequence. The decoder also uses the self-attention mechanism and feedforward neural network, but unlike the encoder, it also needs to consider the generated part of the output to ensure the coherence and consistency of the generated text.

[0071] For a question content, when it is input into the language model with different requirements, there are certain differences in the processing of the question content by the language model, specifically the difference in model parameters. For example, for the question content of information extraction, when the unstructured output requirements of "Please extract the date, place and activity content in the following text, and the marathon event held in Shanghai on February 5, 2024 went smoothly." and the structured output requirements of "Please extract the date, place and activity content in the following text, and the marathon event held in Shanghai on February 5, 2024 went smoothly. Output in json format." are respectively input into the language model, when the speech model processes these two requirements, the model structure has differences in different parameter positions, so the present invention obtains the first model parameters of the language model in structured output and the second model parameters in unstructured output. The first model parameters include multiple model parameters corresponding to different parameter positions of the model structure when the large language model performs structured output, and there is a set of model parameters corresponding to each of the different formatted question contents; the second model adoption number includes multiple model parameters corresponding to different parameter positions of the model structure when the large language model performs unstructured output, and there is a set of model parameters corresponding to each of the different unformatted question contents.

[0072] Step S102, comparing the first model parameter with the second model parameter to determine the structural key parameters of the language model, where the structural key parameters are differential model parameters that characterize the language model between structured output and unstructured output.

[0073] In this embodiment, the structured key parameter is a model parameter corresponding to a parameter position in the model structure that affects the structured output of the language model, and specifically can be a model parameter of a hidden layer. Optionally, for each parameter position in the language model, the difference between the first model parameter and the second model parameter is calculated, and then several parameter positions with large differences are used as the structured key parameter. Optionally, the difference between the first model parameter and the second model parameter can be compared by subtraction, or by division, or by other preset functions.

[0074] This embodiment compares the first model parameters with the second model parameters to screen out model parameters of several parameter positions that have a greater impact on the structured output of the large language model, thereby facilitating the updating of these model parameters, so that the large language model can adapt to the generation of structured content for complex tasks in a variety of structured formats.

[0075] Step S103: determining the structural generation parameters of the language model based on the structural key parameters, wherein the structural generation parameters are model parameters that affect the structural format of the final layer vector of the language model.

[0076] In this step, the structured generation parameters are model parameters that directly affect the generation of structured content by the language model. The final layer vector is the vector of the output layer of the language model. Optionally, the language model is updated by the structured key parameters, and the updated language model is used to output the problem data in a structured and unstructured manner, thereby further confirming the model parameters corresponding to the structured format of the final layer vector.

[0077] Step S104: based on the structured generation parameters and the structured generation parameters, the language macro model is updated to obtain a target language macro model.

[0078] In this step, the structured generation parameters are updated to the weights of the large language model, and the structured generation parameters are updated to the final layer vector of the large language model. Compared with the Zero-Shot method, the Few-Shot method and the large model fine-tuning method, the present invention reduces the difficulty of user prompts for engineering design, and different structured generation parameters can be selected according to the required generation format to make the structured output more stable. This method does not require a large amount of high-quality annotation data required for fine-tuning. For different models, a small amount of comparative data can be used to adaptively identify the key structured parameters in the large model, thereby achieving stable model structured generation from an engineering perspective. In addition, the present invention requires different structured generation parameters for different structured content generation requirements. When the final layer vector generates content, different structured generation parameters are additionally added to enable the model to generate content with different structures, making it more convenient for users to obtain the required output format.

[0079] In some embodiments, the step S101 includes:

[0080] The structured question and answer data and the unstructured question and answer data are respectively input into the language big model, and the model parameters in the language big model are monitored to obtain the first model parameters when the language big model performs structured output for the structured question and answer data, and obtain the second model parameters when the language big model performs unstructured output for the unstructured question and answer data. The structured question and answer data are data that require the language big model to perform structured output for the target question content, and the unstructured question and answer data are data that do not require the language big model to perform structured output for the target question content.

[0081] In this embodiment, the language model contains a large number of model parameters, and it is usually difficult to determine the role of each parameter in generating the task. The current Qwen-1.8b model contains 1.8 billion parameters, and each model parameter works together to generate the questions required by the user. For the structured output of the language model, only some model parameters are involved in the work of structured output, so by finding these model parameters, the model output can be customized.

[0082] The difference between structured question-answer data and unstructured question-answer data is whether the answers use the corresponding structured format. For example, five sets of question-answer pairs (each set of question-answer pairs specifically contains multiple question-answer pairs) are used to obtain the structured parameters of the hidden layer of the model. Each set of question-answer pairs is responsible for a structured output, and the structured output includes json format, list, markdown, line break and sequence number, etc. For example, in the question-answer pair in json format, input the unstructured question "Please extract the date, location and activity content from the following text. On February 5, 2024, the marathon event held in Shanghai went smoothly." to the language model, and make the language model output the unstructured answer: "February 5, 2024, Shanghai, marathon event", and the structured question: "Please extract the date, location and activity content from the following text. On February 5, 2024, the marathon event held in Shanghai went smoothly. Output in json format.", and make the language model output the structured answer: {'date':'February 5, 2024', 'location':'Shanghai', 'activity':'marathon'}, monitor all model parameters in the language model, and let represents the model parameters corresponding to the structured output of the i-th question pair in the k-th group of questions (including the model parameters corresponding to multiple parameter positions in the hidden layer), It represents the model parameters corresponding to the structured output of the i-th question pair in the k-th group of questions (including the model parameters corresponding to multiple parameter positions in the hidden layer).

[0083] In some embodiments, the step S102 includes:

[0084] For each parameter position of the large language model, a first mean and a variance value of a difference between the first model parameter and the second model parameter are calculated, wherein the first model parameter includes a plurality of first sub-parameters corresponding to the plurality of parameter positions of the large language model when structured output is performed for a plurality of question data respectively, and the second model parameter includes a plurality of second sub-parameters corresponding to the plurality of parameter positions of the large language model when unstructured output is performed for a plurality of question data respectively;

[0085] The first means corresponding to several parameter positions whose first means are greater than a preset value and whose variance values ​​are the smallest are used as the structural key parameters.

[0086] In this embodiment, the preset value can be preset according to actual conditions, for example, the preset value is 1. Several parameter positions can be set according to the ratio of the total number of parameter positions, for example, the number of position parameters is 25% of the total number of parameter positions.

[0087] Optionally, calculating a first mean and a variance of a difference between the first model parameter and the second model parameter for each parameter position of the large language model includes:

[0088] Calculating a difference between the first sub-parameter and the second sub-parameter based on the plurality of first sub-parameters and the plurality of second sub-parameters corresponding to the parameter position;

[0089] Based on all the differences corresponding to the parameter position, the mean and variance of the differences are calculated to obtain a first mean and variance corresponding to the parameter position.

[0090] In this embodiment, the first model parameter obtained in the above step S101 includes the model parameter corresponding to the large language model when the i-th question pair in the k-th group of questions is structured output, and the model parameter includes the first sub-parameter corresponding to multiple parameter positions in the hidden layer; the second model parameter includes the model parameter corresponding to the large language model when the i-th question pair in the k-th group of questions is structured output, and the model parameter includes the second sub-parameter corresponding to multiple parameter positions in the hidden layer. Therefore, after the large language model outputs multiple question data, each parameter position corresponds to multiple groups of first sub-parameters and second sub-parameters, then for a certain parameter position, the difference between the first sub-parameter and the second sub-parameter in each group can be calculated to obtain multiple differences at the parameter position, and then the first mean and variance values ​​of all differences are calculated, and the first mean and variance values ​​of all parameter positions can be obtained.

[0091] For example, Figure 2 As shown, the structured question-answer pairs "prompt: Please extract the date, location and activity content from the following text. On February 5, 2024, the marathon event held in Shanghai went smoothly." and "Answer: February 5, 2024, Shanghai, marathon event", as well as the unstructured question-answer pairs "prompt: Please extract the date, location and activity content from the following text. On February 5, 2024, the marathon event held in Shanghai went smoothly. Output in json format" and "Answer: {'date':'February 5, 2024', 'location':'Shanghai', 'activity':'marathon'}" are input into the language model to obtain the first model parameter P and the second model parameter P'; wherein for a parameter position j of the hidden layer of the language model, it includes multiple groups and For each group and Calculate the difference between the two Calculate multiple groups and The first mean mean(j) and variance var(j) of all corresponding differences are obtained, and the first mean and variance of each parameter position are obtained; from all parameter positions, the first mean corresponding to the parameter position with a mean greater than 1 and ranked in the top 25% with the smallest variance is selected as the structural key parameter, denoted as struct(P).

[0092] Update the values ​​of the structured key parameters as follows:

[0093]

[0094] In some embodiments, the step S103 includes:

[0095] Based on the structured key parameters, updating the language macro model to obtain an intermediate language macro model;

[0096] Obtaining a first final layer vector of the intermediate language large model when outputting in a structured manner and a second final layer vector of the intermediate language large model when outputting in an unstructured manner;

[0097] Based on the first final layer vector and the second final layer vector, structured generation parameters of the language large model are determined.

[0098] In this embodiment, the content generation of the language large model is actually a decoding process, which can be understood as obtaining the final layer vector after encoding the multi-layer structure of the model. The decoding stage generates word by word according to the final layer vector until the terminator is generated. The calculation process can be expressed as follows:

[0099] x n =f(x1, x2, ..., x n-1 );

[0100] Generate x n The probability of f(x n |x1,x2,...,x n-1 ). In the generation phase, adding different structured generation parameters to the final layer vector can adjust the generation probability in the decoding phase, so that the model can generate structured content according to the structured requirements.

[0101] Exemplarily, the process of updating the language big model with structured key parameters to obtain the intermediate language big model is: for the several parameter positions determined in the above step 102, the corresponding parameter positions are updated, and the updating process can be: Where P is the original weight.

[0102] Optionally, determining the structured generation parameters of the large language model based on the first final layer vector and the second final layer vector includes:

[0103] Calculating a second mean of the difference between the first final layer vector and the second final layer vector, the first final layer vector includes a plurality of vectors corresponding to when the intermediate language large model performs structured output for a plurality of question data respectively, and the second model parameter includes a plurality of vectors corresponding to when the language large model performs unstructured output for a plurality of question data respectively;

[0104] The second mean is used as a structured generation parameter of the large language model.

[0105] In this embodiment, if Figure 3 As shown, the structured key parameters are updated to the model weights of the language model, and then multiple pairs of question data in structured formats are input into the intermediate language model. For example, "prompt: Please extract the date, location and event content from the following text. On February 5, 2024, the marathon event held in Shanghai went smoothly." and "prompt: Please extract the date, location and event content from the following text. On February 5, 2024, the marathon event held in Shanghai went smoothly. Output in json format" are input into the intermediate large model to obtain the first final layer vector F1 corresponding to the structured output of each question data by the language model and the second final layer vector F2 corresponding to the unstructured output of each question data. F1 includes multiple F2 includes multiple represents the first final layer vector corresponding to the i-th pair of questions in the k-th group of questions, represents the second final layer vector corresponding to the i-th question pair of the k-th group of questions. The mean of the difference between the first final layer vector and the second final layer vector of all question pairs in the current group is calculated as F x , as the structured generation parameter for the x-th structured format.

[0106] In some embodiments, the step S104 includes:

[0107] Based on the structured generation parameters, the model weights of the language large model are updated, and based on the structured generation parameters, the final layer of the language large model is updated to obtain the target language large model.

[0108] In this embodiment, the structured key parameters are updated to the model weights. Assuming that the original weight is P, the structured key parameter is struct(P), and the updated weight is

[0109] In order to return the result of the language model in JSON format, in the generation phase, a structured generation parameter is added to the final layer vector, thereby changing the final layer vector of the language model to x2 = f(x1 + Fk ), the generation probability is f(x2|x1+F k ). With the original weights, the model first generates the answer, while the model with the added structural parameters first generates '{'.

[0110] This invention improves interpretability and controllability: Large models have powerful generation capabilities, but their internal working principles are often difficult to understand and explain. Through the structured output method, the output of the model can be controlled more accurately.

[0111] This invention improves performance and efficiency: Structured output methods can help models perform better on specific tasks. For example, in question-answering systems, structured output can directly link answers to information related to questions, thereby improving the accuracy and completeness of answers.

[0112] The present invention makes it clearer for users to understand: The structured output method can make the output of the model clearer, more concise and easier to understand. For example, in medical diagnosis, structured output can organize information such as symptoms, diseases and treatment plans into a hierarchical structure, making it easier for users to grasp this knowledge.

[0113] The present invention reduces the complexity of operation and improves stability: by calling a structured output plug-in, the complexity of the user usage prompt project is simplified, while avoiding the fine-tuning process that requires a lot of resources and ensuring that the model is output in a stable format.

[0114] See also Figure 5 , Figure 5 A flow chart of a method for generating structured content provided by an embodiment of the present invention is shown, and the method includes:

[0115] Step S501, obtaining question data;

[0116] Step S502, based on the target language big model, the question data is processed, and structured format answer data corresponding to the question data is output, wherein the target language big model is the target language big model updated based on the above-mentioned language big model updating method.

[0117] In this embodiment, if Figure 4 As shown, the question data prompt: Please extract the date, location and event content from the following text. On February 5, 2024, the marathon event held in Shanghai went smoothly. " is input into the target language big model, and the structured format reply data "{'date':'February 5, 2024','location':'Shanghai','event':'marathon'}" is output.

[0118] By adopting the above-mentioned large model of the target language, stable structured output can be performed for each structured format problem.

[0119] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0120] Reference Figure 6 , Figure 6 The structure block diagram of a language large model updating device provided in an embodiment of the present invention is shown, which may specifically include the following modules:

[0121] A first acquisition module 601 is used to acquire structured output data and unstructured output data of a large language model;

[0122] A comparison module 602 is used to compare the structured output data and the unstructured output data to determine the structured key parameters of the language model, where the structured key parameters are model parameters that characterize the difference between the structured output and the unstructured output in the language model;

[0123] A determination module 603 is used to determine the structured generation parameters of the language model based on the structured key parameters, wherein the structured generation parameters are model parameters that affect the structured format of the final layer vector of the language model;

[0124] The updating module 604 is used to update the language large model based on the structured generation parameters and the structured generation parameters to obtain the target language large model.

[0125] In some embodiments, the comparison module 602 includes:

[0126] a calculation unit, configured to calculate, for each parameter position of the large language model, a first mean and a variance value of a difference between the first model parameter and the second model parameter, wherein the first model parameter comprises a plurality of first sub-parameters corresponding to the plurality of parameter positions of the large language model when structured output is performed for a plurality of question data respectively, and the second model parameter comprises a plurality of second sub-parameters corresponding to the plurality of parameter positions of the large language model when unstructured output is performed for a plurality of question data respectively;

[0127] A configuration unit is used to use the first mean values ​​corresponding to several parameter positions whose first mean values ​​are greater than a preset value and whose variance values ​​are the smallest as the structural key parameters.

[0128] In some embodiments, the first computing unit is specifically configured to:

[0129] Calculating a difference between the first sub-parameter and the second sub-parameter based on the plurality of first sub-parameters and the plurality of second sub-parameters corresponding to the parameter position;

[0130] Based on all the differences corresponding to the parameter position, the mean and variance of the differences are calculated to obtain a first mean and variance corresponding to the parameter position.

[0131] In some embodiments, the determining module 603 includes:

[0132] An updating unit, configured to update the language macromodel based on the structured key parameters to obtain an intermediate language macromodel;

[0133] An acquisition unit, used for acquiring a first final layer vector of the intermediate language large model in structured output and a second final layer vector in unstructured output;

[0134] A determination unit is used to determine a structured generation parameter of the language large model based on the first final layer vector and the second final layer vector.

[0135] In some embodiments, the determining unit is specifically configured to:

[0136] Calculating a second mean of the difference between the first final layer vector and the second final layer vector, the first final layer vector includes a plurality of vectors corresponding to when the intermediate language large model performs structured output for a plurality of question data respectively, and the second model parameter includes a plurality of vectors corresponding to when the language large model performs unstructured output for a plurality of question data respectively;

[0137] The second mean is used as a structured generation parameter of the large language model.

[0138] In some embodiments, the updating module 604 is specifically configured to:

[0139] Based on the structured generation parameters, the model weights of the language large model are updated, and based on the structured generation parameters, the final layer of the language large model is updated to obtain the target language large model.

[0140] In some embodiments, the first acquisition module 601 is specifically used to:

[0141] The structured question and answer data and the unstructured question and answer data are respectively input into the language big model, and the model parameters in the language big model are monitored to obtain the first model parameters when the language big model performs structured output for the structured question and answer data, and obtain the second model parameters when the language big model performs unstructured output for the unstructured question and answer data. The structured question and answer data are data that require the language big model to perform structured output for the target question content, and the unstructured question and answer data are data that do not require the language big model to perform structured output for the target question content.

[0142] Reference Figure 7 , Figure 7 The structure block diagram of a structured content generation device provided in an embodiment of the present invention is shown, which may specifically include the following modules:

[0143] The second acquisition module 701 is used to acquire problem data;

[0144] The output module 702 is used to process the question data based on the target language big model and output the structured format answer data corresponding to the question data. The target language big model is the target language big model updated based on the above-mentioned language big model updating method.

[0145] As 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.

[0146] An embodiment of the present invention further provides an electronic device, including:

[0147] one or more processors; and

[0148] One or more machine-readable media having instructions stored thereon, when executed by the one or more processors, enable the electronic device to perform the method described in the embodiment of the present invention.

[0149] An embodiment of the present invention further provides a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.

[0150] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0151] It should be understood by those skilled in the art that the embodiments of the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, EEPROM, Flash, and eMMC, etc.) containing computer-usable program codes.

[0152] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0153] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0154] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable terminal device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0155] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0156] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal 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, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0157] The above is a detailed introduction to a language large model updating method, a structured content generating method, a language large model updating device and a structured content generating device provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for updating a large language model, characterized in that: include: Obtaining a first model parameter of the language large model when the language large model is structured output and a second model parameter of the language large model when the language large model is unstructured output; Comparing the first model parameter with the second model parameter to determine structural key parameters of the language model, wherein the structural key parameters are differential model parameters that characterize the language model between structured output and unstructured output; Based on the structured key parameters, determining the structured generation parameters of the language model, wherein the structured generation parameters are model parameters that affect the structured format of the final layer vector of the language model; Based on the structured generation parameters and the structured generation parameters, the language large model is updated to obtain a target language large model.

2. The language model updating method according to claim 1, characterized in that: The comparing the first model parameter with the second model parameter to determine the structural key parameters of the language large model includes: For each parameter position of the large language model, a first mean and a variance value of a difference between the first model parameter and the second model parameter are calculated, wherein the first model parameter includes a plurality of first sub-parameters corresponding to the plurality of parameter positions of the large language model when structured output is performed for a plurality of question data respectively, and the second model parameter includes a plurality of second sub-parameters corresponding to the plurality of parameter positions of the large language model when unstructured output is performed for a plurality of question data respectively; The first means corresponding to several parameter positions whose first means are greater than a preset value and whose variance values ​​are the smallest are used as the structural key parameters.

3. The language model updating method according to claim 2, characterized in that: The step of calculating a first mean and a variance of a difference between the first model parameter and the second model parameter for each parameter position of the large language model comprises: Calculating a difference between the first sub-parameter and the second sub-parameter based on the plurality of first sub-parameters and the plurality of second sub-parameters corresponding to the parameter position; Based on all the differences corresponding to the parameter position, the mean and variance of the differences are calculated to obtain a first mean and variance corresponding to the parameter position.

4. The language model updating method according to claim 1, characterized in that: The step of determining the structural generation parameters of the language large model based on the structural key parameters includes: Based on the structured key parameters, updating the language macro model to obtain an intermediate language macro model; Obtaining a first final layer vector of the intermediate language large model when outputting in a structured manner and a second final layer vector of the intermediate language large model when outputting in an unstructured manner; Based on the first final layer vector and the second final layer vector, structured generation parameters of the language large model are determined.

5. The language model updating method according to claim 4, characterized in that: The determining, based on the first final layer vector and the second final layer vector, structured generation parameters of the language large model comprises: Calculating a second mean of the difference between the first final layer vector and the second final layer vector, the first final layer vector includes a plurality of vectors corresponding to when the intermediate language large model performs structured output for a plurality of question data respectively, and the second model parameter includes a plurality of vectors corresponding to when the language large model performs unstructured output for a plurality of question data respectively; The second mean is used as a structured generation parameter of the large language model.

6. The language model updating method according to claim 1, characterized in that: The updating of the language macromodel based on the structured generation parameter and the structured generation parameter to obtain the target language macromodel includes: Based on the structured generation parameters, the model weights of the language large model are updated, and based on the structured generation parameters, the final layer of the language large model is updated to obtain the target language large model.

7. The language model updating method according to claim 1, characterized in that: The obtaining of the first model parameter of the language large model in structured output and the second model parameter in unstructured output includes: The structured question and answer data and the unstructured question and answer data are respectively input into the language big model, and the model parameters in the language big model are monitored to obtain the first model parameters when the language big model performs structured output for the structured question and answer data, and obtain the second model parameters when the language big model performs unstructured output for the unstructured question and answer data. The structured question and answer data are data that require the language big model to perform structured output for the target question content, and the unstructured question and answer data are data that do not require the language big model to perform structured output for the target question content.

8. A method for generating structured content, characterized in that: include: Obtain question data, and process the question data based on a target language big model, and output structured format answer data corresponding to the question data, wherein the target language big model is a target language big model updated based on the language big model updating method according to any one of claims 1 to 7.

9. A language large model updating device, characterized in that: include: A first acquisition module is used to acquire structured output data and unstructured output data of the language large model; A comparison module, used for comparing the structured output data and the unstructured output data to determine the structured key parameters of the language model, wherein the structured key parameters are model parameters that characterize the difference between the structured output and the unstructured output in the language model; A determination module, configured to determine, based on the structured key parameters, structured generation parameters of the language model, wherein the structured generation parameters are model parameters that affect the structured format of the final layer vector of the language model; An updating module is used to update the language macromodel based on the structured generation parameters and the structured generation parameters to obtain a target language macromodel.

10. A structured content generating device, characterized in that: include: The second acquisition module is used to acquire problem data; An output module is used to process the question data based on a target language big model and output structured format answer data corresponding to the question data. The target language big model is a target language big model updated based on the language big model updating method according to any one of claims 1 to 7.