Binaryzation method and system for training perception large model and online reasoning method

Through the method of alternating initialization and layer-by-layer alignment training, combined with the adaptive order allocation of layer importance, the problem of computing and storage burden of large-scale pre-trained models in edge device deployment is solved, and efficient binarized compression is achieved, suitable for edge devices and online inference scenarios.

CN120509489APending Publication Date: 2025-08-19SHANGHAI JIAOTONG UNIV

Patent Information

Application Number
CN202510673122.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-08-19

AI Technical Summary

Technical Problem

The existing large-scale pre-trained models are overloaded when deployed in edge devices and low-resource environments. Traditional binarization methods are difficult to balance accuracy and resource consumption. In particular, the QAT method is expensive to train, and the resources are limited or the application of rapid iteration scenarios is limited.

Method used

Alternate initialization, layer-by-layer alignment training and layer importance adaptive order allocation strategies are adopted. By alternately refining initialized binarization parameters, layer-by-layer alignment training and coordinated optimization under a unified loss function, combining dynamic learning rate and layer importance allocation of binarization orders to reduce the model volume and calculation complexity.

Benefits of technology

While maintaining accuracy, it significantly reduces model size and computing complexity. It is suitable for edge device deployment and large-scale online inference, improves training efficiency, reduces resource occupancy and computing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120509489A_ABST
    Figure CN120509489A_ABST
Patent Text Reader

Abstract

The invention provides a training perception large model binaryzation method and system and an online reasoning method, and the binaryzation method comprises the steps: employing an alternating mode, and initializing a binaryzation parameter of a large language model; performing layer-by-layer alignment training on the initialized large language model; end-to-end training of the large language model is started, so that all binarization parameters are collaboratively optimized under a unified loss function; and implementing a binarization order allocation strategy based on layer importance on the large language model after unified collaborative optimization is completed to obtain a final large language model for downstream tasks. According to the method, the model size and the calculation complexity can be remarkably reduced while the precision is kept, and the method is suitable for various actual scenes such as edge device deployment and large-scale online reasoning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence and deep learning technology, and specifically to a method and system for binarizing a large training perception model, and an online reasoning method. Background Art

[0002] In recent years, large-scale pretrained models have achieved breakthroughs in fields such as natural language processing and computer vision. In particular, large language models (LLMs) have demonstrated outstanding performance in tasks such as generation, comprehension, and reasoning. However, the number of parameters in such models often reaches billions or even tens of billions, resulting in significant computational and storage burdens in practical deployments, severely limiting their application on edge devices and in low-resource environments.

[0003] To reduce the inference cost of large models, binarization, an extreme quantization compression method, has become a hot topic of research in recent years because it can compress weights and / or activations to 1 bit, significantly reducing model storage and multiplication-addition overhead. Currently, mainstream binarization methods can be divided into two categories: post-training quantization (PTQ) and quantization-aware training (QAT).

[0004] Typical examples of PTQ-based binarization methods include DB-LLM, PB-LLM, and BiLLM. These methods typically directly binarize the full-precision model weights without retraining the original model, offering the advantages of low deployment cost and a streamlined workflow. However, due to the lack of fine-tuning of the target model's behavior, these methods can lead to significant performance degradation at extremely low bit widths (e.g., 1 bit), limiting their practicality and making it difficult to meet the accuracy requirements of practical applications.

[0005] In contrast, QAT-based binarization methods, such as BitNet, BinaryMOS, and OneBit, introduce quantization during the training phase, allowing the model to gradually adapt to the binarization constraints during learning, significantly improving the model's post-quantization performance. Although these methods offer improved accuracy, their training typically requires significant computational resources and time, especially when working with very large pre-trained models. The high training cost makes them difficult to apply to resource-constrained scenarios or engineering practices requiring rapid iteration.

[0006] A search revealed a method for automated structural learning of brain-inspired binary neural networks, disclosed in Chinese patent application number 202210021671.0. This method employs binary parameterization to reduce model size. However, this method fails to fully account for the accumulation of quantization errors across layers and does not adequately address the functional differences between different layers within the model. Summary of the Invention

