Model coding generation method and device

By optimizing the number of coding layers of the large model and generating coding information in parallel, the problems of low efficiency and insufficient integrity of traditional large model generation are solved, and efficient and excellent content generation is achieved.

CN120301432BActive Publication Date: 2025-08-29SHANGHAI XIYU JIZHI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510780088.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-12
Publication Date
2025-08-29
Estimated Expiration
2045-06-12

AI Technical Summary

Technical Problem

Traditional big models use autoregression to generate and encode for a long time, low efficiency, and insufficient integrity and quality of the generated content, especially lacking overall design and composition in text, pictures and music generation.

Method used

By determining the input data of the target model at the current layer, based on the output data encoded by the current layer and the compression rate of the next layer, the number of encoded layers is optimized and the encoding information is generated in parallel until the preset number of layers is reached, the target output information is decoded to obtain the target output information, and parallel generation and compression of the encoded information are realized.

Benefits of technology

It improves the efficiency and quality of the content generated by the model, ensures the integrity and detail of the content generated, reduces the number of times of encoding information output, and improves the generation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120301432B_ABST
    Figure CN120301432B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for generating a model code. The method includes: determining the input data of the target model encoded at the current layer; the target model is a large language model; based on the input data encoded at the current layer, obtaining the output data encoded at the current layer; the output data includes a first preset number of encoding information; based on the input data encoded at the current layer, the output data encoded at the current layer, and the compression rate of the next layer, determining the input data encoded at the next layer; until the number of encoding layers of the target model reaches the preset number of encoding layers, the output data encoded at each layer are combined into an encoding data set, and the encoding data set is decoded to obtain the target output information of the target model. The technical solution of the present invention greatly improves the efficiency of model-generated content while ensuring the integrity and quality of the model-generated content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning technology, and in particular to a method and device for generating coding for a model. Background Art

[0002] Traditional large-scale models all use an autoregressive approach to sequentially output encodings. This results in long encoding times and low model generation efficiency. Furthermore, since large models generate one token at a time and then combine multiple tokens to form a complete output, the overall quality of the content generated by these models is relatively poor. For example, when a large model outputs a piece of text, it generates one segmented word at a time and then combines multiple segments into a text. While the generated text is coherent, the content is hollow and incomprehensible. When the model outputs an image, it generates one pixel at a time and then combines multiple pixels into an image. While the generated image is rich in detail, the overall style or content does not meet the generation requirements, lacking a cohesive design, composition, and artistic conception. When a large model outputs music, it outputs one audio frame at a time and then combines multiple audio frames into a piece of music. While the generated music is rich in detail in each frame, the overall quality of the music is poor, with unclear distinctions between the verse, chorus, intro, climax, and ending, resulting in low overall quality. Summary of the Invention

[0003] The present invention provides a method and device for generating code of a model, which can greatly improve the efficiency of generating content by the model while ensuring the integrity and quality of the content generated by the model.

[0004] According to one aspect of the present invention, a method for generating a code of a model is provided, the method comprising:

[0005] Determining input data encoded by a target model at a current layer; the target model is a large language model;

[0006] Based on the input data of the current layer code, obtaining the output data of the current layer code; the output data includes a first preset number of coding information;

[0007] Determining input data for a next layer of encoding based on input data for the current layer of encoding, output data for the current layer of encoding, and a compression rate for a next layer of encoding;

[0008] Until the number of coding layers of the target model reaches a preset number of coding layers, the output data of each layer of coding is composed into a coding data set, so as to decode the coding data set to obtain the target output information of the target model.

[0009] According to another aspect of the present invention, there is provided a model encoding generation device, the device comprising:

[0010] A first data determination module is configured to determine input data encoded by a target model at a current layer; the target model is a large language model;

[0011] an encoding module, configured to obtain output data of the current layer encoding based on the input data of the current layer encoding; the output data including a first preset number of encoding information;

[0012] A second data determination module is configured to determine input data for a next layer of encoding based on the input data of the current layer of encoding, the output data of the current layer of encoding, and the compression rate of the next layer of encoding;

[0013] The judgment module is used to form the output data of each layer of coding into a coding data set until the number of coding layers of the target model reaches a preset number of coding layers, so as to decode the coding data set to obtain the target output information of the target model.

[0014] According to another aspect of the present invention, an electronic device is provided, comprising:

[0015] at least one processor; and

[0016] a memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the encoding generation method of the model described in any embodiment of the present invention.