[0007] In response to one of the defects in the prior art, the purpose of this application is to provide a method and system for binarizing a large training perception model.

[0008] In a first aspect of the present application, a method for binarizing a large training perception model is provided, comprising:

[0009] Initialize the binary parameters of the large language model in an alternating manner;

[0010] For the initialized large language model, performing layer-by-layer alignment training on the binarized parameters;

[0011] Initiate end-to-end training of the large language model, so that all binary parameters are collaboratively optimized under a unified loss function;

[0012] For the large language model that has completed unified collaborative optimization, a binarization order allocation strategy based on layer importance is implemented to obtain the final large language model for downstream tasks.

[0013] Optionally, the initializing the binarization parameters of the large language model in an alternating manner includes:

[0014] Load the pre-trained large model parameters. Here, the parameters of the large model are expressed as full-precision weights.

[0015] The large model parameters are binarized and alternately trained to obtain initialized binarized parameters.

[0016] Optionally, binarizing the large model parameters and alternately training to obtain initialized binarized parameters includes:

[0017] Using a scaled binarization structure, the full-precision weights of the original large model are converted into binary parameters;

[0018] Alternatingly updating the mean shift term, the scaling factor, and the binary mask in the binarization structure to train the binarization parameters;

[0019] After initialization, each layer of the large model includes both initialized binary parameters and full-precision weights.

[0020] Optionally, performing layer-by-layer alignment training on the binarized parameters of the initialized large language model includes:

[0021] When training and optimizing the initialization binary parameters of the current layer, freeze other layers;

[0022] Compare the binary output of the current layer and the original full-precision weight output, minimize the output difference between the two, complete the alignment training of the single front layer, and the trained binary parameters completely replace the full-precision weights.

[0023] Optionally, starting the end-to-end training of the large language model so that all binarized parameters are collaboratively optimized under a unified loss function includes:

[0024] Use the dataset of the downstream task target to establish the overall loss and update all the binary parameters;

[0025] During the parameter update process, the optimizer is used to dynamically adjust the learning rate or update strategy.

[0026] Optionally, the large language model that has completed unified collaborative optimization is subjected to a binarization order allocation strategy based on layer importance to obtain a final large language model for use in downstream tasks, including:

[0027] Calculate layer importance using one or more metrics such as Fisher information, activation sensitivity, and output change rate;

[0028] Setting a threshold, and dividing all layers into important layers and non-important layers according to a comparison result between the importance of the layer and the threshold;

[0029] The important layers are given binary representations, and the unimportant layers are only represented by the first order.

[0030] In a second aspect of the present application, a system for training a large perception model binarization is provided, comprising:

[0031] Parameter initialization module: uses an alternating method to initialize the binary parameters of the large language model;

[0032] Layer-by-layer alignment training module: for the initialized large language model, performing layer-by-layer alignment training on the binarized parameters;

[0033] End-to-end binary parameter training module: starts end-to-end training of the large language model, so that all binary parameters are collaboratively optimized under a unified loss function;

[0034] Binarization order allocation module: For the large language model that has completed unified collaborative optimization, a binarization order allocation strategy based on layer importance is implemented to obtain the final large language model for downstream tasks.

[0035] A third aspect of the present application provides an online reasoning method, comprising:

[0036] Get language text instructions;

[0037] Convert the language text instruction into a token sequence through a word segmenter;

[0038] Mapping the token sequence into an embedding vector;

[0039] Inputting the embedding vector into a large language model trained by the method or system;

[0040] After multi-layer binarization calculation, the large language model outputs a probability distribution, which is used to predict the next token or action as a language response or understanding execution for the language text instruction.

[0041] In a fourth aspect of the present application, a terminal is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor can be used to execute the method described, or to run the system described, when executing the program.

[0042] In a fifth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, it can be used to execute the method described, or run the system described.

[0043] The training-aware large model binarization method provided in this application adopts the technical means of alternating refinement initialization, layer-by-layer alignment training mechanism and layer importance adaptive order allocation strategy, which brings the technical effect of significantly reducing the model volume and computational complexity while maintaining accuracy.

[0044] Other technical effects brought about by the additional features will be further explained in the corresponding embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Other features, objects and advantages of the present application will become more apparent upon reading the detailed description of non-limiting embodiments with reference to the following drawings:

[0046] Figure 1 The present invention is a flowchart of a method for binarizing a large training perception model according to an exemplary embodiment;

[0047] Figure 2 1 is a structural diagram of a system for training a large perception model binarization according to an exemplary embodiment;

[0048] Figure 3 The figure is a flowchart of an online reasoning method for language text according to an exemplary embodiment. DETAILED DESCRIPTION

[0049] The present application is described in detail below with reference to specific embodiments. The following examples will help those skilled in the art to further understand the present application, but are not intended to limit the present application in any form. It should be noted that, without departing from the concept of the present application, a number of variations and improvements may be made by those skilled in the art, and these all fall within the scope of protection of the present application. Parts not described in detail in the following examples may be implemented using existing technologies.

[0050] QAT-type binarization methods, such as BitNet, BinaryMOS, and OneBit, gradually adapt the model to the binarization restrictions by adding a quantization step during training, effectively enhancing the performance after quantization. However, these methods consume a lot of computing resources and time during training, especially when processing large-scale pre-trained models. This limits their application in environments with limited resources or requiring rapid iteration. Based on this, an embodiment of the present application provides a method for binarizing a large training perception model to solve the above problems.

[0051] See also Figure 1 , is a flowchart of a method for binarizing a large training perception model according to an exemplary embodiment.

[0052] In one embodiment of the present application, a method for binarizing a large training perception model mainly includes the following steps:

[0053] Step 1: Initialize the binary parameters of the large language model in an alternating manner;

[0054] Step 2: For the initialized large language model, perform layer-by-layer alignment training on the binary parameters;

[0055] Step 3: Start end-to-end training of the large language model so that all binary parameters are collaboratively optimized under a unified loss function.

[0056] Step 4: For the large language model that has completed unified collaborative optimization, a binary order allocation strategy based on layer importance is implemented to obtain the final large language model for downstream tasks.

[0057] Specifically, in traditional full-precision models, weights are usually stored in float32 or float16. The goal of binarization here is to approximate these weights to only two values, so that each weight can be represented by 1 bit.

[0058] The above-mentioned embodiments can significantly reduce the size and computational complexity of large models while maintaining accuracy, thereby improving training efficiency. They are applicable to various practical scenarios such as edge device deployment and large-scale online inference.

[0059] Existing QAT methods typically use a simple initial binarization or random initialization method, which can easily lead to a sharp drop in accuracy and unstable training in the early stages of training. In some specific embodiments of this application, step 1 uses an alternating method to initialize the binarization parameters of the large language model, which can adopt steps S1.1-S1.3.

[0060] S1.1, load the pre-trained large model parameters.

[0061] Specifically, the large model here refers to an existing large pre-trained model, such as a language model with a Transformer structure. The parameters of the large model are in full-precision format, typically float32 or float16.

[0062] S1.2, initialize the parameters of the language model.

[0063] Using a scaled binary structure, each row or each block of the original full-precision weight is represented as:

[0064] W≈α×B+μ

[0065] Where: W is the original full-precision weight matrix; B is a binary mask matrix with only -1 or +1 elements; α is a scaling factor (which can be a real number per row or per block); μ is a mean shift term used to improve fitting accuracy.

[0066] S1.3, alternately refine the initialized parameters.

[0067] Specifically, alternation refers to the process of generating binary parameters, alternating updates of the mean shift term μ, the scaling factor α, and the binary mask B. Refinement means that during the alternating update process, each update makes the parameters more accurately fit the distribution of the full-precision weights.