[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the encoding generation method of the model described in any embodiment of the present invention when executed.

[0019] The technical solution of the embodiment of the present invention determines the input data of the target model encoded in the current layer; the target model is a large language model; based on the input data encoded in the current layer, the output data of the current layer encoding is obtained; the output data includes a first preset number of encoding information, which enables the encoding information of the same layer to be generated in parallel, greatly improving the parallel degree of the model generating encoding information; further based on the input data encoded in the current layer, the output data encoded in the current layer and the compression rate of the next layer encoding, the input data of the next layer encoding is determined, so that the next layer encoding performs an inference operation based on the input data encoded in the next layer; until the number of encoding layers of the target model reaches the preset number of encoding layers, the output data of each layer encoding are combined into an encoding data set to decode the encoding data set to obtain the target output information of the target model, thereby reducing the number of times the model encoding information is output, and improving the efficiency of the model generating content while ensuring the integrity and quality of the model generating content.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 is a flow chart of a method for generating code of a model provided in an embodiment of the present invention;

[0023] Figure 2 is a flowchart of another model encoding generation method provided by an embodiment of the present invention;

[0024] Figure 3 2 is a schematic structural diagram of a code generation device for a model according to an embodiment of the present invention;

[0025] Figure 4 3 is a schematic structural diagram of an electronic device for implementing the coding generation method of the model according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described 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 efforts should fall within the scope of protection of the present invention.

[0027] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Example 1

[0029] Figure 1 This is a flowchart of a coding generation method for a model provided by an embodiment of the present invention. This embodiment is applicable to coding generation in the process of generating content using a large language model in an autoregressive manner. This method can be executed by a coding generation device for the model. The coding generation device for the model can be implemented in the form of hardware and / or software. The coding generation device for the model can be configured in any electronic device with network communication capabilities. Figure 1 As shown in Figure 2, the encoding generation method of the model includes the following steps:

[0030] S110. Determine input data encoded by the target model at the current layer; the target model is a large language model.

[0031] The target model is pre-trained. Before training the target model, the target model's codec must be trained to fix parameters such as the number of feature extraction layers and the compression rate of each layer of codec, thereby reducing the number of coding layers of the target model. Because the codec of a traditional large language model generally only generates one layer of coding information and cannot perform layered feature compression, thereby outputting multiple coding information, for example, if 256 coding information needs to be output, the traditional large language model needs to perform 256 coding outputs. However, the fixed number of feature extraction layers and the compression rate of each layer of codec in the present invention can ensure that each layer of code outputs at least one coding information, and the target model only needs to perform a preset number of coding outputs. For example, compared to the traditional large language model performing 256 coding outputs, the present invention does not require 256 coding outputs, but only requires a number of coding outputs roughly equivalent to the preset number of coding layers, greatly improving the efficiency of model content generation. The preset number of coding layers is determined based on the number of feature extraction layers of the codec in the target model, i.e., the preset number of coding layers is the same as the number of feature extraction layers of the codec in the target model.

[0032] Specifically, after the target model is successfully trained, the first information can be input into the target model, and the target model performs inference operations for a preset number of coding layers to obtain the target output information of the target model. Furthermore, to ensure the accuracy of the inference operations for the preset number of coding layers, it is necessary to ensure the accuracy of the input data encoded at each layer, that is, to determine the input data encoded by the target model at the current layer, including steps A1-A2:

[0033] Step A1: If the current layer encoding is the first layer encoding, the input data of the current layer encoding is the first information obtained in response to an input operation; the input operation is an input operation triggered from outside the target model to input the first information into the target model.

[0034] Among them, the first information can be understood as data that prompts the target model to generate target output information, and is data input from the outside into the target model; for example, questions in question and answer data.

[0035] The target model can be a text model, a visual model, or an audio model. A text model is used for text content analysis. For a text model, the first information can be the text document information provided, such as "arrange a three-day itinerary to a certain place." A visual model can be a model for image generation. For a visual model, the first information can be information data describing the output image, such as "generate an image of a family celebrating the New Year." An audio model can be a model for generating sound or music. For an audio model, the first information can be sound data or music data, such as "a verse of lyrics."

[0036] Step A2: If the current layer coding is other layer coding than the first layer coding, the input data of the current layer coding is determined based on the input data of the previous layer coding, the output data of the previous layer coding and the compression rate of the current layer coding.

[0037] Among them, the compression rate of the current layer code is the compression rate between the current layer code and the previous layer code. The compression rate is determined according to at least one of the convolution kernel size, step size, padding amount, and the coding crossover range between adjacent coding information. The compression rate of each layer of code can be the same or different, and both are parameters determined during the codec training process. For example, the compression rate can be 1.5, 2, 3, 4, etc. The smaller the compression rate, the less information is lost during the target model's inference operation, and the higher the quality of the content generated by the target model; the larger the compression rate, the faster the target model generates content and the higher the generation efficiency; therefore, the setting of the compression rate is very important, that is, a suitable compression rate can ensure both the quality of the content generated by the target model and the generation efficiency of the target model.

[0038] Among them, adjacent coding information can be non-intersecting or intersecting, and the coding intersection range can be adjusted by parameters such as the convolution kernel size and step size, and then the compression rate is adjusted by the coding intersection range between adjacent coding information, so that the range of information extracted by adjacent coding information is crossed. This can be to make the content connection between different coding information in the same layer coding smoother, and avoid the problem that the coding information of two adjacent frames appears to be completely unrelated or completely opposite; in addition, the range of information extracted by two adjacent coding information is crossed, so that the intersection area can refer to the characteristics of multiple coding information during decoding, and then achieve a smoother transition by taking the average value and other methods.

[0039] Specifically, the input data of other layers of coding except the first layer of coding can be obtained within the target model. In order to ensure the quality of the output data between adjacent layers of coding, the input data of each layer of coding can be determined by the input data of the previous layer of coding, the output data of the previous layer of coding and the compression rate of the current layer of coding, so as to ensure the accuracy of the input data of each layer of coding.

[0040] S120. Obtain output data of the current layer encoding based on the input data of the current layer encoding; the output data includes a first preset number of encoding information.

[0041] Specifically, the target model performs an inference operation on the input data of the current layer code, and outputs the output data of the current layer code; and the output data includes a first preset number of coding information, that is, the output data of each layer code contains at least one coding information. In addition, as the number of coding layers increases, the more coding information is included in the output data of the corresponding layer code, that is, the more detailed information is included, and the output data of the initial coding layer is more about the layout, style, design and other information of the overall content. That is, the present invention not only ensures the integrity of the generated content, but also controls the details of the generated content, ensuring that the quality of the generated content is higher.

[0042] In an embodiment of the present invention, the output data optionally includes a first preset number of pieces of encoding information, and the first preset number is related to the amount of encoding information in the input data of the current layer encoding, and the amount of encoding information in the input data of the current layer encoding is associated with the compression rate of the current layer encoding and the output data of the previous layer encoding. That is, the first preset number of output data of the current layer encoding can be accurately obtained based on the association between the compression rate of the current layer encoding and the output data of the previous layer encoding. Setting the compression rate can ensure that the amount of generated encoding information is within an appropriate range, ensuring the accuracy of the output data, that is, accurately controlling the overall and detailed aspects of the output content.

[0043] S130 : Determine input data for the next layer of coding based on input data for the current layer of coding, output data for the current layer of coding, and a compression ratio for the next layer of coding.

[0044] The compression ratio of the next layer of coding is the compression ratio between the current layer of coding and the next layer of coding.

[0045] Specifically, each encoding information in the output data of the current encoding layer is copied by a preset number of copies to obtain first encoding data, where the preset number of copies is the product of the first preset number and the compression ratio of the next encoding layer. The first encoding data is further combined with the input data of the current encoding layer to determine the input data of the next encoding layer.

[0046] Optionally, combining the first coded data and the input data of the current layer code to determine the input data of the next layer code may include: adjusting the number of identical coding information in the input data of the current layer code to a preset number to obtain the second coded data; and combining the first coded data and the second coded data to determine the input data of the next layer code.

[0047] For example, the input data of the first layer encoding is the first information a, and the output data of the first layer encoding is the encoding information a1; the compression rate of the second layer encoding is 2, and the input data of the second layer encoding is two first reference encoding information, and each first reference encoding information is the same, the first reference encoding information is the first information a and the encoding information a1, but the encoding position information corresponding to the two first reference encoding information is different. The output data of the second-layer encoding obtained based on the input data of the second-layer encoding includes two pieces of encoding information, namely, encoding information b1 and encoding information b2. The compression rate of the third-layer encoding is 2, so the preset number of shares is 2*2=4. The first encoding data of the third-layer encoding is encoding information b1, encoding information b1, encoding information b1, encoding information b1, encoding information b2, encoding information b2, encoding information b2, and encoding information b2. The second encoding data of the third-layer encoding is first information a, first information a, first information a, first information a, encoding information a1, encoding information a1, encoding information a1, and encoding information a1. The input data of the third-layer encoding is four pieces of second reference encoding data, and each piece of second reference encoding data is the same, namely, first information a, encoding information a1, encoding information b1, and encoding information b2. However, the encoding position information corresponding to each piece of second reference encoding information may be different. This process is repeated until the number of encoding layers of the target model reaches the preset number of encoding layers.

[0048] S140, until the number of coding layers of the target model reaches a preset number of coding layers, the output data of each layer of coding is combined into a coding data set, and the coding data set is decoded to obtain the target output information of the target model.

[0049] Specifically, until the number of coding layers of the target model reaches the preset number of coding layers, that is, the coding times of the target model have been completed, the output data of each layer of coding have been saved in the coding data set. In order to output accurate target output information of the target model, it is necessary to decode the output data of each layer of coding in the coding data set to obtain the decoded data of the output data of each layer of coding, and further combine the decoded data of each layer of coding to obtain the target output information of the target model.

[0050] The technical solution of the embodiment of the present invention determines the input data of the target model encoded in the current layer; the target model is a large language model; based on the input data encoded in the current layer, the output data of the current layer encoding is obtained; the output data includes a first preset number of encoding information, which enables the encoding information of the same layer to be generated in parallel, greatly improving the parallel degree of the model generating encoding information; further based on the input data encoded in the current layer, the output data encoded in the current layer and the compression rate of the next layer encoding, the input data of the next layer encoding is determined, so that the next layer encoding performs an inference operation based on the input data encoded in the next layer; until the number of encoding layers of the target model reaches the preset number of encoding layers, the output data of each layer encoding are combined into an encoding data set to decode the encoding data set to obtain the target output information of the target model, thereby reducing the number of times the model encoding information is output, and improving the efficiency of the model generating content while ensuring the integrity and quality of the model generating content.

[0051] Example 2

[0052] Figure 2 This is a flowchart of another model encoding generation method provided by an embodiment of the present invention. The technical solution of this embodiment further optimizes the process of "determining the input data of the next layer encoding based on the input data of the current layer encoding, the output data of the current layer encoding and the compression rate of the next layer encoding" in the above embodiment. This embodiment can be combined with various optional solutions in one or more of the above embodiments. Figure 2 As shown, the encoding generation method of the model includes:

[0053] S210. Determine the input data encoded by the target model at the current layer; the target model is a large language model.

[0054] S220. Obtain output data of the current layer encoding based on the input data of the current layer encoding; the output data includes a first preset number of encoding information.

[0055] The input data of the current layer encoding also includes the second encoding position information of each encoding information. The second encoding position information can be understood as the position information of each encoding information corresponding to the execution of the inference operation.

[0056] Specifically, based on the autoregressive mechanism of the target model and the second encoding position information of each encoding information, an inference operation is performed on each encoding information in the input data of the current layer encoding to obtain the output data of the current layer encoding.

[0057] S230: Determine the data content of the input data of the next layer encoding based on the input data of the current layer encoding and the output data of the current layer encoding.

[0058] Specifically, the input data of the current encoding layer and the output data of the current encoding layer are combined as the data content of the input data of the next encoding layer. For example, the input data of the current encoding layer is two pieces of first reference encoding information, and each piece of first reference encoding information is the same, namely, first information a and encoding information a1; the output data of the current encoding layer includes encoding information b1 and encoding information b2, each corresponding to a piece of input first reference encoding information; then the data content of the piece of input data of the next encoding layer is the first reference encoding information, encoding information b1, and encoding information b2.

[0059] The current layer of encoding is the first layer of encoding, and the prediction length is greater than the preset length. The first preset number is 1. The input data of the first layer of encoding is the first information. The output data of the first layer of encoding includes one third encoding information, a second preset number of first encoding position information, and the deviation value between the third encoding information and each fourth encoding information. The second preset number is the ratio between the prediction length and the preset length, rounded up. The third encoding information can be the average value of the fourth encoding information. The fourth encoding information is the second preset number of encoding information output one by one by the first layer of encoding based on the first information target model when the prediction length is greater than the preset length. There is a one-to-one correspondence between the fourth encoding information and the first encoding position information. The input data of the next layer of encoding includes the first information, one third encoding information, a second preset number of first encoding position information, and the deviation value between the third encoding information and each fourth encoding information.

[0060] S240. Determine the amount of encoded information in the input data of the next layer of encoding based on the product of the first preset number and the compression rate of the next layer of encoding; or determine the amount of encoded information in the input data of the next layer of encoding based on the product of the first preset number and the compression rate of the next layer of encoding and the first encoding position information of the output data of the current layer of encoding.

[0061] Specifically, if the current layer encoding is the first layer encoding, and the prediction length is less than or equal to the preset length, and the first preset number is 1, then the amount of encoding information in the input data of the next layer encoding is the product of the first preset number and the compression rate of the next layer encoding.

[0062] If the current layer encoding is the first layer encoding, and the prediction length is greater than the preset length, the first preset number is the value of the ratio between the prediction length and the preset length rounded up, then the amount of encoding information in the input data of the next layer encoding is the product of the first preset number and the compression rate of the next layer encoding.

[0063] If the current layer encoding is the first layer encoding, the prediction length is greater than the preset length, and the first preset number is 1, then the amount of encoding information in the input data of the next layer encoding is determined by the product of the first preset number and the compression ratio of the next layer encoding, and the first encoding position information of the output data of the current layer encoding. Specifically, the amount of encoding information in the input data of the next layer encoding is determined based on the product of the first preset number and the compression ratio of the next layer encoding, and the first encoding position information of the output data of the current layer encoding, including: the output data of the first layer encoding also includes a second preset number of first encoding position information, and the amount of encoding information in the input data of the next layer encoding is the product of the first preset number, the compression ratio of the next layer encoding, and the second preset number.

[0064] If the current layer coding is other layer coding than the first layer coding, the amount of coding information in the input data of the next layer coding is the product of the first preset amount and the compression rate of the next layer coding.

[0065] S250: Determine input data for the next layer of encoding based on data content of the input data for the next layer of encoding and the amount of encoding information in the input data for the next layer of encoding.

[0066] Specifically, if the current layer encoding is the first layer encoding, and the amount of encoding information in the input data of the next layer encoding is the product of a first preset amount and a compression rate of the next layer encoding, and the data content of the input data of the next layer encoding includes multiple pieces of encoding information, then the amount of encoding information in the data content of the input data of the next layer encoding is adjusted to the amount of encoding information in the input data of the next layer encoding, and the adjusted encoding information is combined to obtain multiple identical pieces of encoding information as the input data of the next layer encoding. For example, if the input data of the first layer encoding is the first information a, the output data of the first layer encoding is the encoding information a1, and the compression rate of the second layer encoding is 2, then the data content of the input data of the second layer encoding is the first information a and the encoding information a1, and the amount of encoding information in the input data of the second layer encoding is 2; further, the first information a and the encoding information a1 are both divided into two pieces, and the two pieces of encoding information are combined to obtain two identical pieces of encoding information, each piece of encoding information being a combination of the first information a and the encoding information a1, wherein the position information corresponding to the two pieces of encoding information may be different.

[0067] If the current layer encoding is the first layer encoding and the prediction length is greater than a preset length, the first preset number is 1, the number of encoding information in the input data of the next layer encoding is the product of the first preset number, the compression ratio of the next layer encoding, and the second preset number, and the data content of the input data of the next layer encoding is the first information, one piece of third encoding information, a second preset number of first encoding position information, and the deviation values ​​between the third encoding information and each fourth encoding information. Furthermore, it is necessary to obtain a second preset number of fifth encoding information as the actual output of the first layer encoding using the third encoding information, the second preset number of first encoding position information, and the deviation values ​​between the third encoding information and each fourth encoding information, then combine the second preset number of fifth encoding information with the first information to form sixth encoding information, where the number of sixth encoding information is the same as the number of encoding information in the input data of the next layer encoding, and use the plurality of sixth encoding information as the input data of the next layer encoding.

[0068] For example, the input data for the next layer of encoding includes the first information a, one piece of third encoded information A, two pieces of first encoded position information, and the deviation between the third encoded information A and each piece of fourth encoded information (fourth encoded information a1, fourth encoded information a2). The number of encoded information in the input data for the next layer of encoding is four. The fourth encoded information a1 and the fourth encoded information a2 are obtained using the deviation between the third encoded information A and each piece of fourth encoded information and the first encoded position information. Therefore, each piece of sixth encoded information in the input data for the next layer of encoding is a combination of the first information a, the fourth encoded information a1, and the fourth encoded information a2, and the input data for the next layer of encoding includes four pieces of sixth encoded information.

[0069] If the current layer encoding is a layer encoding other than the first layer encoding, the amount of encoding information in the input data of the next layer encoding is the product of the first preset amount and the compression ratio of the next layer encoding, and the data content of the input data of the next layer encoding includes multiple pieces of encoding information, then the amount of encoding information in the data content of the input data of the next layer encoding is adjusted to the amount of encoding information in the input data of the next layer encoding, and the adjusted encoding information is code-combined to obtain multiple identical pieces of encoding information as the input data of the next layer encoding. The code-combining process can be understood as combining different pieces of encoding information included in the data content of the input data of the next layer encoding to form a piece of encoding information included in the input data of the next layer encoding.

[0070] For example, the input data for the current layer of encoding includes two pieces of first reference encoding information, which are a combination of first information a and encoding information a1. The output data for the current layer of encoding includes encoding information b1 and encoding information b2. The input data for the next layer of encoding includes the two pieces of first reference encoding information, encoding information b1, and encoding information b2. The compression rate for the next layer of encoding is 2, and the number of encoding information in the input data for the next layer of encoding is 2*2=4. Therefore, the two pieces of first reference encoding information are converted into four pieces of reference encoding information, with encoding information b1 adjusted to four pieces of encoding information b1 and encoding information b2 adjusted to four pieces of encoding information b2. Furthermore, the different pieces of encoding information are combined to form one piece of encoding information, i.e., second reference encoding data, included in the input data for the next layer of encoding. The second reference encoding data is a combination of the first reference encoding information, encoding information b1, and encoding information b2. Therefore, the input data for the next layer of encoding includes four pieces of second reference encoding data, where the position information corresponding to the four pieces of encoding information may be different.

[0071] S260, until the number of coding layers of the target model reaches a preset number of coding layers, the output data of each layer of coding is composed into a coding data set, and the coding data set is decoded to obtain the target output information of the target model.

[0072] The technical solution of an embodiment of the present invention determines input data encoded by a target model at a current layer; the target model is a large language model. Based on the input data encoded at the current layer, output data encoded at the current layer is obtained; the output data includes a first preset number of encoding information. Based on the input data encoded at the current layer and the output data encoded at the current layer, the data content of the input data encoded at the next layer is determined, achieving accurate determination of the data content, thereby facilitating subsequent combination of the data content based on the amount of input data encoded at the next layer. At the same time, the amount of coding information in the input data of the next layer of coding is determined based on the product of the first preset number and the compression rate of the next layer of coding; or, the amount of coding information in the input data of the next layer of coding is determined based on the product of the first preset number and the compression rate of the next layer of coding and the first coding position information of the output data of the current layer of coding; the accuracy of the amount of coding information in the input data of the next layer of coding is ensured, so that the input data of the next layer of coding can be accurately determined based on the data content of the input data of the next layer of coding and the amount of coding information in the input data of the next layer of coding, so that the next layer of coding can perform inference operations, so that the coding information of the same layer can be generated in parallel, greatly improving the parallel degree of model generation of coding information; until the number of coding layers of the target model reaches the preset number of coding layers, the output data of each layer of coding are combined into a coding data set to decode the coding data set to obtain the target output information of the target model, reducing the number of times the model coding information is output, and improving the efficiency of model generation content while ensuring the integrity and quality of the model generation content.

[0073] Example 3

[0074] The technical solution of this embodiment further optimizes the process of "obtaining output data of the current layer encoding based on the input data of the current layer encoding" in the aforementioned embodiment. Optionally, the first preset number is related to the amount of encoding information in the input data of the current layer encoding, and the amount of encoding information in the input data of the current layer encoding is associated with the compression ratio of the current layer encoding and the output data of the previous layer encoding. This embodiment can be combined with various optional solutions in one or more of the above embodiments.

[0075] Specifically, the first preset number is related to the amount of coded information in the input data of the current layer encoding, and the amount of coded information in the input data of the current layer encoding is associated with the compression rate of the current layer encoding and the output data of the previous layer encoding. For details, refer to the following steps B1-B2:

[0076] Step B1: If the current layer encoding is the first layer encoding, the first preset number is determined based on the prediction length of the target output information; the prediction length is predicted by the target model based on the first information.

[0077] The pre-trained target model has the ability to predict the length of the target output information based on the length of the first information input to the target model, so that in actual application, when the first information is input to the target model, the predicted length can be accurately obtained. Furthermore, based on the predicted length, the amount of encoded information included in the output data of the first layer of encoding, i.e., the first preset amount, is determined.

[0078] Specifically, when the prediction length is less than or equal to the preset length, the first preset number is 1; the preset length can be the maximum length of a coded message. That is, when the prediction length is equal to the preset length, the output data of the current layer encoding includes one first coded message, and the content of the first coded message is all meaningful data; when the prediction length is less than the preset length, the output data of the current layer encoding includes one second coded message, and the second coded message includes meaningful data of the predicted length and meaningless data of a reference length; the reference length is the difference between the preset length and the prediction length; the meaningless data of the reference length is information supplemented using special coding, and during decoding, only the meaningful data of the predicted length can be decoded.

[0079] When the predicted length is greater than the preset length, the first preset number is the ratio of the predicted length to the preset length, rounded up. For example, using a large sound model to generate music, with a preset length of 1 second and a predicted length of 5 seconds, the first preset number is 5, meaning the output information of the first layer of encoding includes 5 pieces of encoded information.

[0080] When the prediction length is greater than the preset length, the first preset number is 1, meaning the output data of the first-layer encoding includes one piece of third encoding information. The output data of the first-layer encoding also includes a second preset number of pieces of first encoding position information, where the second preset number is the ratio of the prediction length to the preset length, rounded up. The third encoding information can be the average of the fourth encoding information. The fourth encoding information is the second preset number of pieces of encoding information output one by one by the first-layer encoding based on the first information target model when the prediction length is greater than the preset length. There is a one-to-one correspondence between the fourth encoding information and the first encoding position information. The output data of the first-layer encoding also includes the deviation value between the third encoding information and each piece of fourth encoding information.

[0081] For example, taking the generation of music using a large sound model as an example, the preset length is 1 second, the predicted length is 5 seconds, and there are 5 fourth coding information. The 5 fourth coding information are averaged to obtain the third coding information, and the third coding information is used as the output data of the first layer of coding. Furthermore, the 5 fourth coding information correspond to 5 first coding position information and 5 deviation values, so that when the predicted length is greater than the preset length and the output data of the first layer of coding includes one third coding information, it can accurately reflect the accuracy of the output data of the first layer of coding obtained based on the first information. That is, the fourth coding information corresponding to the first coding position information is accurately obtained through the first coding position information, the deviation value corresponding to the first coding position information, and the third coding information. In this way, the coding generation efficiency can be further improved.

[0082] Step B2: If the current layer coding is other layer coding except the first layer coding, the first preset number is determined based on the amount of coding information in the output data of the previous layer coding and the compression rate of the current layer coding.

[0083] Specifically, the first preset number may be the product of the amount of coding information in the output data of the previous layer coding and the compression rate of the current layer coding, and the first preset number is a positive integer.

[0084] In an embodiment of the present invention, by judging whether the current layer encoding is the first layer encoding, if the current layer encoding is the first layer encoding, the first preset number is accurately determined based on the predicted length of the target output information, and if the current layer encoding is other layer encoding except the first layer encoding, the product of the number of encoding information in the output data of the previous layer encoding and the compression rate of the current layer encoding is used as the first preset number, thereby achieving accurate determination of the number of encoding information of the output data of each layer encoding, and the number of different encoding information of each layer encoding with different numbers can also reflect whether the encoding information of the encoding layer reflects the overall information or detailed information of the content generated by the target model.

[0085] Example 4

[0086] Figure 3This is a schematic diagram of the structure of a coding generation device for a model provided by an embodiment of the present invention. This embodiment is applicable to coding generation in the process of generating content using a large language model in an autoregressive manner. The coding generation device for this model can be implemented in the form of hardware and / or software. The coding generation device for this model can be configured in any electronic device with network communication capabilities. Figure 3 As shown, the coding generation device of the model includes:

[0087] A first data determination module 310 is configured to determine input data encoded by a target model at a current layer; the target model is a large language model;

[0088] The encoding module 320 is configured to obtain output data of the current layer encoding based on the input data of the current layer encoding; the output data includes a first preset number of encoding information;

[0089] A second data determination module 330 is configured to determine input data for a next layer of encoding based on the input data of the current layer encoding, the output data of the current layer encoding, and the compression rate of the next layer encoding;

[0090] The judgment module 340 is used to form the output data of each layer of coding into a coding data set until the number of coding layers of the target model reaches a preset number of coding layers, so as to decode the coding data set to obtain the target output information of the target model.

[0091] On the basis of the above embodiment, optionally, a first data determination module is used: if the current layer encoding is the first layer encoding, the current layer encoding input data is the first information obtained in response to the input operation; the input operation is an input operation triggered from the outside of the target model to input the first information to the target model; if the current layer encoding is other layer encoding except the first layer encoding, the input data of the current layer encoding is determined based on the input data of the previous layer encoding, the output data of the previous layer encoding and the compression rate of the current layer encoding.

[0092] Based on the above embodiment, optionally, the encoding generation device of the model also includes a first quantity determination module, and the first quantity determination module is used to: if the current layer encoding is the first layer encoding, then the first preset quantity is determined based on the predicted length of the target output information; the predicted length is predicted by the target model based on the first information.

[0093] Based on the above embodiment, optionally, the first quantity determination module is also used to: when the predicted length is less than or equal to the preset length, the first preset quantity is 1; when the predicted length is greater than the preset length, the first preset quantity is the value of the ratio between the predicted length and the preset length rounded up; or, the first preset quantity is 1, and the output data also includes a second preset number of first encoding position information, and the second preset quantity is the value of the ratio between the predicted length and the preset length rounded up.

[0094] Based on the above embodiment, optionally, the coding generation device of the model also includes a second quantity determination module, which is used to: if the current layer coding is other layer coding other than the first layer coding, the first preset quantity is determined based on the amount of coding information in the output data of the previous layer coding and the compression rate of the current layer coding.

[0095] On the basis of the above embodiment, optionally, a second data determination module is used to: determine the data content of the input data of the next layer of encoding based on the input data of the current layer encoding and the output data of the current layer encoding; determine the amount of encoded information in the input data of the next layer of encoding based on the product of the first preset number and the compression rate of the next layer of encoding; or determine the amount of encoded information in the input data of the next layer of encoding based on the product of the first preset number and the compression rate of the next layer of encoding and the first encoding position information of the output data of the current layer encoding; determine the input data of the next layer of encoding based on the data content of the input data of the next layer of encoding and the amount of encoded information in the input data of the next layer of encoding.

[0096] Based on the above embodiment, optionally, the preset number of coding layers is determined according to the number of feature extraction layers of the codec in the target model.

[0097] Based on the above embodiment, optionally, the compression rate is determined according to at least one of the convolution kernel size, step size, padding amount, and coding crossover range between adjacent coding information.

[0098] Based on the above embodiment, optionally, the input data of the current layer encoding also includes the second encoding position information of each encoding information, and the encoding module is used to: perform inference operations on each encoding information in the input data of the current layer encoding based on the autoregressive mechanism of the target model and the second encoding position information of each encoding information to obtain the output data of the current layer encoding.

[0099] The coding generation device for the model provided in the embodiment of the present invention can execute the coding generation method for the model provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0100] Example 5