[0068] It's worth noting that the completion of steps S1.1 through S1.3 marks the end of the initialization phase. At this point, each layer will have both a binary initialization result and a set of full-precision layer parameters. Subsequently, during the layer-by-layer training and replacement process, the full-precision layers will be replaced by the binary layers.

[0069] The full-precision model loading, parameter initialization, and alternating refinement process in the above-mentioned embodiment of this application provides a stable starting point for the subsequent training perception binarization process, ensuring good convergence of the optimization process. Throughout the entire process, unlike the random initialization or rough shearing used in traditional QAT methods, this embodiment alternately refines the initialized binarized parameters based on the parameters of the original model, making the initialized binarized parameters closer to the distribution of the original model parameters, effectively alleviating the oscillation problem in the early stages of training and improving the stability and convergence speed of training.

[0070] In traditional QAT methods, quantization errors accumulate across layers during global training, easily causing performance degradation in deeper layers. To avoid this, in some specific implementations of this application, S2 performs layer-by-layer alignment training on the binarized parameters of the initialized large language model, using steps S2.1-S2.2.

[0071] S2.1, when training and optimizing the initialized binarization parameters of the current layer, freeze other layers and train the current layer.

[0072] S2.2 compares the binary output of the current layer and the original full-precision weight output, minimizes the output difference between the two, completes the alignment training of the single front layer, and the trained binary parameters completely replace the full-precision weights.

[0073] In the above-mentioned embodiments of the present application, the proposed embodiments adopt a layered freezing and replacement optimization strategy to ensure that the output of the binarization layer is consistent with the output of the original layer, significantly reducing the error of the intermediate representation. This embodiment is different from the existing QAT method, which usually performs a one-time end-to-end training of the entire model. In contrast, this embodiment effectively avoids global degradation by reducing the cumulative effect of quantization errors in the early stages of training, thereby improving the stability and convergence speed of the model.

[0074] Traditional QAT methods generally adopt an end-to-end full-parameter joint training strategy. During the training process, not only the original full-precision floating-point parameters need to be maintained and updated, but also the quantization parameters (such as scaling factors, zero offsets, etc.) need to be learned at the same time. This greatly increases the number of trainable parameters, resulting in large video memory overhead, slow training speed, and low overall efficiency, especially in large model scenarios. In order to increase the training speed, in some specific implementations of this application, S3 starts the end-to-end training of the large language model, so that all binary parameters are collaboratively optimized under a unified loss function, and steps S3.1-S3.2 can be used.

[0075] S3.1, unfreeze all layers and construct the joint optimization objective.

[0076] Use downstream task objectives (such as language modeling or classification loss) to drive overall model optimization, and combine quantization loss, output consistency loss, regularization terms, etc. to improve generalization capabilities.

[0077] Specifically, the dataset of the downstream task can be used as the training dataset. The training set is mainly used to calculate the model loss and then train the model.

[0078] S3.2, use the optimizer to dynamically adjust the learning rate or update strategy.

[0079] Specifically, dynamic learning rate adjustment refers to implementing a hierarchical or grouped differentiated learning rate adjustment strategy for the structural layers and binary mask matrices in the large language model, dynamically adjusting the parameter update amplitude of each part according to the parameter characteristics to adapt to the imbalance of gradient distribution.

[0080] Dynamic adjustment update strategy: refers to the use of fine-grained optimization control for two types of parameters (continuous scaling factor Scale and discrete binary mask matrix):

[0081] Scaling factor (Scale): uses floating-point precision optimization combined with the second-order momentum accumulation of adaptive optimizers (such as Adam / LAMB) to achieve smooth and stable gradient updates;

[0082] Binary mask matrix: Bypass the non-differentiable problem through straight-through estimation (STE) and soft rounding technology, combined with first-order momentum adaptive update, coordinate the gradient propagation of discrete variables.