[0101] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0102] Figure 4 A schematic diagram of the structure of an electronic device that can be used to implement the coding generation method of the model of an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0103] like Figure 4 As shown, electronic device 10 includes at least one processor 11 and memory, such as read-only memory (ROM) 12 and random access memory (RAM) 13, communicatively connected to at least one processor 11. The memory stores computer programs executable by the at least one processor. Processor 11 can perform various appropriate actions and processes based on the computer programs stored in ROM 12 or loaded from storage unit 18 into RAM 13. RAM 13 can also store various programs and data required for the operation of electronic device 10. Processor 11, ROM 12, and RAM 13 are interconnected via bus 14. An input / output (I / O) interface 15 is also connected to bus 14.

[0104] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0105] Processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any other suitable processor, controller, microcontroller, etc. Processor 11 executes the various methods and processes described above, such as the model code generation method.

[0106] In some embodiments, the model encoding generation method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the model encoding generation method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the model encoding generation method by any other appropriate means (for example, by means of firmware).

[0107] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0108] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0109] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or apparatus. A computer-readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0110] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device that has: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0111] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0112] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0113] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0114] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A method for generating a code of a model, characterized in that: The method comprises: Determining input data for encoding a target model at a current layer; the target model is a large sound model for generating sound or music, and the input data includes sound data or music data; the target model is pre-trained, and before training the target model, a codec of the target model is first trained to fix the number of feature extraction layers of the codec and the compression rate of each layer of encoding, wherein the compression rate is determined based on at least one of a convolution kernel size, a step size, a padding amount, a coding crossover range between adjacent coding information, and a maximum number of parallel operations; Based on the input data of the current layer code, obtaining the output data of the current layer code; the output data includes a first preset number of coding information; Determining input data for a next layer of encoding based on input data for the current layer of encoding, output data for the current layer of encoding, and a compression rate for a next layer of encoding; until the number of coding layers of the target model reaches a preset number of coding layers, then composing the output data of each layer of coding into a coding data set, and decoding the coding data set to obtain target output information of the target model; the preset number of coding layers is determined according to the number of feature extraction layers of the codec in the target model; The step of determining input data for a next layer of encoding based on the input data for the current layer of encoding, the output data for the current layer of encoding, and the compression rate of the next layer of encoding includes: Determining data content of input data for a next layer of encoding based on input data for the current layer of encoding and output data for the current layer of encoding; Determining the amount of coded information in the input data for the next layer of coding based on a product of the first preset number and a compression ratio of the next layer of coding; or determining the amount of coded information in the input data for the next layer of coding based on a product of the first preset number and the compression ratio of the next layer of coding and first coding position information of output data of the current layer of coding; The input data for the next layer of encoding is determined based on data content of the input data for the next layer of encoding and the amount of encoding information in the input data for the next layer of encoding.