[0083] Compared to conventional optimization methods using a fixed learning rate, the adaptive optimizer in the above-mentioned embodiments of this application is more responsive to uneven gradient distribution during model training and is particularly suitable for mixed optimization scenarios involving discrete and continuous variables. A gradient-based binarization method, combined with soft rounding and straight-through estimation (STE), enables coordinated convergence of the scale and the binarized mask matrix.

[0084] It should be noted that the above-mentioned embodiment of the present application includes two training stages, layer-by-layer alignment training and end-to-end training. First, a layer-by-layer training strategy is adopted, and only the binary parameters and full-precision parameters of one layer are aligned and optimized at a time, and the other layers remain frozen. This method controls the amount of training parameters to involve only a single layer each time, greatly reducing the memory occupancy and computational burden, and greatly improving the training efficiency. Then, after completing the layer-by-layer alignment, end-to-end training is performed, and the model is already in a binary state. At this stage, there is no need to maintain or update the full-precision parameters, and only the binary parameters are jointly fine-tuned. Therefore, compared with the dual-parameter update method of the traditional QAT, the training of the above-mentioned embodiment remains efficient and gives full play to the resource advantages of the binary model. Therefore, the method of the embodiment of the present application can achieve a significant improvement in training efficiency, mainly due to the redesign of the training process and the optimization of the parameter update strategy, avoiding the problems of high resource occupancy and high training complexity in the traditional QAT method.

[0085] Traditional QAT methods typically use a unified quantization strategy for all layers, such as a fixed 1-bit quantization strategy, ignoring the functional differences between different layers in the model, resulting in limited model expressiveness. To improve the binary expressiveness, in some specific implementations of this application, S4 implements a layer-importance-based binary order allocation strategy for the large language model that has completed unified collaborative optimization, obtaining the final large language model for downstream tasks using steps S4.1-S4.3.

[0086] Step 4.1: Calculate the importance metrics for each layer in the model.

[0087] Specifically, a variety of methods can be used to evaluate layer importance.

[0088] Exemplarily, layer importance is calculated based on metrics such as Fisher information, activation sensitivity, and output change rate.

[0089] Step 4.2: Group all the layers.

[0090] Set a threshold, and the layers exceeding the threshold are important layers, and the rest are unimportant layers.

[0091] Step 4.3: Assign binary expressions of different orders according to importance.

[0092] Important layers are given higher-order binary representations, while unimportant layers only use first-order representations, thereby allocating limited representation capacity more effectively.

[0093] For example, the second-order residual binarization is used for the important layers as follows:

[0094] In ordinary first-order binarization, a scaling factor α, a mean μ, and a binary mask matrix B are used to approximate the original weight matrix W: W≈α×B+μ

[0095] Original matrix W:

[0096]

[0097] First-order approximation:

[0098] W≈α1×B1+μ

[0099] in

[0100]

[0101] α1=[0.733,0.400,1.467]

[0102] μ=[0.2,0.1,0.7]

[0103] In the important layer, a set of residual scale+sign is further introduced to improve the expressive ability:

[0104] Keep the first group first:

[0105] W≈α1×B1+α2×B2+μ

[0106]

[0107] α1=[0.733,0.400,1.467]

[0108] μ=[0.2,0.1,0.7]

[0109] Then calculate the residual R:

[0110] R=W-(α1×B1+μ)

[0111] The residual is binarized again:

[0112] B2=sign(R)

[0113] α2 = average (|R|) (row by row)

[0114]

[0115] α2=[0.15,0.12,0.23]

[0116] Final expression:

[0117] W≈α1×B1+α2×B2+μ

[0118] In the above-mentioned embodiment of this application, unlike the unified second-order scheme adopted by methods such as BiLLM, hierarchically adaptive binarization order allocation and differentiated resource allocation are successfully implemented for the first time. This achieves a better balance between compression and accuracy, thereby improving the overall performance of the model.

[0119] Based on the same technical concept, in other embodiments of the present application, Figure 2 As shown, a training perception large model binarization system includes:

[0120] Parameter initialization module: uses an alternating method to initialize the binary parameters of the large language model;