2. The method according to claim 1, characterized in that Determine the input data encoded by the target model at the current layer, including: If the current layer encoding is the first layer encoding, the input data of the current layer encoding is the first information obtained in response to an input operation; the input operation is an input operation triggered externally by the target model to input the first information to the target model; If the current layer coding is other layer coding except the first layer coding, the input data of the current layer coding is determined based on the input data of the previous layer coding, the output data of the previous layer coding and the compression rate of the current layer coding.

3. The method according to claim 2, characterized in that The method further comprises: If the current layer encoding is the first layer encoding, the first preset number is determined based on the prediction length of the target output information; the prediction length is predicted by the target model based on the first information.

4. The method according to claim 3, characterized in that If the current layer encoding is the first layer encoding, the first preset number is determined based on the prediction length of the target output information, including: When the predicted length is less than or equal to the preset length, the first preset number is 1; When the predicted length is greater than the preset length, the first preset number is the value of the ratio between the predicted length and the preset length rounded up; or, the first preset number is 1, and the output data also includes a second preset number of first encoding position information, and the second preset number is the value of the ratio between the predicted length and the preset length rounded up.

5. The method according to claim 2, characterized in that The method further comprises: If the current layer coding is other layer coding except the first layer coding, the first preset number is determined based on the amount of coding information in the output data of the previous layer coding and the compression rate of the current layer coding.

6. The method according to claim 1, characterized in that The input data of the current layer encoding further includes second encoding position information of each encoding information, and obtaining output data of the current layer encoding based on the input data of the current layer encoding includes: Based on the autoregressive mechanism of the target model and the second encoding position information of each encoding information, an inference operation is performed on each encoding information in the input data of the current layer encoding to obtain the output data of the current layer encoding.

7. A coding generation device for a model, characterized in that: The device comprises: a first data determination module, configured to determine input data for encoding a target model at a current layer; the target model being a large sound model for generating sound or music, and the input data comprising sound data or music data; the target model being pre-trained, and prior to training the target model, a codec of the target model being trained to fix the number of feature extraction layers of the codec and the compression ratio of each layer of encoding, wherein the compression ratio is determined based on at least one of a convolution kernel size, a step size, an amount of padding, a coding crossover range between adjacent coding information, and a maximum number of parallel accesses; an encoding module, configured to obtain output data of the current layer encoding based on the input data of the current layer encoding; the output data including a first preset number of encoding information; A second data determination module is configured to determine input data for a next layer of encoding based on the input data of the current layer of encoding, the output data of the current layer of encoding, and the compression rate of the next layer of encoding; a judgment module, configured to, until the number of coding layers of the target model reaches a preset number of coding layers, combine the output data of each layer of coding into a coding data set, and decode the coding data set to obtain target output information of the target model; the preset number of coding layers is determined according to the number of feature extraction layers of the codec in the target model; Among them, the second data determination module is used to: determine the data content of the input data of the next layer of encoding based on the input data of the current layer encoding and the output data of the current layer encoding; determine the amount of encoded information in the input data of the next layer of encoding based on the product of the first preset number and the compression rate of the next layer of encoding; or determine the amount of encoded information in the input data of the next layer of encoding based on the product of the first preset number and the compression rate of the next layer of encoding and the first encoding position information of the output data of the current layer encoding; determine the input data of the next layer of encoding based on the data content of the input data of the next layer of encoding and the amount of encoded information in the input data of the next layer of encoding.

Citation Information

Patent Citations

  • Data coding method and related equipment

    CN114978189A

  • Training method and apparatus and recognition method and apparatus for text error correction model, and computer device

    WO2022121178A1