[0121] Layer-by-layer alignment training module: For the initialized large language model, perform layer-by-layer alignment training on the binary parameters;

[0122] End-to-end binary parameter training module: Enables end-to-end training of large language models, enabling collaborative optimization of all binary parameters under a unified loss function.

[0123] Binarization order allocation module: For the large language model that has completed unified collaborative optimization, a binarization order allocation strategy based on layer importance is implemented to obtain the final large language model for downstream tasks.

[0124] The specific implementation techniques of each module / unit in the above examples of this application can refer to the corresponding steps of the method for training the large perception model binarization in the above embodiments, which will not be repeated here.

[0125] The training perception large model binarization method and system of the above embodiment of the present application can be applied to various practical scenarios such as online reasoning. Figure 3 As shown, an online reasoning method for language text includes:

[0126] S100, obtaining a language text instruction;

[0127] S200, converting the language text instruction into a token sequence through a word segmenter;

[0128] Specifically, token is the number corresponding to a word or subword.

[0129] S300, mapping the token sequence into an embedding vector;

[0130] S400, input the embedding vector into the trained large language model;

[0131] At step S500 , after multi-layer binarization calculations, the large language module outputs a probability distribution, which is used to predict the next token or action as a language response or understanding execution for the language text instruction.

[0132] The following further illustrates the present application in conjunction with specific application examples / comparative examples to facilitate a better understanding of the above technical solutions of the present application. It should be understood that the following are merely partial examples and are not intended to limit the present application.

[0133] Application Example 1:

[0134] When building multi-round question-answering and knowledge retrieval systems, companies often deploy high-performance language models to support real-time user conversations. For example, the LLaMA-13B model, originally sized at approximately 26GB, consumes significant memory and bandwidth resources during inference on traditional servers, limiting high-concurrency processing capabilities.

[0135] The LLaMA-13B model is compressed using the method of the embodiment of the present application. The model is converted into a 1-bit expression, occupying only about 3.7GB of video memory, greatly reducing the inference cost, and supporting efficient operation on cloud or edge inference acceleration cards (such as NVIDIA T4 / A10, Alibaba Cloud Lingjun, Baidu Kunlun, etc.).

[0136] Furthermore, online users ask natural language questions through a webpage or voice interface, such as: "Please explain quantum entanglement in simple terms." This question is processed by a tokenizer and converted into a token sequence, which is then input into the LLaMA-13B model. The compressed model processes the input sequence through multiple binary Transformer layers, combining the context to generate a response token. The output generated by the LLaMA-13B model is a natural language answer, which might be: "Quantum entanglement is a strange phenomenon in which the states of two particles are correlated, regardless of their distance." This answer is output by a decoder and displayed on the user interface, enabling natural language understanding and knowledge services.

[0137] Application Example 2:

[0138] In the field of autonomous driving technology, the trained LLaMA-13B language model is applied to the semantic understanding unit of the on-board domain controller. The controller integrates low-power AI inference chips (such as NVIDIA OrinNX, HorizonJourney 5, Huawei Ascend 910B, etc.). By running the LLaMA-13B language model, an in-depth understanding of natural language is achieved. For example, when inputting instructions such as "navigate to the nearest charging station" or "detect the construction area ahead", the system can output the corresponding operation instructions, which are implemented by the execution unit. Therefore, the trained LLaMA-13B language model effectively reduces the pressure on chip memory and power consumption while ensuring response speed and model understanding capabilities, and meets the stability and real-time requirements of automotive level.

[0139] Application Example 3:

[0140] Large language models (such as GPT, LLaMA, etc.) contain multiple stacked Transformer encoding blocks, each of which consists of an attention layer (Attention) and a feedforward network (MLP), and contains a large number of fully connected weight matrices such as Wq, Wk, Wv, Wo, W1, W2, etc. These matrices were originally of float32 or float16 type, with high storage cost and large computational complexity. When training using the method of the embodiment of the present application, the above-mentioned weight matrix will be replaced with the following structure: W≈alpha×B+mu, where W is the original full-precision weight matrix; B is a binary mask matrix (elements are only ±1, which can be learned); alpha is the scaling factor for each row (can be learned); mu is the mean offset for each row (can also be learned).

[0141] Specifically,

[0142]

[0143] Calculate the mean (mu) by row:

[0144] mu= [0.2 0.1 0.7]

[0148] Decentralization (W-mu):

[0149]

[0150] Generate a binary mask matrix B:

[0151]

[0152] Calculate the scaling factor (alpha) for each row: Use the average L1 norm of each row as alpha, that is, the average of the absolute values of each row:

[0153] alpha= [0.733 0.400 1.467]

[0157] That is, the original matrix can be approximated as the following structure:

[0158] W≈alpha×B+mu.

[0159] The model with approximate structure is then trained layer by layer, end-to-end, and binary expressions of different orders are assigned according to importance to obtain a trained large language model.

[0160] The trained large language model is fed with discrete natural language text sequences. Before entering the model, the natural language text sequences are converted into integer token sequences, such as the numbers corresponding to words or subwords, by a tokenizer.

[0161] Next, the token sequence is mapped into a series of embedding vectors (Embedding), that is, each token is converted into a dense vector representation of a fixed dimension as the input feature of the model.

[0162] After multiple layers of binarization, the model outputs a probability distribution, which is used to predict the next token or answer the user's question. For example, given the discrete natural language text "today" as input, the model predicts the probability of the next word being "weather" with a probability of 0.81, "temperature" with a probability of 0.13, and so on. After processing by the decoder, the model can generate a complete answer: "Today is sunny and the temperature is moderate."

[0163] In some comparative experiments, the comparative data of the model obtained by the binarization method of the training perception large model in the embodiment of the present application and the full-precision model are shown in Table 1.

[0164] Table 1

[0165] Model Type Perplexity Model size (unit: GB) Full precision (FP16) 5.09 26.03GB This application (two values) 10.18 3.73GB

[0166] The data in the table shows that, under extreme compression ratios (i.e., 1-bit), the proposed method increases the model's perplexity from 5.09 to 10.18, maintaining satisfactory performance. The model size is significantly reduced from the original 26.03GB to 3.73GB, achieving a compression ratio of approximately 7:1. This significantly reduces the storage space and memory footprint required for model deployment without adding additional inference costs. Because the linear transformation portion of the model is replaced with a simplified "scaling × binary mask + mean shift" structure, computational complexity is significantly reduced, making the model suitable for low-power inference chips.

[0167] Optionally, the memory is used to store programs; the memory may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviated: RAM), such as static random-access memory (English: static random-access memory, abbreviated: SRAM), double data rate synchronous dynamic random access memory (English: Double Data Rate Synchronous Dynamic Random Access Memory, abbreviated: DDR SDRAM), etc.; the memory may also include non-volatile memory (English: non-volatile memory), such as flash memory (English: flash memory). The memory is used to store computer programs (such as applications, functional modules, etc. that implement the above-mentioned methods), computer instructions, etc., and the above-mentioned computer programs, computer instructions, etc. can be partitioned and stored in one or more memories. In addition, the above-mentioned computer programs, computer instructions, data, etc. can be called by the processor.

[0168] The aforementioned computer programs, computer instructions, etc. may be partitioned and stored in one or more memories, and the aforementioned computer programs, computer instructions, data, etc. may be called by a processor.

[0169] The processor is configured to execute the computer program stored in the memory to implement the various steps of the method involved in the above embodiment. For details, please refer to the relevant description in the above method embodiment.

[0170] The processor and memory can be independent structures or integrated structures. When the processor and memory are independent structures, the memory and processor can be coupled via a bus.

[0171] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0172] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. 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.

[0173] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

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

[0175] The above describes some specific embodiments of the present application. It should be understood that the present application is not limited to the specific embodiments described above, and those skilled in the art may make various variations or modifications within the scope of the claims, which do not affect the substantive content of the present application. The above preferred features may be used in any combination as long as they do not conflict with each other.

Claims

1. A method for binarizing a large training perception model, characterized in that: include: Initialize the binary parameters of the large language model in an alternating manner; For the initialized large language model, performing layer-by-layer alignment training on the binarized parameters; Initiate end-to-end training of the large language model, so that all binary parameters are collaboratively optimized under a unified loss function; For the large language model that has completed unified collaborative optimization, a binarization order allocation strategy based on layer importance is implemented to obtain the final large language model for downstream tasks.

2. A method for binarizing a large training perception model according to claim 1, characterized in that: The alternating method for initializing the binarization parameters of the large language model includes: Load the pre-trained large model parameters. Here, the parameters of the large model are expressed as full-precision weights. The large model parameters are binarized and alternately trained to obtain initialized binarized parameters.

3. A method for binarizing a large training perception model according to claim 2, characterized in that: The binarization and alternating training of the large model parameters to obtain initialized binarized parameters includes: Using a scaled binarization structure, the full-precision weights of the original large model are converted into binary parameters; Alternatingly updating the mean shift term, the scaling factor, and the binary mask in the binarization structure to train the binarization parameters; After initialization, each layer of the large model includes both initialized binary parameters and full-precision weights.

4. A method for binarizing a large training perception model according to claim 1, characterized in that: The step of performing layer-by-layer alignment training on the binary parameters of the initialized large language model includes: When training and optimizing the initialization binary parameters of the current layer, freeze other layers; Compare the binary output of the current layer and the original full-precision weight output, minimize the output difference between the two, complete the alignment training of the single front layer, and the trained binary parameters completely replace the full-precision weights.

5. A method for binarizing a large training perception model according to claim 1, characterized in that: The initiating end-to-end training of the large language model so that all binary parameters are collaboratively optimized under a unified loss function includes: Use the dataset of the downstream task target to establish the overall loss and update all the binary parameters; During the parameter update process, the optimizer is used to dynamically adjust the learning rate or update strategy.

6. A method for binarizing a large training perception model according to claim 1, characterized in that: The method of implementing a layer-importance-based binarization order allocation strategy on the large language model that has completed unified collaborative optimization to obtain a final large language model for downstream tasks includes: Calculate layer importance using one or more metrics such as Fisher information, activation sensitivity, and output change rate; Setting a threshold, and dividing all layers into important layers and non-important layers according to a comparison result between the importance of the layer and the threshold; The important layers are given binary representations, and the unimportant layers are only represented by the first order.

7. A training perception large model binarization system, characterized by: include: Parameter initialization module: uses an alternating method to initialize the binary parameters of the large language model; Layer-by-layer alignment training module: for the initialized large language model, performing layer-by-layer alignment training on the binarized parameters; End-to-end binary parameter training module: starts end-to-end training of the large language model, so that all binary parameters are collaboratively optimized under a unified loss function; Binarization order allocation module: For the large language model that has completed unified collaborative optimization, a binarization order allocation strategy based on layer importance is implemented to obtain the final large language model for downstream tasks.

8. An online reasoning method for language text, characterized in that: include: Get language text instructions; Convert the language text instruction into a token sequence through a word segmenter; Mapping the token sequence into an embedding vector; Inputting the embedding vector into a large language model obtained by training the method according to any one of claims 1 to 6 or the system according to claim 7; After multi-layer binarization calculation, the large language model outputs a probability distribution, which is used to predict the next token or action as a language response or understanding execution for the language text instruction.

9. A terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, it can be used to perform the method according to any one of claims 1 to 6 and 8, or run the system according to claim 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, it can be used to perform the method described in any one of claims 1 to 6 and 8, or to run the system described in claim 7.

Citation Information

Patent Citations

  • Brain-like binary neural network automatic structure learning method

    CN114386576A

Cited By

  • Large language model processing system and method based on prompt adaptive tuning

    CN121457604A